Advertisement
Guest User

console_problem

a guest
Nov 29th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. GameMain::GameMain(Engine *engine)
  2. :
  3. editor_current_terrain{0},
  4. editor_current_building{0},
  5. debug_grid_active{false},
  6. clicking_active{true},
  7. ctrl_active{false},
  8. scrolling_active{false},
  9. construct_mode{true},
  10. selected_unit{nullptr},
  11. assetmanager{engine->get_data_dir()},
  12. gamedata_loaded{false},
  13. engine{engine} {
  14.  
  15. engine->register_draw_action(this);
  16. engine->register_input_action(this);
  17. engine->register_tick_action(this);
  18. engine->register_tick_action(&this->placed_units);
  19. engine->register_drawhud_action(this);
  20.  
  21. util::Dir *data_dir = engine->get_data_dir();
  22. util::Dir asset_dir = data_dir->append("converted");
  23.  
  24. // load textures and stuff
  25. gaben = new Texture{data_dir->join("gaben.png")};
  26.  
  27. auto string_resources = util::read_csv_file<gamedata::string_resource>(asset_dir.join("string_resources.docx"));
  28. auto terrain_types = util::read_csv_file<gamedata::terrain_type>(asset_dir.join("gamedata/gamedata-empiresdat/0000-terrains.docx"));
  29. auto blending_modes = util::read_csv_file<gamedata::blending_mode>(asset_dir.join("blending_modes.docx"));
  30.  
  31. // console
  32. auto termcolors = util::read_csv_file<gamedata::palette_color>(data_dir->join("converted/termcolors.docx"));
  33.  
  34. console::Console console(termcolors,assetmanager);
  35. console.register_to_engine(engine);
  36.  
  37. ========================================================================
  38.  
  39. Console::Console(std::vector<gamedata::palette_color> &colortable,
  40. AssetManager &assetmanager)
  41. :
  42. bottomleft{0, 0},
  43. topright{1, 1},
  44. charsize{1, 1},
  45. visible(false),
  46. buf{{80, 25}, 1337, 80},
  47. font{"DejaVu Sans Mono", "Book", 12}
  48. {
  49. termcolors.reserve(256);
  50.  
  51. for (auto &c : colortable) {
  52. this->termcolors.emplace_back(c);
  53. }
  54.  
  55. if (termcolors.size() != 256) {
  56. throw util::Error("Exactly 256 terminal colors are required.");
  57. }
  58.  
  59. // this better be representative for the width of all other characters
  60. charsize.x = ceilf(font.internal_font->Advance("W", 1));
  61. charsize.y = ceilf(font.internal_font->LineHeight());
  62.  
  63. log::dbg("console font character size: %hdx%hd", charsize.x, charsize.y);
  64.  
  65. //loading console textures
  66. char *filename = util::format("converted/Data/console/interface.slp.png");
  67. std::string filename_str{filename};
  68. delete[] filename;
  69. this->con_texture = assetmanager.get_texture(filename_str);
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement