예제 #1
0
def compile_dialog_states(processor, dialog_file):
  global start_states
  global end_states
  unique_state_list = ["start", "party_encounter", "prisoner_liberated", "enemy_defeated", "party_relieved",
      "event_triggered", "close_window", "trade", "exchange_members", "trade_prisoners", "buy_mercenaries",
      "view_char", "training", "member_chat", "prisoner_chat"]
  unique_state_usages = [1 for i in unique_state_list]
  unique_states = dict((k, i) for i, k in enumerate(unique_state_list))
  last_index = len(unique_state_list)
  for entry in module_dialogs.dialogs:
    end_state = entry[5]
    index = unique_states.setdefault(end_state, last_index)
    if index == last_index:
      last_index += 1
      unique_state_list.append(end_state)
      unique_state_usages.append(0)
    end_states.append(index)
  for entry in module_dialogs.dialogs:
    start_state = entry[2]
    try:
      index = unique_states[start_state]
      unique_state_usages[index] += 1
      start_states.append(index)
    except KeyError:
      pc.ERROR("starting dialog state '%s' has no matching ending state" % start_state)
  for state, usages in zip(unique_state_list, unique_state_usages):
    if not usages:
      pc.ERROR("ending dialog state '%s' is not used" % state)
  with open(module_info.export_path("dialog_states.txt"), "wb") as state_file:
    state_file.write("".join("%s\r\n" % e for e in unique_state_list))
def compile_dialog_states(processor, dialog_file):
  global start_states
  global end_states
  unique_state_list = ["start", "party_encounter", "prisoner_liberated", "enemy_defeated", "party_relieved",
      "event_triggered", "close_window", "trade", "exchange_members", "trade_prisoners", "buy_mercenaries",
      "view_char", "training", "member_chat", "prisoner_chat"]
  unique_state_usages = [1 for i in unique_state_list]
  unique_states = dict((k, i) for i, k in enumerate(unique_state_list))
  last_index = len(unique_state_list)
  for entry in module_dialogs.dialogs:
    end_state = entry[5]
    index = unique_states.setdefault(end_state, last_index)
    if index == last_index:
      last_index += 1
      unique_state_list.append(end_state)
      unique_state_usages.append(0)
    end_states.append(index)
  for entry in module_dialogs.dialogs:
    start_state = entry[2]
    try:
      index = unique_states[start_state]
      unique_state_usages[index] += 1
      start_states.append(index)
    except KeyError:
      pc.ERROR("starting dialog state '%s' has no matching ending state" % start_state)
  for state, usages in zip(unique_state_list, unique_state_usages):
    if not usages:
      pc.ERROR("ending dialog state '%s' is not used" % state)
  with open(module_info.export_path("dialog_states.txt"), "wb") as state_file:
    state_file.write("".join("%s\r\n" % e for e in unique_state_list))
 def export_wrapper(processor):
     if not file_name:
         file_name_ = data_name
     else:
         file_name_ = file_name
     txt_file = open(module_info.export_path("%s.txt" % file_name_), "wb")
     print "Exporting %s..." % data_name.replace("_", " ")
     if tag and processor.write_id:
         id_file = open("ID_%s.py" % data_name, "w")
     else:
         id_file = None
     try:
         if process_list:
             process_list(processor, txt_file)
         if header_format:
             txt_file.write(header_format % len(data))
         for i, entry in enumerate(data):
             name = entry[0]
             if tag:
                 pc.assert_valid_identifier(name, entry=data_name)
                 if id_file:
                     id_file.write("%s_%s = %d\n" % (tag, name, i))
             if process_entry:
                 try:
                     process_entry(processor, txt_file, entry, i)
                 except pc.ModuleSystemError as e:
                     if not e.entry:
                         e.entry = "%s_%s" % (tag,
                                              name) if tag else "#%d" % i
                     raise
                 except Exception as e:
                     if processor.show_backtrace:
                         raise
                     else:
                         msg = e.args[0]
                         if isinstance(e, TypeError) and (
                                 "has no len()" in msg
                                 or "object is not iterable" in msg
                                 or "object is not subscriptable" in msg):
                             msg = "a list was expected: %s" % msg
                         else:
                             msg = "%s: %s" % (type(e).__name__, repr(msg))
                         raise pc.ModuleSystemError(
                             msg,
                             entry=("%s_%s" %
                                    (tag, name) if tag else "#%d" % i))
     finally:
         txt_file.close()
         if id_file:
             id_file.close()
def compile_profile(profile, name):
  command_list = ["./fxc.exe", "/nologo", "/T", "fx_2_0", "/D", "PS_2_X=%s" % profile, "/Fo", "mb.fxo", "mb.fx"]
  exit_code = subprocess.call(command_list, cwd="shaders")
  output_fxo = os.path.join("shaders", "mb.fxo")
  if exit_code == 0:
    module_fxo = module_info.export_path(name)
    try:
      os.remove(module_fxo)
    except Exception:
      pass
    shutil.move(output_fxo, module_fxo)
  else:
    try:
      os.remove(output_fxo)
    except Exception:
      pass
    exit(exit_code)
