Ejemplo n.º 1
0
void Memory::initializeDefaultValues(Gameexe& gameexe) {
  // Note: We ignore the \#NAME_MAXLEN variable because manual allocation is
  // error prone and for losers.
  GameexeFilteringIterator end = gameexe.filtering_end();
  for (GameexeFilteringIterator it = gameexe.filtering_begin("NAME.");
      it != end; ++it) {
    try {
      setName(ConvertLetterIndexToInt(it->key_parts().at(1)),
              removeQuotes(it->to_string()));
    } catch(...) {
      cerr << "WARNING: Invalid format for key " << it->key() << endl;
    }
  }

  for (GameexeFilteringIterator it = gameexe.filtering_begin("LOCALNAME.");
      it != end; ++it) {
    try {
      setLocalName(ConvertLetterIndexToInt(it->key_parts().at(1)),
                   removeQuotes(it->to_string()));
    } catch(...) {
      cerr << "WARNING: Invalid format for key " << it->key() << endl;
    }
  }
}
Ejemplo n.º 2
0
TextWindow::TextWindow(System& system, int window_num)
    : window_num_(window_num), text_insertion_point_x_(0),
      text_insertion_point_y_(0),
      ruby_begin_point_(-1), current_line_number_(0),
      current_indentation_in_pixels_(0), last_token_was_name_(false),
      use_indentation_(0), colour_(),
      filter_(0), is_visible_(0), in_selection_mode_(0),
      system_(system),
      text_system_(system.text()) {
  Gameexe& gexe = system.gameexe();

  // POINT
  Size size = getScreenSize(gexe);
  screen_width_ = size.width();
  screen_height_ = size.height();

  // Base form for everything to follow.
  GameexeInterpretObject window(gexe("WINDOW", window_num));

  // Handle: #WINDOW.index.ATTR_MOD, #WINDOW_ATTR, #WINDOW.index.ATTR
  window_attr_mod_ = window("ATTR_MOD");
  if (window_attr_mod_ == 0)
    setRGBAF(system.text().windowAttr());
  else
    setRGBAF(window("ATTR"));

  default_font_size_in_pixels_ = window("MOJI_SIZE").to_int(25);
  setFontSizeInPixels(default_font_size_in_pixels_);
  setWindowSizeInCharacters(window("MOJI_CNT"));
  setSpacingBetweenCharacters(window("MOJI_REP"));
  setRubyTextSize(window("LUBY_SIZE").to_int(0));
  setTextboxPadding(window("MOJI_POS"));

  setWindowPosition(window("POS"));

  setDefaultTextColor(gexe("COLOR_TABLE", 0));

  // INDENT_USE appears to default to on. See the first scene in the
  // game with Nagisa, paying attention to indentation; then check the
  // Gameexe.ini.
  setUseIndentation(window("INDENT_USE").to_int(1));

  setKeycurMod(window("KEYCUR_MOD"));
  setActionOnPause(window("R_COMMAND_MOD").to_int(0));

  // Main textbox waku
  waku_set_ = window("WAKU_SETNO").to_int(0);
  textbox_waku_.reset(TextWaku::Create(system_, *this, waku_set_, 0));

  // Name textbox if that setting has been enabled.
  setNameMod(window("NAME_MOD").to_int(0));
  if (name_mod_ == 1 && window("NAME_WAKU_SETNO").exists()) {
    name_waku_set_ = window("NAME_WAKU_SETNO");
    namebox_waku_.reset(TextWaku::Create(system_, *this, name_waku_set_, 0));
    setNameSpacingBetweenCharacters(window("NAME_MOJI_REP"));
    setNameboxPadding(window("NAME_MOJI_POS"));
    // Ignoring NAME_WAKU_MIN for now
    setNameboxPosition(window("NAME_POS"));
    name_waku_dir_set_ = window("NAME_WAKU_DIR").to_int(0);
    namebox_centering_ = window("NAME_CENTERING").to_int(0);
    minimum_namebox_size_ = window("NAME_MOJI_MIN").to_int(4);
    name_size_ = window("NAME_MOJI_SIZE");
  }

  // Load #FACE information.
  GameexeFilteringIterator it = gexe.filtering_begin(window.key() + ".FACE");
  GameexeFilteringIterator end = gexe.filtering_end();
  for (; it != end; ++it) {
    // Retrieve the face slot number
    std::vector<std::string> key_parts = it->key_parts();

    try {
      int slot = boost::lexical_cast<int>(key_parts.at(3));
      if (slot < kNumFaceSlots) {
        face_slot_[slot].reset(new FaceSlot(it->to_intVector()));
      }
    } catch (...) {
      // Parsing failure. Ignore this key.
    }
  }
}