From: <geo...@us...> - 2007-12-20 18:28:04
|
Revision: 2271 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2271&view=rev Author: geoffthemedio Date: 2007-12-20 10:27:58 -0800 (Thu, 20 Dec 2007) Log Message: ----------- -Added initial empty ship design screen and a button to toggle it open / closed -Got ship_parts.txt parser working, except for usual end-of-file line ending problem I can't seem to avoid... Modified Paths: -------------- trunk/FreeOrion/SConscript trunk/FreeOrion/UI/MapWnd.cpp trunk/FreeOrion/UI/MapWnd.h trunk/FreeOrion/default/eng_stringtable.txt trunk/FreeOrion/default/ship_hulls.txt trunk/FreeOrion/default/ship_parts.txt trunk/FreeOrion/msvc2005/FreeOrion/freeorion/freeorion.vcproj trunk/FreeOrion/universe/TopLevelParsers.cpp Added Paths: ----------- trunk/FreeOrion/UI/DesignWnd.cpp trunk/FreeOrion/UI/DesignWnd.h Modified: trunk/FreeOrion/SConscript =================================================================== --- trunk/FreeOrion/SConscript 2007-12-20 14:35:46 UTC (rev 2270) +++ trunk/FreeOrion/SConscript 2007-12-20 18:27:58 UTC (rev 2271) @@ -106,6 +106,7 @@ 'UI/MapWnd.cpp', 'UI/MultiplayerLobbyWnd.cpp', 'UI/OptionsWnd.cpp', + 'UI/DesignWnd.cpp', 'UI/ProductionWnd.cpp', 'UI/ResearchWnd.cpp', 'UI/ServerConnectWnd.cpp', Added: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp (rev 0) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2007-12-20 18:27:58 UTC (rev 2271) @@ -0,0 +1,59 @@ +#include "DesignWnd.h" + +#include "../util/AppInterface.h" +#include "ClientUI.h" +#include "CUIControls.h" +#include "../Empire/Empire.h" +#include "../client/human/HumanClientApp.h" +#include "../util/MultiplayerCommon.h" +#include "../universe/ShipDesign.h" + +#include <GG/DrawUtil.h> +#include <GG/StaticGraphic.h> + +#include <boost/format.hpp> +#include <cmath> + + +////////////////////////////////////////////////// +// DesignWnd // +////////////////////////////////////////////////// +DesignWnd::DesignWnd(int w, int h) : + GG::Wnd(0, 0, w, h, GG::ONTOP) { + EnableChildClipping(true); + + const PartTypeManager& manager = GetPartTypeManager(); + for (PartTypeManager::iterator it = manager.begin(); it != manager.end(); ++it) + Logger().errorStream() << "part: " << it->first; +} + +void DesignWnd::Reset() { +} + +void DesignWnd::Sanitize() { +} + +void DesignWnd::Render() { + GG::Pt ul = UpperLeft(); + GG::Pt lr = LowerRight(); + + // use GL to draw the lines + glDisable(GL_TEXTURE_2D); + GLint initial_modes[2]; + glGetIntegerv(GL_POLYGON_MODE, initial_modes); + + // draw background + glPolygonMode(GL_BACK, GL_FILL); + glBegin(GL_POLYGON); + glColor(ClientUI::WndColor()); + glVertex2i(ul.x, ul.y); + glVertex2i(lr.x, ul.y); + glVertex2i(lr.x, lr.y); + glVertex2i(ul.x, lr.y); + glVertex2i(ul.x, ul.y); + glEnd(); + + // reset this to whatever it was initially + glPolygonMode(GL_BACK, initial_modes[1]); + glEnable(GL_TEXTURE_2D); +} \ No newline at end of file Added: trunk/FreeOrion/UI/DesignWnd.h =================================================================== --- trunk/FreeOrion/UI/DesignWnd.h (rev 0) +++ trunk/FreeOrion/UI/DesignWnd.h 2007-12-20 18:27:58 UTC (rev 2271) @@ -0,0 +1,24 @@ +// -*- C++ -*- +#ifndef _DesignWnd_h_ +#define _DesignWnd_h_ + +#include "CUIWnd.h" + +class ShipDesign; + +/** Lets the player design ships */ +class DesignWnd : public GG::Wnd { +public: + /** \name Structors */ //@{ + DesignWnd(int w, int h); + //@} + + /** \name Mutators */ //@{ + void Reset(); + void Sanitize(); + + void Render(); + //@} +}; + +#endif // _DesignWnd_h_ Modified: trunk/FreeOrion/UI/MapWnd.cpp =================================================================== --- trunk/FreeOrion/UI/MapWnd.cpp 2007-12-20 14:35:46 UTC (rev 2270) +++ trunk/FreeOrion/UI/MapWnd.cpp 2007-12-20 18:27:58 UTC (rev 2271) @@ -13,6 +13,7 @@ #include "../universe/Planet.h" #include "../universe/Predicates.h" #include "../util/Random.h" +#include "DesignWnd.h" #include "ProductionWnd.h" #include "ResearchWnd.h" #include "SidePanel.h" @@ -192,6 +193,11 @@ m_production_wnd->Hide(); GG::Connect(m_production_wnd->SystemSelectedSignal, &MapWnd::SelectSystem, this); // productionwnd requests system selection change -> select it + m_design_wnd = new DesignWnd(GG::GUI::GetGUI()->AppWidth(), GG::GUI::GetGUI()->AppHeight() - m_toolbar->Height()); + m_design_wnd->MoveTo(GG::Pt(0, m_toolbar->Height())); + GG::GUI::GetGUI()->Register(m_design_wnd); + m_design_wnd->Hide(); + // turn button m_turn_update = new CUITurnButton(LAYOUT_MARGIN, LAYOUT_MARGIN, END_TURN_BTN_WIDTH, "" ); m_toolbar->AttachChild(m_turn_update); @@ -210,8 +216,13 @@ m_toolbar->AttachChild(m_btn_menu); GG::Connect(m_btn_menu->ClickedSignal, BoolToVoidAdapter(boost::bind(&MapWnd::ShowMenu, this))); + button_width = font->TextExtent(UserString("MAP_BTN_DESIGN")).x + BUTTON_TOTAL_MARGIN; + m_btn_design = new CUIButton(m_btn_menu->UpperLeft().x-LAYOUT_MARGIN-button_width, 0, button_width, UserString("MAP_BTN_DESIGN") ); + m_toolbar->AttachChild(m_btn_design); + GG::Connect(m_btn_design->ClickedSignal, BoolToVoidAdapter(boost::bind(&MapWnd::ToggleDesign, this))); + button_width = font->TextExtent(UserString("MAP_BTN_PRODUCTION")).x + BUTTON_TOTAL_MARGIN; - m_btn_production = new CUIButton(m_btn_menu->UpperLeft().x-LAYOUT_MARGIN-button_width, 0, button_width, UserString("MAP_BTN_PRODUCTION") ); + m_btn_production = new CUIButton(m_btn_design->UpperLeft().x-LAYOUT_MARGIN-button_width, 0, button_width, UserString("MAP_BTN_PRODUCTION") ); m_toolbar->AttachChild(m_btn_production); GG::Connect(m_btn_production->ClickedSignal, BoolToVoidAdapter(boost::bind(&MapWnd::ToggleProduction, this))); @@ -302,6 +313,7 @@ GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_F2), &MapWnd::ToggleSitRep, this); GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_F3), &MapWnd::ToggleResearch, this); GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_F4), &MapWnd::ToggleProduction, this); + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_F5), &MapWnd::ToggleDesign, this); GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_F10), &MapWnd::ShowMenu, this); GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_s), &MapWnd::CloseSystemView, this); @@ -341,6 +353,7 @@ delete m_toolbar; delete m_research_wnd; delete m_production_wnd; + delete m_design_wnd; RemoveAccelerators(); } @@ -737,6 +750,7 @@ m_research_wnd->Hide(); m_production_wnd->Hide(); + m_design_wnd->Hide(); m_in_production_view_mode = false; m_chat_edit->Hide(); @@ -1729,6 +1743,7 @@ RemoveAccelerators(); m_research_wnd->Hide(); m_production_wnd->Hide(); + m_design_wnd->Hide(); m_in_production_view_mode = false; m_toolbar->Hide(); m_FPS->Hide(); @@ -1747,6 +1762,7 @@ m_zoom_factor = 1.0; m_research_wnd->Sanitize(); m_production_wnd->Sanitize(); + m_design_wnd->Sanitize(); m_previously_selected_system = UniverseObject::INVALID_OBJECT_ID; } @@ -1758,6 +1774,8 @@ m_research_wnd->Hide(); HumanClientApp::GetApp()->MoveDown(m_research_wnd); } + if (m_design_wnd->Visible()) + m_design_wnd->Hide(); if (m_production_wnd->Visible()) { m_production_wnd->Hide(); if (m_in_production_view_mode) { @@ -1802,6 +1820,8 @@ // hide other "competing" windows m_research_wnd->Hide(); HumanClientApp::GetApp()->MoveDown(m_research_wnd); + m_design_wnd->Hide(); + HumanClientApp::GetApp()->MoveDown(m_design_wnd); m_production_wnd->Hide(); if (m_in_production_view_mode) { m_in_production_view_mode = false; @@ -1827,6 +1847,7 @@ } else { // hide other "competing" windows m_sitrep_panel->Hide(); + m_design_wnd->Hide(); m_production_wnd->Hide(); if (m_in_production_view_mode) { m_in_production_view_mode = false; @@ -1857,6 +1878,7 @@ m_sitrep_panel->Hide(); DetachChild(m_sitrep_panel); m_research_wnd->Hide(); + m_design_wnd->Hide(); // show the production window m_production_wnd->Show(); @@ -1873,6 +1895,31 @@ return true; } +bool MapWnd::ToggleDesign() +{ + m_projected_fleet_line = MovementLineData(); + if (m_design_wnd->Visible()) { + m_design_wnd->Hide(); + } else { + // hide other "competing" windows + m_sitrep_panel->Hide(); + m_research_wnd->Hide(); + m_production_wnd->Hide(); + if (m_in_production_view_mode) { + m_in_production_view_mode = false; + ShowAllPopups(); + if (!m_side_panel->Visible()) + m_side_panel->SetSystem(m_side_panel->SystemID()); + } + + // show the design window + m_design_wnd->Show(); + GG::GUI::GetGUI()->MoveUp(m_design_wnd); + m_design_wnd->Reset(); + } + return true; +} + bool MapWnd::ShowMenu() { if (!m_menu_showing) { Modified: trunk/FreeOrion/UI/MapWnd.h =================================================================== --- trunk/FreeOrion/UI/MapWnd.h 2007-12-20 14:35:46 UTC (rev 2270) +++ trunk/FreeOrion/UI/MapWnd.h 2007-12-20 18:27:58 UTC (rev 2271) @@ -15,6 +15,7 @@ class FleetButton; class FleetWnd; class MapWndPopup; +class DesignWnd; class ProductionWnd; class ResearchWnd; struct SaveGameUIData; @@ -131,12 +132,6 @@ void UpdateMeterEstimates(); ///< re-estimates meter values based on orders given void UpdateEmpireResourcePools(); ///< recalculates production and predicted changes of player's empire's resource and population pools - void TurnBtnClicked() {EndTurn();} - void MenuBtnClicked() {ShowMenu();} - void ProductionBtnClicked() {ToggleProduction();} - void ResearchBtnClicked() {ToggleResearch();} - void SitRepBtnClicked() {ToggleSitRep();} - struct StarlaneData; ///< contains all the information necessary to render a single fleet movement line on the main map /** contains all the information necessary to render a single fleet movement line on the main map */ @@ -182,6 +177,7 @@ bool ToggleSitRep(); bool ToggleResearch(); bool ToggleProduction(); + bool ToggleDesign(); bool ShowMenu(); bool CloseSystemView(); //!< closes off the current system view bool KeyboardZoomIn(); @@ -223,6 +219,7 @@ SitRepPanel* m_sitrep_panel; //! sitrep panel ResearchWnd* m_research_wnd; //! research screen ProductionWnd* m_production_wnd; //! production screen + DesignWnd* m_design_wnd; //! design screen GG::MultiEdit* m_chat_display; //! (read-only) MP-chat output multi-line edit box CUIEdit* m_chat_edit; //! MP-chat input edit box std::vector<FleetButton*> m_moving_fleet_buttons; //! moving fleets in the main map (SystemIcons contain stationary fleet buttons) @@ -248,7 +245,7 @@ CUIToolBar *m_toolbar; StatisticIcon *m_food, *m_mineral, *m_trade, *m_population, *m_research, *m_industry; - CUIButton *m_btn_siterep, *m_btn_research, *m_btn_production, *m_btn_menu; + CUIButton *m_btn_siterep, *m_btn_research, *m_btn_production, *m_btn_design, *m_btn_menu; FPSIndicator* m_FPS; Modified: trunk/FreeOrion/default/eng_stringtable.txt =================================================================== --- trunk/FreeOrion/default/eng_stringtable.txt 2007-12-20 14:35:46 UTC (rev 2270) +++ trunk/FreeOrion/default/eng_stringtable.txt 2007-12-20 18:27:58 UTC (rev 2271) @@ -1038,6 +1038,9 @@ MAP_BTN_PRODUCTION Production +MAP_BTN_DESIGN +Design + ################# # SidePanel # ################# Modified: trunk/FreeOrion/default/ship_hulls.txt =================================================================== --- trunk/FreeOrion/default/ship_hulls.txt 2007-12-20 14:35:46 UTC (rev 2270) +++ trunk/FreeOrion/default/ship_hulls.txt 2007-12-20 18:27:58 UTC (rev 2271) @@ -12,4 +12,12 @@ slots = 10 mass = 300 graphic = "ship_hull_icons/Large.png" - model = "ship_models/Large.mod" \ No newline at end of file + model = "ship_models/Large.mod" + +Hull + name = "SH_HUGE" + description = "SH_HUGE_DESC" + slots = 20 + mass = 1500 + graphic = "ship_hull_icons/Huge.png" + model = "ship_models/Huge.mod" Modified: trunk/FreeOrion/default/ship_parts.txt =================================================================== --- trunk/FreeOrion/default/ship_parts.txt 2007-12-20 14:35:46 UTC (rev 2270) +++ trunk/FreeOrion/default/ship_parts.txt 2007-12-20 18:27:58 UTC (rev 2271) @@ -15,5 +15,5 @@ power = 20 range = 15 mass = 50 - upgrade = [] - graphic = "ship_part_icons/Ion_Cannon.png" \ No newline at end of file + upgrade = "" + graphic = "ship_part_icons/Ion_Cannon.png" Modified: trunk/FreeOrion/msvc2005/FreeOrion/freeorion/freeorion.vcproj =================================================================== --- trunk/FreeOrion/msvc2005/FreeOrion/freeorion/freeorion.vcproj 2007-12-20 14:35:46 UTC (rev 2270) +++ trunk/FreeOrion/msvc2005/FreeOrion/freeorion/freeorion.vcproj 2007-12-20 18:27:58 UTC (rev 2271) @@ -457,6 +457,14 @@ > </File> <File + RelativePath="..\..\..\UI\DesignWnd.cpp" + > + </File> + <File + RelativePath="..\..\..\UI\DesignWnd.h" + > + </File> + <File RelativePath="..\..\..\Ui\FleetButton.cpp" > </File> Modified: trunk/FreeOrion/universe/TopLevelParsers.cpp =================================================================== --- trunk/FreeOrion/universe/TopLevelParsers.cpp 2007-12-20 14:35:46 UTC (rev 2270) +++ trunk/FreeOrion/universe/TopLevelParsers.cpp 2007-12-20 18:27:58 UTC (rev 2271) @@ -67,7 +67,7 @@ ParamLabel unlock_label("unlock"); ParamLabel type_label("type"); ParamLabel location_label("location"); - ParamLabel partclass_label("partclass"); + ParamLabel partclass_label("class"); ParamLabel upgrade_label("upgrade"); ParamLabel power_label("power"); ParamLabel range_label("range"); @@ -136,15 +136,15 @@ >> researchcost_label >> real_p[tech_p.research_cost = arg1] >> researchturns_label >> int_p[tech_p.research_turns = arg1] >> prerequisites_label - >> (name_p[insert_(tech_p.prerequisites, arg1)] | - ('[' >> *(name_p[insert_(tech_p.prerequisites, arg1)]) >> ']')) - >> unlock_label - >> (tech_item_spec_p[push_back_(tech_p.unlocked_items, arg1)] - | ('[' >> *(tech_item_spec_p[push_back_(tech_p.unlocked_items, arg1)]) >> ']')) - >> !(effectsgroups_label >> effects_group_vec_p[tech_p.effects_groups = arg1]) - >> graphic_label >> file_name_p[tech_p.graphic = arg1]) - [tech_p.this_ = new_<Tech>(tech_p.name, tech_p.description, tech_p.short_description, tech_p.category, - tech_p.tech_type, tech_p.research_cost, tech_p.research_turns, + >> (name_p[insert_(tech_p.prerequisites, arg1)] | + ('[' >> *(name_p[insert_(tech_p.prerequisites, arg1)]) >> ']')) + >> unlock_label + >> (tech_item_spec_p[push_back_(tech_p.unlocked_items, arg1)] + | ('[' >> *(tech_item_spec_p[push_back_(tech_p.unlocked_items, arg1)]) >> ']')) + >> !(effectsgroups_label >> effects_group_vec_p[tech_p.effects_groups = arg1]) + >> graphic_label >> file_name_p[tech_p.graphic = arg1]) + [tech_p.this_ = new_<Tech>(tech_p.name, tech_p.description, tech_p.short_description, tech_p.category, + tech_p.tech_type, tech_p.research_cost, tech_p.research_turns, tech_p.effects_groups, tech_p.prerequisites, tech_p.unlocked_items, tech_p.graphic)]; |