예제 #5
0
 def export_wrapper(processor):
   if not file_name:
     file_name_ = data_name
   else:
     file_name_ = file_name
   txt_file = open(module_info.export_path("%s.txt" % file_name_), "wb")
   print "Exporting %s..." % data_name.replace("_", " ")
   if tag and processor.write_id:
     id_file = open("ID_%s.py" % data_name, "w")
   else:
     id_file = None
   try:
     if process_list:
       process_list(processor, txt_file)
     if header_format:
       txt_file.write(header_format % len(data))
     for i, entry in enumerate(data):
       name = entry[0]
       if tag:
         pc.assert_valid_identifier(name, entry=data_name)
         if id_file:
           id_file.write("%s_%s = %d\n" % (tag, name, i))
       if process_entry:
         try:
           process_entry(processor, txt_file, entry, i)
         except pc.ModuleSystemError as e:
           if not e.entry:
             e.entry = "%s_%s" % (tag, name) if tag else "#%d" % i
           raise
         except Exception as e:
           if processor.show_backtrace:
             raise
           else:
             msg = e.args[0]
             if isinstance(e, TypeError) and ("has no len()" in msg or
               "object is not iterable" in msg or "object is not subscriptable" in msg):
               msg = "a list was expected: %s" % msg
             else:
               msg = "%s: %s" % (type(e).__name__, repr(msg))
             raise pc.ModuleSystemError(msg, entry=("%s_%s" % (tag, name) if tag else "#%d" % i))
   finally:
     txt_file.close()
     if id_file:
       id_file.close()
def compile_profile(profile, name):
    command_list = [
        "./fxc.exe", "/nologo", "/T", "fx_2_0", "/D",
        "PS_2_X=%s" % profile, "/Fo", "mb.fxo", "mb.fx"
    ]
    exit_code = subprocess.call(command_list, cwd="shaders")
    output_fxo = os.path.join("shaders", "mb.fxo")
    if exit_code == 0:
        module_fxo = module_info.export_path(name)
        try:
            os.remove(module_fxo)
        except Exception:
            pass
        shutil.move(output_fxo, module_fxo)
    else:
        try:
            os.remove(output_fxo)
        except Exception:
            pass
        exit(exit_code)
 def write(self):
     with open(module_info.export_path("variables.txt"), "wb") as var_file:
         for name, id_uses in self.variables.iteritems():
             var_file.write("%s\r\n" % name)
 def write(self):
     with open(module_info.export_path("quick_strings.txt"), "wb") as f:
         f.write("%d\r\n" % len(self.quick_strings))
         for id_str, num_str in self.quick_strings.iteritems():
             f.write("qstr_%s %s\r\n" % (id_str, num_str[1]))
예제 #9
0
 def write(self):
   with open(module_info.export_path("variables.txt"), "wb") as var_file:
     for name, id_uses in self.variables.iteritems():
       var_file.write("%s\r\n" % name)
예제 #10
0
 def write(self):
   with open(module_info.export_path("quick_strings.txt"), "wb") as f:
     f.write("%d\r\n" % len(self.quick_strings))
     for id_str, num_str in self.quick_strings.iteritems():
       f.write("qstr_%s %s\r\n" % (id_str, num_str[1]))
예제 #11
0
  import process_mission_templates
  process_mission_templates.export(processor)
  import process_game_menus
  process_game_menus.export(processor)
  import process_simple_triggers
  process_simple_triggers.export(processor)
  import process_triggers
  process_triggers.export(processor)
  import process_dialogs
  process_dialogs.export(processor)
  import process_postfx
  process_postfx.export(processor)

  if args.build_data:
    import os
    data_path = module_info.export_path("Data")
    if not os.path.isdir(data_path):
      os.mkdir(data_path)
    import module_flora_kinds
    module_flora_kinds.export(processor)
    import module_ground_specs
    module_ground_specs.export(processor)
    import module_skyboxes
    module_skyboxes.export(processor)

  global_variables.warn_unused(None)
  global_variables.write()
  quick_strings.write()

except pc.ModuleSystemError as e:
  print e
예제 #12
0
    import process_mission_templates
    process_mission_templates.export(processor)
    import process_game_menus
    process_game_menus.export(processor)
    import process_simple_triggers
    process_simple_triggers.export(processor)
    import process_triggers
    process_triggers.export(processor)
    import process_dialogs
    process_dialogs.export(processor)
    import process_postfx
    process_postfx.export(processor)

    if args.build_data:
        import os
        data_path = module_info.export_path("Data")
        if not os.path.isdir(data_path):
            os.mkdir(data_path)
        import module_flora_kinds
        module_flora_kinds.export(processor)
        import module_ground_specs
        module_ground_specs.export(processor)
        import module_skyboxes
        module_skyboxes.export(processor)

    global_variables.warn_unused(None)
    global_variables.write()
    quick_strings.write()

except pc.ModuleSystemError as e:
    print e