From: <geo...@us...> - 2009-01-16 05:16:24
|
Revision: 2754 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2754&view=rev Author: geoffthemedio Date: 2009-01-16 05:16:21 +0000 (Fri, 16 Jan 2009) Log Message: ----------- More system resource summary tooltip progress. Big TO DOs include determining what allocation to report for objects in a system, and making sure the tooltip gets updated when something changes, like happens for MeterBrowseWnd Modified Paths: -------------- trunk/FreeOrion/UI/InfoPanels.cpp trunk/FreeOrion/UI/InfoPanels.h trunk/FreeOrion/UI/SidePanel.cpp trunk/FreeOrion/default/eng_stringtable.txt Modified: trunk/FreeOrion/UI/InfoPanels.cpp =================================================================== --- trunk/FreeOrion/UI/InfoPanels.cpp 2009-01-16 05:11:50 UTC (rev 2753) +++ trunk/FreeOrion/UI/InfoPanels.cpp 2009-01-16 05:16:21 UTC (rev 2754) @@ -28,6 +28,18 @@ using boost::lexical_cast; namespace { + /** Returns text representation of number wrapped in GG RGBA tags for colour depending on whether number + is positive, negative or 0.0 */ + std::string ColouredNumber(double number) { + GG::Clr clr = ClientUI::TextColor(); + if (number > 0.0) + clr = ClientUI::StatIncrColor(); + else if (number < 0.0) + clr = ClientUI::StatDecrColor(); + return GG::RgbaTag(clr) + DoubleToString(number, 3, false, true) + "</rgba>"; + } + + /** Gives details about what effects contribute to a meter's maximum value (Effect Accounting) and * shows the current turn's current meter value and the predicted current meter value for next turn. */ class MeterBrowseWnd : public GG::BrowseInfoWnd { @@ -90,16 +102,12 @@ AttachChild(m_meter_title); UpdateSummary(); - UpdateEffectLabelsAndValues(); - GG::Y y = m_meter_title->LowerRight().y; - for (unsigned int i = 0; i < m_effect_labels_and_values.size(); ++i) { - m_effect_labels_and_values[i].first->MoveTo(GG::Pt(GG::X0, y)); - m_effect_labels_and_values[i].second->MoveTo(GG::Pt(LABEL_WIDTH, y)); - y += row_height; - } - Resize(GG::Pt(LABEL_WIDTH + VALUE_WIDTH, y)); + GG::Y next_row_y = m_meter_title->LowerRight().y; + UpdateEffectLabelsAndValues(next_row_y); + Resize(GG::Pt(LABEL_WIDTH + VALUE_WIDTH, next_row_y)); + initialized = true; } @@ -121,12 +129,7 @@ m_current_value->SetText(DoubleToString(current, 3, false, false)); m_next_turn_value->SetText(DoubleToString(next, 3, false, false)); - GG::Clr clr = ClientUI::TextColor(); - if (change > 0.0) - clr = ClientUI::StatIncrColor(); - else if (change < 0.0) - clr = ClientUI::StatDecrColor(); - m_change_value->SetText(GG::RgbaTag(clr) + DoubleToString(change, 3, false, true) + "</rgba>"); + m_change_value->SetText(ColouredNumber(change)); m_meter_title->SetText(boost::io::str(FlexibleFormat(UserString("TT_METER")) % DoubleToString(meter_cur, 3, false, false) % DoubleToString(meter_max, 3, false, false))); @@ -164,7 +167,7 @@ } // meter effect entries - void UpdateEffectLabelsAndValues() { + void UpdateEffectLabelsAndValues(GG::Y& top) { for (unsigned int i = 0; i < m_effect_labels_and_values.size(); ++i) { DeleteChild(m_effect_labels_and_values[i].first); DeleteChild(m_effect_labels_and_values[i].second); @@ -241,19 +244,17 @@ default: text += UserString("TT_UNKNOWN"); } - GG::TextControl* label = new GG::TextControl(GG::X0, GG::Y0, LABEL_WIDTH, row_height, text, font, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); - label->Resize(GG::Pt(LABEL_WIDTH, row_height)); + + GG::TextControl* label = new GG::TextControl(GG::X0, top, LABEL_WIDTH, row_height, text, font, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); AttachChild(label); - GG::Clr clr = ClientUI::TextColor(); - if (info_it->meter_change > 0.0) - clr = ClientUI::StatIncrColor(); - else if (info_it->meter_change < 0.0) - clr = ClientUI::StatDecrColor(); - GG::TextControl* value = new GG::TextControl(VALUE_WIDTH, GG::Y0, VALUE_WIDTH, row_height, - GG::RgbaTag(clr) + DoubleToString(info_it->meter_change, 3, false, true) + "</rgba>", + + GG::TextControl* value = new GG::TextControl(LABEL_WIDTH, top, VALUE_WIDTH, row_height, + ColouredNumber(info_it->meter_change), font, ClientUI::TextColor(), GG::FORMAT_CENTER | GG::FORMAT_VCENTER); AttachChild(value); m_effect_labels_and_values.push_back(std::pair<GG::TextControl*, GG::TextControl*>(label, value)); + + top += row_height; } } @@ -312,6 +313,12 @@ return GG::CLR_WHITE; } } + + + /** */ + double ObjectResourceConsumption(const UniverseObject* obj, ResourceType resource_type, int player_id = -1) { + return 0.0; + } } ///////////////////////////////////// @@ -2249,14 +2256,15 @@ ////////////////////////////////////// // SystemResourceSummaryBrowseWnd // ////////////////////////////////////// -const GG::X SystemResourceSummaryBrowseWnd::LABEL_WIDTH(300); -const GG::X SystemResourceSummaryBrowseWnd::VALUE_WIDTH(50); +const GG::X SystemResourceSummaryBrowseWnd::LABEL_WIDTH(200); +const GG::X SystemResourceSummaryBrowseWnd::VALUE_WIDTH(60); const int SystemResourceSummaryBrowseWnd::EDGE_PAD(3); -SystemResourceSummaryBrowseWnd::SystemResourceSummaryBrowseWnd(ResourceType resource_type, const System* system) : +SystemResourceSummaryBrowseWnd::SystemResourceSummaryBrowseWnd(ResourceType resource_type, const System* system, int player_id) : GG::BrowseInfoWnd(GG::X0, GG::Y0, LABEL_WIDTH + VALUE_WIDTH, GG::Y1), m_resource_type(resource_type), m_system(system), + m_player_id(player_id), m_production_label(0), m_allocation_label(0), m_import_export_label(0), m_import_export_amount(0), row_height(1), production_label_top(0), allocation_label_top(0), import_export_label_top(0), @@ -2296,14 +2304,14 @@ GG::Y top = GG::Y0; production_label_top = top; - m_production_label = new GG::TextControl(GG::X0, production_label_top, TOTAL_WIDTH - EDGE_PAD, production_label_top + row_height, "", font_bold, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); + m_production_label = new GG::TextControl(GG::X0, production_label_top, TOTAL_WIDTH - EDGE_PAD, row_height, "", font_bold, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); AttachChild(m_production_label); top += row_height; UpdateProduction(top); allocation_label_top = top; - m_allocation_label = new GG::TextControl(GG::X0, allocation_label_top, TOTAL_WIDTH - EDGE_PAD, allocation_label_top + row_height, "", font_bold, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); + m_allocation_label = new GG::TextControl(GG::X0, allocation_label_top, TOTAL_WIDTH - EDGE_PAD, row_height, "", font_bold, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); AttachChild(m_allocation_label); top += row_height; @@ -2348,6 +2356,11 @@ std::vector<UniverseObject*> obj_vec = m_system->FindObjects(); for (std::vector<UniverseObject*>::const_iterator it = obj_vec.begin(); it != obj_vec.end(); ++it) { const UniverseObject* obj = *it; + + // display information only for the requested player + if (m_player_id != -1 && !obj->OwnedBy(m_player_id)) + continue; // if m_player_id == -1, display resource production for all empires. otherwise, skip this resource production if it's not owned by the requested player + const ResourceCenter* rc = dynamic_cast<const ResourceCenter*>(obj); if (!rc) continue; @@ -2359,13 +2372,13 @@ std::string amount_text = DoubleToString(production, 3, false, false); - GG::TextControl* label = new GG::TextControl(GG::X0, top, LABEL_WIDTH, top + row_height, + GG::TextControl* label = new GG::TextControl(GG::X0, top, LABEL_WIDTH, row_height, name, font, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); label->Resize(GG::Pt(LABEL_WIDTH, row_height)); AttachChild(label); - GG::TextControl* value = new GG::TextControl(VALUE_WIDTH, top, VALUE_WIDTH, top + row_height, + GG::TextControl* value = new GG::TextControl(LABEL_WIDTH, top, VALUE_WIDTH, row_height, amount_text, font, ClientUI::TextColor(), GG::FORMAT_CENTER | GG::FORMAT_VCENTER); AttachChild(value); @@ -2376,7 +2389,6 @@ } - // set production label std::string resource_text = ""; switch (m_resource_type) { @@ -2398,7 +2410,6 @@ resource_text % DoubleToString(total_system_resource_production, 3, false, false))); - // height of label already added to top outside this function } @@ -2411,10 +2422,75 @@ } m_allocation_labels_and_amounts.clear(); - // UserString("TT_RESOURCE_ALLOCATION") // parames: object_name and allocation + if (!m_system || m_resource_type == INVALID_RESOURCE_TYPE) + return; - // TEMP - top += row_height; + + double total_system_resource_allocation = 0.0; + + + const boost::shared_ptr<GG::Font>& font = ClientUI::GetFont(); + + // add label-value pair for each resource-consuming object in system to indicate amount of resource consumed + std::vector<UniverseObject*> obj_vec = m_system->FindObjects(); + for (std::vector<UniverseObject*>::const_iterator it = obj_vec.begin(); it != obj_vec.end(); ++it) { + const UniverseObject* obj = *it; + + // display information only for the requested player + if (m_player_id != -1 && !obj->OwnedBy(m_player_id)) + continue; // if m_player_id == -1, display resource production for all empires. otherwise, skip this resource production if it's not owned by the requested player + + + std::string name = obj->Name(); + + + double allocation = ObjectResourceConsumption(obj, m_resource_type, m_player_id); + + + total_system_resource_allocation += allocation; + + std::string amount_text = DoubleToString(allocation, 3, false, false); + + + GG::TextControl* label = new GG::TextControl(GG::X0, top, LABEL_WIDTH, row_height, + name, font, ClientUI::TextColor(), + GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); + label->Resize(GG::Pt(LABEL_WIDTH, row_height)); + AttachChild(label); + + GG::TextControl* value = new GG::TextControl(LABEL_WIDTH, top, VALUE_WIDTH, row_height, + amount_text, font, ClientUI::TextColor(), + GG::FORMAT_CENTER | GG::FORMAT_VCENTER); + AttachChild(value); + + m_allocation_labels_and_amounts.push_back(std::pair<GG::TextControl*, GG::TextControl*>(label, value)); + + top += row_height; + } + + + // set consumption / allocation label + std::string resource_text = ""; + switch (m_resource_type) { + case RE_FOOD: + resource_text = UserString("FOOD_CONSUMPTION"); break; + case RE_MINERALS: + resource_text = UserString("MINERALS_CONSUMPTION"); break; + case RE_INDUSTRY: + resource_text = UserString("INDUSTRY_CONSUMPTION"); break; + case RE_RESEARCH: + resource_text = UserString("RESEARCH_CONSUMPTION"); break; + case RE_TRADE: + resource_text = UserString("TRADE_CONSUMPTION"); break; + default: + resource_text = UserString("UNKNOWN_VALUE_SYMBOL"); break; + } + + m_allocation_label->SetText(boost::io::str(FlexibleFormat(UserString("RESOURCE_ALLOCATION_TOOLTIP")) % + resource_text % + DoubleToString(total_system_resource_allocation, 3, false, false))); + + // height of label already added to top outside this function } void SystemResourceSummaryBrowseWnd::UpdateImportExport(GG::Y& top) { Modified: trunk/FreeOrion/UI/InfoPanels.h =================================================================== --- trunk/FreeOrion/UI/InfoPanels.h 2009-01-16 05:11:50 UTC (rev 2753) +++ trunk/FreeOrion/UI/InfoPanels.h 2009-01-16 05:16:21 UTC (rev 2754) @@ -391,7 +391,7 @@ * over the system resource production summary. */ class SystemResourceSummaryBrowseWnd : public GG::BrowseInfoWnd { public: - SystemResourceSummaryBrowseWnd(ResourceType resource_type, const System* system); + SystemResourceSummaryBrowseWnd(ResourceType resource_type, const System* system, int player_id = -1); virtual bool WndHasBrowseInfo(const Wnd* wnd, std::size_t mode) const; @@ -407,6 +407,7 @@ ResourceType m_resource_type; const System* m_system; + int m_player_id; GG::TextControl* m_production_label; GG::TextControl* m_allocation_label; Modified: trunk/FreeOrion/UI/SidePanel.cpp =================================================================== --- trunk/FreeOrion/UI/SidePanel.cpp 2009-01-16 05:11:50 UTC (rev 2753) +++ trunk/FreeOrion/UI/SidePanel.cpp 2009-01-16 05:16:21 UTC (rev 2754) @@ -1438,7 +1438,7 @@ MeterType type = *it; // add tooltip for each meter type boost::shared_ptr<GG::BrowseInfoWnd> browse_wnd = boost::shared_ptr<GG::BrowseInfoWnd>( - new SystemResourceSummaryBrowseWnd(MeterToResource(type), s_system)); + new SystemResourceSummaryBrowseWnd(MeterToResource(type), s_system, HumanClientApp::GetApp()->EmpireID())); m_system_resource_summary->SetToolTip(type, browse_wnd); } Modified: trunk/FreeOrion/default/eng_stringtable.txt =================================================================== --- trunk/FreeOrion/default/eng_stringtable.txt 2009-01-16 05:11:50 UTC (rev 2753) +++ trunk/FreeOrion/default/eng_stringtable.txt 2009-01-16 05:16:21 UTC (rev 2754) @@ -1115,7 +1115,42 @@ SP_SYSTEM_PRODUCTION System Production +RESOURCE_PRODUCTION_TOOLTIP +System %1%: %2% + +RESOURCE_ALLOCATION_TOOLTIP +System %1%: %2% + +FOOD_CONSUMPTION +Food Consumption + +MINERALS_CONSUMPTION +Minerals Consumption + +INDUSTRY_CONSUMPTION +Industrial Consumption + +RESEARCH_CONSUMPTION +Research Consumption + +TRADE_CONSUMPTION +Trade Consumption + +INTERSYSTEM_EXCHANGE_TOOLTIP +Inter-System Exchange + +RESOURCE_IMPORT +Importing + +RESOURCE_EXPORT +Exporting + +RESOURCE_UNUSED +Unused + + ##Planet Panel############# + PLANET_PANEL Planet Panel @@ -1131,6 +1166,7 @@ PL_COLONIZE Colonize + ##Population Panel######### PP_POPULATION @@ -1139,6 +1175,7 @@ PP_HEALTH Health + ## Resources Panel ########## RP_PRIMARY_FOCUS_TOOLTIP @@ -1165,6 +1202,7 @@ RP_CONSTRUCTION Construction Infrastructure + ## Military Panel ########## MP_SUPPLY @@ -1182,6 +1220,7 @@ MP_STEALTH Stealth + ## Buildings Panel########## BP_INCOMPLETE_BUILDING_TOOLTIP @@ -1194,6 +1233,7 @@ %2%''' + ## General Tooltips######### TT_CURRENT @@ -1229,6 +1269,12 @@ TT_UNKNOWN Unknown +TT_RESOURCE_PRODUCTION +%1% produces %2% + +TT_RESOURCE_ALLOCATION +%1% consumes %2% + ## Misc. Sidepanel########## SP_UNKNOWN_SYSTEM |
From: <geo...@us...> - 2009-01-16 09:50:44
|
Revision: 2756 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2756&view=rev Author: geoffthemedio Date: 2009-01-16 09:50:35 +0000 (Fri, 16 Jan 2009) Log Message: ----------- -More SystemResourceSummaryBrowseWnd progress. Food, mineral, industry and trade consumption for a system are broken down by objects consuming. (Research isn't consumed at a particular location) --Still showing all objects returned by System::FindObjects, which seems to be returning duplicates of some objects. Will later only show objects that have nonzero consumption and production in these tooltips. -Random commenting and grooming Modified Paths: -------------- trunk/FreeOrion/Empire/Empire.cpp trunk/FreeOrion/UI/InfoPanels.cpp trunk/FreeOrion/UI/InfoPanels.h trunk/FreeOrion/UI/MapWnd.cpp trunk/FreeOrion/UI/SidePanel.cpp trunk/FreeOrion/default/eng_stringtable.txt trunk/FreeOrion/universe/Building.cpp trunk/FreeOrion/universe/Building.h Modified: trunk/FreeOrion/Empire/Empire.cpp =================================================================== --- trunk/FreeOrion/Empire/Empire.cpp 2009-01-16 05:29:08 UTC (rev 2755) +++ trunk/FreeOrion/Empire/Empire.cpp 2009-01-16 09:50:35 UTC (rev 2756) @@ -2462,7 +2462,7 @@ Building *building = universe_object_cast<Building*>(*it); if (!building) continue; //if (building->Operating()) - m_maintenance_total_cost += GetBuildingType(building->BuildingTypeName())->MaintenanceCost(); + m_maintenance_total_cost += building->GetBuildingType()->MaintenanceCost(); } m_resource_pools[RE_TRADE]->ChangedSignal(); } Modified: trunk/FreeOrion/UI/InfoPanels.cpp =================================================================== --- trunk/FreeOrion/UI/InfoPanels.cpp 2009-01-16 05:29:08 UTC (rev 2755) +++ trunk/FreeOrion/UI/InfoPanels.cpp 2009-01-16 09:50:35 UTC (rev 2756) @@ -112,6 +112,10 @@ } virtual void UpdateImpl(std::size_t mode, const Wnd* target) { + // because a MeterBrowseWnd's contents depends only on the meters of a single object, if that object doesn't + // change between showings of the meter browse wnd, it's not necessary to fully recreate the MeterBrowseWnd, + // and it can be just reshown.without being altered. To refresh a MeterBrowseWnd, recreate it by assigning + // a new one as the moused-over object's BrowseWnd in this Wnd's place if (!initialized) Initialize(); } @@ -315,8 +319,84 @@ } - /** */ - double ObjectResourceConsumption(const UniverseObject* obj, ResourceType resource_type, int player_id = -1) { + /** Returns how much of specified \a resource_type is being consumed by the empire with id \a empire_id + * at the location of the specified object \a obj. */ + double ObjectResourceConsumption(const UniverseObject* obj, ResourceType resource_type, int empire_id = ALL_EMPIRES) { + if (!obj) { + Logger().errorStream() << "ObjectResourceConsumption passed a null object"; + return 0.0; + } + if (resource_type == INVALID_RESOURCE_TYPE) { + Logger().errorStream() << "ObjectResourceConsumption passed a INVALID_RESOURCE_TYPE"; + return 0.0; + } + + + const Empire* empire = 0; + + if (empire_id != ALL_EMPIRES) { + empire = Empires().Lookup(empire_id); + + if (!empire) { + Logger().errorStream() << "ObjectResourceConsumption requested consumption for empire " << empire_id << " but this empire was not found"; + return 0.0; // requested a specific empire, but didn't find it in this client, so production is 0.0 + } + + if (!obj->OwnedBy(empire_id)) { + Logger().debugStream() << "ObjectResourceConsumption requested consumption for empire " << empire_id << " but this empire doesn't own the object"; + return 0.0; // if the empire doesn't own the object, assuming it can't be consuming any of the empire's resources. May need to revisit this assumption later. + } + } + + + const PopCenter* pc = 0; + double prod_queue_allocation_sum = 0.0; + const Building* building = 0; + + switch (resource_type) { + case RE_FOOD: + // food allocated to obj if obj is a PopCenter + if (pc = dynamic_cast<const PopCenter*>(obj)) + return pc->AllocatedFood(); + return 0.0; // can't consume food if not a PopCenter + break; + + case RE_MINERALS: + case RE_INDUSTRY: + // PP (equal to mineral and industry) cost of objects on production queue at this object's location + if (empire) { + // add allocated PP for all production items at this location for this empire + const ProductionQueue& queue = empire->GetProductionQueue(); + for (ProductionQueue::const_iterator queue_it = queue.begin(); queue_it != queue.end(); ++queue_it) + if (queue_it->location == obj->ID()) + prod_queue_allocation_sum += queue_it->allocated_pp; + + } else { + // add allocated PP for all production items at this location for all empires + for (EmpireManager::const_iterator it = Empires().begin(); it != Empires().end(); ++it) { + empire = it->second; + const ProductionQueue& queue = empire->GetProductionQueue(); + for (ProductionQueue::const_iterator queue_it = queue.begin(); queue_it != queue.end(); ++queue_it) + if (queue_it->location == obj->ID()) + prod_queue_allocation_sum += queue_it->allocated_pp; + } + } + return prod_queue_allocation_sum; + break; + + case RE_TRADE: + // maintenance cost of this object + if (building = dynamic_cast<const Building*>(obj)) + return building->GetBuildingType()->MaintenanceCost(); + return 0.0; // if not a building, doesn't presently consume trade + break; + + case RE_RESEARCH: + // research isn't consumed at a particular location, so none is consumed at any location + default: + // for INVALID_RESOURCE_TYPE just return 0.0. Could throw an exception, I suppose... + break; + } return 0.0; } } @@ -528,7 +608,7 @@ if(obj->Owners().empty()) owner = OS_NONE; // uninhabited else { - if(!obj->OwnedBy(HumanClientApp::GetApp()->EmpireID())) + if (!obj->OwnedBy(HumanClientApp::GetApp()->EmpireID())) owner = OS_FOREIGN; // inhabited by other empire else owner = OS_SELF; // inhabited by this empire (and possibly other empires) @@ -923,6 +1003,8 @@ owner = OS_SELF; // inhabited by this empire (and possibly other empires) } + + // only allow focus changes in UI for planets this client's player's empire owns if (owner == OS_SELF) { m_primary_focus_drop->Disable(false); m_secondary_focus_drop->Disable(false); @@ -973,6 +1055,9 @@ browse_wnd = boost::shared_ptr<GG::BrowseInfoWnd>(new MeterBrowseWnd(METER_CONSTRUCTION, obj, *meter_map)); m_multi_icon_value_indicator->SetToolTip(METER_CONSTRUCTION, browse_wnd); + } else { + // I'd like to do something like m_*_stat->ClearBrowseWnd(); to enesure an old BrowseWnd isn't shown + // but as far as I know, there's no way to do this. } // focus droplists @@ -1795,6 +1880,7 @@ void BuildingsPanel::Update() { + // remove old indicators for (std::vector<BuildingIndicator*>::iterator it = m_building_indicators.begin(); it != m_building_indicators.end(); ++it) { DetachChild(*it); delete (*it); @@ -2267,8 +2353,7 @@ m_player_id(player_id), m_production_label(0), m_allocation_label(0), m_import_export_label(0), m_import_export_amount(0), - row_height(1), production_label_top(0), allocation_label_top(0), import_export_label_top(0), - initialized(false) + row_height(1), production_label_top(0), allocation_label_top(0), import_export_label_top(0) {} bool SystemResourceSummaryBrowseWnd::WndHasBrowseInfo(const GG::Wnd* wnd, std::size_t mode) const { @@ -2290,8 +2375,13 @@ } void SystemResourceSummaryBrowseWnd::UpdateImpl(std::size_t mode, const GG::Wnd* target) { - if (!initialized) - Initialize(); + // fully recreate browse wnd for each viewing. finding all the queues, resourcepools and (maybe?) individual + // UniverseObject that would have ChangedSignals that would need to be connected to the object that creates + // this BrowseWnd seems like more trouble than it's worth to avoid recreating the BrowseWnd every time it's shown + // (the alternative is to only reinitialize when something changes that would affect what's displayed in the + // BrowseWnd, which is how MeterBrowseWnd works) + Clear(); + Initialize(); } void SystemResourceSummaryBrowseWnd::Initialize() { @@ -2329,9 +2419,6 @@ Resize(GG::Pt(LABEL_WIDTH + VALUE_WIDTH, top)); - - - initialized = true; } void SystemResourceSummaryBrowseWnd::UpdateProduction(GG::Y& top) { @@ -2389,6 +2476,24 @@ } + if (m_production_labels_and_amounts.empty()) { + // add "blank" line to indicate no production + GG::TextControl* label = new GG::TextControl(GG::X0, top, LABEL_WIDTH, row_height, + UserString("NOT_APPLICABLE"), font, ClientUI::TextColor(), + GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); + AttachChild(label); + + GG::TextControl* value = new GG::TextControl(LABEL_WIDTH, top, VALUE_WIDTH, row_height, + "", font, ClientUI::TextColor(), + GG::FORMAT_CENTER | GG::FORMAT_VCENTER); + AttachChild(value); + + m_production_labels_and_amounts.push_back(std::pair<GG::TextControl*, GG::TextControl*>(label, value)); + + top += row_height; + } + + // set production label std::string resource_text = ""; switch (m_resource_type) { @@ -2447,6 +2552,16 @@ double allocation = ObjectResourceConsumption(obj, m_resource_type, m_player_id); + // following section should be uncommented, but I'm leaving it commented now to help isolate an apparent bug where more + // objects are returned from m_system->FindObjects() than would be expected. (Multiple copies of some objects are returned) + //// don't add summary entries for objects that consume no resource. (otherwise there would be a loooong pointless list of 0's + //if (allocation <= 0.0) { + // if (allocation < 0.0) + // Logger().errorStream() << "object " << obj->Name() << " is reported having negative " << boost::lexical_cast<std::string>(m_resource_type) << " consumption"; + // continue; + //} + + total_system_resource_allocation += allocation; std::string amount_text = DoubleToString(allocation, 3, false, false); @@ -2455,7 +2570,6 @@ GG::TextControl* label = new GG::TextControl(GG::X0, top, LABEL_WIDTH, row_height, name, font, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); - label->Resize(GG::Pt(LABEL_WIDTH, row_height)); AttachChild(label); GG::TextControl* value = new GG::TextControl(LABEL_WIDTH, top, VALUE_WIDTH, row_height, @@ -2469,6 +2583,24 @@ } + if (m_allocation_labels_and_amounts.empty()) { + // add "blank" line to indicate no allocation + GG::TextControl* label = new GG::TextControl(GG::X0, top, LABEL_WIDTH, row_height, + UserString("NOT_APPLICABLE"), font, ClientUI::TextColor(), + GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); + AttachChild(label); + + GG::TextControl* value = new GG::TextControl(LABEL_WIDTH, top, VALUE_WIDTH, row_height, + "", font, ClientUI::TextColor(), + GG::FORMAT_CENTER | GG::FORMAT_VCENTER); + AttachChild(value); + + m_allocation_labels_and_amounts.push_back(std::pair<GG::TextControl*, GG::TextControl*>(label, value)); + + top += row_height; + } + + // set consumption / allocation label std::string resource_text = ""; switch (m_resource_type) { @@ -2486,9 +2618,15 @@ resource_text = UserString("UNKNOWN_VALUE_SYMBOL"); break; } + std::string system_allocation_text = DoubleToString(total_system_resource_allocation, 3, false, false); + + // for research only, local allocation makes no sense + if (m_resource_type == RE_RESEARCH && total_system_resource_allocation == 0.0) + system_allocation_text = UserString("NOT_APPLICABLE"); + m_allocation_label->SetText(boost::io::str(FlexibleFormat(UserString("RESOURCE_ALLOCATION_TOOLTIP")) % resource_text % - DoubleToString(total_system_resource_allocation, 3, false, false))); + system_allocation_text)); // height of label already added to top outside this function } @@ -2504,3 +2642,22 @@ top += row_height; } +void SystemResourceSummaryBrowseWnd::Clear() { + DeleteChild(m_production_label); + DeleteChild(m_allocation_label); + + DeleteChild(m_import_export_label); + DeleteChild(m_import_export_amount); + + for (std::vector<std::pair<GG::TextControl*, GG::TextControl*> >::iterator it = m_production_labels_and_amounts.begin(); it != m_production_labels_and_amounts.end(); ++it) { + DeleteChild(it->first); + DeleteChild(it->second); + } + m_production_labels_and_amounts.clear(); + + for (std::vector<std::pair<GG::TextControl*, GG::TextControl*> >::iterator it = m_allocation_labels_and_amounts.begin(); it != m_allocation_labels_and_amounts.end(); ++it) { + DeleteChild(it->first); + DeleteChild(it->second); + } + m_allocation_labels_and_amounts.clear(); +} \ No newline at end of file Modified: trunk/FreeOrion/UI/InfoPanels.h =================================================================== --- trunk/FreeOrion/UI/InfoPanels.h 2009-01-16 05:29:08 UTC (rev 2755) +++ trunk/FreeOrion/UI/InfoPanels.h 2009-01-16 09:50:35 UTC (rev 2756) @@ -398,6 +398,7 @@ virtual void Render(); private: + void Clear(); void Initialize(); virtual void UpdateImpl(std::size_t mode, const GG::Wnd* target); @@ -427,8 +428,6 @@ static const GG::X LABEL_WIDTH; static const GG::X VALUE_WIDTH; static const int EDGE_PAD; - - bool initialized; }; #endif Modified: trunk/FreeOrion/UI/MapWnd.cpp =================================================================== --- trunk/FreeOrion/UI/MapWnd.cpp 2009-01-16 05:29:08 UTC (rev 2755) +++ trunk/FreeOrion/UI/MapWnd.cpp 2009-01-16 09:50:35 UTC (rev 2756) @@ -258,7 +258,6 @@ m_side_panel = new SidePanel(GG::GUI::GetGUI()->AppWidth() - SIDE_PANEL_WIDTH, m_toolbar->LowerRight().y, SIDE_PANEL_WIDTH, GG::GUI::GetGUI()->AppHeight()); GG::Connect(m_side_panel->SystemSelectedSignal, &MapWnd::SelectSystem, this); // sidepanel requests system selection change -> select it GG::Connect(m_side_panel->ResourceCenterChangedSignal, &MapWnd::UpdateSidePanelSystemObjectMetersAndResourcePools, this); // something in sidepanel changed resource pool(s), so need to recalculate and update meteres and resource pools and refresh their indicators - //GG::Connect(m_side_panel->ResourceCenterChangedSignal, &MapWnd::UpdateMetersAndResourcePools, this); // something in sidepanel changed resource pool(s), so need to recalculate and update meteres and resource pools and refresh their indicators m_sitrep_panel = new SitRepPanel( (GG::GUI::GetGUI()->AppWidth()-SITREP_PANEL_WIDTH)/2, (GG::GUI::GetGUI()->AppHeight()-SITREP_PANEL_HEIGHT)/2, SITREP_PANEL_WIDTH, SITREP_PANEL_HEIGHT ); GG::Connect(m_sitrep_panel->ClosingSignal, BoolToVoidAdapter(boost::bind(&MapWnd::ToggleSitRep, this))); // sitrep panel is manually closed by user Modified: trunk/FreeOrion/UI/SidePanel.cpp =================================================================== --- trunk/FreeOrion/UI/SidePanel.cpp 2009-01-16 05:29:08 UTC (rev 2755) +++ trunk/FreeOrion/UI/SidePanel.cpp 2009-01-16 09:50:35 UTC (rev 2756) @@ -833,6 +833,7 @@ { const Planet *planet = GetPlanet(); + // determine the ownership status of planet with respect to this client's player's empire enum OWNERSHIP {OS_NONE, OS_FOREIGN, OS_SELF} owner = OS_NONE; if (planet->Owners().empty() || planet->IsAboutToBeColonized()) { @@ -844,17 +845,23 @@ owner = OS_SELF; } + + // colour planet name with owner's empire colour if (!planet->Owners().empty()) { Empire* planet_empire = Empires().Lookup(*(planet->Owners().begin())); m_planet_name->SetTextColor(planet_empire ? planet_empire->Color() : ClientUI::TextColor()); } + + // set up planet panel differently for owned and unowned planets... if (owner == OS_NONE && !SHOW_ALL_PLANET_PANELS) { + // show only the environment and size information and (if applicable) buildings and specials AttachChild(m_env_size); DetachChild(m_population_panel); DetachChild(m_resource_panel); DetachChild(m_military_panel); } else { + // show population, resource and military panels, but hide environement / size indicator that's used only for uncolonized planets DetachChild(m_env_size); AttachChild(m_population_panel); m_population_panel->Refresh(); @@ -864,6 +871,8 @@ m_military_panel->Refresh(); } + + // create colonize or cancel button, if appropriate (a ship is in the system that can colonize, or the planet has been ordered to be colonized already this turn) if (owner == OS_NONE && planet->GetMeter(METER_POPULATION)->Max() > 0 && !planet->IsAboutToBeColonized() && FindColonyShip(planet->SystemID())) { AttachChild(m_button_colonize); m_button_colonize->SetText(UserString("PL_COLONIZE") + " " + boost::lexical_cast<std::string>(planet->GetMeter(METER_POPULATION)->Max())); @@ -876,6 +885,8 @@ DetachChild(m_button_colonize); } + + // update panels m_buildings_panel->Refresh(); m_specials_panel->Update(); Modified: trunk/FreeOrion/default/eng_stringtable.txt =================================================================== --- trunk/FreeOrion/default/eng_stringtable.txt 2009-01-16 05:29:08 UTC (rev 2755) +++ trunk/FreeOrion/default/eng_stringtable.txt 2009-01-16 09:50:35 UTC (rev 2756) @@ -79,6 +79,8 @@ NEW_FLEET_NAME_NO_NUMBER New Fleet +NOT_APPLICABLE +N/A ########################## # Status Update Messages # Modified: trunk/FreeOrion/universe/Building.cpp =================================================================== --- trunk/FreeOrion/universe/Building.cpp 2009-01-16 05:29:08 UTC (rev 2755) +++ trunk/FreeOrion/universe/Building.cpp 2009-01-16 09:50:35 UTC (rev 2756) @@ -57,7 +57,7 @@ AddOwner(empire_id); const BuildingType* type = GetBuildingType(); if (type) - Rename(type->Name()); + Rename(UserString(type->Name())); else Rename(UserString("ENC_BUILDING")); } Modified: trunk/FreeOrion/universe/Building.h =================================================================== --- trunk/FreeOrion/universe/Building.h 2009-01-16 05:29:08 UTC (rev 2755) +++ trunk/FreeOrion/universe/Building.h 2009-01-16 09:50:35 UTC (rev 2756) @@ -27,7 +27,7 @@ /** \name Accessors */ //@{ /** returns the BuildingType object for this building, specific to the owning empire (or the default version if there is other than exactly one owner) */ - const BuildingType* GetBuildingType() const; + const BuildingType* GetBuildingType() const; const std::string& BuildingTypeName() const; ///< returns the name of the BuildingType object for this building int PlanetID() const; ///< returns the ID number of the planet this building is on |
From: <geo...@us...> - 2009-01-17 01:13:22
|
Revision: 2758 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2758&view=rev Author: geoffthemedio Date: 2009-01-17 01:13:12 +0000 (Sat, 17 Jan 2009) Log Message: ----------- -Fixed a bug with one of the overloads of System::FindObjects that was returning multiple copies of objects that were contained within objects in the system -Removed some unneeded entries in the SystemResourceSummaryBrowseWnd tooltip that were being used to debug the previous issue -Commented out various other bits of debug output Modified Paths: -------------- trunk/FreeOrion/Empire/ResourcePool.cpp trunk/FreeOrion/UI/InfoPanels.cpp trunk/FreeOrion/client/human/HumanClientAppSoundOpenAL.cpp trunk/FreeOrion/universe/PopCenter.cpp trunk/FreeOrion/universe/System.cpp trunk/FreeOrion/universe/System.h Modified: trunk/FreeOrion/Empire/ResourcePool.cpp =================================================================== --- trunk/FreeOrion/Empire/ResourcePool.cpp 2009-01-16 17:12:30 UTC (rev 2757) +++ trunk/FreeOrion/Empire/ResourcePool.cpp 2009-01-17 01:13:12 UTC (rev 2758) @@ -151,7 +151,7 @@ } void ResourcePool::SetResourceCenters(const std::vector<ResourceCenter*>& resource_center_vec) { - Logger().debugStream() << "ResourcePool::SetResourceCenters for type " << boost::lexical_cast<std::string>(m_type); + //Logger().debugStream() << "ResourcePool::SetResourceCenters for type " << boost::lexical_cast<std::string>(m_type); m_resource_centers = resource_center_vec; m_resource_center_objs.clear(); for (std::vector<ResourceCenter*>::const_iterator it = m_resource_centers.begin(); it != m_resource_centers.end(); ++it) { @@ -161,19 +161,21 @@ Logger().errorStream() << "ResourcePool::SetResourceCenters couldn't cast a ResourceCenter to a UniverseObject"; continue; } - Logger().debugStream() << "... adding object: " << obj->Name() << " (" << obj->ID() << ")"; + //Logger().debugStream() << "... adding object: " << obj->Name() << " (" << obj->ID() << ")"; m_resource_center_objs[rc] = obj; } } void ResourcePool::SetSystemSupplyGroups(const std::set<std::set<int> >& supply_system_groups) { - Logger().debugStream() << "ResourcePool::SetSystemSupplyGroups for type " << boost::lexical_cast<std::string>(m_type); + //Logger().debugStream() << "ResourcePool::SetSystemSupplyGroups for type " << boost::lexical_cast<std::string>(m_type); m_supply_system_groups_resource_production.clear(); // get rid of old data // add a (zero-valued, for now) entry in the map from sets to production amounts for each group. will accumulate actual production later for (std::set<std::set<int> >::const_iterator it = supply_system_groups.begin(); it != supply_system_groups.end(); ++it) { - Logger().debugStream() << "... group: "; - for (std::set<int>::const_iterator set_it = it->begin(); set_it != it->end(); ++set_it) - Logger().debugStream() << "... ... " << *set_it; + //// DEBUG + //Logger().debugStream() << "... group: "; + //for (std::set<int>::const_iterator set_it = it->begin(); set_it != it->end(); ++set_it) + // Logger().debugStream() << "... ... " << *set_it; + //// END DBUG m_supply_system_groups_resource_production[*it] = 0.0; } } Modified: trunk/FreeOrion/UI/InfoPanels.cpp =================================================================== --- trunk/FreeOrion/UI/InfoPanels.cpp 2009-01-16 17:12:30 UTC (rev 2757) +++ trunk/FreeOrion/UI/InfoPanels.cpp 2009-01-17 01:13:12 UTC (rev 2758) @@ -2538,6 +2538,13 @@ // add label-value pair for each resource-consuming object in system to indicate amount of resource consumed std::vector<UniverseObject*> obj_vec = m_system->FindObjects(); + //// DEBUG + //Logger().debugStream() << "System::FindObjects for system " << m_system->Name(); + //for (std::vector<UniverseObject*>::const_iterator it = obj_vec.begin(); it != obj_vec.end(); ++it) + // Logger().debugStream() << ".... " << (*it)->Name(); + //// END DEBUG + + for (std::vector<UniverseObject*>::const_iterator it = obj_vec.begin(); it != obj_vec.end(); ++it) { const UniverseObject* obj = *it; @@ -2552,14 +2559,12 @@ double allocation = ObjectResourceConsumption(obj, m_resource_type, m_player_id); - // following section should be uncommented, but I'm leaving it commented now to help isolate an apparent bug where more - // objects are returned from m_system->FindObjects() than would be expected. (Multiple copies of some objects are returned) - //// don't add summary entries for objects that consume no resource. (otherwise there would be a loooong pointless list of 0's - //if (allocation <= 0.0) { - // if (allocation < 0.0) - // Logger().errorStream() << "object " << obj->Name() << " is reported having negative " << boost::lexical_cast<std::string>(m_resource_type) << " consumption"; - // continue; - //} + // don't add summary entries for objects that consume no resource. (otherwise there would be a loooong pointless list of 0's + if (allocation <= 0.0) { + if (allocation < 0.0) + Logger().errorStream() << "object " << obj->Name() << " is reported having negative " << boost::lexical_cast<std::string>(m_resource_type) << " consumption"; + continue; + } total_system_resource_allocation += allocation; Modified: trunk/FreeOrion/client/human/HumanClientAppSoundOpenAL.cpp =================================================================== --- trunk/FreeOrion/client/human/HumanClientAppSoundOpenAL.cpp 2009-01-16 17:12:30 UTC (rev 2757) +++ trunk/FreeOrion/client/human/HumanClientAppSoundOpenAL.cpp 2009-01-17 01:13:12 UTC (rev 2758) @@ -29,7 +29,7 @@ { m_context = alcCreateContext(m_device,NULL); // instead of NULL we can pass a ALCint* pointing to a set of // attributes (ALC_FREQUENCY, ALC_REFRESH and ALC_SYNC) - + if ((m_context != NULL) && (alcMakeContextCurrent(m_context) == AL_TRUE)) { alutInitWithoutContext(NULL,NULL); // we need to init alut or we won't be able to read .wav files @@ -39,7 +39,7 @@ error_code = alGetError(); if(error_code != AL_NO_ERROR) { - Logger().errorStream() << "Unable to create OpenAL sources: " << alGetString(error_code) << "\n" << "Disabling OpenAL sound system!\n"; + Logger().errorStream() << "Unable to create OpenAL sources: " << alGetString(error_code) << "\n" << "Disabling OpenAL sound system!\n"; alcMakeContextCurrent(NULL); alcDestroyContext(m_context); } @@ -66,10 +66,9 @@ << "Renderer " << alGetString(AL_RENDERER) << "Vendor " - << alGetString(AL_VENDOR) - << "\nExtensions: " - << alGetString(AL_EXTENSIONS) - << "\n"; + << alGetString(AL_VENDOR) << "\n" + << "Extensions: " + << alGetString(AL_EXTENSIONS) << "\n"; } } } Modified: trunk/FreeOrion/universe/PopCenter.cpp =================================================================== --- trunk/FreeOrion/universe/PopCenter.cpp 2009-01-16 17:12:30 UTC (rev 2757) +++ trunk/FreeOrion/universe/PopCenter.cpp 2009-01-17 01:13:12 UTC (rev 2758) @@ -72,7 +72,7 @@ { double max = GetMeter(METER_POPULATION)->Max(); double cur = GetMeter(METER_POPULATION)->Current(); - Logger().debugStream() << "PopCenter::FuturePopGrowth growth max: " << FuturePopGrowthMax() << " allocated food: " << AllocatedFood(); + //Logger().debugStream() << "PopCenter::FuturePopGrowth growth max: " << FuturePopGrowthMax() << " allocated food: " << AllocatedFood(); return std::max(-cur, std::min(FuturePopGrowthMax(), std::min(AllocatedFood(), max) - cur)); } Modified: trunk/FreeOrion/universe/System.cpp =================================================================== --- trunk/FreeOrion/universe/System.cpp 2009-01-16 17:12:30 UTC (rev 2757) +++ trunk/FreeOrion/universe/System.cpp 2009-01-17 01:13:12 UTC (rev 2758) @@ -106,12 +106,13 @@ { Universe& universe = GetUniverse(); std::vector<UniverseObject*> retval; - // add objects contained in this system, and objects contained in those objects for (ObjectMultimap::const_iterator it = m_objects.begin(); it != m_objects.end(); ++it) { - UniverseObject* object = universe.Object(it->second); - retval.push_back(object); - std::vector<UniverseObject*> contained_objects = object->FindObjects(); - std::copy(contained_objects.begin(), contained_objects.end(), std::back_inserter(retval)); + UniverseObject* obj = universe.Object(it->second); + if (!obj) { + Logger().errorStream() << "System::FindObjects couldn't get a UniverseObject for an object ID in the system"; + continue; + } + retval.push_back(obj); } return retval; } @@ -245,10 +246,10 @@ return -1; } - Logger().debugStream() << "System::Insert system " << this->Name() << " (object " << obj->Name() << ", orbit " << orbit << ")"; + //Logger().debugStream() << "System::Insert system " << this->Name() << " (object " << obj->Name() << ", orbit " << orbit << ")"; //Logger().debugStream() << "..initial objects in system: "; //for (ObjectMultimap::iterator it = m_objects.begin(); it != m_objects.end(); ++it) - // Logger().debugStream() << "...." << GetUniverse().Object(it->second)->Name(); + // Logger().debugStream() << ".... id: " << it->second << " name: " << GetUniverse().Object(it->second)->Name(); //Logger().debugStream() << "..initial object systemid: " << obj->SystemID(); if (orbit < -1) { Modified: trunk/FreeOrion/universe/System.h =================================================================== --- trunk/FreeOrion/universe/System.h 2009-01-16 17:12:30 UTC (rev 2757) +++ trunk/FreeOrion/universe/System.h 2009-01-17 01:13:12 UTC (rev 2758) @@ -302,6 +302,11 @@ m_orbits = orbits; m_objects = objects; m_starlanes_wormholes = starlanes_wormholes; + //// DEBUG + //Logger().debugStream() << "system " << this->Name() << " deserialized objects ids:"; + //for (ObjectMultimap::const_iterator it = m_objects.begin(); it != m_objects.end(); ++it) + // Logger().debugStream() << ".... " << it->second; + //// END DEBUG } } |
From: <geo...@us...> - 2009-01-17 07:17:28
|
Revision: 2760 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2760&view=rev Author: geoffthemedio Date: 2009-01-17 07:17:18 +0000 (Sat, 17 Jan 2009) Log Message: ----------- Finished SystemResourceSummaryBrowseWnd by adding importing / available for export totals Modified Paths: -------------- trunk/FreeOrion/UI/InfoPanels.cpp trunk/FreeOrion/UI/InfoPanels.h trunk/FreeOrion/default/eng_stringtable.txt Modified: trunk/FreeOrion/UI/InfoPanels.cpp =================================================================== --- trunk/FreeOrion/UI/InfoPanels.cpp 2009-01-17 01:15:30 UTC (rev 2759) +++ trunk/FreeOrion/UI/InfoPanels.cpp 2009-01-17 07:17:18 UTC (rev 2760) @@ -28,6 +28,11 @@ using boost::lexical_cast; namespace { + /** Returns text wrapped in GG RGBA tags for specified colour */ + std::string ColourWrappedtext(const std::string& text, const GG::Clr colour) { + return GG::RgbaTag(colour) + text + "</rgba>"; + } + /** Returns text representation of number wrapped in GG RGBA tags for colour depending on whether number is positive, negative or 0.0 */ std::string ColouredNumber(double number) { @@ -36,7 +41,7 @@ clr = ClientUI::StatIncrColor(); else if (number < 0.0) clr = ClientUI::StatDecrColor(); - return GG::RgbaTag(clr) + DoubleToString(number, 3, false, true) + "</rgba>"; + return ColourWrappedtext(DoubleToString(number, 3, false, true), clr); } @@ -1033,6 +1038,9 @@ meter_map = &(map_it->second); if (meter_map) { + // create an attach browse info wnds for each meter type on the icon+number stats used when collapsed and + // for all meter types shown in the multi icon value indicator. this replaces any previous-present + // browse wnd on these indicators boost::shared_ptr<GG::BrowseInfoWnd> browse_wnd = boost::shared_ptr<GG::BrowseInfoWnd>(new MeterBrowseWnd(METER_FARMING, obj, *meter_map)); m_farming_stat->SetBrowseInfoWnd(browse_wnd); m_multi_icon_value_indicator->SetToolTip(METER_FARMING, browse_wnd); @@ -1056,15 +1064,29 @@ browse_wnd = boost::shared_ptr<GG::BrowseInfoWnd>(new MeterBrowseWnd(METER_CONSTRUCTION, obj, *meter_map)); m_multi_icon_value_indicator->SetToolTip(METER_CONSTRUCTION, browse_wnd); } else { - // I'd like to do something like m_*_stat->ClearBrowseWnd(); to enesure an old BrowseWnd isn't shown - // but as far as I know, there's no way to do this. + // remove any old browse wnds + m_farming_stat->ClearBrowseInfoWnd(); + m_multi_icon_value_indicator->ClearToolTip(METER_FARMING); + + m_mining_stat->ClearBrowseInfoWnd(); + m_multi_icon_value_indicator->ClearToolTip(METER_MINING); + + m_industry_stat->ClearBrowseInfoWnd(); + m_multi_icon_value_indicator->ClearToolTip(METER_INDUSTRY); + + m_research_stat->ClearBrowseInfoWnd(); + m_multi_icon_value_indicator->ClearToolTip(METER_RESEARCH); + + m_trade_stat->ClearBrowseInfoWnd(); + m_multi_icon_value_indicator->ClearToolTip(METER_TRADE); + + m_multi_icon_value_indicator->ClearToolTip(METER_CONSTRUCTION); } // focus droplists m_drop_changed_connections[m_primary_focus_drop].block(); // prevent cyclic signalling std::string text; - switch (res->PrimaryFocus()) - { + switch (res->PrimaryFocus()) { case FOCUS_BALANCED: m_primary_focus_drop->Select(0); text = boost::io::str(FlexibleFormat(UserString("RP_PRIMARY_FOCUS_TOOLTIP")) % UserString("FOCUS_BALANCED")); @@ -1098,8 +1120,7 @@ m_primary_focus_drop->SetBrowseText(text); m_drop_changed_connections[m_secondary_focus_drop].block(); - switch (res->SecondaryFocus()) - { + switch (res->SecondaryFocus()) { case FOCUS_BALANCED: m_secondary_focus_drop->Select(0); text = boost::io::str(FlexibleFormat(UserString("RP_SECONDARY_FOCUS_TOOLTIP")) % UserString("FOCUS_BALANCED")); @@ -1621,6 +1642,12 @@ m_icons.at(i)->SetBrowseInfoWnd(browse_wnd); } +void MultiIconValueIndicator::ClearToolTip(MeterType meter_type) +{ + for (unsigned int i = 0; i < m_icons.size(); ++i) + if (m_meter_types.at(i) == meter_type) + m_icons.at(i)->ClearBrowseInfoWnd(); +} ///////////////////////////////////// // MultiMeterStatusBar // @@ -2342,17 +2369,16 @@ ////////////////////////////////////// // SystemResourceSummaryBrowseWnd // ////////////////////////////////////// -const GG::X SystemResourceSummaryBrowseWnd::LABEL_WIDTH(200); +const GG::X SystemResourceSummaryBrowseWnd::LABEL_WIDTH(240); const GG::X SystemResourceSummaryBrowseWnd::VALUE_WIDTH(60); const int SystemResourceSummaryBrowseWnd::EDGE_PAD(3); -SystemResourceSummaryBrowseWnd::SystemResourceSummaryBrowseWnd(ResourceType resource_type, const System* system, int player_id) : +SystemResourceSummaryBrowseWnd::SystemResourceSummaryBrowseWnd(ResourceType resource_type, const System* system, int empire_id) : GG::BrowseInfoWnd(GG::X0, GG::Y0, LABEL_WIDTH + VALUE_WIDTH, GG::Y1), m_resource_type(resource_type), m_system(system), - m_player_id(player_id), - m_production_label(0), m_allocation_label(0), - m_import_export_label(0), m_import_export_amount(0), + m_empire_id(empire_id), + m_production_label(0), m_allocation_label(0), m_import_export_label(0), row_height(1), production_label_top(0), allocation_label_top(0), import_export_label_top(0) {} @@ -2393,31 +2419,28 @@ GG::Y top = GG::Y0; + production_label_top = top; m_production_label = new GG::TextControl(GG::X0, production_label_top, TOTAL_WIDTH - EDGE_PAD, row_height, "", font_bold, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); AttachChild(m_production_label); top += row_height; - UpdateProduction(top); + allocation_label_top = top; m_allocation_label = new GG::TextControl(GG::X0, allocation_label_top, TOTAL_WIDTH - EDGE_PAD, row_height, "", font_bold, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); AttachChild(m_allocation_label); top += row_height; - UpdateAllocation(top); - // create import / export labels anywhere... will be positions in UpdateImportExport() - m_import_export_label = new GG::TextControl(GG::X0, GG::Y0, TOTAL_WIDTH - EDGE_PAD, row_height, "", font_bold, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); + import_export_label_top = top; + m_import_export_label = new GG::TextControl(GG::X0, import_export_label_top, TOTAL_WIDTH - EDGE_PAD, row_height, "", font_bold, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); AttachChild(m_import_export_label); - m_import_export_amount = new GG::TextControl(GG::X0, GG::Y0, TOTAL_WIDTH - EDGE_PAD, row_height, "", font_bold, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); - AttachChild(m_import_export_amount); + top += row_height; + UpdateImportExport(top); - import_export_label_top = top; - UpdateImportExport(top); // positions and updates import / export labels - Resize(GG::Pt(LABEL_WIDTH + VALUE_WIDTH, top)); } @@ -2434,7 +2457,7 @@ return; - double total_system_resource_production = 0.0; + m_production = 0.0; const boost::shared_ptr<GG::Font>& font = ClientUI::GetFont(); @@ -2445,8 +2468,8 @@ const UniverseObject* obj = *it; // display information only for the requested player - if (m_player_id != -1 && !obj->OwnedBy(m_player_id)) - continue; // if m_player_id == -1, display resource production for all empires. otherwise, skip this resource production if it's not owned by the requested player + if (m_empire_id != ALL_EMPIRES && !obj->OwnedBy(m_empire_id)) + continue; // if m_empire_id == -1, display resource production for all empires. otherwise, skip this resource production if it's not owned by the requested player const ResourceCenter* rc = dynamic_cast<const ResourceCenter*>(obj); if (!rc) @@ -2454,7 +2477,7 @@ std::string name = obj->Name(); double production = rc->ProjectedMeterPoints(ResourceToMeter(m_resource_type)); - total_system_resource_production += production; + m_production += production; std::string amount_text = DoubleToString(production, 3, false, false); @@ -2513,7 +2536,7 @@ m_production_label->SetText(boost::io::str(FlexibleFormat(UserString("RESOURCE_PRODUCTION_TOOLTIP")) % resource_text % - DoubleToString(total_system_resource_production, 3, false, false))); + DoubleToString(m_production, 3, false, false))); // height of label already added to top outside this function } @@ -2531,10 +2554,10 @@ return; - double total_system_resource_allocation = 0.0; + const boost::shared_ptr<GG::Font>& font = ClientUI::GetFont(); + m_allocation = 0.0; - const boost::shared_ptr<GG::Font>& font = ClientUI::GetFont(); // add label-value pair for each resource-consuming object in system to indicate amount of resource consumed std::vector<UniverseObject*> obj_vec = m_system->FindObjects(); @@ -2549,14 +2572,14 @@ const UniverseObject* obj = *it; // display information only for the requested player - if (m_player_id != -1 && !obj->OwnedBy(m_player_id)) - continue; // if m_player_id == -1, display resource production for all empires. otherwise, skip this resource production if it's not owned by the requested player + if (m_empire_id != ALL_EMPIRES && !obj->OwnedBy(m_empire_id)) + continue; // if m_empire_id == ALL_EMPIRES, display resource production for all empires. otherwise, skip this resource production if it's not owned by the requested player std::string name = obj->Name(); - double allocation = ObjectResourceConsumption(obj, m_resource_type, m_player_id); + double allocation = ObjectResourceConsumption(obj, m_resource_type, m_empire_id); // don't add summary entries for objects that consume no resource. (otherwise there would be a loooong pointless list of 0's @@ -2567,16 +2590,29 @@ } - total_system_resource_allocation += allocation; + m_allocation += allocation; std::string amount_text = DoubleToString(allocation, 3, false, false); + // TODO: for food only, colour allocation text depending on need of PopCenter: + // - if allocation < need to avoid starvation: colour stat decr colour (red) + // - if allocation > need to avoid starvation and allocation < need for max growth: colour generic text colour (white) + // - if allocation = need for max growth: colour stat incr colour (green) + // if (m_resource_type == RE_FOOD) { + // // get various needs, determine appropriate colour for food text + // GG::Clr text_colour = // something? + // amount_text = ColourWrappedtext(amount_text, text_colour); + // } + // TODO: for minerals and industry, consider something similar as colouring text for food above. + + GG::TextControl* label = new GG::TextControl(GG::X0, top, LABEL_WIDTH, row_height, name, font, ClientUI::TextColor(), GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); AttachChild(label); + GG::TextControl* value = new GG::TextControl(LABEL_WIDTH, top, VALUE_WIDTH, row_height, amount_text, font, ClientUI::TextColor(), GG::FORMAT_CENTER | GG::FORMAT_VCENTER); @@ -2623,12 +2659,13 @@ resource_text = UserString("UNKNOWN_VALUE_SYMBOL"); break; } - std::string system_allocation_text = DoubleToString(total_system_resource_allocation, 3, false, false); + std::string system_allocation_text = DoubleToString(m_allocation, 3, false, false); // for research only, local allocation makes no sense - if (m_resource_type == RE_RESEARCH && total_system_resource_allocation == 0.0) + if (m_resource_type == RE_RESEARCH && m_allocation == 0.0) system_allocation_text = UserString("NOT_APPLICABLE"); + m_allocation_label->SetText(boost::io::str(FlexibleFormat(UserString("RESOURCE_ALLOCATION_TOOLTIP")) % resource_text % system_allocation_text)); @@ -2637,22 +2674,83 @@ } void SystemResourceSummaryBrowseWnd::UpdateImportExport(GG::Y& top) { - // sets m_import_export_label and m_import_export text and amount to indicate how much resource is being - // imported or exported from this system, and moves them to vertical position \a top and updates \a top - // to be the vertical position below these labels - m_import_export_label; - m_import_export_amount; + m_import_export_label->SetText(UserString("IMPORT_EXPORT_TOOLTIP")); - // TEMP + const Empire* empire = 0; + + // check for early exit cases... + bool abort = false; + if (m_empire_id == ALL_EMPIRES ||m_resource_type == RE_RESEARCH) { + // multiple empires have complicated stockpiling which don't make sense to try to display. + // Research use is nonlocalized, so importing / exporting doesn't make sense to display + abort = true; + } else { + empire = Empires().Lookup(m_empire_id); + if (!empire) + abort = true; + } + + + std::string label_text = "", amount_text = ""; + + + if (!abort) { + double difference = m_production - m_allocation; + + switch (m_resource_type) { + case RE_FOOD: + case RE_MINERALS: + case RE_TRADE: + case RE_INDUSTRY: + if (difference > 0.0) { + // show surplus + label_text = UserString("RESOURCE_EXPORT"); + amount_text = DoubleToString(difference, 3, false, false); + break; + } else if (difference < 0.0) { + // show amount being imported + label_text = UserString("RESOURCE_IMPORT"); + amount_text = DoubleToString(std::abs(difference), 3, false, false); + break; + } + // else fall back to do nothing case + case RE_RESEARCH: + default: + // show nothing + abort = true; + break; + } + } + + + if (abort) { + label_text = UserString("NOT_APPLICABLE"); + amount_text = ""; // no change + } + + + const boost::shared_ptr<GG::Font>& font = ClientUI::GetFont(); + + // add label and amount. may be "NOT APPLIABLE" and nothing if aborted above + GG::TextControl* label = new GG::TextControl(GG::X0, top, LABEL_WIDTH, row_height, + label_text, font, ClientUI::TextColor(), + GG::FORMAT_RIGHT | GG::FORMAT_VCENTER); + AttachChild(label); + + GG::TextControl* value = new GG::TextControl(LABEL_WIDTH, top, VALUE_WIDTH, row_height, + amount_text, font, ClientUI::TextColor(), + GG::FORMAT_CENTER | GG::FORMAT_VCENTER); + AttachChild(value); + + m_import_export_labels_and_amounts.push_back(std::pair<GG::TextControl*, GG::TextControl*>(label, value)); + top += row_height; } void SystemResourceSummaryBrowseWnd::Clear() { DeleteChild(m_production_label); DeleteChild(m_allocation_label); - DeleteChild(m_import_export_label); - DeleteChild(m_import_export_amount); for (std::vector<std::pair<GG::TextControl*, GG::TextControl*> >::iterator it = m_production_labels_and_amounts.begin(); it != m_production_labels_and_amounts.end(); ++it) { DeleteChild(it->first); @@ -2665,4 +2763,10 @@ DeleteChild(it->second); } m_allocation_labels_and_amounts.clear(); + + for (std::vector<std::pair<GG::TextControl*, GG::TextControl*> >::iterator it = m_import_export_labels_and_amounts.begin(); it != m_import_export_labels_and_amounts.end(); ++it) { + DeleteChild(it->first); + DeleteChild(it->second); + } + m_import_export_labels_and_amounts.clear(); } \ No newline at end of file Modified: trunk/FreeOrion/UI/InfoPanels.h =================================================================== --- trunk/FreeOrion/UI/InfoPanels.h 2009-01-17 01:15:30 UTC (rev 2759) +++ trunk/FreeOrion/UI/InfoPanels.h 2009-01-17 07:17:18 UTC (rev 2760) @@ -324,6 +324,7 @@ void Update(); void SetToolTip(MeterType meter_type, const boost::shared_ptr<GG::BrowseInfoWnd>& browse_wnd); + void ClearToolTip(MeterType meter_type); private: std::vector<StatisticIcon*> m_icons; @@ -391,7 +392,7 @@ * over the system resource production summary. */ class SystemResourceSummaryBrowseWnd : public GG::BrowseInfoWnd { public: - SystemResourceSummaryBrowseWnd(ResourceType resource_type, const System* system, int player_id = -1); + SystemResourceSummaryBrowseWnd(ResourceType resource_type, const System* system, int empire_id = ALL_EMPIRES); virtual bool WndHasBrowseInfo(const Wnd* wnd, std::size_t mode) const; @@ -408,16 +409,18 @@ ResourceType m_resource_type; const System* m_system; - int m_player_id; + int m_empire_id; + double m_production; // set by UpdateProduction - used to store production in system so that import / export / unused can be more easily calculated + double m_allocation; // set by UpdateAllocation - used like m_production + GG::TextControl* m_production_label; GG::TextControl* m_allocation_label; - GG::TextControl* m_import_export_label; - GG::TextControl* m_import_export_amount; std::vector<std::pair<GG::TextControl*, GG::TextControl*> > m_production_labels_and_amounts; std::vector<std::pair<GG::TextControl*, GG::TextControl*> > m_allocation_labels_and_amounts; + std::vector<std::pair<GG::TextControl*, GG::TextControl*> > m_import_export_labels_and_amounts; GG::Y row_height; Modified: trunk/FreeOrion/default/eng_stringtable.txt =================================================================== --- trunk/FreeOrion/default/eng_stringtable.txt 2009-01-17 01:15:30 UTC (rev 2759) +++ trunk/FreeOrion/default/eng_stringtable.txt 2009-01-17 07:17:18 UTC (rev 2760) @@ -1141,16 +1141,16 @@ INTERSYSTEM_EXCHANGE_TOOLTIP Inter-System Exchange +IMPORT_EXPORT_TOOLTIP +Import / Export + RESOURCE_IMPORT Importing RESOURCE_EXPORT -Exporting +Available for Export -RESOURCE_UNUSED -Unused - ##Planet Panel############# PLANET_PANEL |
From: <geo...@us...> - 2009-01-18 00:36:24
|
Revision: 2762 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2762&view=rev Author: geoffthemedio Date: 2009-01-18 00:36:17 +0000 (Sun, 18 Jan 2009) Log Message: ----------- Replaced TechDetailPanel with EncyclopediaDetailPanel and updated display of several types of item on EncyclopediaDetailPanel. Patch by OndrejR. Modified Paths: -------------- trunk/FreeOrion/UI/EncyclopediaDetailPanel.cpp trunk/FreeOrion/UI/EncyclopediaDetailPanel.h trunk/FreeOrion/UI/TechTreeWnd.cpp trunk/FreeOrion/UI/TechTreeWnd.h trunk/FreeOrion/default/eng_stringtable.txt Modified: trunk/FreeOrion/UI/EncyclopediaDetailPanel.cpp =================================================================== --- trunk/FreeOrion/UI/EncyclopediaDetailPanel.cpp 2009-01-17 10:45:16 UTC (rev 2761) +++ trunk/FreeOrion/UI/EncyclopediaDetailPanel.cpp 2009-01-18 00:36:17 UTC (rev 2762) @@ -81,12 +81,18 @@ lr = ul + GG::Pt(Width() - TEXT_MARGIN_X - BORDER_RIGHT, Height() - BORDER_BOTTOM - ul.y - TEXT_MARGIN_Y); m_description_box->SizeMove(ul, lr); - // icons + // icon if (m_icon) { ul = GG::Pt(GG::X1, GG::Y1); lr = ul + GG::Pt(GG::X(ICON_SIZE), GG::Y(ICON_SIZE)); m_icon->SizeMove(ul, lr); } + // other icon + if (m_other_icon) { + lr = GG::Pt(Width() - BORDER_RIGHT, GG::Y(ICON_SIZE + 1)); + ul = lr - GG::Pt(GG::X(ICON_SIZE), GG::Y(ICON_SIZE)); + m_other_icon->SizeMove(ul, lr); + } } void EncyclopediaDetailPanel::SizeMove(const GG::Pt& ul, const GG::Pt& lr) { @@ -164,8 +170,7 @@ glEnable(GL_TEXTURE_2D); } -void EncyclopediaDetailPanel::LDrag(const GG::Pt& pt, const GG::Pt& move, GG::Flags<GG::ModKey> mod_keys) -{ +void EncyclopediaDetailPanel::LDrag(const GG::Pt& pt, const GG::Pt& move, GG::Flags<GG::ModKey> mod_keys) { if (m_drag_offset != GG::Pt(-GG::X1, -GG::Y1)) { // resize-dragging GG::Pt new_lr = pt - m_drag_offset; @@ -202,8 +207,7 @@ return (!m_tech && !m_part && !m_hull && !m_building && !m_design && !m_special); } -void EncyclopediaDetailPanel::Reset() -{ +void EncyclopediaDetailPanel::Reset() { if (m_icon) { DeleteChild(m_icon); m_icon = 0; @@ -230,7 +234,9 @@ std::string general_type = ""; // general type of thing being shown, eg. "Building" or "Ship Part" std::string specific_type = ""; // specific type of thing; thing's purpose. eg. "Farming" or "Colonization". May be left blank for things without specific types (eg. specials) std::string detailed_description = ""; - + GG::Clr color = GG::CLR_ZERO; + + using boost::io::str; if (m_part) { // Ship Parts name = UserString(m_part->Name()); @@ -240,8 +246,11 @@ cost_units = UserString("ENC_PP"); general_type = UserString("ENC_SHIP_PART"); specific_type = UserString(boost::lexical_cast<std::string>(m_part->Class())); - detailed_description = UserString(m_part->Description()) + - boost::io::str(FlexibleFormat(UserString("ENC_EFFECTS_STR")) % EffectsDescription(m_part->Effects())); + + detailed_description = UserString(m_part->Description()); + if (!m_part->Effects().empty()) { + detailed_description += str(FlexibleFormat(UserString("ENC_EFFECTS_STR")) % EffectsDescription(m_part->Effects())); + } } else if (m_hull) { // Ship Hulls name = UserString(m_hull->Name()); @@ -251,18 +260,39 @@ cost_units = UserString("ENC_PP"); general_type = UserString("ENC_SHIP_HULL"); // hulls have no specific types - detailed_description = UserString(m_hull->Description()) + - boost::io::str(FlexibleFormat(UserString("ENC_EFFECTS_STR")) % EffectsDescription(m_hull->Effects())); + + detailed_description = UserString(m_hull->Description()); + if (!m_hull->Effects().empty()) { + detailed_description += str(FlexibleFormat(UserString("ENC_EFFECTS_STR")) % EffectsDescription(m_hull->Effects())); + } } else if (m_tech) { // Technologies name = UserString(m_tech->Name()); texture = ClientUI::TechTexture(m_tech->Name()); - other_texture = ClientUI::CategoryIcon(m_tech->Category()); + other_texture = ClientUI::CategoryIcon(m_tech->Category()); + color = ClientUI::CategoryColor(m_tech->Category()); turns = m_tech->ResearchTurns(); cost = m_tech->ResearchCost(); cost_units = UserString("ENC_RP"); - general_type = UserString("ENC_TECH"); - specific_type = UserString(m_tech->Category()); + general_type = str(FlexibleFormat(UserString("ENC_TECH_DETAIL_TYPE_STR")) + % UserString(m_tech->Category()) + % UserString(boost::lexical_cast<std::string>(m_tech->Type())) + % UserString(m_tech->ShortDescription())); + + detailed_description = UserString(m_tech->Description()); + if (!m_tech->Effects().empty()) { + detailed_description += str(FlexibleFormat(UserString("ENC_EFFECTS_STR")) % EffectsDescription(m_tech->Effects())); + } + + const std::vector<ItemSpec>& unlocked_items = m_tech->UnlockedItems(); + if (!unlocked_items.empty()) { + detailed_description += UserString("ENC_TECH_DETAIL_UNLOCKS_SECTION_STR"); + for (unsigned int i = 0; i < unlocked_items.size(); ++i) { + detailed_description += str(FlexibleFormat(UserString("ENC_TECH_DETAIL_UNLOCKED_ITEM_STR")) + % UserString(boost::lexical_cast<std::string>(unlocked_items[i].type)) + % UserString(unlocked_items[i].name)); + } + } } else if (m_building) { // Buildings name = UserString(m_building->Name()); @@ -271,8 +301,11 @@ cost = m_building->BuildCost(); cost_units = UserString("ENC_PP"); general_type = UserString("ENC_BUILDING_TYPE"); - detailed_description = UserString(m_building->Description()) + - boost::io::str(FlexibleFormat(UserString("ENC_EFFECTS_STR")) % EffectsDescription(m_building->Effects())); + + detailed_description = UserString(m_building->Description()); + if (!m_building->Effects().empty()) { + detailed_description += str(FlexibleFormat(UserString("ENC_EFFECTS_STR")) % EffectsDescription(m_building->Effects())); + } } else if (m_design) { // Ship Designs name = m_design->Name(); @@ -281,7 +314,7 @@ cost = m_design->Cost(); cost_units = UserString("ENC_PP"); general_type = UserString("ENC_SHIP_DESIGN"); - detailed_description = boost::io::str(FlexibleFormat(UserString("ENC_SHIP_DESIGN_DESCRIPTION_STR")) + detailed_description = str(FlexibleFormat(UserString("ENC_SHIP_DESIGN_DESCRIPTION_STR")) % m_design->Description() % m_design->Attack() % m_design->Defense() @@ -293,10 +326,16 @@ } // Create Icons - if (texture) + if (texture) { m_icon = new GG::StaticGraphic(GG::X0, GG::Y0, GG::X(10), GG::Y(10), texture, GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); - if (other_texture) + if (color != GG::CLR_ZERO) + m_icon->SetColor(color); + } + if (other_texture) { m_other_icon = new GG::StaticGraphic(GG::X0, GG::Y0, GG::X(10), GG::Y(10), other_texture, GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); + if (color != GG::CLR_ZERO) + m_other_icon->SetColor(color); + } if (m_icon) { m_icon->Show(); @@ -308,7 +347,6 @@ } // Set Text - using boost::io::str; using boost::format; m_name_text->SetText(name); @@ -316,6 +354,8 @@ m_summary_text->SetText(str(format(UserString("ENC_DETAIL_TYPE_STR")) % specific_type % general_type)); + if (color != GG::CLR_ZERO) + m_summary_text->SetColor(color); m_cost_text->SetText(str(format(UserString("ENC_COST_AND_TURNS_STR")) % static_cast<int>(cost + 0.5) @@ -324,7 +364,6 @@ m_description_box->SetText(detailed_description); - DoLayout(); } @@ -338,6 +377,9 @@ } void EncyclopediaDetailPanel::SetItem(const Tech* tech) { + UnsetAll(); + m_tech = tech; + Reset(); } void EncyclopediaDetailPanel::SetItem(const PartType* part) { Modified: trunk/FreeOrion/UI/EncyclopediaDetailPanel.h =================================================================== --- trunk/FreeOrion/UI/EncyclopediaDetailPanel.h 2009-01-17 10:45:16 UTC (rev 2761) +++ trunk/FreeOrion/UI/EncyclopediaDetailPanel.h 2009-01-18 00:36:17 UTC (rev 2762) @@ -22,9 +22,9 @@ */ class EncyclopediaDetailPanel : public CUIWnd { public: - /** \name Structors */ //@{ + //! \name Structors //!@{ EncyclopediaDetailPanel(GG::X x, GG::Y y); - //@} + //!@} /** \name Mutators */ //@{ virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr); Modified: trunk/FreeOrion/UI/TechTreeWnd.cpp =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.cpp 2009-01-17 10:45:16 UTC (rev 2761) +++ trunk/FreeOrion/UI/TechTreeWnd.cpp 2009-01-18 00:36:17 UTC (rev 2762) @@ -6,6 +6,7 @@ #include "CUIWnd.h" #include "../client/human/HumanClientApp.h" #include "../util/AppInterface.h" +#include "EncyclopediaDetailPanel.h" #include "../util/MultiplayerCommon.h" #include "../util/OptionsDB.h" #include "../universe/Tech.h" @@ -636,302 +637,6 @@ ////////////////////////////////////////////////// -// TechTreeWnd::TechDetailPanel // -////////////////////////////////////////////////// -/** A panel of text controls and/or graphics that shows a greater level of detail about a tech (such - as its full description text and effects text) than what appears in the tech graph. */ -class TechTreeWnd::TechDetailPanel : public CUIWnd -{ -public: - TechDetailPanel(GG::X w, GG::Y h); - - const Tech* CurrentTech() const {return m_tech;} - - void SizeMove(const GG::Pt& ul, const GG::Pt& lr); - void Render(); - void LDrag(const GG::Pt& pt, const GG::Pt& move, GG::Flags<GG::ModKey> mod_keys); - - /* need to redefine this so that icons and name can be put at the top of the Wnd, rather - than being restricted to the client area of a CUIWnd */ - GG::Pt ClientUpperLeft() const; - - void SetTech(const Tech* tech) {m_tech = tech; Reset();} - -private: - static const GG::X TEXT_MARGIN_X; - static const GG::Y TEXT_MARGIN_Y; - - void Reset(); - void DoLayout(); - - const Tech* m_tech; - GG::TextControl* m_tech_name_text; - GG::TextControl* m_cost_text; - GG::TextControl* m_summary_text; - CUIMultiEdit* m_description_box; - GG::StaticGraphic* m_tech_graphic; - GG::StaticGraphic* m_category_graphic; -}; -const GG::X TechTreeWnd::TechDetailPanel::TEXT_MARGIN_X(3); -const GG::Y TechTreeWnd::TechDetailPanel::TEXT_MARGIN_Y(3); - -TechTreeWnd::TechDetailPanel::TechDetailPanel(GG::X w, GG::Y h) : - CUIWnd("", GG::X1, GG::Y1, w - 1, h - 1, GG::CLICKABLE | GG::DRAGABLE | GG::RESIZABLE | GG::ONTOP), - m_tech(0) -{ - const int PTS = ClientUI::Pts(); - const int NAME_PTS = PTS*3/2; - const int COST_PTS = PTS; - const int SUMMARY_PTS = PTS*4/3; - - m_tech_name_text = new GG::TextControl(GG::X0, GG::Y0, GG::X(10), GG::Y(10), "", ClientUI::GetBoldFont(NAME_PTS), ClientUI::TextColor()); - m_cost_text = new GG::TextControl(GG::X0, GG::Y0, GG::X(10), GG::Y(10), "", ClientUI::GetFont(COST_PTS), ClientUI::TextColor()); - m_summary_text = new GG::TextControl(GG::X0, GG::Y0, GG::X(10), GG::Y(10), "", ClientUI::GetFont(SUMMARY_PTS), ClientUI::TextColor()); - m_description_box = new CUILinkTextMultiEdit(GG::X0, GG::Y0, GG::X(10), GG::Y(10), "", GG::MULTI_WORDBREAK | GG::MULTI_READ_ONLY); - m_description_box->SetColor(GG::CLR_ZERO); - m_description_box->SetInteriorColor(GG::CLR_ZERO); - - m_tech_graphic = 0; - m_category_graphic = 0; - - AttachChild(m_tech_name_text); - AttachChild(m_cost_text); - AttachChild(m_summary_text); - AttachChild(m_description_box); - - DoLayout(); -} - -void TechTreeWnd::TechDetailPanel::DoLayout() -{ - const int PTS = ClientUI::Pts(); - const int NAME_PTS = PTS*3/2; - const int COST_PTS = PTS; - const int SUMMARY_PTS = PTS*4/3; - - const int ICON_SIZE = 12 + NAME_PTS + COST_PTS + SUMMARY_PTS; - - // name - GG::Pt ul = GG::Pt(); - GG::Pt lr = ul + GG::Pt(Width(), GG::Y(NAME_PTS + 4)); - m_tech_name_text->SizeMove(ul, lr); - - // cost / turns - ul += GG::Pt(GG::X0, m_tech_name_text->Height()); - lr = ul + GG::Pt(Width(), GG::Y(COST_PTS + 4)); - m_cost_text->SizeMove(ul, lr); - - // one line summary - ul += GG::Pt(GG::X0, m_cost_text->Height()); - lr = ul + GG::Pt(Width(), GG::Y(SUMMARY_PTS + 4)); - m_summary_text->SizeMove(ul, lr); - - // main verbose description (fluff, effects, unlocks, ...) - ul = GG::Pt(GG::X1, ICON_SIZE + TEXT_MARGIN_Y + 1); - lr = ul + GG::Pt(Width() - TEXT_MARGIN_X - BORDER_RIGHT, Height() - BORDER_BOTTOM - ul.y - TEXT_MARGIN_Y); - m_description_box->SizeMove(ul, lr); - - // icons - if (m_tech_graphic) { - ul = GG::Pt(GG::X1, GG::Y1); - lr = ul + GG::Pt(GG::X(ICON_SIZE), GG::Y(ICON_SIZE)); - m_tech_graphic->SizeMove(ul, lr); - } - if (m_category_graphic) { - lr = GG::Pt(Width() - BORDER_RIGHT, GG::Y(ICON_SIZE + 1)); - ul = lr - GG::Pt(GG::X(ICON_SIZE), GG::Y(ICON_SIZE)); - m_category_graphic->SizeMove(ul, lr); - } -} - -void TechTreeWnd::TechDetailPanel::SizeMove(const GG::Pt& ul, const GG::Pt& lr) -{ - GG::Pt old_size = GG::Wnd::LowerRight() - GG::Wnd::UpperLeft(); - - // maybe later do something interesting with docking - GG::Wnd::SizeMove(ul, lr); - - if (Visible() && old_size != GG::Wnd::Size()) - DoLayout(); -} - -GG::Pt TechTreeWnd::TechDetailPanel::ClientUpperLeft() const -{ - return GG::Wnd::UpperLeft(); -} - -void TechTreeWnd::TechDetailPanel::Render() -{ - GG::Pt ul = UpperLeft(); - GG::Pt lr = LowerRight(); - const GG::Y ICON_HEIGHT = m_summary_text->LowerRight().y - m_tech_name_text->UpperLeft().y; - GG::Pt cl_ul = ul + GG::Pt(BORDER_LEFT, ICON_HEIGHT + BORDER_BOTTOM); - GG::Pt cl_lr = lr - GG::Pt(BORDER_RIGHT, BORDER_BOTTOM); - - // 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()); - glVertex(ul.x, ul.y); - glVertex(lr.x, ul.y); - glVertex(lr.x, lr.y - OUTER_EDGE_ANGLE_OFFSET); - glVertex(lr.x - OUTER_EDGE_ANGLE_OFFSET, lr.y); - glVertex(ul.x, lr.y); - glVertex(ul.x, ul.y); - glEnd(); - - // draw outer border on pixel inside of the outer edge of the window - glPolygonMode(GL_BACK, GL_LINE); - glBegin(GL_POLYGON); - glColor(ClientUI::WndOuterBorderColor()); - glVertex(ul.x, ul.y); - glVertex(lr.x, ul.y); - glVertex(lr.x, lr.y - OUTER_EDGE_ANGLE_OFFSET); - glVertex(lr.x - OUTER_EDGE_ANGLE_OFFSET, lr.y); - glVertex(ul.x, lr.y); - glVertex(ul.x, ul.y); - glEnd(); - - // reset this to whatever it was initially - glPolygonMode(GL_BACK, initial_modes[1]); - - // draw inner border, including extra resize-tab lines - glBegin(GL_LINE_STRIP); - glColor(ClientUI::WndInnerBorderColor()); - glVertex(cl_ul.x, cl_ul.y); - glVertex(cl_lr.x, cl_ul.y); - glVertex(cl_lr.x, cl_lr.y - INNER_BORDER_ANGLE_OFFSET); - glVertex(cl_lr.x - INNER_BORDER_ANGLE_OFFSET, cl_lr.y); - glVertex(cl_ul.x, cl_lr.y); - glVertex(cl_ul.x, cl_ul.y); - glEnd(); - glBegin(GL_LINES); - // draw the extra lines of the resize tab - glColor(ClientUI::WndInnerBorderColor()); - glVertex(cl_lr.x, cl_lr.y - RESIZE_HASHMARK1_OFFSET); - glVertex(cl_lr.x - RESIZE_HASHMARK1_OFFSET, cl_lr.y); - - glVertex(cl_lr.x, cl_lr.y - RESIZE_HASHMARK2_OFFSET); - glVertex(cl_lr.x - RESIZE_HASHMARK2_OFFSET, cl_lr.y); - glEnd(); - glEnable(GL_TEXTURE_2D); -} - -void TechTreeWnd::TechDetailPanel::LDrag(const GG::Pt& pt, const GG::Pt& move, GG::Flags<GG::ModKey> mod_keys) -{ - if (m_drag_offset != GG::Pt(-GG::X1, -GG::Y1)) { // resize-dragging - GG::Pt new_lr = pt - m_drag_offset; - - // constrain to within parent - if (GG::Wnd* parent = Parent()) { - GG::Pt max_lr = parent->ClientLowerRight(); - new_lr.x = std::min(new_lr.x, max_lr.x); - new_lr.y = std::min(new_lr.y, max_lr.y); - } - - Resize(new_lr - UpperLeft()); - } else { // normal-dragging - GG::Pt final_move = move; - - if (GG::Wnd* parent = Parent()) { - GG::Pt ul = UpperLeft(), lr = LowerRight(); - GG::Pt new_ul = ul + move, new_lr = lr + move; - - GG::Pt min_ul = parent->ClientUpperLeft() + GG::Pt(GG::X1, GG::Y1); - GG::Pt max_lr = parent->ClientLowerRight(); - GG::Pt max_ul = max_lr - Size(); - - new_ul.x = std::max(min_ul.x, std::min(max_ul.x, new_ul.x)); - new_ul.y = std::max(min_ul.y, std::min(max_ul.y, new_ul.y)); - - final_move = new_ul - ul; - } - - GG::Wnd::LDrag(pt, final_move, mod_keys); - } -} - -void TechTreeWnd::TechDetailPanel::Reset() -{ - if (m_tech_graphic) { - DeleteChild(m_tech_graphic); - m_tech_graphic = 0; - } - if (m_category_graphic) { - DeleteChild(m_category_graphic); - m_category_graphic = 0; - } - - if (!m_tech) { - m_tech_name_text->SetText(""); - m_summary_text->SetText(""); - m_cost_text->SetText(""); - m_description_box->SetText(""); - return; - } - - m_tech_graphic = new GG::StaticGraphic(GG::X0, GG::Y0, GG::X(10), GG::Y(10), - ClientUI::TechTexture(m_tech->Name()), - GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); - m_tech_graphic->Show(); - m_tech_graphic->SetColor(ClientUI::CategoryColor(m_tech->Category())); - AttachChild(m_tech_graphic); - - m_category_graphic = new GG::StaticGraphic(GG::X0, GG::Y0, GG::X(10), GG::Y(10), - ClientUI::CategoryIcon(m_tech->Category()), - GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE); - m_category_graphic->Show(); - m_category_graphic->SetColor(ClientUI::CategoryColor(m_tech->Category())); - AttachChild(m_category_graphic); - - - DoLayout(); - - m_tech_name_text->SetText(UserString(m_tech->Name())); - using boost::io::str; - - m_summary_text->SetText("<i>" + str(FlexibleFormat(UserString("TECH_DETAIL_TYPE_STR")) - % UserString(m_tech->Category()) - % UserString(boost::lexical_cast<std::string>(m_tech->Type())) - % UserString(m_tech->ShortDescription())) - + "</i>"); - - m_summary_text->SetColor(ClientUI::CategoryColor(m_tech->Category())); - - m_cost_text->SetText(str(FlexibleFormat(UserString("TECH_TOTAL_COST_STR")) - % static_cast<int>(m_tech->ResearchCost() + 0.5) - % m_tech->ResearchTurns())); - - - std::string description_str = str(FlexibleFormat(UserString("TECH_DETAIL_DESCRIPTION_STR")) - % UserString(m_tech->Description())); - - - if (!m_tech->Effects().empty()) { - description_str += str(FlexibleFormat(UserString("TECH_DETAIL_EFFECTS_STR")) - % EffectsDescription(m_tech->Effects())); - } - - - const std::vector<ItemSpec>& unlocked_items = m_tech->UnlockedItems(); - if (!unlocked_items.empty()) - description_str += UserString("TECH_DETAIL_UNLOCKS_SECTION_STR"); - for (unsigned int i = 0; i < unlocked_items.size(); ++i) { - description_str += str(FlexibleFormat(UserString("TECH_DETAIL_UNLOCKED_ITEM_STR")) - % UserString(boost::lexical_cast<std::string>(unlocked_items[i].type)) - % UserString(unlocked_items[i].name)); - } - - - m_description_box->SetText(description_str); -} - -////////////////////////////////////////////////// // TechTreeWnd::TechNavigator // ////////////////////////////////////////////////// /** A window with a single lisbox in it. The listbox represents the techs that are required for and are @@ -2501,7 +2206,7 @@ TechTreeWnd::TechTreeWnd(GG::X w, GG::Y h) : GG::Wnd(GG::X0, GG::Y0, w, h, GG::CLICKABLE), - m_tech_detail_panel(0), + m_enc_detail_panel(0), m_tech_navigator(0), m_layout_panel(0), m_tech_list(0) @@ -2521,11 +2226,11 @@ GG::Connect(m_tech_list->TechClickedSignal, &TechTreeWnd::TechClickedSlot, this); GG::Connect(m_tech_list->TechDoubleClickedSignal, &TechTreeWnd::TechDoubleClickedSlot, this); - m_tech_detail_panel = new TechDetailPanel(m_layout_panel->ClientWidth() - NAVIGATOR_WIDTH, NAVIGATOR_AND_DETAIL_HEIGHT); - AttachChild(m_tech_detail_panel); + m_enc_detail_panel = new EncyclopediaDetailPanel(m_layout_panel->ClientWidth() - NAVIGATOR_WIDTH, NAVIGATOR_AND_DETAIL_HEIGHT); + AttachChild(m_enc_detail_panel); m_tech_navigator = new TechNavigator(NAVIGATOR_WIDTH, NAVIGATOR_AND_DETAIL_HEIGHT); - m_tech_navigator->MoveTo(GG::Pt(m_tech_detail_panel->Width(), GG::Y1)); + m_tech_navigator->MoveTo(GG::Pt(m_enc_detail_panel->Width(), GG::Y1)); GG::Connect(m_tech_navigator->TechClickedSignal, &TechTreeWnd::CenterOnTech, this); m_layout_panel->AttachChild(m_tech_navigator); @@ -2592,8 +2297,8 @@ void TechTreeWnd::Clear() { - m_tech_navigator->SetTech(0); - m_tech_detail_panel->SetTech(0); + m_tech_navigator->SetTech(0); + m_enc_detail_panel->UnsetAll(); m_layout_panel->Clear(); } @@ -2789,7 +2494,7 @@ void TechTreeWnd::TechClickedSlot(const Tech* tech) { m_tech_navigator->SetTech(tech); - m_tech_detail_panel->SetTech(tech); + m_enc_detail_panel->SetItem(tech); TechSelectedSignal(tech); } Modified: trunk/FreeOrion/UI/TechTreeWnd.h =================================================================== --- trunk/FreeOrion/UI/TechTreeWnd.h 2009-01-17 10:45:16 UTC (rev 2761) +++ trunk/FreeOrion/UI/TechTreeWnd.h 2009-01-18 00:36:17 UTC (rev 2762) @@ -6,6 +6,7 @@ #include "../universe/Enums.h" class Tech; +class EncyclopediaDetailPanel; /** Contains the tech graph layout, some controls to control what is visible in the tech layout, the tech navigator, and the tech detail window. */ class TechTreeWnd : public GG::Wnd @@ -57,7 +58,7 @@ void CenterOnTech(const Tech* tech); //@} - static const GG::Y NAVIGATOR_AND_DETAIL_HEIGHT; + static const GG::Y NAVIGATOR_AND_DETAIL_HEIGHT; mutable TechBrowsedSignalType TechBrowsedSignal; mutable TechClickedSignalType TechSelectedSignal; @@ -66,7 +67,6 @@ private: class TechTreeControls; - class TechDetailPanel; class TechNavigator; class LayoutPanel; class TechListBox; @@ -75,11 +75,11 @@ void TechClickedSlot(const Tech* tech); void TechDoubleClickedSlot(const Tech* tech); - TechTreeControls* m_tech_tree_controls; - TechDetailPanel* m_tech_detail_panel; - TechNavigator* m_tech_navigator; - LayoutPanel* m_layout_panel; - TechListBox* m_tech_list; + TechTreeControls* m_tech_tree_controls; + EncyclopediaDetailPanel* m_enc_detail_panel; + TechNavigator* m_tech_navigator; + LayoutPanel* m_layout_panel; + TechListBox* m_tech_list; }; #endif // _TechTreeWnd_h_ Modified: trunk/FreeOrion/default/eng_stringtable.txt =================================================================== --- trunk/FreeOrion/default/eng_stringtable.txt 2009-01-17 10:45:16 UTC (rev 2761) +++ trunk/FreeOrion/default/eng_stringtable.txt 2009-01-18 00:36:17 UTC (rev 2762) @@ -1371,30 +1371,7 @@ TECH_TURNS_LEFT_NEVER Never -TECH_DETAIL_TYPE_STR -%1% %2% - %3% -TECH_DETAIL_DESCRIPTION_STR -%1% - -TECH_DETAIL_EFFECTS_STR -''' - -<u>Effects</u> - -%1%''' - -TECH_DETAIL_UNLOCKS_SECTION_STR -''' - -<u>Unlocks</u> - -''' - -TECH_DETAIL_UNLOCKED_ITEM_STR -'''%1%: %2% -''' - TECH_WND_TECH_COMPLETED COMPLETED @@ -1636,8 +1613,20 @@ Defense: %3% Speed: %4%''' +ENC_TECH_DETAIL_UNLOCKS_SECTION_STR +''' +<u>Unlocks</u> +''' + +ENC_TECH_DETAIL_UNLOCKED_ITEM_STR +'''%1%: %2% +''' + +ENC_TECH_DETAIL_TYPE_STR +%1% %2% - %3% + #################### # Combat Messages # #################### |
From: <geo...@us...> - 2009-01-20 12:23:02
|
Revision: 2763 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2763&view=rev Author: geoffthemedio Date: 2009-01-20 12:06:26 +0000 (Tue, 20 Jan 2009) Log Message: ----------- -Added dropshadow-esque black backgrounds around system names on map to improve readability over similar-coloured starlanes or galaxy gas -Removed Python include directories from MSVC projects other than AI, since they don't need them -Grooming -Removed unused code from SidePanel Modified Paths: -------------- trunk/FreeOrion/UI/CUIControls.cpp trunk/FreeOrion/UI/CUIControls.h trunk/FreeOrion/UI/IntroScreen.cpp trunk/FreeOrion/UI/SidePanel.cpp trunk/FreeOrion/UI/SystemIcon.cpp trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj trunk/FreeOrion/msvc2008/FreeOrion/freeoriond/freeoriond.vcproj Modified: trunk/FreeOrion/UI/CUIControls.cpp =================================================================== --- trunk/FreeOrion/UI/CUIControls.cpp 2009-01-18 00:36:17 UTC (rev 2762) +++ trunk/FreeOrion/UI/CUIControls.cpp 2009-01-20 12:06:26 UTC (rev 2763) @@ -1432,3 +1432,43 @@ { m_enabled = GetOptionsDB().Get<bool>("show-fps"); } + +////////////////////////////////////////////////// +// ShadowedTextControl +////////////////////////////////////////////////// +ShadowedTextControl::ShadowedTextControl(GG::X x, GG::Y y, GG::X w, GG::Y h, const std::string& str, const boost::shared_ptr<GG::Font>& font, + GG::Clr color, GG::Flags<GG::TextFormat> format, + GG::Flags<GG::WndFlag> flags) : + GG::TextControl(x, y, w, h, str, font, color, format, flags) +{} + +ShadowedTextControl::ShadowedTextControl(GG::X x, GG::Y y, const std::string& str, const boost::shared_ptr<GG::Font>& font, + GG::Clr color, GG::Flags<GG::TextFormat> format, + GG::Flags<GG::WndFlag> flags) : + GG::TextControl(x, y, str, font, color, format, flags) +{} + + +void ShadowedTextControl::Render() +{ + GG::Clr text_colour = TextColor(); // save original colour + + SetTextColor(GG::CLR_BLACK); // render shadows in opaque black + + OffsetMove(GG::Pt(-GG::X1, GG::Y(0))); // shadow to left + TextControl::Render(); + + OffsetMove(GG::Pt(GG::X1, GG::Y1)); // up + TextControl::Render(); + + OffsetMove(GG::Pt(GG::X1, -GG::Y1)); // right + TextControl::Render(); + + OffsetMove(GG::Pt(-GG::X1, -GG::Y1)); // down + TextControl::Render(); + + SetTextColor(text_colour); // restore original colour + + OffsetMove(GG::Pt(GG::X(0), GG::Y1)); // render main coloured text + TextControl::Render(); +} Modified: trunk/FreeOrion/UI/CUIControls.h =================================================================== --- trunk/FreeOrion/UI/CUIControls.h 2009-01-18 00:36:17 UTC (rev 2762) +++ trunk/FreeOrion/UI/CUIControls.h 2009-01-20 12:06:26 UTC (rev 2763) @@ -538,4 +538,21 @@ void UpdateEnabled(); bool m_enabled; }; + +/** Acts like a normal TextControl, but renders extra black copy / copies of text behind to create a + * drop-shadow effect, impriving text readability. */ +class ShadowedTextControl : public GG::TextControl +{ +public: + ShadowedTextControl(GG::X x, GG::Y y, GG::X w, GG::Y h, const std::string& str, const boost::shared_ptr<GG::Font>& font, + GG::Clr color = GG::CLR_BLACK, GG::Flags<GG::TextFormat> format = GG::FORMAT_NONE, + GG::Flags<GG::WndFlag> flags = GG::Flags<GG::WndFlag>()); + + ShadowedTextControl(GG::X x, GG::Y y, const std::string& str, const boost::shared_ptr<GG::Font>& font, + GG::Clr color = GG::CLR_BLACK, GG::Flags<GG::TextFormat> format = GG::FORMAT_NONE, + GG::Flags<GG::WndFlag> flags = GG::Flags<GG::WndFlag>()); + + virtual void Render(); +}; + #endif // _CUIControls_h_ Modified: trunk/FreeOrion/UI/IntroScreen.cpp =================================================================== --- trunk/FreeOrion/UI/IntroScreen.cpp 2009-01-18 00:36:17 UTC (rev 2762) +++ trunk/FreeOrion/UI/IntroScreen.cpp 2009-01-20 12:06:26 UTC (rev 2763) @@ -44,7 +44,7 @@ { public: CreditsWnd(GG::X x, GG::Y y, GG::X w, GG::Y h,const XMLElement &credits,int cx, int cy, int cw, int ch,int co); - + virtual void Render(); virtual void LClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) {m_bRender=false;} Modified: trunk/FreeOrion/UI/SidePanel.cpp =================================================================== --- trunk/FreeOrion/UI/SidePanel.cpp 2009-01-18 00:36:17 UTC (rev 2762) +++ trunk/FreeOrion/UI/SidePanel.cpp 2009-01-20 12:06:26 UTC (rev 2763) @@ -548,14 +548,6 @@ return static_cast<int>(ClientUI::Pts()*3/2); } - boost::shared_ptr<GG::Texture> IconPopulation() {return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "pop.png" );} - boost::shared_ptr<GG::Texture> IconIndustry () {return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "industry.png" );} - boost::shared_ptr<GG::Texture> IconTrade () {return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "trade.png" );} - boost::shared_ptr<GG::Texture> IconResearch () {return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "research.png" );} - boost::shared_ptr<GG::Texture> IconMining () {return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "mining.png" );} - boost::shared_ptr<GG::Texture> IconFarming () {return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "farming.png" );} - boost::shared_ptr<GG::Texture> IconDefense () {return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "defensebase.png");} - struct SystemRow : public GG::ListBox::Row { public: Modified: trunk/FreeOrion/UI/SystemIcon.cpp =================================================================== --- trunk/FreeOrion/UI/SystemIcon.cpp 2009-01-18 00:36:17 UTC (rev 2762) +++ trunk/FreeOrion/UI/SystemIcon.cpp 2009-01-20 12:06:26 UTC (rev 2763) @@ -11,6 +11,7 @@ #include "../universe/System.h" #include "../Empire/Empire.h" #include "../util/OptionsDB.h" +#include "CUIControls.h" #include <GG/DrawUtil.h> #include <GG/StaticGraphic.h> @@ -39,7 +40,7 @@ GG::Clr text_color = ClientUI::TextColor(); if (!owners.empty()) text_color = Empires().Lookup(*owners.begin())->Color(); - GG::TextControl* text = new GG::TextControl(width, GG::Y0, str, font, text_color); + GG::TextControl* text = new ShadowedTextControl(width, GG::Y0, str, font, text_color); m_subcontrols.push_back(text); AttachChild(m_subcontrols.back()); width += m_subcontrols.back()->Width(); @@ -55,7 +56,7 @@ while (last_char_pos < str.size() && lines[0].char_data[last_char_pos].extent < (owner_idx * pixels_per_owner)) { ++last_char_pos; } - m_subcontrols.push_back(new GG::TextControl(width, GG::Y0, str.substr(first_char_pos, last_char_pos - first_char_pos), + m_subcontrols.push_back(new ShadowedTextControl(width, GG::Y0, str.substr(first_char_pos, last_char_pos - first_char_pos), font, Empires().Lookup(*it)->Color())); AttachChild(m_subcontrols.back()); first_char_pos = last_char_pos; Modified: trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj 2009-01-18 00:36:17 UTC (rev 2762) +++ trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj 2009-01-20 12:06:26 UTC (rev 2763) @@ -43,7 +43,7 @@ <Tool Name="VCCLCompilerTool" Optimization="3" - AdditionalIncludeDirectories="../../../log4cpp/;../../../../include/;"../../../../Boost/include/boost-1_36";C:\Python25\include;../../../GG/;../../include" + AdditionalIncludeDirectories="../../../log4cpp/;../../../../include/;"../../../../Boost/include/boost-1_36";../../../GG/;../../include" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GIGI_EXPORTS;GIGI_SDL_EXPORTS;FREEORION_BUILD_HUMAN;FREEORION_WIN32;BOOST_SIGNALS_STATIC_LINK;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" StringPooling="true" MinimalRebuild="true" Modified: trunk/FreeOrion/msvc2008/FreeOrion/freeoriond/freeoriond.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/freeoriond/freeoriond.vcproj 2009-01-18 00:36:17 UTC (rev 2762) +++ trunk/FreeOrion/msvc2008/FreeOrion/freeoriond/freeoriond.vcproj 2009-01-20 12:06:26 UTC (rev 2763) @@ -42,7 +42,7 @@ <Tool Name="VCCLCompilerTool" Optimization="3" - AdditionalIncludeDirectories="../../../log4cpp/;../../../../include/;"../../../../Boost/include/boost-1_36";C:\Python25\include;../../../GG/;../../include" + AdditionalIncludeDirectories="../../../log4cpp/;../../../../include/;"../../../../Boost/include/boost-1_36";../../../GG/;../../include" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GIGI_EXPORTS;FREEORION_BUILD_SERVER;FREEORION_WIN32;BOOST_SIGNALS_STATIC_LINK;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" StringPooling="true" MinimalRebuild="true" |
From: <geo...@us...> - 2009-01-23 03:22:09
|
Revision: 2765 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2765&view=rev Author: geoffthemedio Date: 2009-01-23 02:05:47 +0000 (Fri, 23 Jan 2009) Log Message: ----------- -Made it possible to start a single-player game with zero AIs -Converted some left-over #ifdef FREEORION_WIN32 to #ifdef USE_GL_BIND_BUFFER_ARB in MapWnd Modified Paths: -------------- trunk/FreeOrion/UI/GalaxySetupWnd.cpp trunk/FreeOrion/UI/MapWnd.cpp trunk/FreeOrion/server/ServerFSM.cpp trunk/FreeOrion/server/ServerFSM.h Modified: trunk/FreeOrion/UI/GalaxySetupWnd.cpp =================================================================== --- trunk/FreeOrion/UI/GalaxySetupWnd.cpp 2009-01-22 06:38:27 UTC (rev 2764) +++ trunk/FreeOrion/UI/GalaxySetupWnd.cpp 2009-01-23 02:05:47 UTC (rev 2765) @@ -35,7 +35,7 @@ db.Add("GameSetup.specials-frequency", "OPTIONS_DB_GAMESETUP_SPECIALS_FREQUENCY", SPECIALS_UNCOMMON, RangedValidator<SpecialsFrequency>(SPECIALS_NONE, SPECIALS_COMMON)); db.Add("GameSetup.empire-name", "OPTIONS_DB_GAMESETUP_EMPIRE_NAME", std::string("Human"), Validator<std::string>()); db.Add("GameSetup.empire-color", "OPTIONS_DB_GAMESETUP_EMPIRE_COLOR", 0, RangedValidator<int>(0, 100)); - db.Add("GameSetup.ai-players", "OPTIONS_DB_GAMESETUP_NUM_AI_PLAYERS", 4, RangedValidator<int>(1, MAX_AI_PLAYERS)); + db.Add("GameSetup.ai-players", "OPTIONS_DB_GAMESETUP_NUM_AI_PLAYERS", 4, RangedValidator<int>(0, MAX_AI_PLAYERS)); } bool temp_bool = RegisterOptions(&AddOptions); } @@ -334,7 +334,7 @@ m_number_ais_label = new GG::TextControl(CONTROL_MARGIN, ypos, LABELS_WIDTH, CONTROL_HEIGHT, UserString("GSETUP_NUMBER_AIS"), font, ClientUI::TextColor(), GG::FORMAT_RIGHT, GG::CLICKABLE); m_number_ais_label->SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); m_number_ais_label->SetBrowseText(UserString(GetOptionsDB().GetDescription("GameSetup.ai-players"))); - m_number_ais_spin = new CUISpin<int>(LABELS_WIDTH + 2 * CONTROL_MARGIN, ypos, GG::X(75), GetOptionsDB().Get<int>("GameSetup.ai-players"), 1, 1, MAX_AI_PLAYERS, true); + m_number_ais_spin = new CUISpin<int>(LABELS_WIDTH + 2 * CONTROL_MARGIN, ypos, GG::X(75), GetOptionsDB().Get<int>("GameSetup.ai-players"), 1, 0, MAX_AI_PLAYERS, true); m_number_ais_label->OffsetMove(GG::Pt(GG::X0, (PANEL_CONTROL_SPACING - m_number_ais_label->Height()) / 2)); m_number_ais_spin->OffsetMove(GG::Pt(GG::X0, (PANEL_CONTROL_SPACING - m_number_ais_spin->Height()) / 2)); Modified: trunk/FreeOrion/UI/MapWnd.cpp =================================================================== --- trunk/FreeOrion/UI/MapWnd.cpp 2009-01-22 06:38:27 UTC (rev 2764) +++ trunk/FreeOrion/UI/MapWnd.cpp 2009-01-23 02:05:47 UTC (rev 2765) @@ -250,9 +250,9 @@ // MapWnd // static(s) -double MapWnd::s_min_scale_factor = 0.35; -double MapWnd::s_max_scale_factor = 8.0; -const GG::X MapWnd::SIDE_PANEL_WIDTH(360); +double MapWnd::s_min_scale_factor = 0.35; +double MapWnd::s_max_scale_factor = 8.0; +const GG::X MapWnd::SIDE_PANEL_WIDTH(360); MapWnd::MapWnd() : GG::Wnd(-GG::GUI::GetGUI()->AppWidth(), -GG::GUI::GetGUI()->AppHeight(), @@ -1211,7 +1211,7 @@ } if (m_starlane_fleet_supply_colors.m_name) { -#ifdef FREEORION_WIN32 +#ifdef USE_GL_BIND_BUFFER_ARB glDeleteBuffersARB(1, &m_starlane_fleet_supply_colors.m_name); #else glDeleteBuffers(1, &m_starlane_fleet_supply_colors.m_name); @@ -1326,7 +1326,7 @@ m_starlane_vertices.m_size = raw_starlane_vertices.size() / 2; } if (!raw_starlane_colors.empty()) { -#ifdef FREEORION_WIN32 +#ifdef USE_GL_BIND_BUFFER_ARB glGenBuffersARB(1, &m_starlane_colors.m_name); glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_starlane_colors.m_name); glBufferDataARB(GL_ARRAY_BUFFER_ARB, @@ -1853,13 +1853,13 @@ // basis, however, since GL 2.0 will soon be required for the use of // Ogre, shaders, etc. This note applies to all such uses of the ARB // versions of GL functions and macros. -#ifdef FREEORION_WIN32 +#ifdef USE_GL_BIND_BUFFER_ARB glBindBufferARB(GL_ARRAY_BUFFER_ARB, it->second.m_name); #else glBindBuffer(GL_ARRAY_BUFFER, it->second.m_name); #endif glVertexPointer(2, GL_FLOAT, 0, 0); -#ifdef FREEORION_WIN32 +#ifdef USE_GL_BIND_BUFFER_ARB glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_star_texture_coords.m_name); #else glBindBuffer(GL_ARRAY_BUFFER, m_star_texture_coords.m_name); @@ -1885,13 +1885,13 @@ it != m_star_halo_quad_vertices.end(); ++it) { glBindTexture(GL_TEXTURE_2D, it->first->OpenGLId()); -#ifdef FREEORION_WIN32 +#ifdef USE_GL_BIND_BUFFER_ARB glBindBufferARB(GL_ARRAY_BUFFER_ARB, it->second.m_name); #else glBindBuffer(GL_ARRAY_BUFFER, it->second.m_name); #endif glVertexPointer(2, GL_FLOAT, 0, 0); -#ifdef FREEORION_WIN32 +#ifdef USE_GL_BIND_BUFFER_ARB glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_star_texture_coords.m_name); #else glBindBuffer(GL_ARRAY_BUFFER, m_star_texture_coords.m_name); @@ -1908,13 +1908,13 @@ it != m_star_core_quad_vertices.end(); ++it) { glBindTexture(GL_TEXTURE_2D, it->first->OpenGLId()); -#ifdef FREEORION_WIN32 +#ifdef USE_GL_BIND_BUFFER_ARB glBindBufferARB(GL_ARRAY_BUFFER_ARB, it->second.m_name); #else glBindBuffer(GL_ARRAY_BUFFER, it->second.m_name); #endif glVertexPointer(2, GL_FLOAT, 0, 0); -#ifdef FREEORION_WIN32 +#ifdef USE_GL_BIND_BUFFER_ARB glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_star_texture_coords.m_name); #else glBindBuffer(GL_ARRAY_BUFFER, m_star_texture_coords.m_name); @@ -1925,7 +1925,7 @@ } -#ifdef FREEORION_WIN32 +#ifdef USE_GL_BIND_BUFFER_ARB glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); #else glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -1963,7 +1963,7 @@ glVertexPointer(2, GL_FLOAT, 0, 0); if (coloured) { -#ifdef FREEORION_WIN32 +#ifdef USE_GL_BIND_BUFFER_ARB glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_starlane_colors.m_name); #else glBindBuffer(GL_ARRAY_BUFFER, m_starlane_colors.m_name); Modified: trunk/FreeOrion/server/ServerFSM.cpp =================================================================== --- trunk/FreeOrion/server/ServerFSM.cpp 2009-01-22 06:38:27 UTC (rev 2764) +++ trunk/FreeOrion/server/ServerFSM.cpp 2009-01-23 02:05:47 UTC (rev 2765) @@ -400,6 +400,8 @@ m_num_expected_players = m_player_save_game_data.size(); server.CreateAIClients(std::vector<PlayerSetupData>(m_num_expected_players - 1), m_expected_ai_player_names); } + + Base::post_event(CheckStartConditions()); // force immediate check if all expected AIs are present, so that the FSM won't get stuck in this state waiting for JoinGame messages that will never come since no other AIs are left to join } WaitingForSPGameJoiners::~WaitingForSPGameJoiners() @@ -443,7 +445,24 @@ return discard_event(); } +boost::statechart::result WaitingForSPGameJoiners::react(const CheckStartConditions& u) +{ + if (TRACE_EXECUTION) Logger().debugStream() << "(ServerFSM) WaitingForSPGameJoiners.CheckStartConditions"; + ServerApp& server = Server(); + if (static_cast<int>(server.m_networking.NumPlayers()) == m_num_expected_players) { + if (m_setup_data->m_new_game) + server.NewGameInit(m_setup_data); + else + server.LoadGameInit(m_player_save_game_data, m_server_save_game_data); + return transit<PlayingGame>(); + } + + return discard_event(); +} + + + //////////////////////////////////////////////////////////// // WaitingForMPGameJoiners //////////////////////////////////////////////////////////// Modified: trunk/FreeOrion/server/ServerFSM.h =================================================================== --- trunk/FreeOrion/server/ServerFSM.h 2009-01-22 06:38:27 UTC (rev 2764) +++ trunk/FreeOrion/server/ServerFSM.h 2009-01-23 02:05:47 UTC (rev 2765) @@ -36,7 +36,10 @@ PlayerConnectionPtr& m_player_connection; }; +struct CheckStartConditions : boost::statechart::event<CheckStartConditions> +{}; + // Message events /** The base class for all state machine events that are based on Messages. */ struct MessageEventBase @@ -49,7 +52,7 @@ // Define Boost.Preprocessor list of all Message events #define MESSAGE_EVENTS \ - (HostMPGame) \ + (HostMPGame) \ (HostSPGame) \ (StartMPGame) \ (LobbyUpdate) \ @@ -179,13 +182,15 @@ typedef boost::mpl::list< boost::statechart::in_state_reaction<Disconnection, ServerFSM, &ServerFSM::HandleNonLobbyDisconnection>, - boost::statechart::custom_reaction<JoinGame> + boost::statechart::custom_reaction<JoinGame>, + boost::statechart::custom_reaction<CheckStartConditions> > reactions; WaitingForSPGameJoiners(my_context c); ~WaitingForSPGameJoiners(); boost::statechart::result react(const JoinGame& msg); + boost::statechart::result react(const CheckStartConditions& u); boost::shared_ptr<SinglePlayerSetupData> m_setup_data; std::vector<PlayerSaveGameData> m_player_save_game_data; |
From: <geo...@us...> - 2009-01-23 15:45:58
|
Revision: 2766 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2766&view=rev Author: geoffthemedio Date: 2009-01-23 15:45:46 +0000 (Fri, 23 Jan 2009) Log Message: ----------- -Tweaked GL version test output text -Trivial grooming Modified Paths: -------------- trunk/FreeOrion/UI/MapWnd.cpp trunk/FreeOrion/server/dmain.cpp Modified: trunk/FreeOrion/UI/MapWnd.cpp =================================================================== --- trunk/FreeOrion/UI/MapWnd.cpp 2009-01-23 02:05:47 UTC (rev 2765) +++ trunk/FreeOrion/UI/MapWnd.cpp 2009-01-23 15:45:46 UTC (rev 2766) @@ -115,14 +115,14 @@ std::istringstream iss(gl_version_string); iss >> version_number; - Logger().debugStream() << "extracted version number: " << boost::lexical_cast<std::string>(version_number); + Logger().debugStream() << "...extracted version number: " << DoubleToString(version_number + 0.05, 2, false, false); // combination of floating point precision and DoubleToString preferring to round down means the +0.05 is needed to round properly if (version_number < 1.5) { - Logger().errorStream() << "OpenGL version number less than 1.5. FreeOrion requires OpenGL 1.5. The following code should crash."; - std::cerr << "OpenGL version number" << boost::lexical_cast<std::string>(version_number) << " is less than 1.5." << std::endl; - std::cerr << "FreeOrion requires OpenGL 1.5. The following code will likely crash." << std::endl; + Logger().errorStream() << "OpenGL version number less than 1.5. FreeOrion uses OpenGL 1.5 features and may crash on this system."; + std::cerr << "OpenGL version number " << DoubleToString(version_number, 2, false, false) << " is less than 1.5." << std::endl; // combination of floating point precision and DoubleToString preferring to round down means the +0.05 is needed to round properly + std::cerr << "FreeOrion requires OpenGL 1.5 and may crash on this system." << std::endl; } else if (version_number < 2.0) { - Logger().debugStream() << "OpenGL version number less than 2.0. FreeOrion requires OpenGL 2.0 unless specially compiled. The following code may crash."; + Logger().debugStream() << "OpenGL version number less than 2.0. FreeOrion reccomended OpenGL version is 2.0 or greater and you may have problems on this system."; } } Modified: trunk/FreeOrion/server/dmain.cpp =================================================================== --- trunk/FreeOrion/server/dmain.cpp 2009-01-23 02:05:47 UTC (rev 2765) +++ trunk/FreeOrion/server/dmain.cpp 2009-01-23 15:45:46 UTC (rev 2766) @@ -34,8 +34,8 @@ return 1; } - ServerApp g_app; - g_app(); // run app (intialization and main process loop) - return 0; + ServerApp g_app; + g_app(); // run app (intialization and main process loop) + return 0; } |
From: <kr...@us...> - 2009-01-25 21:28:56
|
Revision: 2769 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2769&view=rev Author: kroddn Date: 2009-01-25 21:28:50 +0000 (Sun, 25 Jan 2009) Log Message: ----------- Added command-line param external-server-address to support connecting to a dedicated server process and create a new game there. Must be used in combination with --force-external-server Modified Paths: -------------- trunk/FreeOrion/UI/IntroScreen.cpp trunk/FreeOrion/client/human/HumanClientApp.cpp trunk/FreeOrion/default/eng_stringtable.txt Modified: trunk/FreeOrion/UI/IntroScreen.cpp =================================================================== --- trunk/FreeOrion/UI/IntroScreen.cpp 2009-01-25 10:45:22 UTC (rev 2768) +++ trunk/FreeOrion/UI/IntroScreen.cpp 2009-01-25 21:28:50 UTC (rev 2769) @@ -31,6 +31,7 @@ void Options(OptionsDB& db) { db.AddFlag("force-external-server", "OPTIONS_DB_FORCE_EXTERNAL_SERVER", false); + db.Add<std::string>("external-server-address", "OPTIONS_DB_EXTERNAL_SERVER_ADDRESS", "localhost"); db.Add("UI.main-menu.x", "OPTIONS_DB_UI_MAIN_MENU_X", 0.75, RangedValidator<double>(0.0, 1.0)); db.Add("UI.main-menu.y", "OPTIONS_DB_UI_MAIN_MENU_Y", 0.47, RangedValidator<double>(0.0, 1.0)); } Modified: trunk/FreeOrion/client/human/HumanClientApp.cpp =================================================================== --- trunk/FreeOrion/client/human/HumanClientApp.cpp 2009-01-25 10:45:22 UTC (rev 2768) +++ trunk/FreeOrion/client/human/HumanClientApp.cpp 2009-01-25 21:28:50 UTC (rev 2769) @@ -249,8 +249,9 @@ if (!GetOptionsDB().Get<bool>("force-external-server")) { HumanClientApp::GetApp()->StartServer(); HumanClientApp::GetApp()->FreeServer(); - } - server_name = "localhost"; + server_name = "localhost"; + } + server_name = GetOptionsDB().Get<std::string>("external-server-address"); } unsigned int start_time = Ticks(); while (!Networking().ConnectToServer(server_name)) { Modified: trunk/FreeOrion/default/eng_stringtable.txt =================================================================== --- trunk/FreeOrion/default/eng_stringtable.txt 2009-01-25 10:45:22 UTC (rev 2768) +++ trunk/FreeOrion/default/eng_stringtable.txt 2009-01-25 21:28:50 UTC (rev 2769) @@ -176,6 +176,9 @@ OPTIONS_DB_FORCE_EXTERNAL_SERVER Force the client not to start a server, even when hosting a game on localhost, playing single player, etc. +OPTIONS_DB_EXTERNAL_SERVER_ADDRESS +Address to connect to in external server mode. If used, this client becomes the manager of the game. + OPTIONS_DB_UI_MAIN_MENU_X Position of the center of the intro screen main menu, as a portion of the application's total width. |
From: <geo...@us...> - 2009-01-27 15:02:33
|
Revision: 2773 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2773&view=rev Author: geoffthemedio Date: 2009-01-27 15:02:24 +0000 (Tue, 27 Jan 2009) Log Message: ----------- -Added independent Layout code for SidePanel that is (or will be) used if the SidePanel is resized, and after construction for initial layout -Fixed minor positioning issue with unexplored system names on systems droplist by replacing some special case use of a TextControl with a slightly tweaked OwnerColoredSystemName -Tweaked relative sizes of rendered planets -Added strings forgotten in previous commit Modified Paths: -------------- trunk/FreeOrion/UI/SidePanel.cpp trunk/FreeOrion/UI/SidePanel.h trunk/FreeOrion/UI/SystemIcon.cpp trunk/FreeOrion/default/eng_stringtable.txt Modified: trunk/FreeOrion/UI/SidePanel.cpp =================================================================== --- trunk/FreeOrion/UI/SidePanel.cpp 2009-01-27 10:47:59 UTC (rev 2772) +++ trunk/FreeOrion/UI/SidePanel.cpp 2009-01-27 15:02:24 UTC (rev 2773) @@ -340,14 +340,14 @@ double scale = 0.0; switch (size) { - case SZ_TINY : scale = 0.0/5.0; break; - case SZ_SMALL : scale = 1.0/5.0; break; - case SZ_MEDIUM : scale = 2.0/5.0; break; - case SZ_LARGE : scale = 3.0/5.0; break; - case SZ_HUGE : scale = 4.0/5.0; break; - case SZ_GASGIANT : scale = 5.0/5.0; break; - case SZ_ASTEROIDS : scale = 5.0/5.0; break; - default : scale = 2.0/5.0; break; + case SZ_TINY : scale = 1.0/7.0; break; + case SZ_SMALL : scale = 2.0/7.0; break; + case SZ_MEDIUM : scale = 3.0/7.0; break; + case SZ_LARGE : scale = 4.0/7.0; break; + case SZ_HUGE : scale = 5.0/7.0; break; + case SZ_GASGIANT : scale = 7.0/7.0; break; + case SZ_ASTEROIDS : scale = 7.0/7.0; break; + default : scale = 3.0/7.0; break; } const int MAX_PLANET_DIAMETER = GetOptionsDB().Get<int>("UI.sidepanel-planet-max-diameter"); @@ -363,7 +363,7 @@ void AddOptions(OptionsDB& db) { - db.Add("UI.sidepanel-width", "OPTIONS_DB_UI_SIDEPANEL_WIDTH", 360, RangedValidator<int>(64, 512)); + db.Add("UI.sidepanel-width", "OPTIONS_DB_UI_SIDEPANEL_WIDTH", 370, RangedValidator<int>(64, 512)); db.Add("UI.sidepanel-planet-max-diameter", "OPTIONS_DB_UI_SIDEPANEL_PLANET_MAX_DIAMETER", 128, RangedValidator<int>(16, 512)); db.Add("UI.sidepanel-planet-min-diameter", "OPTIONS_DB_UI_SIDEPANEL_PLANET_MIN_DIAMETER", 24, RangedValidator<int>(8, 128)); } @@ -565,9 +565,14 @@ namespace { int SystemNameFontSize() { - return static_cast<int>(ClientUI::Pts()*3/2); + return ClientUI::Pts()*3/2; } + GG::Y SystemNameTextControlHeight() + { + return GG::Y(SystemNameFontSize()*4/3); + } + struct SystemRow : public GG::ListBox::Row { public: @@ -1179,11 +1184,10 @@ y += panel->Height() + SidePanel::EDGE_PAD; // panel height may be different for each panel depending whether that panel has been previously left expanded or collapsed } - GG::Y available_height = y; - const GG::Y BIG_PAD_TO_BE_SAFE = GG::Y(300); - + GG::Y available_height = Height(); if (GG::Wnd* parent = Parent()) { GG::Y containing_height = parent->Height(); + const GG::Y BIG_PAD_TO_BE_SAFE = GG::Y(300); available_height = containing_height - BIG_PAD_TO_BE_SAFE; // height of visible "page" of panels } @@ -1281,15 +1285,17 @@ m_planet_panel_container(0), m_system_resource_summary(0) { - const boost::shared_ptr<GG::Font>& font = ClientUI::GetFont(SystemNameFontSize()); - const GG::Y DROP_HEIGHT(SystemNameFontSize()); - const int MAX_PLANET_DIAMETER = GetOptionsDB().Get<int>("UI.sidepanel-planet-max-diameter"); + const boost::shared_ptr<GG::Font>& font = ClientUI::GetFont(SystemNameFontSize()); + const GG::Y SYSTEM_NAME_TEXT_HEIGHT = SystemNameTextControlHeight(); + const GG::X BUTTON_WIDTH = GG::X(Value(SYSTEM_NAME_TEXT_HEIGHT)); + const GG::X MAX_PLANET_DIAMETER = GG::X(GetOptionsDB().Get<int>("UI.sidepanel-planet-max-diameter")); + const GG::Y DROP_DISPLAYED_LIST_HEIGHT = GG::Y(10*SystemNameFontSize()); m_planet_panel_container = new PlanetPanelContainer(GG::X0, GG::Y(140), Width(), h - 170); - m_button_prev = new GG::Button(GG::X(MAX_PLANET_DIAMETER + EDGE_PAD), GG::Y(EDGE_PAD), GG::X(Value(DROP_HEIGHT)), DROP_HEIGHT, "", font, GG::CLR_WHITE); - m_button_next = new GG::Button(Width() - Value(DROP_HEIGHT) - EDGE_PAD, GG::Y(EDGE_PAD), GG::X(Value(DROP_HEIGHT)), DROP_HEIGHT, "", font, GG::CLR_WHITE); - m_system_name = new CUIDropDownList(GG::X(MAX_PLANET_DIAMETER), GG::Y0, Width() - MAX_PLANET_DIAMETER, DROP_HEIGHT, GG::Y(10*SystemNameFontSize()), GG::CLR_ZERO, GG::FloatClr(0.0, 0.0, 0.0, 0.5)); + m_button_prev = new GG::Button(MAX_PLANET_DIAMETER + EDGE_PAD, GG::Y(EDGE_PAD), BUTTON_WIDTH, SYSTEM_NAME_TEXT_HEIGHT, "", font, GG::CLR_WHITE); + m_button_next = new GG::Button(Width() - BUTTON_WIDTH - EDGE_PAD, GG::Y(EDGE_PAD), BUTTON_WIDTH, SYSTEM_NAME_TEXT_HEIGHT, "", font, GG::CLR_WHITE); + m_system_name = new CUIDropDownList(MAX_PLANET_DIAMETER, GG::Y0, Width() - MAX_PLANET_DIAMETER, SYSTEM_NAME_TEXT_HEIGHT, DROP_DISPLAYED_LIST_HEIGHT, GG::CLR_ZERO, GG::FloatClr(0.0, 0.0, 0.0, 0.5)); TempUISoundDisabler sound_disabler; @@ -1307,8 +1313,7 @@ m_button_next->SetPressedGraphic (GG::SubTexture(ClientUI::GetTexture( ClientUI::ArtDir() / "icons" / "rightarrowclicked.png" ), GG::X0, GG::Y0, GG::X(32), GG::Y(32))); m_button_next->SetRolloverGraphic (GG::SubTexture(ClientUI::GetTexture( ClientUI::ArtDir() / "icons" / "rightarrowmouseover.png"), GG::X0, GG::Y0, GG::X(32), GG::Y(32))); - m_system_resource_summary = new MultiIconValueIndicator(Width() - MAX_PLANET_DIAMETER - EDGE_PAD*2); - m_system_resource_summary->MoveTo(GG::Pt(GG::X(MAX_PLANET_DIAMETER + EDGE_PAD), 140 - m_system_resource_summary->Height())); + m_system_resource_summary = new MultiIconValueIndicator(Width() - EDGE_PAD*2); AttachChild(m_system_name); @@ -1322,6 +1327,7 @@ GG::Connect(m_button_next->ClickedSignal, &SidePanel::NextButtonClicked, this); GG::Connect(m_planet_panel_container->PlanetSelectedSignal, &SidePanel::PlanetSelected, this); + DoLayout(); Hide(); s_side_panels.insert(this); @@ -1371,6 +1377,46 @@ m_planet_panel_container->RefreshAllPlanetPanels(); } +void SidePanel::DoLayout() +{ + const GG::X MAX_PLANET_DIAMETER(GetOptionsDB().Get<int>("UI.sidepanel-planet-max-diameter")); + const GG::Y SYSTEM_NAME_TEXT_HEIGHT = SystemNameTextControlHeight(); + const GG::Y BUTTON_HEIGHT = SYSTEM_NAME_TEXT_HEIGHT; + const GG::X BUTTON_WIDTH = GG::X(Value(BUTTON_HEIGHT)); + const GG::Y PLANET_PANEL_TOP = GG::Y(140); + const GG::Y PLANET_PANEL_BOTTOM_PAD = GG::Y(30); // makes things line up nice. accounts for top of sidepanel not being top of screen, I think... + + GG::Pt ul = GG::Pt(MAX_PLANET_DIAMETER + EDGE_PAD, GG::Y(EDGE_PAD)); + GG::Pt lr = ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); + m_button_prev->SizeMove(ul, lr); + + ul = GG::Pt(Width() - BUTTON_WIDTH - EDGE_PAD, GG::Y(EDGE_PAD)); + lr = ul + GG::Pt(BUTTON_WIDTH, BUTTON_HEIGHT); + m_button_next->SizeMove(ul, lr); + + ul = GG::Pt(MAX_PLANET_DIAMETER, GG::Y0); // no EDGE_PAD-ing for name... not sure why, but it works. + lr = ul + GG::Pt(Width() - MAX_PLANET_DIAMETER, m_system_name->Height()); // There's no obvious way to determine what the height of a droplist will be. It's determined from the height passed to the constructor (not the font passed) but isn't equal to the passed height. + m_system_name->SizeMove(ul, lr); + + ul = GG::Pt(GG::X0, PLANET_PANEL_TOP); + lr = GG::Pt(Width(), Height() - PLANET_PANEL_BOTTOM_PAD); + m_planet_panel_container->SizeMove(ul, lr); + + ul = GG::Pt(GG::X(EDGE_PAD), m_planet_panel_container->UpperLeft().y - m_system_resource_summary->Height()); + lr = ul + GG::Pt(Width() - EDGE_PAD*2, m_system_resource_summary->Height()); + m_system_resource_summary->SizeMove(ul, lr); +} + +void SidePanel::SizeMove(const GG::Pt& ul, const GG::Pt& lr) +{ + GG::Pt old_size = GG::Wnd::LowerRight() - GG::Wnd::UpperLeft(); + + GG::Wnd::SizeMove(ul, lr); + + if (Visible() && old_size != GG::Wnd::Size()) + DoLayout(); +} + void SidePanel::SetSystemImpl() { TempUISoundDisabler sound_disabler; @@ -1406,20 +1452,17 @@ int system_names_in_droplist = 0; for (unsigned int i = 0; i < sys_vec.size(); i++) { - GG::ListBox::Row *row = new SystemRow(sys_vec[i]->ID()); + const System* sys = sys_vec[i]; + GG::ListBox::Row *row = new SystemRow(sys->ID()); - if (sys_vec[i]->Name().length()==0) { - if (sys_vec[i] == s_system) { - row->push_back(UserString("SP_UNKNOWN_SYSTEM"), ClientUI::Font(), SystemNameFontSize(), ClientUI::TextColor()); - GG::Control* control = row->at(0); - GG::TextControl* text_control = dynamic_cast<GG::TextControl*>(control); - text_control->SetTextFormat(GG::FORMAT_VCENTER | GG::FORMAT_CENTER); - } else { - delete row; - continue; - } + if (sys->Name().empty() && sys != s_system) { + delete row; // delete rows for systems that aren't known to this client, except the selected system + continue; } else { - row->push_back(new OwnerColoredSystemName(sys_vec[i], ClientUI::GetFont(SystemNameFontSize()), UserString("SP_SYSTEM_NAME"))); + std::string text = UserString("SP_SYSTEM_NAME"); + if (sys->Name().empty()) + text = UserString("SP_UNKNOWN_SYSTEM"); // if showing an unexplored system (with no name) use "Unknown System" instead of displaying system name text + row->push_back(new OwnerColoredSystemName(sys, ClientUI::GetFont(SystemNameFontSize()), text)); } m_system_name->Insert(row); Modified: trunk/FreeOrion/UI/SidePanel.h =================================================================== --- trunk/FreeOrion/UI/SidePanel.h 2009-01-27 10:47:59 UTC (rev 2772) +++ trunk/FreeOrion/UI/SidePanel.h 2009-01-27 15:02:24 UTC (rev 2773) @@ -46,6 +46,7 @@ /** \name Mutators */ //@{ virtual void Render(); + virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr); static void Refresh(); ///< causes all sidepanels to refresh / update indicators @@ -66,6 +67,8 @@ private: class PlanetPanelContainer; + void DoLayout(); + void RefreshImpl(); void SetSystemImpl(); void SystemSelectionChanged(GG::DropDownList::iterator it); Modified: trunk/FreeOrion/UI/SystemIcon.cpp =================================================================== --- trunk/FreeOrion/UI/SystemIcon.cpp 2009-01-27 10:47:59 UTC (rev 2772) +++ trunk/FreeOrion/UI/SystemIcon.cpp 2009-01-27 15:02:24 UTC (rev 2773) @@ -33,7 +33,7 @@ { // TODO: Have this make a single call per color. Set up texture coord and vertex buffers (quads) for the glyphs. Consider extending GG::Font to do similar. - std::string str = format_text == "" ? system->Name() : boost::io::str(boost::format(format_text) % system->Name()); + std::string str = format_text == "" ? system->Name() : boost::io::str(FlexibleFormat(format_text) % system->Name()); GG::X width(0); const std::set<int>& owners = system->Owners(); if (owners.size() <= 1) { Modified: trunk/FreeOrion/default/eng_stringtable.txt =================================================================== --- trunk/FreeOrion/default/eng_stringtable.txt 2009-01-27 10:47:59 UTC (rev 2772) +++ trunk/FreeOrion/default/eng_stringtable.txt 2009-01-27 15:02:24 UTC (rev 2773) @@ -398,6 +398,15 @@ OPTIONS_DB_UI_WINDOW_QUICKCLOSE Close open windows such as fleet windows and the system-view side panel when you right-click on the main map. +OPTIONS_DB_UI_SIDEPANEL_WIDTH +Sets size of system sidepanel. + +OPTIONS_DB_UI_SIDEPANEL_PLANET_MAX_DIAMETER +Sets size of largest-rendered rotating planets on sidepanel. + +OPTIONS_DB_UI_SIDEPANEL_PLANET_MIN_DIAMETER +Sets size of smallest-rendered rotating planets on sidepanel. + OPTIONS_DB_GAMESETUP_STARS The number of stars in the galaxy to be generated. |
From: <geo...@us...> - 2009-01-30 10:08:18
|
Revision: 2781 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2781&view=rev Author: geoffthemedio Date: 2009-01-30 10:08:16 +0000 (Fri, 30 Jan 2009) Log Message: ----------- -Committing modified version of patch by francys to add QuickStart button to main title menu. Uses previously-used single player options to start game without showing galaxy setup screen. -Removed "Human" empire name since this is the default player name and was likely to lead to an AI and a player name the same thing with default settings -Minor grooming Modified Paths: -------------- trunk/FreeOrion/UI/GalaxySetupWnd.cpp trunk/FreeOrion/UI/IntroScreen.cpp trunk/FreeOrion/UI/IntroScreen.h trunk/FreeOrion/client/human/HumanClientApp.cpp trunk/FreeOrion/client/human/HumanClientApp.h trunk/FreeOrion/default/empire_names.txt trunk/FreeOrion/default/eng_stringtable.txt trunk/FreeOrion/universe/Enums.h Modified: trunk/FreeOrion/UI/GalaxySetupWnd.cpp =================================================================== --- trunk/FreeOrion/UI/GalaxySetupWnd.cpp 2009-01-29 17:15:59 UTC (rev 2780) +++ trunk/FreeOrion/UI/GalaxySetupWnd.cpp 2009-01-30 10:08:16 UTC (rev 2781) @@ -27,15 +27,15 @@ // persistant between-executions galaxy setup settings, mainly so I don't have to redo these settings to what I want every time I run FO to test something void AddOptions(OptionsDB& db) { - db.Add("GameSetup.stars", "OPTIONS_DB_GAMESETUP_STARS", 100, RangedValidator<int>(10, 500)); - db.Add("GameSetup.galaxy-shape", "OPTIONS_DB_GAMESETUP_GALAXY_SHAPE", SPIRAL_3, RangedValidator<Shape>(SPIRAL_2, RING)); - db.Add("GameSetup.galaxy-age", "OPTIONS_DB_GAMESETUP_GALAXY_AGE", AGE_MATURE, RangedValidator<Age>(AGE_YOUNG, AGE_ANCIENT)); - db.Add("GameSetup.planet-density", "OPTIONS_DB_GAMESETUP_PLANET_DENSITY", PD_AVERAGE, RangedValidator<PlanetDensity>(PD_LOW, PD_HIGH)); - db.Add("GameSetup.starlane-frequency", "OPTIONS_DB_GAMESETUP_STARLANE_FREQUENCY", LANES_SEVERAL, RangedValidator<StarlaneFrequency>(ALLOW_NO_STARLANES ? LANES_NONE : LANES_FEW, LANES_VERY_MANY)); - db.Add("GameSetup.specials-frequency", "OPTIONS_DB_GAMESETUP_SPECIALS_FREQUENCY", SPECIALS_UNCOMMON, RangedValidator<SpecialsFrequency>(SPECIALS_NONE, SPECIALS_COMMON)); - db.Add("GameSetup.empire-name", "OPTIONS_DB_GAMESETUP_EMPIRE_NAME", std::string("Human"), Validator<std::string>()); - db.Add("GameSetup.empire-color", "OPTIONS_DB_GAMESETUP_EMPIRE_COLOR", 0, RangedValidator<int>(0, 100)); - db.Add("GameSetup.ai-players", "OPTIONS_DB_GAMESETUP_NUM_AI_PLAYERS", 4, RangedValidator<int>(0, MAX_AI_PLAYERS)); + db.Add("GameSetup.stars", "OPTIONS_DB_GAMESETUP_STARS", 100, RangedValidator<int>(10, 500)); + db.Add("GameSetup.galaxy-shape", "OPTIONS_DB_GAMESETUP_GALAXY_SHAPE", SPIRAL_3, RangedValidator<Shape>(SPIRAL_2, RING)); + db.Add("GameSetup.galaxy-age", "OPTIONS_DB_GAMESETUP_GALAXY_AGE", AGE_MATURE, RangedValidator<Age>(AGE_YOUNG, AGE_ANCIENT)); + db.Add("GameSetup.planet-density", "OPTIONS_DB_GAMESETUP_PLANET_DENSITY", PD_AVERAGE, RangedValidator<PlanetDensity>(PD_LOW, PD_HIGH)); + db.Add("GameSetup.starlane-frequency", "OPTIONS_DB_GAMESETUP_STARLANE_FREQUENCY", LANES_SEVERAL, RangedValidator<StarlaneFrequency>(ALLOW_NO_STARLANES ? LANES_NONE : LANES_FEW, LANES_VERY_MANY)); + db.Add("GameSetup.specials-frequency", "OPTIONS_DB_GAMESETUP_SPECIALS_FREQUENCY", SPECIALS_UNCOMMON, RangedValidator<SpecialsFrequency>(SPECIALS_NONE, SPECIALS_COMMON)); + db.Add("GameSetup.empire-name", "OPTIONS_DB_GAMESETUP_EMPIRE_NAME", std::string("Human"), Validator<std::string>()); + db.Add("GameSetup.empire-color", "OPTIONS_DB_GAMESETUP_EMPIRE_COLOR", 0, RangedValidator<int>(0, 100)); + db.Add("GameSetup.ai-players", "OPTIONS_DB_GAMESETUP_NUM_AI_PLAYERS", 4, RangedValidator<int>(0, MAX_AI_PLAYERS)); } bool temp_bool = RegisterOptions(&AddOptions); } @@ -339,11 +339,11 @@ m_number_ais_spin->OffsetMove(GG::Pt(GG::X0, (PANEL_CONTROL_SPACING - m_number_ais_spin->Height()) / 2)); m_preview_ul = GG::Pt(ClientWidth() - PREVIEW_SZ.x - 7, GG::Y(7)); - + // create a temporary texture and static graphic boost::shared_ptr<GG::Texture> temp_tex(new GG::Texture()); m_preview_image = new GG::StaticGraphic(m_preview_ul.x, m_preview_ul.y, PREVIEW_SZ.x, PREVIEW_SZ.y, temp_tex, GG::GRAPHIC_FITGRAPHIC); // create a blank graphic - + ypos += PANEL_CONTROL_SPACING + 5; m_ok = new CUIButton(GG::X(10), ypos, GG::X(75), UserString("OK")); m_cancel = new CUIButton(10 + m_ok->Size().x + 15, ypos, GG::X(75), UserString("CANCEL")); @@ -442,16 +442,15 @@ void GalaxySetupWnd::OkClicked() { // record selected galaxy setup options as new defaults - GetOptionsDB().Set("GameSetup.stars", m_galaxy_setup_panel->Systems()); - GetOptionsDB().Set("GameSetup.galaxy-shape", m_galaxy_setup_panel->GetShape()); - GetOptionsDB().Set("GameSetup.galaxy-age", m_galaxy_setup_panel->GetAge()); - GetOptionsDB().Set("GameSetup.starlane-frequency", m_galaxy_setup_panel->GetStarlaneFrequency()); - GetOptionsDB().Set("GameSetup.planet-density", m_galaxy_setup_panel->GetPlanetDensity()); - GetOptionsDB().Set("GameSetup.specials-frequency", m_galaxy_setup_panel->GetSpecialsFrequency()); - GetOptionsDB().Set("GameSetup.empire-name", EmpireName()); - GetOptionsDB().Set("GameSetup.empire-color", - static_cast<int>(m_empire_color_selector->CurrentItemIndex())); - GetOptionsDB().Set("GameSetup.ai-players", m_number_ais_spin->Value()); + GetOptionsDB().Set("GameSetup.stars", m_galaxy_setup_panel->Systems()); + GetOptionsDB().Set("GameSetup.galaxy-shape", m_galaxy_setup_panel->GetShape()); + GetOptionsDB().Set("GameSetup.galaxy-age", m_galaxy_setup_panel->GetAge()); + GetOptionsDB().Set("GameSetup.starlane-frequency", m_galaxy_setup_panel->GetStarlaneFrequency()); + GetOptionsDB().Set("GameSetup.planet-density", m_galaxy_setup_panel->GetPlanetDensity()); + GetOptionsDB().Set("GameSetup.specials-frequency", m_galaxy_setup_panel->GetSpecialsFrequency()); + GetOptionsDB().Set("GameSetup.empire-name", EmpireName()); + GetOptionsDB().Set("GameSetup.empire-color", static_cast<int>(m_empire_color_selector->CurrentItemIndex())); + GetOptionsDB().Set("GameSetup.ai-players", m_number_ais_spin->Value()); // Save the changes: boost::filesystem::ofstream ofs(GetConfigPath()); Modified: trunk/FreeOrion/UI/IntroScreen.cpp =================================================================== --- trunk/FreeOrion/UI/IntroScreen.cpp 2009-01-29 17:15:59 UTC (rev 2780) +++ trunk/FreeOrion/UI/IntroScreen.cpp 2009-01-30 10:08:16 UTC (rev 2781) @@ -26,7 +26,7 @@ namespace { const GG::X MAIN_MENU_WIDTH(200); - const GG::Y MAIN_MENU_HEIGHT(340); + const GG::Y MAIN_MENU_HEIGHT(380); void Options(OptionsDB& db) { @@ -40,7 +40,6 @@ } -//**************************************************************************************************** class CreditsWnd : public GG::Wnd { public: @@ -160,15 +159,17 @@ //create buttons m_single_player = new CUIButton(GG::X(15), GG::Y(12), GG::X(160), UserString("INTRO_BTN_SINGLE_PLAYER")); - m_multi_player = new CUIButton(GG::X(15), GG::Y(52), GG::X(160), UserString("INTRO_BTN_MULTI_PLAYER")); - m_load_game = new CUIButton(GG::X(15), GG::Y(92), GG::X(160), UserString("INTRO_BTN_LOAD_GAME")); - m_options = new CUIButton(GG::X(15), GG::Y(132), GG::X(160), UserString("INTRO_BTN_OPTIONS")); - m_about = new CUIButton(GG::X(15), GG::Y(172), GG::X(160), UserString("INTRO_BTN_ABOUT")); - m_credits = new CUIButton(GG::X(15), GG::Y(212), GG::X(160), UserString("INTRO_BTN_CREDITS")); - m_exit_game = new CUIButton(GG::X(15), GG::Y(282), GG::X(160), UserString("INTRO_BTN_EXIT")); - + m_quick_start = new CUIButton(GG::X(15), GG::Y(52), GG::X(160), UserString("INTRO_BTN_QUICK_START")); + m_multi_player = new CUIButton(GG::X(15), GG::Y(92), GG::X(160), UserString("INTRO_BTN_MULTI_PLAYER")); + m_load_game = new CUIButton(GG::X(15), GG::Y(132), GG::X(160), UserString("INTRO_BTN_LOAD_GAME")); + m_options = new CUIButton(GG::X(15), GG::Y(172), GG::X(160), UserString("INTRO_BTN_OPTIONS")); + m_about = new CUIButton(GG::X(15), GG::Y(212), GG::X(160), UserString("INTRO_BTN_ABOUT")); + m_credits = new CUIButton(GG::X(15), GG::Y(252), GG::X(160), UserString("INTRO_BTN_CREDITS")); + m_exit_game = new CUIButton(GG::X(15), GG::Y(322), GG::X(160), UserString("INTRO_BTN_EXIT")); + //attach buttons AttachChild(m_single_player); + AttachChild(m_quick_start); AttachChild(m_multi_player); AttachChild(m_load_game); AttachChild(m_options); @@ -178,6 +179,7 @@ //connect signals and slots GG::Connect(m_single_player->ClickedSignal, &IntroScreen::OnSinglePlayer, this); + GG::Connect(m_quick_start->ClickedSignal, &IntroScreen::OnQuickStart, this); GG::Connect(m_multi_player->ClickedSignal, &IntroScreen::OnMultiPlayer, this); GG::Connect(m_load_game->ClickedSignal, &IntroScreen::OnLoadGame, this); GG::Connect(m_options->ClickedSignal, &IntroScreen::OnOptions, this); @@ -201,6 +203,13 @@ HumanClientApp::GetApp()->NewSinglePlayerGame(); } +void IntroScreen::OnQuickStart() +{ + delete m_credits_wnd; + m_credits_wnd = 0; + HumanClientApp::GetApp()->NewSinglePlayerGame(true); +} + void IntroScreen::OnMultiPlayer() { delete m_credits_wnd; Modified: trunk/FreeOrion/UI/IntroScreen.h =================================================================== --- trunk/FreeOrion/UI/IntroScreen.h 2009-01-29 17:15:59 UTC (rev 2780) +++ trunk/FreeOrion/UI/IntroScreen.h 2009-01-30 10:08:16 UTC (rev 2781) @@ -30,6 +30,7 @@ /** \name Mutators*/ //!@{ void OnSinglePlayer(); //!< called when single player is clicked + void OnQuickStart(); //!< called when quick start is clicked void OnMultiPlayer(); //!< called when multi player is clicked void OnLoadGame(); //!< called when load game is clicked void OnOptions(); //!< called when options is clicked @@ -45,6 +46,7 @@ private: CUIButton* m_single_player; //!< opens up the single player game dialog + CUIButton* m_quick_start; //!< starts a single-player game with the default options (no dialog) CUIButton* m_multi_player; //!< opens up the multi player game dialog CUIButton* m_load_game; //!< loads a saved single player game CUIButton* m_options; //!< opens the options dialog Modified: trunk/FreeOrion/client/human/HumanClientApp.cpp =================================================================== --- trunk/FreeOrion/client/human/HumanClientApp.cpp 2009-01-29 17:15:59 UTC (rev 2780) +++ trunk/FreeOrion/client/human/HumanClientApp.cpp 2009-01-30 10:08:16 UTC (rev 2781) @@ -184,7 +184,7 @@ SetPlayerName(""); } -void HumanClientApp::NewSinglePlayerGame() +void HumanClientApp::NewSinglePlayerGame(bool quickstart) { if (!GetOptionsDB().Get<bool>("force-external-server")) { try { @@ -197,10 +197,12 @@ } GalaxySetupWnd galaxy_wnd; - galaxy_wnd.Run(); + if (!quickstart) { + galaxy_wnd.Run(); + } bool failed = false; - if (galaxy_wnd.EndedWithOk()) { + if (quickstart || galaxy_wnd.EndedWithOk()) { unsigned int start_time = Ticks(); while (!Networking().ConnectToLocalHostServer()) { if (SERVER_CONNECT_TIMEOUT < Ticks() - start_time) { @@ -213,14 +215,42 @@ } if (!failed) { - // TODO: Select difficulty of AIs SinglePlayerSetupData setup_data; - galaxy_wnd.Panel().GetSetupData(setup_data); + if (quickstart) { + // get values stored in options from previous time game was run + + setup_data.m_size = GetOptionsDB().Get<int>("GameSetup.stars"); + setup_data.m_shape = GetOptionsDB().Get<Shape>("GameSetup.galaxy-shape"); + setup_data.m_age = GetOptionsDB().Get<Age>("GameSetup.galaxy-age"); + + // GalaxySetupWnd doesn't allow LANES_NON, but I'll assume the value in the OptionsDB is valid here + // since this is quickstart, and should be based on previous acceptable value stored, unless + // the options file has be corrupted or edited + setup_data.m_starlane_freq = GetOptionsDB().Get<StarlaneFrequency>("GameSetup.starlane-frequency"); + + setup_data.m_planet_density = GetOptionsDB().Get<PlanetDensity>("GameSetup.planet-density"); + setup_data.m_specials_freq = GetOptionsDB().Get<SpecialsFrequency>("GameSetup.specials-frequency"); + setup_data.m_empire_name = GetOptionsDB().Get<std::string>("GameSetup.empire-name"); + + // DB stores index into array of available colours, so need to get that array to look up value of index. + // if stored value is invalid, use a default colour + const std::vector<GG::Clr>& empire_colours = EmpireColors(); + int colour_index = GetOptionsDB().Get<int>("GameSetup.empire-color"); + if (colour_index >= 0 && colour_index < empire_colours.size()) + setup_data.m_empire_color = empire_colours[colour_index]; + else + setup_data.m_empire_color = GG::CLR_GREEN; + + setup_data.m_AIs = GetOptionsDB().Get<int>("GameSetup.ai-players"); + + } else { + galaxy_wnd.Panel().GetSetupData(setup_data); + setup_data.m_empire_name = galaxy_wnd.EmpireName(); + setup_data.m_empire_color = galaxy_wnd.EmpireColor(); + setup_data.m_AIs = galaxy_wnd.NumberAIs(); + } setup_data.m_new_game = true; setup_data.m_host_player_name = SinglePlayerName(); - setup_data.m_empire_name = galaxy_wnd.EmpireName(); - setup_data.m_empire_color = galaxy_wnd.EmpireColor(); - setup_data.m_AIs = galaxy_wnd.NumberAIs(); Networking().SendMessage(HostSPGameMessage(setup_data)); m_fsm->process_event(HostSPGameRequested(WAITING_FOR_NEW_GAME)); } Modified: trunk/FreeOrion/client/human/HumanClientApp.h =================================================================== --- trunk/FreeOrion/client/human/HumanClientApp.h 2009-01-29 17:15:59 UTC (rev 2780) +++ trunk/FreeOrion/client/human/HumanClientApp.h 2009-01-30 10:08:16 UTC (rev 2781) @@ -42,7 +42,7 @@ void StartServer(); ///< starts a server process on localhost void FreeServer(); ///< frees (relinquishes ownership and control of) any running server process already started by this client; performs no cleanup of other processes, such as AIs void KillServer(); ///< kills any running server process already started by this client; performs no cleanup of other processes, such as AIs - void NewSinglePlayerGame(); + void NewSinglePlayerGame(bool quickstart = false); void MulitplayerGame(); void SaveGame(const std::string& filename); ///< saves the current game; blocks until all save-related network traffic is resolved. void EndGame(); ///< kills the server (if appropriate) and ends the current game, leaving the application in its start state Modified: trunk/FreeOrion/default/empire_names.txt =================================================================== --- trunk/FreeOrion/default/empire_names.txt 2009-01-29 17:15:59 UTC (rev 2780) +++ trunk/FreeOrion/default/empire_names.txt 2009-01-30 10:08:16 UTC (rev 2781) @@ -1,4 +1,3 @@ -Human Gyisache Chato'matou'Gormoshk Eaxaw Modified: trunk/FreeOrion/default/eng_stringtable.txt =================================================================== --- trunk/FreeOrion/default/eng_stringtable.txt 2009-01-29 17:15:59 UTC (rev 2780) +++ trunk/FreeOrion/default/eng_stringtable.txt 2009-01-30 10:08:16 UTC (rev 2781) @@ -548,6 +548,9 @@ INTRO_BTN_SINGLE_PLAYER Single Player +INTRO_BTN_QUICK_START +Quick Start + INTRO_BTN_MULTI_PLAYER Multi Player Modified: trunk/FreeOrion/universe/Enums.h =================================================================== --- trunk/FreeOrion/universe/Enums.h 2009-01-29 17:15:59 UTC (rev 2780) +++ trunk/FreeOrion/universe/Enums.h 2009-01-30 10:08:16 UTC (rev 2781) @@ -297,11 +297,11 @@ /** starlane frequencies during universe generation */ enum StarlaneFrequency { INVALID_STARLANE_FREQENCY = -1, - LANES_NONE, - LANES_FEW, - LANES_SOME, - LANES_SEVERAL, - LANES_MANY, + LANES_NONE, + LANES_FEW, + LANES_SOME, + LANES_SEVERAL, + LANES_MANY, LANES_VERY_MANY, NUM_STARLANE_FREQENCIES ///< keep this last, the number of starlane frequency options }; |
From: <geo...@us...> - 2009-01-31 02:59:13
|
Revision: 2783 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2783&view=rev Author: geoffthemedio Date: 2009-01-31 02:59:08 +0000 (Sat, 31 Jan 2009) Log Message: ----------- -Initial outline of MarkupBox control that lays out text and images from an input string with HTML-like formatting tags. Not yet used. -Added francys to credits -Removed some unused commented out code Modified Paths: -------------- trunk/FreeOrion/UI/CUIControls.cpp trunk/FreeOrion/UI/InfoPanels.cpp trunk/FreeOrion/default/credits.xml Added Paths: ----------- trunk/FreeOrion/UI/MarkupBox.cpp trunk/FreeOrion/UI/MarkupBox.h Modified: trunk/FreeOrion/UI/CUIControls.cpp =================================================================== --- trunk/FreeOrion/UI/CUIControls.cpp 2009-01-30 14:39:10 UTC (rev 2782) +++ trunk/FreeOrion/UI/CUIControls.cpp 2009-01-31 02:59:08 UTC (rev 2783) @@ -878,7 +878,7 @@ // Since highlighting links on rollover also involves setting text, there are a lot of potentially unnecessary // calls to SetText and FindLinks. This check for whether text is already being set eliminates many of those // calls when they aren't necessary, since the results will be overridden later anyway by the outermost (or - // lowest on stack, or first ) call to SetText + // lowest on stack, or first) call to SetText if (!m_already_setting_text_so_dont_link) { m_already_setting_text_so_dont_link = true; CUIMultiEdit::SetText(str); @@ -888,8 +888,6 @@ } else { CUIMultiEdit::SetText(str); } - //CUIMultiEdit::SetText(str); - //FindLinks(); } void CUILinkTextMultiEdit::SetLinkedText(const std::string& str) Modified: trunk/FreeOrion/UI/InfoPanels.cpp =================================================================== --- trunk/FreeOrion/UI/InfoPanels.cpp 2009-01-30 14:39:10 UTC (rev 2782) +++ trunk/FreeOrion/UI/InfoPanels.cpp 2009-01-31 02:59:08 UTC (rev 2783) @@ -586,21 +586,6 @@ glPolygonMode(GL_BACK, initial_modes[1]); glEnable(GL_TEXTURE_2D); - - // draw details depending on state of ownership and expanded / collapsed status - - // determine ownership - /*const UniverseObject* obj = GetUniverse().Object(m_popcenter_id); - if(obj->Owners().empty()) - // uninhabited - else - { - if(!obj->OwnedBy(HumanClientApp::GetApp()->EmpireID())) - // inhabited by other empire - else - // inhabited by this empire (and possibly other empires) - }*/ - } void PopulationPanel::Update() Added: trunk/FreeOrion/UI/MarkupBox.cpp =================================================================== --- trunk/FreeOrion/UI/MarkupBox.cpp (rev 0) +++ trunk/FreeOrion/UI/MarkupBox.cpp 2009-01-31 02:59:08 UTC (rev 2783) @@ -0,0 +1,365 @@ +#include "MarkupBox.h" + +#include "CUIControls.h" + +#include <GG/StaticGraphic.h> +#include <GG/MultiEdit.h> +#include <GG/WndEvent.h> +#include <GG/DrawUtil.h> +#include <GG/StyleFactory.h> + +namespace { + static const GG::X SCROLL_WIDTH(14); + static const int EDGE_PAD(3); +} + +////////////////////////////// +// MarkupBox::MarkupSurface // +////////////////////////////// +class MarkupBox::MarkupSurface : public GG::Control { +public: + /** \name Structors */ ///@{ + /** Ctor. */ + MarkupSurface(GG::X x, GG::Y y, GG::X w, GG::Y h, const std::string& str); + + MarkupSurface(); ///< default ctor + ~MarkupSurface(); ///< dtor + //@} + + /** \name Accessors */ ///@{ + const std::string& Text() const; + //@} + + /** \name Mutators */ ///@{ + + /** Removes old controls and recreates new contents of surface from passed + \a str text. If PreserveScrollPositionOnNextTextSet() has been called, + does not alter scroll position. Otherwise, resets scroll position to + top of contents. */ + void SetText(const std::string& str); + + void Clear(); ///< Removes all controls from surface. + void Refresh(); ///< Removes and recreates all controls on surface using existing text + + virtual void Render(); + //@} + +private: + std::string m_text; + + std::vector<GG::Control*> m_controls; ///< GG::Controls used to display marked up text +}; + +MarkupBox::MarkupSurface::MarkupSurface(GG::X x, GG::Y y, GG::X w, GG::Y h, const std::string& str) : + GG::Control(x, y, w, h), + m_text(""), + m_controls() +{ + SetText(str); + EnableChildClipping(true); +} + +MarkupBox::MarkupSurface::MarkupSurface() : + m_text(""), + GG::Control(), + m_controls() +{ + EnableChildClipping(true); +} + +MarkupBox::MarkupSurface::~MarkupSurface() { + Clear(); +} + +const std::string& MarkupBox::MarkupSurface::Text() const { + return m_text; +} + +void MarkupBox::MarkupSurface::SetText(const std::string& str) { + Clear(); + m_text = str; + Refresh(); +} + +void MarkupBox::MarkupSurface::Clear() { + for (std::vector<GG::Control*>::iterator it = m_controls.begin(); it != m_controls.end(); ++it) + delete *it; + m_controls.clear(); + m_text = ""; +} + +void MarkupBox::MarkupSurface::Refresh() { + // remove old controls / contents + for (std::vector<GG::Control*>::iterator it = m_controls.begin(); it != m_controls.end(); ++it) + delete *it; + m_controls.clear(); + + // recreate controls / content based on current m_str + + // TEMP / TEST~! + GG::Y top = GG::Y0; + GG::Control* control = new GG::TextControl(GG::X0, top, m_text, ClientUI::GetFont(), ClientUI::TextColor()); + m_controls.push_back(control); + AttachChild(control); + + control->MoveTo(GG::Pt(GG::X0, top)); + top += control->Height() + EDGE_PAD; + + std::cout << "MarkupSurface::Refresh control (x,y): " << control->UpperLeft().x << ", " << control->UpperLeft().y << + " (w,h): " << control->Width() << ", " << control->Height() << std::endl; + + Resize(GG::Pt(Width(), GG::Y(m_text.length()*ClientUI::Pts()))); + // END TEMP / TEST +} + +void MarkupBox::MarkupSurface::Render() { + // do nothing. controls on surface give it appearance. background that contains surface give it a background. +} + + +////////////////////////////// +// MarkupBox // +////////////////////////////// +namespace { + static const std::string EMPTY_STRING(""); +} + +MarkupBox::MarkupBox(GG::X x, GG::Y y, GG::X w, GG::Y h, const std::string& str, GG::Flags<GG::WndFlag> flags) : + GG::Control(x, y, w, h, flags), + m_vscroll(0), + m_surface(0), + m_preserve_scroll_position_on_next_text_set(false) +{ + m_surface = new MarkupSurface(GG::X0 + EDGE_PAD, GG::Y0 + EDGE_PAD, w - 2*EDGE_PAD, h - 2*EDGE_PAD, str); + AttachChild(m_surface); + EnableChildClipping(true); + Refresh(); + AdjustScrolls(); + VScrolled(0, 0, 0, 0); +} + + +MarkupBox::MarkupBox() : + GG::Control(), + m_vscroll(0), + m_surface(0), + m_preserve_scroll_position_on_next_text_set(false) +{ + m_surface = new MarkupSurface(GG::X0, GG::Y0, GG::X0, GG::Y0, ""); + AttachChild(m_surface); + EnableChildClipping(true); + Refresh(); + VScrolled(0, 0, 0, 0); + // shouldn't need to adjust scrolls since text is empty +} + +MarkupBox::~MarkupBox() { + delete m_vscroll; + //delete m_surface; // should be unnecessary +} + +const std::string& MarkupBox::Text() const { + if (m_surface) + return m_surface->Text(); + else + return EMPTY_STRING; +} + +void MarkupBox::Render() { + // Draw outline and background... + + // copied from CUIWnd + GG::Pt ul = UpperLeft(); + GG::Pt lr = LowerRight(); + GG::Pt cl_ul = ClientUpperLeft(); + GG::Pt cl_lr = ClientLowerRight(); + + // 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()); + glVertex(ul.x, ul.y); + glVertex(lr.x, ul.y); + glVertex(lr.x, lr.y); + glVertex(ul.x, lr.y); + glVertex(ul.x, ul.y); + glEnd(); + + // draw outer border on pixel inside of the outer edge of the window + glPolygonMode(GL_BACK, GL_LINE); + glBegin(GL_POLYGON); + glColor(ClientUI::WndOuterBorderColor()); + glVertex(ul.x, ul.y); + glVertex(lr.x, ul.y); + glVertex(lr.x, lr.y); + glVertex(ul.x, lr.y); + glVertex(ul.x, ul.y); + glEnd(); + + // reset this to whatever it was initially + glPolygonMode(GL_BACK, initial_modes[1]); + + glEnable(GL_TEXTURE_2D); +} + +void MarkupBox::SizeMove(const GG::Pt& ul, const GG::Pt& lr) { + GG::Pt old_size = Size(); + GG::Control::SizeMove(ul, lr); + if (Size() != old_size) { + if (m_vscroll) + m_surface->SizeMove(GG::Pt(GG::X0 + EDGE_PAD, GG::Y0 + EDGE_PAD), + GG::Pt(Width() - SCROLL_WIDTH - 2*EDGE_PAD, Height() - 2*EDGE_PAD)); + else + m_surface->SizeMove(GG::Pt(GG::X0 + EDGE_PAD, GG::Y0 + EDGE_PAD), + GG::Pt(Width() - 2*EDGE_PAD, Height() - 2*EDGE_PAD)); + + Refresh(); + } +} + +void MarkupBox::SetText(const std::string& str) { + if (m_preserve_scroll_position_on_next_text_set) { + m_preserve_scroll_position_on_next_text_set = false; + m_surface->SetText(str); + return; + } + + // save old surface size + GG::Pt old_surface_size = m_surface->Size(); + + // update text, which might change size of surface + m_surface->SetText(str); + + // check new surface size. if it has changed, check if scrollbar positions and layout need changing + if (m_surface->Size() != old_surface_size) + AdjustScrolls(); +} + +void MarkupBox::PreserveScrollPositionOnNextTextSet() { + m_preserve_scroll_position_on_next_text_set = true; +} + +void MarkupBox::Refresh() { + m_surface->Refresh(); +} + +void MarkupBox::MouseWheel(const GG::Pt& pt, int move, GG::Flags<GG::ModKey> mod_keys) { + if (!Disabled() && m_vscroll) { + for (int i = 0; i < move; ++i) + m_vscroll->ScrollLineDecr(); + for (int i = 0; i < -move; ++i) + m_vscroll->ScrollLineIncr(); + } +} + +void MarkupBox::KeyPress(GG::Key key, boost::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys) { + if (Disabled()) { + GG::Control::KeyPress(key, key_code_point, mod_keys); + return; + } + + if (!m_vscroll) + return; + + int bottom = 0; + + switch (key) { + case GG::GGK_UP: + m_vscroll->ScrollLineDecr(); + break; + case GG::GGK_DOWN: + m_vscroll->ScrollLineIncr(); + break; + case GG::GGK_HOME: + m_vscroll->ScrollTo(0); + break; + case GG::GGK_END: + bottom = Value(m_surface->Height() - Height()); // find top position so that bottom of surface is at bottom of this box + m_vscroll->ScrollTo(std::max(0, bottom)); // but don't allow negative scroll positions, in case this height is larger than surface height + break; + case GG::GGK_PAGEUP: + m_vscroll->ScrollPageDecr(); + break; + case GG::GGK_PAGEDOWN: + m_vscroll->ScrollPageIncr(); + break; + } +} + +void MarkupBox::Clear() { + m_surface->Clear(); + VScrolled(0, 0, 0, 0); +} + +void MarkupBox::AdjustScrolls() { + if (!m_surface) { + delete m_vscroll; m_vscroll = NULL; + return; + } + + GG::Y surface_height = m_surface->Height(); + GG::Y this_height = Height(); + + int line_height = ClientUI::Pts(); + + if (m_vscroll) { + if (surface_height <= this_height) { + // there is a scrollbar, but it's not needed. Remove it. + delete m_vscroll; m_vscroll = NULL; + + // resize surface to account for extra horizontal space due to lack of scrollbars + m_surface->SizeMove(UpperLeft(), LowerRight()); + + // redo text layout, since removing scrollbar added extra width + m_surface->Refresh(); + + // ensure surface top is at top of this control + VScrolled(0, 0, 0, 0); + + } else { + // there is a scrollbar already and it's still needed. adjust scroll range + m_vscroll->SizeScroll(0 /* min value scrollbar can take */, Value(surface_height) /* max value scrollbar can take */, + static_cast<unsigned int>(line_height) /* size of one line tick of bar */, + static_cast<unsigned int>(Value(this_height)) /* size of one page tick of bar */); + } + } else if (!m_vscroll) { + if (surface_height <= this_height) { + // there is no scrollbar, and no bar is needed. Make sure surface is showing from top. + VScrolled(0, 0, 0, 0); + + } else { + // there is no scrollbar, but one is needed. Create one + boost::shared_ptr<GG::StyleFactory> style = GetStyleFactory(); + + m_vscroll = style->NewMultiEditVScroll(Width() - SCROLL_WIDTH, GG::Y0, SCROLL_WIDTH, Height(), + ClientUI::TextColor(), GG::CLR_ZERO); + + // adjust size of surface since creating a scrollbar takes up some horizontal space, which affects layout + m_surface->SizeMove(UpperLeft(), LowerRight() - GG::Pt(SCROLL_WIDTH, GG::Y0)); + + // redo layout after changing surface size + m_surface->Refresh(); + + // adjust range of scrolling and size of increments and pages after potentially resizing surface during refresh + m_vscroll->SizeScroll(0, Value(surface_height), + static_cast<unsigned int>(line_height), + static_cast<unsigned int>(Value(this_height))); + + // show new scrollbar and connect it functionally to this control + AttachChild(m_vscroll); + GG::Connect(m_vscroll->ScrolledSignal, &MarkupBox::VScrolled, this); + } + } +} + +void MarkupBox::VScrolled(int upper, int ignored1, int ignored2, int ignored3) { + // move surface in opposite direction to distance scroll is scrolled in vertical direction. Thus, scrolling down + // reveals more of lower parts of surface, and vice versa. + m_surface->MoveTo(GG::Pt(GG::X0, GG::Y(-upper))); +} + Added: trunk/FreeOrion/UI/MarkupBox.h =================================================================== --- trunk/FreeOrion/UI/MarkupBox.h (rev 0) +++ trunk/FreeOrion/UI/MarkupBox.h 2009-01-31 02:59:08 UTC (rev 2783) @@ -0,0 +1,64 @@ +// -*- C++ -*- +//MarkupBox.h +#ifndef _MARKUP_BOX_H_ +#define _MARKUP_BOX_H_ + +#include <GG/Control.h> +namespace GG { + class Scroll; +} + + +/** A control similar to GG::MultiEdit that displayed text, links, and images with layout determined + * from HTML-like markup in the provided text. */ +class MarkupBox : public GG::Control +{ +public: + /** \name Structors */ ///@{ + /** Ctor. */ + MarkupBox(GG::X x, GG::Y y, GG::X w, GG::Y h, const std::string& str, GG::Flags<GG::WndFlag> flags = GG::CLICKABLE); + + MarkupBox(); ///< default ctor + + virtual ~MarkupBox(); ///< dtor + //@} + + /** \name Accessors */ ///@{ + const std::string& Text() const; + //@} + + /** \name Mutators */ ///@{ + virtual void Render(); + virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr); + virtual void MouseWheel(const GG::Pt& pt, int move, GG::Flags<GG::ModKey> mod_keys); + virtual void KeyPress(GG::Key key, boost::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys); + + virtual void SetText(const std::string& str); + void Clear(); + + void Refresh(); + + /** Ensures that the next call to SetText() preserves the scroll position. Useful when repeatedly + * setting the same text with slight changes in markup that will not affect the layout, such as + * when responding to mouseovers of links in text. */ + void PreserveScrollPositionOnNextTextSet(); + + //@} + +private: + class MarkupSurface; + + void AdjustScrolls(); ///< sets the sizes of the scroll-space and the screen-space of the scrolls + void VScrolled(int upper, int ignored1, int ignored2, int ignored3); + + GG::Scroll* m_vscroll; ///< scrollbar used to scroll through marked up text + MarkupSurface* m_surface; ///< all contents are attached as children of surface so that scrolling only needs to update the surface position to move all contents + + GG::Y m_surface_top; ///< position, relative to top of MarkupBox where MarkupSurface is located. Used to keep track of scrolling position. + + bool m_preserve_scroll_position_on_next_text_set; + +}; + + +#endif \ No newline at end of file Modified: trunk/FreeOrion/default/credits.xml =================================================================== --- trunk/FreeOrion/default/credits.xml 2009-01-30 14:39:10 UTC (rev 2782) +++ trunk/FreeOrion/default/credits.xml 2009-01-31 02:59:08 UTC (rev 2783) @@ -22,6 +22,7 @@ <PERSON name="Eliot Eshelman" nick="igrok" task="Programming"/> <PERSON name="stride" nick="" task="Programming"/> <PERSON name="Ondrej Riha" nick="OndrejR" task="Programming"/> + <PERSON name="Francesco Marass" nick="francys" task="Programming"/> </GROUP> <GROUP name ="GAMEDESIGN"> <PERSON name="Samuel Knowlton" nick="Aquitaine" task="Game Design"/> |
From: <geo...@us...> - 2009-02-01 12:22:28
|
Revision: 2786 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2786&view=rev Author: geoffthemedio Date: 2009-02-01 11:59:24 +0000 (Sun, 01 Feb 2009) Log Message: ----------- -Progress with MarkupBox. Now parses a line of text and gets blocks of text from line -Grooming / warning removal Modified Paths: -------------- trunk/FreeOrion/UI/MarkupBox.cpp trunk/FreeOrion/client/human/HumanClientApp.cpp trunk/FreeOrion/util/AppInterface.h Modified: trunk/FreeOrion/UI/MarkupBox.cpp =================================================================== --- trunk/FreeOrion/UI/MarkupBox.cpp 2009-01-31 06:50:09 UTC (rev 2785) +++ trunk/FreeOrion/UI/MarkupBox.cpp 2009-02-01 11:59:24 UTC (rev 2786) @@ -1,6 +1,7 @@ #include "MarkupBox.h" #include "CUIControls.h" +#include "../util/AppInterface.h" #include <GG/StaticGraphic.h> #include <GG/MultiEdit.h> @@ -9,20 +10,199 @@ #include <GG/StyleFactory.h> namespace { - static const GG::X SCROLL_WIDTH(14); - static const int EDGE_PAD(3); + static const GG::X SCROLL_WIDTH(14); // width of scrollbar in MarkupBox + static const int EDGE_PAD(3); // padding on edges of MarkupBox that limits size of MarkupSurface + static const GG::Y VERY_FAR_DOWN_LAYOUT_SURFACE(2 << 15); // maximum length in pixels of surface on which to render marked up text - static const std::string EMPTY_STRING(""); + static const std::string EMPTY_STRING(""); + static const std::string IMAGE_TAG("img"); + static const std::string HEADING_TAG("h"); + static bool markup_tags_registered = false; - static bool markup_tags_registered = false; + /** Ensures GG::Font knows about markup tags. */ + void RegisterMarkupTags() { + if (markup_tags_registered) + return; + GG::Font::RegisterKnownTag(IMAGE_TAG); // indicates image should be placed in markup text. optional right or left flags indicate alignment; if absent, image appear in text + GG::Font::RegisterKnownTag(HEADING_TAG); // indicates enclosed text should be rendered as a heading: in different size or style of font + markup_tags_registered = true; + } - void RegisterMarkupTags() { - if (markup_tags_registered) - return; - GG::Font::RegisterKnownTag("img"); - GG::Font::RegisterKnownTag("h"); - markup_tags_registered = true; - } + + /** types of text that can appear in a MarkupBox input string, depending on present (or absence of) enclosing + * markup tags. */ + enum MarkupTextBlockType { + INVALID_MARKUP_TEXT_BLOCK_TYPE = -1, + PLAIN_TEXT_MARKUP, + HEADING_MARKUP, + IMAGE_MARKUP, + NUM_MARKUP_TEXT_BLOCK_TYPES + }; + + + /** contains text of a single type of markup text-block, and the parsed type and params of the tags. */ + struct MarkupTextBlock { + std::string text; + MarkupTextBlockType type; + std::vector<std::string> params; + }; + + + /** Parses text and returns array of MarkupTextBlock that can be individually interpreted as a single type of + * object on MarkupSurface (heading, plain text, image...) */ + std::vector<MarkupTextBlock> ParseMarkupText(const std::string& text) { + std::vector<MarkupTextBlock> retval; + + // use GG::Font to parse string to extract determine tags applied to text + std::vector<GG::Font::LineData> line_data; + GG::Flags<GG::TextFormat> fmt = GG::FORMAT_NONE; + ClientUI::GetFont()->DetermineLines(text, fmt, GG::X1, line_data); + if (line_data.empty()) { + Logger().debugStream() << "ParseMarkupText line data empty! raw text:" << text; + return retval; + } + + // TODO: loop through lines + const GG::Font::LineData& line = *(line_data.begin()); + if (line.Empty()) { + // TODO:: continue looping through lines instead of returning + return retval; + } + const std::vector<GG::Font::LineData::CharData>& char_data_vec = line.char_data; + + + // scan through char data vector, creating a new entry in retval for each block of text + // that is delimited by a markup tag + + MarkupTextBlockType open_text_block_type = PLAIN_TEXT_MARKUP; // what kind of text is at current char, determined from the most recent markup tag + std::vector<std::string> open_text_block_params; // parameters specified in current text block opening tag + unsigned int text_block_start = 0; // first character in the current block of text + unsigned int text_block_end = char_data_vec.size() - 1; // last character in current block of text. + + + // scan through text until the text block type changes. text block type changes happen + // when a an (open or close) markup tag is one of the tags of a CharData in the vector + for (unsigned int i = 0; i < char_data_vec.size(); ++i) { + // get current CharData + const GG::Font::LineData::CharData& cur_char_data = char_data_vec[i]; + // get tags on current CharData + const std::vector<boost::shared_ptr<GG::Font::FormattingTag> >& tags = cur_char_data.tags; + + //DEBUG + { + GG::StrSize char_start = cur_char_data.string_index; + GG::StrSize char_size = cur_char_data.string_size; + std::string char_text = std::string(text, Value(char_start), Value(char_size)); + std::cout << "ParseMarkupText char: " << char_text; + for (std::vector<boost::shared_ptr<GG::Font::FormattingTag> >::const_iterator it = tags.begin(); it != tags.end(); ++it) { + boost::shared_ptr<GG::Font::FormattingTag> temp_format_tag = *it; + std::cout << " <"; + if (temp_format_tag->close_tag) + std::cout << "/"; + std::cout << temp_format_tag->tag_name; + std::cout << ">"; + } + std::cout << std::endl; + } + //END DEBUG + + + // scan tags for markup tag + MarkupTextBlockType current_char_type = PLAIN_TEXT_MARKUP; // default, if no tag present in current CharData + boost::shared_ptr<GG::Font::FormattingTag> current_char_format_tag; + + + for (std::vector<boost::shared_ptr<GG::Font::FormattingTag> >::const_iterator it = tags.begin(); it != tags.end(); ++it) { + boost::shared_ptr<GG::Font::FormattingTag> format_tag = *it; + // check for image tag first. image overrides / ends any other tags + if (format_tag->tag_name == IMAGE_TAG) { + current_char_type = IMAGE_MARKUP; + current_char_format_tag = format_tag; + break; + // next check for header tag + } else if (format_tag->tag_name == HEADING_TAG) { + current_char_type = HEADING_MARKUP; + current_char_format_tag = format_tag; + break; + } + } + + // if current char has a format tag, get the params to that tag + std::vector<std::string> current_format_tag_params; + if (current_char_format_tag) { + + // DEBUG + if (current_char_format_tag->close_tag) + std::cout << "format tag </" << current_char_format_tag->tag_name << " "; + else + std::cout << "format tag <" << current_char_format_tag->tag_name << " "; + // END DBUG + + std::vector<GG::Font::Substring> params_temp = current_char_format_tag->params; + for (std::vector<GG::Font::Substring>::const_iterator it = params_temp.begin(); it != params_temp.end(); ++it) { + current_format_tag_params.push_back(*it); + + // DEBUG + std::cout << current_format_tag_params.back() << " "; + // END DEBUG + } + + // DEBUG + std::cout << ">" << std::endl << std::endl; + // END DBUG + } + + + // if current CharData has a markup tag (ie. is not Plain Text), or if current CharData is + // is the last, need to make a new MarkupTextBlock entry in retval + if (current_char_type != PLAIN_TEXT_MARKUP || i >= char_data_vec.size() - 1) { + + // get last character of current text block + if (i < char_data_vec.size() - 1) { + text_block_end = i - 1; // end at preceeding character if closing block due to following tag + } else { + text_block_end = i; // end at current character if it is the last CharData + } + + + // add new MarkupTextBlock entry to retval, as long as the entry is not empty + if (text_block_end >= text_block_start) { + GG::StrSize start = char_data_vec[text_block_start].string_index; + GG::StrSize end = char_data_vec[text_block_end].string_index + char_data_vec[text_block_end].string_size; + + + MarkupTextBlock block; + block.text = std::string(text, Value(start), Value(end - start)); + block.type = open_text_block_type; + block.params = open_text_block_params; + + // DEBUG + std::cout << "MarkupTextBlock: " << std::endl; + std::cout << "text: " << block.text << std::endl; + std::cout << "type: " << block.type << std::endl; + std::cout << "params: "; + for (std::vector<std::string>::const_iterator pit = block.params.begin(); pit != block.params.end(); ++pit) + std::cout << *pit << " "; + std::cout << std::endl << std::endl; + // END DEBUG + + retval.push_back(block); + } + + // set new open tag type and start + text_block_start = i; + open_text_block_type = current_char_type; + open_text_block_params = current_format_tag_params; + } + } + + // DEBUG + std::cout << "retval.size(): " << retval.size() << std::endl; + std::cout << "ParseMarkupText done!" << std::endl << std::endl; + // END DEBUG + + return retval; + } } ////////////////////////////// @@ -106,16 +286,44 @@ delete *it; m_controls.clear(); - // TEMP / TEST~! + // common resources... + boost::shared_ptr<GG::Font> plain_font = ClientUI::GetFont(); // font for plain text + boost::shared_ptr<GG::Font> header_font = ClientUI::GetTitleFont(); // font for headings + GG::Flags<GG::TextFormat> format = GG::FORMAT_LEFT | GG::FORMAT_WORDBREAK; // format for text blocks: header and plain text + + std::stack<GG::Rect> working_space_stack; // keeps track of nested constrains on space where controls can be positioned. + GG::Rect(GG::X0, GG::Y0, Width(), VERY_FAR_DOWN_LAYOUT_SURFACE); + + // put default element position at top left of surface GG::Y top = GG::Y0; - boost::shared_ptr<GG::Font> font = ClientUI::GetFont(); - GG::Flags<GG::TextFormat> format = GG::FORMAT_LEFT | GG::FORMAT_WORDBREAK; + GG::X left = GG::X0; - // if tags for image: ... - // create image + // start with full width of surface to put elements in + GG::X available_width = Width(); + + std::vector<MarkupTextBlock> markup_text_blocks = ParseMarkupText(m_text); + + std::cout << "MarkupSurface::Refresh() after calling ParseMarkupText" << std::endl; + std::cout << "size of vector of blocks: " << markup_text_blocks.size() << std::endl << std::endl; + + // DEBUG + for (std::vector<MarkupTextBlock>::const_iterator it = markup_text_blocks.begin(); it != markup_text_blocks.end(); ++it) { + std::cout << "Markup Text Block type: " << it->type << " params: "; + for (std::vector<std::string>::const_iterator strit = it->params.begin(); strit != it->params.end(); ++strit) + std:: cout << *strit << " "; + std::cout << " text: " << it->text << std::endl << std::endl; + } + // END DEBUG + + // for each MarkupTextBlock, create the appropriate markup object + + // if object is an image, check if it has left or right tags. if it does, position it + // appropriately, and adjust available_Width and top and left to fit around image. + + // if just text: - GG::Control* control = new LinkText(GG::X0, top, Width(), m_text, font, format, ClientUI::TextColor()); + GG::Control* control = new LinkText(GG::X0, top, Width(), m_text, plain_font, format, ClientUI::TextColor()); m_controls.push_back(control); Modified: trunk/FreeOrion/client/human/HumanClientApp.cpp =================================================================== --- trunk/FreeOrion/client/human/HumanClientApp.cpp 2009-01-31 06:50:09 UTC (rev 2785) +++ trunk/FreeOrion/client/human/HumanClientApp.cpp 2009-02-01 11:59:24 UTC (rev 2786) @@ -236,7 +236,7 @@ // if stored value is invalid, use a default colour const std::vector<GG::Clr>& empire_colours = EmpireColors(); int colour_index = GetOptionsDB().Get<int>("GameSetup.empire-color"); - if (colour_index >= 0 && colour_index < empire_colours.size()) + if (colour_index >= 0 && colour_index < static_cast<int>(empire_colours.size())) setup_data.m_empire_color = empire_colours[colour_index]; else setup_data.m_empire_color = GG::CLR_GREEN; Modified: trunk/FreeOrion/util/AppInterface.h =================================================================== --- trunk/FreeOrion/util/AppInterface.h 2009-01-31 06:50:09 UTC (rev 2785) +++ trunk/FreeOrion/util/AppInterface.h 2009-02-01 11:59:24 UTC (rev 2786) @@ -16,7 +16,7 @@ /** Accessor for the App's universe object */ Universe& GetUniverse(); - + /** Accessor for the App's logger */ log4cpp::Category& Logger(); |
From: <geo...@us...> - 2009-02-06 05:00:46
|
Revision: 2796 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2796&view=rev Author: geoffthemedio Date: 2009-02-06 05:00:44 +0000 (Fri, 06 Feb 2009) Log Message: ----------- -Added an GiGiOgrePlugin_OIS project to 2008 project files to build the required DLL -Removed some now-unused SDL dependency libs from freeorion client project -Added a pre-set ogre_plugins.cfg for use when SCons isn't being run to make it (such as when using MSVC project files). I assume running SCons to build FreeOrion will overwrite this. Modified Paths: -------------- trunk/FreeOrion/msvc2008/FreeOrion/FreeOrion.sln trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj Added Paths: ----------- trunk/FreeOrion/ogre_plugins.cfg Modified: trunk/FreeOrion/msvc2008/FreeOrion/FreeOrion.sln =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/FreeOrion.sln 2009-02-05 13:31:47 UTC (rev 2795) +++ trunk/FreeOrion/msvc2008/FreeOrion/FreeOrion.sln 2009-02-06 05:00:44 UTC (rev 2796) @@ -6,17 +6,21 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freeorionca", "freeorionca\freeorionca.vcproj", "{4B69AB88-9DA9-41AB-B6D6-CACFE5F3DAD9}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GiGiOgrePlugin_OIS", "GiGiOgrePlugin_OIS\GiGiOgrePlugin_OIS.vcproj", "{28EF8C66-4DEB-43A2-9987-1066A98B44BF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Defaut|Win32 = Defaut|Win32 + Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DB6FF1B0-5485-4DB9-8390-88CE29C22261}.Defaut|Win32.ActiveCfg = Release|Win32 - {DB6FF1B0-5485-4DB9-8390-88CE29C22261}.Defaut|Win32.Build.0 = Release|Win32 - {BA9529CC-B803-4763-B803-2B374D4ECD43}.Defaut|Win32.ActiveCfg = Release|Win32 - {BA9529CC-B803-4763-B803-2B374D4ECD43}.Defaut|Win32.Build.0 = Release|Win32 - {4B69AB88-9DA9-41AB-B6D6-CACFE5F3DAD9}.Defaut|Win32.ActiveCfg = Release|Win32 - {4B69AB88-9DA9-41AB-B6D6-CACFE5F3DAD9}.Defaut|Win32.Build.0 = Release|Win32 + {DB6FF1B0-5485-4DB9-8390-88CE29C22261}.Release|Win32.ActiveCfg = Release|Win32 + {DB6FF1B0-5485-4DB9-8390-88CE29C22261}.Release|Win32.Build.0 = Release|Win32 + {BA9529CC-B803-4763-B803-2B374D4ECD43}.Release|Win32.ActiveCfg = Release|Win32 + {BA9529CC-B803-4763-B803-2B374D4ECD43}.Release|Win32.Build.0 = Release|Win32 + {4B69AB88-9DA9-41AB-B6D6-CACFE5F3DAD9}.Release|Win32.ActiveCfg = Release|Win32 + {4B69AB88-9DA9-41AB-B6D6-CACFE5F3DAD9}.Release|Win32.Build.0 = Release|Win32 + {28EF8C66-4DEB-43A2-9987-1066A98B44BF}.Release|Win32.ActiveCfg = Release|Win32 + {28EF8C66-4DEB-43A2-9987-1066A98B44BF}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj 2009-02-05 13:31:47 UTC (rev 2795) +++ trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj 2009-02-06 05:00:44 UTC (rev 2796) @@ -44,7 +44,7 @@ Name="VCCLCompilerTool" Optimization="3" AdditionalIncludeDirectories="../../../log4cpp/;../../../../include/;"../../../../Boost/include/boost-1_36";../../../GG/;../../include;C:\OgreSDK\include" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GIGI_EXPORTS;GIGI_SDL_EXPORTS;GIGI_OGRE_EXPORTS;GIGI_OGRE_PLUGIN_EXPORTS;FREEORION_BUILD_HUMAN;FREEORION_WIN32;BOOST_SIGNALS_STATIC_LINK;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GIGI_EXPORTS;GIGI_OGRE_EXPORTS;GIGI_OGRE_PLUGIN_EXPORTS;FREEORION_BUILD_HUMAN;FREEORION_WIN32;BOOST_SIGNALS_STATIC_LINK;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" StringPooling="true" MinimalRebuild="true" RuntimeLibrary="2" @@ -69,11 +69,11 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="opengl32.lib glu32.lib wsock32.lib zdll.lib SDL.lib SDLmain.lib freetype214MT.lib cdt.lib circogen.lib common.lib dotgen.lib fdpgen.lib gd.lib graph.lib gvc.lib libexpat.lib neatogen.lib pack.lib pathplan.lib plugin.lib twopigen.lib png.lib jpeg.lib OpenAL32.lib alut.lib libvorbisfile.lib glew32.lib OgreMain.lib OIS.lib CEGUIBase.lib libbulletcollision_d.lib libbulletdynamics_d.lib libbulletmath_d.lib libbulletmultithreaded_d.lib libbulletopenglsupport_d.lib" + AdditionalDependencies="opengl32.lib glu32.lib wsock32.lib zdll.lib freetype214MT.lib cdt.lib circogen.lib common.lib dotgen.lib fdpgen.lib gd.lib graph.lib gvc.lib libexpat.lib neatogen.lib pack.lib pathplan.lib plugin.lib twopigen.lib png.lib jpeg.lib OpenAL32.lib alut.lib libvorbisfile.lib glew32.lib OgreMain.lib OIS.lib CEGUIBase.lib libbulletcollision_d.lib libbulletmath_d.lib" ShowProgress="0" OutputFile="../../../freeorion.exe" LinkIncremental="2" - AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;C:\Python25\libs;C:\boost_1_36_0\lib;C:\OgreSDK\lib" + AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;C:\boost_1_36_0\lib;C:\OgreSDK\lib" GenerateManifest="true" IgnoreDefaultLibraryNames="LIBCMT" GenerateDebugInformation="true" Added: trunk/FreeOrion/ogre_plugins.cfg =================================================================== --- trunk/FreeOrion/ogre_plugins.cfg (rev 0) +++ trunk/FreeOrion/ogre_plugins.cfg 2009-02-06 05:00:44 UTC (rev 2796) @@ -0,0 +1,9 @@ +# Ogre 3D engine plugins to load + +# Plugin folder +PluginFolder=. + +# Plugins +Plugin=RenderSystem_GL.dll +Plugin=Plugin_ParticleFX.dll +Plugin=Plugin_OctreeSceneManager.dll |
From: <geo...@us...> - 2009-02-07 03:16:40
|
Revision: 2798 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2798&view=rev Author: geoffthemedio Date: 2009-02-07 03:16:35 +0000 (Sat, 07 Feb 2009) Log Message: ----------- -Updated MSVC 2008 project files. GiGi libs are now built as separate projects and linked into the freeorion client and eachother. freeorionca and freeoriond only need a small subset of the GiGi files, so they include these directly rather than adding a dependency on the full GiGi DLL. -Hopefully fixed [ 2567920 ] On Win Vista: Game crashes in Design window, which was due to FlexibleFormat not being used and missing German stringtable entries. Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp trunk/FreeOrion/UI/EncyclopediaDetailPanel.cpp trunk/FreeOrion/msvc2008/FreeOrion/FreeOrion.sln trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgrePlugin_OIS/GiGiOgrePlugin_OIS.vcproj trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj trunk/FreeOrion/msvc2008/FreeOrion/freeorionca/freeorionca.vcproj trunk/FreeOrion/msvc2008/FreeOrion/freeoriond/freeoriond.vcproj Added Paths: ----------- trunk/FreeOrion/msvc2008/FreeOrion/GiGi/ trunk/FreeOrion/msvc2008/FreeOrion/GiGi/GiGi.vcproj trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgre/ trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgre/GiGiOgre.vcproj Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2009-02-06 05:55:21 UTC (rev 2797) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2009-02-07 03:16:35 UTC (rev 2798) @@ -18,7 +18,6 @@ #include <GG/TabWnd.h> #include <boost/cast.hpp> -#include <boost/format.hpp> #include <boost/function.hpp> #include <algorithm> Modified: trunk/FreeOrion/UI/EncyclopediaDetailPanel.cpp =================================================================== --- trunk/FreeOrion/UI/EncyclopediaDetailPanel.cpp 2009-02-06 05:55:21 UTC (rev 2797) +++ trunk/FreeOrion/UI/EncyclopediaDetailPanel.cpp 2009-02-07 03:16:35 UTC (rev 2798) @@ -11,8 +11,6 @@ #include <GG/StaticGraphic.h> #include <GG/GUI.h> -#include <boost/format.hpp> - namespace { const GG::X TEXT_MARGIN_X(3); const GG::Y TEXT_MARGIN_Y(3); @@ -347,17 +345,15 @@ } // Set Text - using boost::format; - m_name_text->SetText(name); - m_summary_text->SetText(str(format(UserString("ENC_DETAIL_TYPE_STR")) + m_summary_text->SetText(str(FlexibleFormat(UserString("ENC_DETAIL_TYPE_STR")) % specific_type % general_type)); if (color != GG::CLR_ZERO) m_summary_text->SetColor(color); - m_cost_text->SetText(str(format(UserString("ENC_COST_AND_TURNS_STR")) + m_cost_text->SetText(str(FlexibleFormat(UserString("ENC_COST_AND_TURNS_STR")) % static_cast<int>(cost + 0.5) % cost_units % turns)); Modified: trunk/FreeOrion/msvc2008/FreeOrion/FreeOrion.sln =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/FreeOrion.sln 2009-02-06 05:55:21 UTC (rev 2797) +++ trunk/FreeOrion/msvc2008/FreeOrion/FreeOrion.sln 2009-02-07 03:16:35 UTC (rev 2798) @@ -1,26 +1,59 @@ Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freeorion", "freeorion\freeorion.vcproj", "{DB6FF1B0-5485-4DB9-8390-88CE29C22261}" + ProjectSection(ProjectDependencies) = postProject + {28EF8C66-4DEB-43A2-9987-1066A98B44BF} = {28EF8C66-4DEB-43A2-9987-1066A98B44BF} + {9EE326E7-AB6C-4BDA-95C4-96ECAFCA4EC5} = {9EE326E7-AB6C-4BDA-95C4-96ECAFCA4EC5} + {AF4274F4-4139-4877-BE34-71E73B513914} = {AF4274F4-4139-4877-BE34-71E73B513914} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freeoriond", "freeoriond\freeoriond.vcproj", "{BA9529CC-B803-4763-B803-2B374D4ECD43}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "freeorionca", "freeorionca\freeorionca.vcproj", "{4B69AB88-9DA9-41AB-B6D6-CACFE5F3DAD9}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GiGiOgrePlugin_OIS", "GiGiOgrePlugin_OIS\GiGiOgrePlugin_OIS.vcproj", "{28EF8C66-4DEB-43A2-9987-1066A98B44BF}" + ProjectSection(ProjectDependencies) = postProject + {9EE326E7-AB6C-4BDA-95C4-96ECAFCA4EC5} = {9EE326E7-AB6C-4BDA-95C4-96ECAFCA4EC5} + {AF4274F4-4139-4877-BE34-71E73B513914} = {AF4274F4-4139-4877-BE34-71E73B513914} + EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GiGi", "GiGi\GiGi.vcproj", "{AF4274F4-4139-4877-BE34-71E73B513914}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GiGiOgre", "GiGiOgre\GiGiOgre.vcproj", "{9EE326E7-AB6C-4BDA-95C4-96ECAFCA4EC5}" + ProjectSection(ProjectDependencies) = postProject + {AF4274F4-4139-4877-BE34-71E73B513914} = {AF4274F4-4139-4877-BE34-71E73B513914} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DB6FF1B0-5485-4DB9-8390-88CE29C22261}.Debug|Win32.ActiveCfg = Release|Win32 + {DB6FF1B0-5485-4DB9-8390-88CE29C22261}.Debug|Win32.Build.0 = Release|Win32 {DB6FF1B0-5485-4DB9-8390-88CE29C22261}.Release|Win32.ActiveCfg = Release|Win32 {DB6FF1B0-5485-4DB9-8390-88CE29C22261}.Release|Win32.Build.0 = Release|Win32 + {BA9529CC-B803-4763-B803-2B374D4ECD43}.Debug|Win32.ActiveCfg = Release|Win32 + {BA9529CC-B803-4763-B803-2B374D4ECD43}.Debug|Win32.Build.0 = Release|Win32 {BA9529CC-B803-4763-B803-2B374D4ECD43}.Release|Win32.ActiveCfg = Release|Win32 {BA9529CC-B803-4763-B803-2B374D4ECD43}.Release|Win32.Build.0 = Release|Win32 + {4B69AB88-9DA9-41AB-B6D6-CACFE5F3DAD9}.Debug|Win32.ActiveCfg = Release|Win32 + {4B69AB88-9DA9-41AB-B6D6-CACFE5F3DAD9}.Debug|Win32.Build.0 = Release|Win32 {4B69AB88-9DA9-41AB-B6D6-CACFE5F3DAD9}.Release|Win32.ActiveCfg = Release|Win32 {4B69AB88-9DA9-41AB-B6D6-CACFE5F3DAD9}.Release|Win32.Build.0 = Release|Win32 + {28EF8C66-4DEB-43A2-9987-1066A98B44BF}.Debug|Win32.ActiveCfg = Release|Win32 + {28EF8C66-4DEB-43A2-9987-1066A98B44BF}.Debug|Win32.Build.0 = Release|Win32 {28EF8C66-4DEB-43A2-9987-1066A98B44BF}.Release|Win32.ActiveCfg = Release|Win32 {28EF8C66-4DEB-43A2-9987-1066A98B44BF}.Release|Win32.Build.0 = Release|Win32 + {AF4274F4-4139-4877-BE34-71E73B513914}.Debug|Win32.ActiveCfg = Release|Win32 + {AF4274F4-4139-4877-BE34-71E73B513914}.Debug|Win32.Build.0 = Release|Win32 + {AF4274F4-4139-4877-BE34-71E73B513914}.Release|Win32.ActiveCfg = Release|Win32 + {AF4274F4-4139-4877-BE34-71E73B513914}.Release|Win32.Build.0 = Release|Win32 + {9EE326E7-AB6C-4BDA-95C4-96ECAFCA4EC5}.Debug|Win32.ActiveCfg = Release|Win32 + {9EE326E7-AB6C-4BDA-95C4-96ECAFCA4EC5}.Debug|Win32.Build.0 = Release|Win32 + {9EE326E7-AB6C-4BDA-95C4-96ECAFCA4EC5}.Release|Win32.ActiveCfg = Release|Win32 + {9EE326E7-AB6C-4BDA-95C4-96ECAFCA4EC5}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Added: trunk/FreeOrion/msvc2008/FreeOrion/GiGi/GiGi.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/GiGi/GiGi.vcproj (rev 0) +++ trunk/FreeOrion/msvc2008/FreeOrion/GiGi/GiGi.vcproj 2009-02-07 03:16:35 UTC (rev 2798) @@ -0,0 +1,411 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="GiGi" + ProjectGUID="{AF4274F4-4139-4877-BE34-71E73B513914}" + RootNamespace="GiGi" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Release|Win32" + OutputDirectory="../../../" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="2" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + AdditionalIncludeDirectories="../../../../include/;../../../GG/;"../../../../Boost/include/boost-1_36";../../include" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_WINDLL;GIGI_EXPORTS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" + MinimalRebuild="true" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="opengl32.lib glu32.lib freetype214MT.lib png.lib " + OutputFile="../../../GiGi.dll" + AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/" + IgnoreDefaultLibraryNames="LIBCMT" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + CLRImageType="0" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="GG" + > + <Filter + Name="GG" + > + <File + RelativePath="..\..\..\GG\GG\AlignmentFlags.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Base.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\BrowseInfoWnd.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Clr.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Control.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Cursor.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\DrawUtil.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\DropDownList.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\DynamicGraphic.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Edit.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Enum.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\EventPump.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Flags.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Font.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\GUI.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Layout.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\ListBox.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Menu.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\MultiEdit.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\PtRect.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Scroll.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Slider.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\StaticGraphic.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\StyleFactory.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\TabWnd.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\TextControl.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Texture.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Timer.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\UnicodeCharsets.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\Wnd.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\WndEditor.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\WndEvent.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\ZList.h" + > + </File> + <Filter + Name="dialogs" + > + <File + RelativePath="..\..\..\GG\GG\Button.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\dialogs\ColorDlg.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\dialogs\FileDlg.h" + > + </File> + <File + RelativePath="..\..\..\GG\GG\dialogs\ThreeButtonDlg.h" + > + </File> + </Filter> + </Filter> + <Filter + Name="src" + > + <File + RelativePath="..\..\..\GG\src\AlignmentFlags.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Base.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\BrowseInfoWnd.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Button.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Clr.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Control.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Cursor.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\DrawUtil.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\DropDownList.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\DynamicGraphic.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Edit.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\EventPump.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Font.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\GUI.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Layout.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\ListBox.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Menu.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\MultiEdit.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\PtRect.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Scroll.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Slider.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\StaticGraphic.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\StyleFactory.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\TabWnd.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\TextControl.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Texture.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Timer.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\UnicodeCharsets.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Wnd.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\WndEditor.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\WndEvent.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\ZList.cpp" + > + </File> + <Filter + Name="dialogs" + > + <File + RelativePath="..\..\..\GG\src\dialogs\ColorDlg.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\dialogs\FileDlg.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\dialogs\ThreeButtonDlg.cpp" + > + </File> + </Filter> + </Filter> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Added: trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgre/GiGiOgre.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgre/GiGiOgre.vcproj (rev 0) +++ trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgre/GiGiOgre.vcproj 2009-02-07 03:16:35 UTC (rev 2798) @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="GiGiOgre" + ProjectGUID="{9EE326E7-AB6C-4BDA-95C4-96ECAFCA4EC5}" + RootNamespace="GiGiOgre" + TargetFrameworkVersion="131072" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Release|Win32" + OutputDirectory="../../../" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="2" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + AdditionalIncludeDirectories="../../../../include/;../../../GG/;../../../../include/OGRE;"../../../../Boost/include/boost-1_36"" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_WINDLL;GIGI_OGRE_EXPORTS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="OgreMain.lib GiGi.lib opengl32.lib" + OutputFile="../../../GiGiOgre.dll" + LinkIncremental="2" + AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;../../../" + IgnoreDefaultLibraryNames="LIBCMT" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="GiGi" + > + <Filter + Name="src" + > + <Filter + Name="Ogre" + > + <File + RelativePath="..\..\..\GG\src\Ogre\OgreGUI.cpp" + > + </File> + </Filter> + </Filter> + <Filter + Name="GiGi" + > + <Filter + Name="Ogre" + > + <File + RelativePath="..\..\..\GG\GG\Ogre\OgreGUI.h" + > + </File> + </Filter> + </Filter> + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Modified: trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgrePlugin_OIS/GiGiOgrePlugin_OIS.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgrePlugin_OIS/GiGiOgrePlugin_OIS.vcproj 2009-02-06 05:55:21 UTC (rev 2797) +++ trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgrePlugin_OIS/GiGiOgrePlugin_OIS.vcproj 2009-02-07 03:16:35 UTC (rev 2798) @@ -40,12 +40,12 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="../../../../include/;"../../../../Boost/include/boost-1_36";../../../GG/;C:\OgreSDK\include;../../include" - PreprocessorDefinitions="WIN32;NDEBUG;GIGI_EXPORTS;GIGI_OGRE_EXPORTS;GIGI_OGRE_PLUGIN_EXPORTS;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" + AdditionalIncludeDirectories="../../../../include/;"../../../../Boost/include/boost-1_36";../../../GG/;../../include;../../../../include/OGRE;../../../../include/OGRE/OIS" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_WINDLL;GIGI_OGRE_PLUGIN_EXPORTS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" IgnoreStandardIncludePath="false" MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="3" + BasicRuntimeChecks="0" + RuntimeLibrary="2" WarningLevel="3" DebugInformationFormat="4" /> @@ -60,10 +60,16 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="OgreMain.lib OIS.lib CEGUIBase.lib freetype214MT.lib opengl32.lib glu32.lib png.lib jpeg.lib" + UseLibraryDependencyInputs="false" + AdditionalDependencies="GiGi.lib GiGiOgre.lib OgreMain.lib OIS.lib" OutputFile="../../../GiGiOgrePlugin_OIS.dll" - AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;C:\boost_1_36_0\lib;C:\OgreSDK\lib" + LinkIncremental="2" + AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;../../../" + IgnoreAllDefaultLibraries="false" + IgnoreDefaultLibraryNames="LIBCMT" GenerateDebugInformation="true" + ResourceOnlyDLL="true" + SupportUnloadOfDelayLoadedDLL="true" TargetMachine="1" /> <Tool @@ -98,141 +104,9 @@ <Filter Name="src" > - <File - RelativePath="..\..\..\GG\src\AlignmentFlags.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Base.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\BrowseInfoWnd.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Button.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Clr.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Control.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Cursor.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\DrawUtil.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\DropDownList.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\DynamicGraphic.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Edit.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\EventPump.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Font.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\GUI.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Layout.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\ListBox.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Menu.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\MultiEdit.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\PtRect.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Scroll.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Slider.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\StaticGraphic.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\StyleFactory.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\TabWnd.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\TextControl.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Texture.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Timer.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\UnicodeCharsets.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Wnd.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\WndEditor.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\WndEvent.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\ZList.cpp" - > - </File> <Filter Name="Ogre" > - <File - RelativePath="..\..\..\GG\src\Ogre\OgreGUI.cpp" - > - </File> <Filter Name="Plugins" > @@ -244,65 +118,9 @@ RelativePath="..\..\..\GG\src\Ogre\Plugins\OgreGUIInputPlugin.h" > </File> - <File - RelativePath="..\..\..\GG\src\Ogre\Plugins\OISInput.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Ogre\Plugins\OISInput.h" - > - </File> </Filter> </Filter> - <Filter - Name="dialogs" - > - <File - RelativePath="..\..\..\GG\src\dialogs\ColorDlg.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\dialogs\FileDlg.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\dialogs\ThreeButtonDlg.cpp" - > - </File> - </Filter> </Filter> - <Filter - Name="GG" - > - <File - RelativePath="..\..\..\GG\GG\Font.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\GUI.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\PtRect.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Texture.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\WndEvent.h" - > - </File> - <Filter - Name="Ogre" - > - <File - RelativePath="..\..\..\GG\GG\Ogre\OgreGUI.h" - > - </File> - </Filter> - </Filter> </Filter> </Files> <Globals> Modified: trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj 2009-02-06 05:55:21 UTC (rev 2797) +++ trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj 2009-02-07 03:16:35 UTC (rev 2798) @@ -43,8 +43,8 @@ <Tool Name="VCCLCompilerTool" Optimization="3" - AdditionalIncludeDirectories="../../../log4cpp/;../../../../include/;"../../../../Boost/include/boost-1_36";../../../GG/;../../include;C:\OgreSDK\include" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GIGI_EXPORTS;GIGI_OGRE_EXPORTS;GIGI_OGRE_PLUGIN_EXPORTS;FREEORION_BUILD_HUMAN;FREEORION_WIN32;BOOST_SIGNALS_STATIC_LINK;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" + AdditionalIncludeDirectories="../../../log4cpp/;../../../../include/;"../../../../Boost/include/boost-1_36";../../../GG/;../../include;../../../../include/OGRE;../../../../include/bullet" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;FREEORION_BUILD_HUMAN;FREEORION_WIN32;BOOST_SIGNALS_STATIC_LINK;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" StringPooling="true" MinimalRebuild="true" RuntimeLibrary="2" @@ -69,11 +69,11 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="opengl32.lib glu32.lib wsock32.lib zdll.lib freetype214MT.lib cdt.lib circogen.lib common.lib dotgen.lib fdpgen.lib gd.lib graph.lib gvc.lib libexpat.lib neatogen.lib pack.lib pathplan.lib plugin.lib twopigen.lib png.lib jpeg.lib OpenAL32.lib alut.lib libvorbisfile.lib glew32.lib OgreMain.lib OIS.lib CEGUIBase.lib libbulletcollision_d.lib libbulletmath_d.lib" + AdditionalDependencies="GiGi.lib GiGiOgre.lib OgreMain.lib opengl32.lib glu32.lib png.lib jpeg.lib libbulletcollision.lib libbulletmath.lib glew32.lib OpenAL32.lib zlib1.lib ALut.lib libvorbisfile.lib cdt.lib circogen.lib common.lib dotgen.lib fdpgen.lib gd.lib graph.lib gvc.lib libexpat.lib neatogen.lib pack.lib pathplan.lib plugin.lib twopigen.lib" ShowProgress="0" OutputFile="../../../freeorion.exe" LinkIncremental="2" - AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;C:\boost_1_36_0\lib;C:\OgreSDK\lib" + AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;../../../" GenerateManifest="true" IgnoreDefaultLibraryNames="LIBCMT" GenerateDebugInformation="true" @@ -828,350 +828,6 @@ </File> </Filter> <Filter - Name="GG" - > - <Filter - Name="GG" - > - <File - RelativePath="..\..\..\GG\GG\AlignmentFlags.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Base.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\BrowseInfoWnd.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Clr.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Control.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Cursor.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\DrawUtil.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\DropDownList.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\DynamicGraphic.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Edit.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Enum.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\EventPump.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Flags.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Font.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\GUI.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Layout.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\ListBox.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Menu.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\MultiEdit.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\PtRect.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Scroll.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Slider.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\StaticGraphic.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\StyleFactory.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\TabWnd.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\TextControl.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Texture.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Timer.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\UnicodeCharsets.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\Wnd.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\WndEditor.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\WndEvent.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\ZList.h" - > - </File> - <Filter - Name="dialogs" - > - <File - RelativePath="..\..\..\GG\GG\Button.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\dialogs\ColorDlg.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\dialogs\FileDlg.h" - > - </File> - <File - RelativePath="..\..\..\GG\GG\dialogs\ThreeButtonDlg.h" - > - </File> - </Filter> - <Filter - Name="Ogre" - > - <File - RelativePath="..\..\..\GG\GG\Ogre\OgreGUI.h" - > - </File> - </Filter> - </Filter> - <Filter - Name="src" - > - <File - RelativePath="..\..\..\GG\src\AlignmentFlags.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Base.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\BrowseInfoWnd.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Button.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Clr.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Control.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Cursor.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\DrawUtil.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\DropDownList.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\DynamicGraphic.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Edit.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\EventPump.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Font.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\GUI.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Layout.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\ListBox.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Menu.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\MultiEdit.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\PtRect.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Scroll.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Slider.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\StaticGraphic.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\StyleFactory.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\TabWnd.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\TextControl.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Texture.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Timer.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\UnicodeCharsets.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Wnd.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\WndEditor.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\WndEvent.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\ZList.cpp" - > - </File> - <Filter - Name="dialogs" - > - <File - RelativePath="..\..\..\GG\src\dialogs\ColorDlg.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\dialogs\FileDlg.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\dialogs\ThreeButtonDlg.cpp" - > - </File> - </Filter> - <Filter - Name="Ogre" - > - <File - RelativePath="..\..\..\GG\src\Ogre\OgreGUI.cpp" - > - </File> - <Filter - Name="Plugins" - > - <File - RelativePath="..\..\..\GG\src\Ogre\Plugins\OgreGUIInputPlugin.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Ogre\Plugins\OgreGUIInputPlugin.h" - > - </File> - <File - RelativePath="..\..\..\GG\src\Ogre\Plugins\OISInput.cpp" - > - </File> - <File - RelativePath="..\..\..\GG\src\Ogre\Plugins\OISInput.h" - > - </File> - </Filter> - </Filter> - </Filter> - </Filter> - <Filter Name="log4cpp" > <Filter Modified: trunk/FreeOrion/msvc2008/FreeOrion/freeorionca/freeorionca.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/freeorionca/freeorionca.vcproj 2009-02-06 05:55:21 UTC (rev 2797) +++ trunk/FreeOrion/msvc2008/FreeOrion/freeorionca/freeorionca.vcproj 2009-02-07 03:16:35 UTC (rev 2798) @@ -68,8 +68,8 @@ Name="VCLinkerTool" AdditionalDependencies="opengl32.lib glu32.lib wsock32.lib zdll.lib freetype214MT.lib cdt.lib common.lib pathplan.lib libexpat.lib python25.lib boost_python-vc90-mt-1_36.lib" OutputFile="../../../freeorionca.exe" - LinkIncremental="1" - AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;C:\Python25\libs;C:\boost_1_36_0\lib" + LinkIncremental="2" + AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;C:\Python25\libs" GenerateManifest="true" GenerateDebugInformation="false" SubSystem="1" Modified: trunk/FreeOrion/msvc2008/FreeOrion/freeoriond/freeoriond.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/freeoriond/freeoriond.vcproj 2009-02-06 05:55:21 UTC (rev 2797) +++ trunk/FreeOrion/msvc2008/FreeOrion/freeoriond/freeoriond.vcproj 2009-02-07 03:16:35 UTC (rev 2798) @@ -69,8 +69,8 @@ Name="VCLinkerTool" AdditionalDependencies="opengl32.lib glu32.lib wsock32.lib zdll.lib freetype214MT.lib cdt.lib common.lib graph.lib pathplan.lib libexpat.lib" OutputFile="../../../freeoriond.exe" - LinkIncremental="1" - AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;C:\Python25\libs;C:\boost_1_36_0\lib" + LinkIncremental="2" + AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;C:\Python25\libs" GenerateManifest="true" GenerateDebugInformation="true" SubSystem="1" |
From: <tz...@us...> - 2009-02-09 03:53:30
|
Revision: 2803 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2803&view=rev Author: tzlaine Date: 2009-02-09 03:53:27 +0000 (Mon, 09 Feb 2009) Log Message: ----------- Added code to add city lights to the night sides of atmosphereless planets. Modified Paths: -------------- trunk/FreeOrion/UI/CombatWnd.cpp trunk/FreeOrion/UI/CombatWnd.h trunk/FreeOrion/default/data/art/combat/meshes/planets/atmosphereless_planet.frag Modified: trunk/FreeOrion/UI/CombatWnd.cpp =================================================================== --- trunk/FreeOrion/UI/CombatWnd.cpp 2009-02-09 03:51:14 UTC (rev 2802) +++ trunk/FreeOrion/UI/CombatWnd.cpp 2009-02-09 03:53:27 UTC (rev 2803) @@ -32,6 +32,8 @@ #include <btBulletCollisionCommon.h> #include <GG/GUI.h> +#include "../GG/src/GIL/image.hpp" +#include "../GG/src/GIL/extension/io/png_dynamic_io.hpp" #include <boost/cast.hpp> #include <boost/algorithm/string/case_conv.hpp> @@ -41,6 +43,7 @@ #include <boost/filesystem/operations.hpp> #include <boost/system/system_error.hpp> + namespace { const GG::Pt INVALID_SELECTION_DRAG_POS(-GG::X1, -GG::Y1); @@ -89,6 +92,8 @@ // The time it takes to recenter on a new point, in seconds. const Ogre::Real CAMERA_RECENTER_TIME = 0.33333; + const unsigned int NO_CITY_LIGHTS = std::numeric_limits<unsigned int>::max(); + Ogre::Real OrbitRadius(unsigned int orbit) { assert(orbit < 10); @@ -220,6 +225,73 @@ return retval; } + struct BadLightsTexture : + GG::ExceptionBase + { + BadLightsTexture(const std::string& msg) throw() : ExceptionBase(msg) {} + virtual const char* type() const throw() {return "BadLightsTexture";} + }; + + Ogre::TexturePtr PlanetLightsTexture(const std::string& base_name, + unsigned int light_level) + { + assert(light_level == NO_CITY_LIGHTS || 0 <= light_level && light_level < 10); + std::string filename = base_name; + unsigned int channel = 0; + if (light_level < 4) { + filename += "LightsA.png"; + channel = light_level; + } else if (light_level < 8) { + filename += "LightsB.png"; + channel = light_level - 4; + } else if (light_level == 8) { + filename += "Day.png"; + channel = 3; + } else { + filename += "Night.png"; + channel = 3; + } + + namespace fs = boost::filesystem; + fs::path path(ClientUI::ArtDir() / "combat" / "meshes" / "planets" / filename); + + if (!fs::exists(path)) + throw BadLightsTexture("Texture file \"" + filename + "\" does not exist"); + + if (!fs::is_regular_file(path)) + throw BadLightsTexture("Texture \"file\" \"" + filename + "\" is not a file"); + + boost::gil::gray8_image_t final_image; + if (light_level == NO_CITY_LIGHTS) { + boost::gil::point2<std::ptrdiff_t> dimensions; + try { + dimensions = boost::gil::png_read_dimensions(path.string()); + } catch (const std::ios_base::failure &) { + throw BadLightsTexture("Texture \"" + path.string() + + "\" could not be read as a PNG file"); + } + final_image.recreate(dimensions); + } else { + boost::gil::rgba8_image_t source_image; + try { + boost::gil::png_read_image(path.string(), source_image); + } catch (const std::ios_base::failure &) { + throw BadLightsTexture("Texture \"" + path.string() + + "\" could not be read as a 32-bit RGBA PNG file"); + } + final_image.recreate(source_image.dimensions()); + copy_pixels(nth_channel_view(const_view(source_image), channel), view(final_image)); + } + + const void* image_data = interleaved_view_get_raw_data(const_view(final_image)); + std::size_t image_size = final_image.width() * final_image.height(); + Ogre::DataStreamPtr stream( + new Ogre::MemoryDataStream(const_cast<void*>(image_data), image_size)); + return Ogre::TextureManager::getSingleton().loadRawData( + base_name + "_city_lights", "General", stream, + final_image.width(), final_image.height(), Ogre::PF_BYTE_L); + } + void AddOptions(OptionsDB& db) { db.AddFlag("tech-demo", "Try out the 3D combat tech demo."); @@ -630,6 +702,11 @@ delete it->second.second; } + for (std::size_t i = 0; i < m_city_lights_textures.size(); ++i) { + Ogre::TextureManager::getSingleton().remove(m_city_lights_textures[i]->getName()); + } + m_city_lights_textures.clear(); + m_collision_shapes.clear(); m_collision_objects.clear(); delete m_collision_world; @@ -822,6 +899,16 @@ material->getTechnique(0)->getPass(0)->getVertexProgramParameters()->setNamedConstant("light_dir", light_dir); entity->setMaterialName(new_material_name); node->attachObject(entity); + } else { + assert(material_name == "atmosphereless_planet"); + material->getTechnique(0)->getPass(0)->getTextureUnitState(2)->setTextureName(base_name + "Normal.png"); + // TODO: Get the integer city lights level of + // NO_CITY_LIGHTS or in the range [0, 9] somehow, and + // supply it here. Right now, we're using a hardcoded 2 + // just for demo purposes. + Ogre::TexturePtr texture = PlanetLightsTexture(base_name, 2); + m_city_lights_textures.push_back(texture); + material->getTechnique(0)->getPass(0)->getTextureUnitState(3)->setTextureName(texture->getName()); } } @@ -837,6 +924,21 @@ void CombatWnd::Render() { +#if 0 // TODO: Remove this. It makes the planets all rotate, to test normal and parallax mapping. + for (std::map<int, std::pair<Ogre::SceneNode*, std::vector<Ogre::MaterialPtr> > >::iterator it = + m_planet_assets.begin(); + it != m_planet_assets.end(); + ++it) { + it->second.first->yaw(Ogre::Radian(3.14159 / 180.0 / 3.0)); + if (dynamic_cast<Ogre::Entity*>(it->second.first->getAttachedObject(0))) { + Ogre::Vector3 light_dir = -it->second.first->getPosition(); + light_dir.normalise(); + light_dir = it->second.first->getOrientation().Inverse() * light_dir; + m_planet_assets[it->first].second.back()->getTechnique(0)->getPass(0)->getVertexProgramParameters()->setNamedConstant("light_dir", light_dir); + } + } +#endif + // render two small lens flares that oppose the star's position relative to // the center of the viewport GG::Pt star_pt = ProjectToPixel(*m_camera, Ogre::Vector3(0.0, 0.0, 0.0)); Modified: trunk/FreeOrion/UI/CombatWnd.h =================================================================== --- trunk/FreeOrion/UI/CombatWnd.h 2009-02-09 03:51:14 UTC (rev 2802) +++ trunk/FreeOrion/UI/CombatWnd.h 2009-02-09 03:53:27 UTC (rev 2803) @@ -129,6 +129,7 @@ // The scene nodes representing ships in the system and their associated // collision meshes, indexed by ship object id. std::map<int, std::pair<Ogre::SceneNode*, btTriangleMesh*> > m_ship_assets; + std::vector<Ogre::TexturePtr> m_city_lights_textures; // The collision detection system btDefaultCollisionConfiguration* m_collision_configuration; Modified: trunk/FreeOrion/default/data/art/combat/meshes/planets/atmosphereless_planet.frag =================================================================== --- trunk/FreeOrion/default/data/art/combat/meshes/planets/atmosphereless_planet.frag 2009-02-09 03:51:14 UTC (rev 2802) +++ trunk/FreeOrion/default/data/art/combat/meshes/planets/atmosphereless_planet.frag 2009-02-09 03:53:27 UTC (rev 2803) @@ -11,11 +11,17 @@ { vec3 daytime = texture2D(day_texture, tex_coord).rgb * diffuse; vec3 color = daytime; - if (diffuse < -TERMINATOR) - color = texture2D(night_texture, tex_coord).rgb; + if (diffuse < -TERMINATOR) { + vec3 nighttime = texture2D(night_texture, tex_coord).rgb; + vec3 city_lights = texture2D(lights_texture, tex_coord).rgb; + color = clamp(nighttime + city_lights, 0.0, 1.0); + } if (abs(diffuse) < TERMINATOR) { vec3 nighttime = texture2D(night_texture, tex_coord).rgb; - color = mix(nighttime, daytime, (diffuse + TERMINATOR) / (2.0 * TERMINATOR)); + vec3 city_lights = texture2D(lights_texture, tex_coord).rgb; + vec3 combined_night_side = clamp(nighttime + city_lights, 0.0, 1.0); + color = mix(combined_night_side, daytime, + (diffuse + TERMINATOR) / (2.0 * TERMINATOR)); } // renormalize to [-1, 1] |
From: <geo...@us...> - 2009-02-09 12:22:42
|
Revision: 2805 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2805&view=rev Author: geoffthemedio Date: 2009-02-09 12:22:40 +0000 (Mon, 09 Feb 2009) Log Message: ----------- Tweaked MSVC 2008 project files. Still don't work, but they're a bit more consistent and generate less weird error messages. Modified Paths: -------------- trunk/FreeOrion/msvc2008/FreeOrion/GiGi/GiGi.vcproj trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgre/GiGiOgre.vcproj trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgrePlugin_OIS/GiGiOgrePlugin_OIS.vcproj trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj trunk/FreeOrion/msvc2008/FreeOrion/freeorionca/freeorionca.vcproj trunk/FreeOrion/msvc2008/FreeOrion/freeoriond/freeoriond.vcproj trunk/FreeOrion/ogre_plugins.cfg Modified: trunk/FreeOrion/msvc2008/FreeOrion/GiGi/GiGi.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/GiGi/GiGi.vcproj 2009-02-09 04:10:39 UTC (rev 2804) +++ trunk/FreeOrion/msvc2008/FreeOrion/GiGi/GiGi.vcproj 2009-02-09 12:22:40 UTC (rev 2805) @@ -20,8 +20,8 @@ OutputDirectory="../../../" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" - CharacterSet="2" - WholeProgramOptimization="1" + CharacterSet="0" + WholeProgramOptimization="0" > <Tool Name="VCPreBuildEventTool" @@ -41,14 +41,16 @@ <Tool Name="VCCLCompilerTool" Optimization="2" - EnableIntrinsicFunctions="true" + EnableIntrinsicFunctions="false" AdditionalIncludeDirectories="../../../../include/;../../../GG/;"../../../../Boost/include/boost-1_36";../../include" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_WINDLL;GIGI_EXPORTS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" MinimalRebuild="true" RuntimeLibrary="2" - EnableFunctionLevelLinking="true" + EnableFunctionLevelLinking="false" + EnableEnhancedInstructionSet="2" WarningLevel="3" DebugInformationFormat="3" + DisableSpecificWarnings="4251; 4275" /> <Tool Name="VCManagedResourceCompilerTool" @@ -63,11 +65,16 @@ Name="VCLinkerTool" AdditionalDependencies="opengl32.lib glu32.lib freetype214MT.lib png.lib " OutputFile="../../../GiGi.dll" + LinkIncremental="0" AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/" IgnoreDefaultLibraryNames="LIBCMT" GenerateDebugInformation="true" - OptimizeReferences="2" - EnableCOMDATFolding="2" + SubSystem="1" + OptimizeReferences="0" + EnableCOMDATFolding="0" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + ImportLibrary="" TargetMachine="1" CLRImageType="0" /> Modified: trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgre/GiGiOgre.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgre/GiGiOgre.vcproj 2009-02-09 04:10:39 UTC (rev 2804) +++ trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgre/GiGiOgre.vcproj 2009-02-09 12:22:40 UTC (rev 2805) @@ -20,8 +20,8 @@ OutputDirectory="../../../" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" - CharacterSet="2" - WholeProgramOptimization="1" + CharacterSet="0" + WholeProgramOptimization="0" > <Tool Name="VCPreBuildEventTool" @@ -41,11 +41,13 @@ <Tool Name="VCCLCompilerTool" Optimization="2" - EnableIntrinsicFunctions="true" + EnableIntrinsicFunctions="false" AdditionalIncludeDirectories="../../../../include/;../../../GG/;../../../../include/OGRE;"../../../../Boost/include/boost-1_36"" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_WINDLL;GIGI_OGRE_EXPORTS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" + MinimalRebuild="true" RuntimeLibrary="2" - EnableFunctionLevelLinking="true" + EnableFunctionLevelLinking="false" + EnableEnhancedInstructionSet="2" WarningLevel="3" DebugInformationFormat="3" /> @@ -62,12 +64,17 @@ Name="VCLinkerTool" AdditionalDependencies="OgreMain.lib GiGi.lib opengl32.lib" OutputFile="../../../GiGiOgre.dll" - LinkIncremental="2" + LinkIncremental="0" AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;../../../" IgnoreDefaultLibraryNames="LIBCMT" GenerateDebugInformation="true" - OptimizeReferences="2" - EnableCOMDATFolding="2" + SubSystem="1" + OptimizeReferences="0" + EnableCOMDATFolding="0" + LinkTimeCodeGeneration="0" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + ImportLibrary="" TargetMachine="1" /> <Tool Modified: trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgrePlugin_OIS/GiGiOgrePlugin_OIS.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgrePlugin_OIS/GiGiOgrePlugin_OIS.vcproj 2009-02-09 04:10:39 UTC (rev 2804) +++ trunk/FreeOrion/msvc2008/FreeOrion/GiGiOgrePlugin_OIS/GiGiOgrePlugin_OIS.vcproj 2009-02-09 12:22:40 UTC (rev 2805) @@ -18,9 +18,9 @@ <Configuration Name="Release|Win32" OutputDirectory="../../../" - IntermediateDirectory="Release" + IntermediateDirectory="$(ConfigurationName)" ConfigurationType="2" - CharacterSet="2" + CharacterSet="0" > <Tool Name="VCPreBuildEventTool" @@ -39,15 +39,17 @@ /> <Tool Name="VCCLCompilerTool" - Optimization="0" + Optimization="3" AdditionalIncludeDirectories="../../../../include/;"../../../../Boost/include/boost-1_36";../../../GG/;../../include;../../../../include/OGRE;../../../../include/OGRE/OIS" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_WINDLL;GIGI_OGRE_PLUGIN_EXPORTS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" IgnoreStandardIncludePath="false" + StringPooling="false" MinimalRebuild="true" BasicRuntimeChecks="0" RuntimeLibrary="2" + EnableEnhancedInstructionSet="2" WarningLevel="3" - DebugInformationFormat="4" + DebugInformationFormat="3" /> <Tool Name="VCManagedResourceCompilerTool" @@ -63,14 +65,21 @@ UseLibraryDependencyInputs="false" AdditionalDependencies="GiGi.lib GiGiOgre.lib OgreMain.lib OIS.lib" OutputFile="../../../GiGiOgrePlugin_OIS.dll" - LinkIncremental="2" + LinkIncremental="0" AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;../../../" IgnoreAllDefaultLibraries="false" IgnoreDefaultLibraryNames="LIBCMT" GenerateDebugInformation="true" - ResourceOnlyDLL="true" - SupportUnloadOfDelayLoadedDLL="true" + SubSystem="1" + EntryPointSymbol="" + ResourceOnlyDLL="false" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + SupportUnloadOfDelayLoadedDLL="false" + ImportLibrary="" TargetMachine="1" + CLRThreadAttribute="0" + CLRImageType="0" /> <Tool Name="VCALinkTool" @@ -118,6 +127,14 @@ RelativePath="..\..\..\GG\src\Ogre\Plugins\OgreGUIInputPlugin.h" > </File> + <File + RelativePath="..\..\..\GG\src\Ogre\Plugins\OISInput.cpp" + > + </File> + <File + RelativePath="..\..\..\GG\src\Ogre\Plugins\OISInput.h" + > + </File> </Filter> </Filter> </Filter> Modified: trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj 2009-02-09 04:10:39 UTC (rev 2804) +++ trunk/FreeOrion/msvc2008/FreeOrion/freeorion/freeorion.vcproj 2009-02-09 12:22:40 UTC (rev 2805) @@ -21,9 +21,8 @@ OutputDirectory="../../../" IntermediateDirectory="Release" ConfigurationType="1" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" - CharacterSet="2" + CharacterSet="0" > <Tool Name="VCPreBuildEventTool" @@ -45,9 +44,11 @@ Optimization="3" AdditionalIncludeDirectories="../../../log4cpp/;../../../../include/;"../../../../Boost/include/boost-1_36";../../../GG/;../../include;../../../../include/OGRE;../../../../include/bullet" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;FREEORION_BUILD_HUMAN;FREEORION_WIN32;BOOST_SIGNALS_STATIC_LINK;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" - StringPooling="true" + StringPooling="false" MinimalRebuild="true" + BasicRuntimeChecks="0" RuntimeLibrary="2" + EnableFunctionLevelLinking="false" EnableEnhancedInstructionSet="2" DisableLanguageExtensions="false" ForceConformanceInForLoopScope="true" @@ -75,7 +76,7 @@ LinkIncremental="2" AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;../../../" GenerateManifest="true" - IgnoreDefaultLibraryNames="LIBCMT" + IgnoreDefaultLibraryNames="LIBCMT; LIBCPMT" GenerateDebugInformation="true" SubSystem="1" OptimizeReferences="0" Modified: trunk/FreeOrion/msvc2008/FreeOrion/freeorionca/freeorionca.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/freeorionca/freeorionca.vcproj 2009-02-09 04:10:39 UTC (rev 2804) +++ trunk/FreeOrion/msvc2008/FreeOrion/freeorionca/freeorionca.vcproj 2009-02-09 12:22:40 UTC (rev 2805) @@ -20,8 +20,7 @@ OutputDirectory="../../../" IntermediateDirectory="Release" ConfigurationType="1" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - CharacterSet="2" + CharacterSet="0" > <Tool Name="VCPreBuildEventTool" @@ -43,7 +42,7 @@ Optimization="3" AdditionalIncludeDirectories="../../../log4cpp/;../../../../include/;"../../../../Boost/include/boost-1_36";C:\Python25\include;../../../GG/" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GIGI_EXPORTS;FREEORION_BUILD_AI;FREEORION_WIN32;BOOST_SIGNALS_STATIC_LINK;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" - StringPooling="true" + StringPooling="false" MinimalRebuild="true" RuntimeLibrary="2" EnableEnhancedInstructionSet="2" @@ -66,12 +65,12 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="opengl32.lib glu32.lib wsock32.lib zdll.lib freetype214MT.lib cdt.lib common.lib pathplan.lib libexpat.lib python25.lib boost_python-vc90-mt-1_36.lib" + AdditionalDependencies="opengl32.lib glu32.lib zlib1.lib wsock32.lib cdt.lib common.lib pathplan.lib libexpat.lib python25.lib boost_python-vc90-mt-1_36.lib" OutputFile="../../../freeorionca.exe" LinkIncremental="2" AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;C:\Python25\libs" GenerateManifest="true" - GenerateDebugInformation="false" + GenerateDebugInformation="true" SubSystem="1" OptimizeReferences="0" EnableCOMDATFolding="0" Modified: trunk/FreeOrion/msvc2008/FreeOrion/freeoriond/freeoriond.vcproj =================================================================== --- trunk/FreeOrion/msvc2008/FreeOrion/freeoriond/freeoriond.vcproj 2009-02-09 04:10:39 UTC (rev 2804) +++ trunk/FreeOrion/msvc2008/FreeOrion/freeoriond/freeoriond.vcproj 2009-02-09 12:22:40 UTC (rev 2805) @@ -21,8 +21,7 @@ OutputDirectory="../../../" IntermediateDirectory="Release" ConfigurationType="1" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - CharacterSet="2" + CharacterSet="0" > <Tool Name="VCPreBuildEventTool" @@ -44,7 +43,7 @@ Optimization="3" AdditionalIncludeDirectories="../../../log4cpp/;../../../../include/;"../../../../Boost/include/boost-1_36";../../../GG/;../../include" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GIGI_EXPORTS;FREEORION_BUILD_SERVER;FREEORION_WIN32;BOOST_SIGNALS_STATIC_LINK;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" - StringPooling="true" + StringPooling="false" MinimalRebuild="true" RuntimeLibrary="2" EnableEnhancedInstructionSet="2" @@ -67,7 +66,7 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="opengl32.lib glu32.lib wsock32.lib zdll.lib freetype214MT.lib cdt.lib common.lib graph.lib pathplan.lib libexpat.lib" + AdditionalDependencies="opengl32.lib glu32.lib zlib1.lib wsock32.lib cdt.lib common.lib graph.lib pathplan.lib libexpat.lib" OutputFile="../../../freeoriond.exe" LinkIncremental="2" AdditionalLibraryDirectories="../../../../lib/;../../../../Boost/lib/;C:\Python25\libs" Modified: trunk/FreeOrion/ogre_plugins.cfg =================================================================== --- trunk/FreeOrion/ogre_plugins.cfg 2009-02-09 04:10:39 UTC (rev 2804) +++ trunk/FreeOrion/ogre_plugins.cfg 2009-02-09 12:22:40 UTC (rev 2805) @@ -1,9 +1,10 @@ -# Ogre 3D engine plugins to load - -# Plugin folder -PluginFolder=. - -# Plugins -Plugin=RenderSystem_GL.dll -Plugin=Plugin_ParticleFX.dll -Plugin=Plugin_OctreeSceneManager.dll +# Ogre 3D engine plugins to load + +# Plugin folder +PluginFolder=. + +# Plugins +Plugin=RenderSystem_GL +Plugin=Plugin_ParticleFX +Plugin=Plugin_OctreeSceneManager + |
From: <tz...@us...> - 2009-02-11 23:26:13
|
Revision: 2806 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2806&view=rev Author: tzlaine Date: 2009-02-11 23:26:09 +0000 (Wed, 11 Feb 2009) Log Message: ----------- Added ENV parameter to SCons.Environment(), to allow easier use with MSVC 2008, and otherwise standardized the Win32 build on that compiler. Modified Paths: -------------- trunk/FreeOrion/SConstruct trunk/FreeOrion/build_support.py Modified: trunk/FreeOrion/SConstruct =================================================================== --- trunk/FreeOrion/SConstruct 2009-02-09 12:22:40 UTC (rev 2805) +++ trunk/FreeOrion/SConstruct 2009-02-11 23:26:09 UTC (rev 2806) @@ -6,7 +6,13 @@ from build_config import * from build_support import * -env = Environment() +if str(Platform()) == 'win32': + env = Environment(ENV = {'PATH' : os.environ['PATH'], + 'LIB' : os.environ['LIB'], + 'INCLUDE' : os.environ['INCLUDE']}) +else: + env = Environment() + # Do not put a .sconsign file into every directory env.SConsignFile() @@ -479,6 +485,7 @@ if str(Platform()) == 'win32': if env['multithreaded']: if env['dynamic']: + env.AppendUnique(CPPDEFINES = ['BOOST_ALL_DYN_LINK']) if env['debug']: code_generation_flag = '/MDd' else: Modified: trunk/FreeOrion/build_support.py =================================================================== --- trunk/FreeOrion/build_support.py 2009-02-09 12:22:40 UTC (rev 2805) +++ trunk/FreeOrion/build_support.py 2009-02-11 23:26:09 UTC (rev 2806) @@ -194,7 +194,7 @@ def BoostLibWin32Name(name, env): # For now, assume VC80 is used - toolset_tag = '-vc80' + toolset_tag = '-vc90' if env['multithreaded']: if env['dynamic']: if env['debug']: |
From: <tz...@us...> - 2009-02-12 03:51:20
|
Revision: 2807 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2807&view=rev Author: tzlaine Date: 2009-02-12 03:51:06 +0000 (Thu, 12 Feb 2009) Log Message: ----------- Changes in preparation for a new release. Modified Paths: -------------- trunk/FreeOrion/Installer/FreeOrion_Install_Script.nsi trunk/FreeOrion/build_config.py trunk/FreeOrion/universe/Universe.cpp Modified: trunk/FreeOrion/Installer/FreeOrion_Install_Script.nsi =================================================================== --- trunk/FreeOrion/Installer/FreeOrion_Install_Script.nsi 2009-02-11 23:26:09 UTC (rev 2806) +++ trunk/FreeOrion/Installer/FreeOrion_Install_Script.nsi 2009-02-12 03:51:06 UTC (rev 2807) @@ -2,7 +2,7 @@ ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "FreeOrion" -!define PRODUCT_VERSION "0.3.11" +!define PRODUCT_VERSION "0.3.12" !define PRODUCT_PUBLISHER "FreeOrion Community" !define PRODUCT_WEB_SITE "http://www.freeorion.org" !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\freeorionca.exe" @@ -44,7 +44,7 @@ ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" -OutFile "..\..\FreeOrion-0.3.11-Setup.exe" +OutFile "..\..\FreeOrion-0.3.12-Setup.exe" InstallDir "$PROGRAMFILES\FreeOrion" InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" ShowInstDetails show @@ -56,28 +56,34 @@ File "..\..\vcredist_x86.exe" ExecWait "$INSTDIR\vcredist_x86.exe /q" File /r /x .svn "..\default" - File "..\glew32.dll" + File "..\GiGi.dll" + File "..\GiGiOgre.dll" + File "..\GiGiOgrePlugin_OIS.dll" + File "..\OIS.dll" + File "..\OgreMain.dll" + File "..\OpenAL32.dll" + File "..\Plugin_OctreeSceneManager.dll" + File "..\Plugin_ParticleFX.dll" + File "..\RenderSystem_GL.dll" File "..\alut.dll" + File "..\boost_date_time-vc90-mt-1_36.dll" + File "..\boost_filesystem-vc90-mt-1_36.dll" + File "..\boost_iostreams-vc90-mt-1_36.dll" File "..\boost_python-vc80-mt-1_36.dll" - File "..\devil.dll" - File "..\GiGi.dll" - File "..\GG\GiGi.dll.manifest" - File "..\GiGiSDL.dll" - File "..\GG\GiGiSDL.dll.manifest" - File "..\ilu.dll" - File "..\ilut.dll" + File "..\boost_python-vc90-mt-1_36.dll" + File "..\boost_regex-vc90-mt-1_36.dll" + File "..\boost_serialization-vc90-mt-1_36.dll" + File "..\boost_signals-vc90-mt-1_36.dll" + File "..\boost_system-vc90-mt-1_36.dll" + File "..\boost_thread-vc90-mt-1_36.dll" + File "..\glew32.dll" File "..\jpeg.dll" File "..\libexpat.dll" File "..\libogg.dll" + File "..\libpng13.dll" File "..\libvorbis.dll" File "..\libvorbisfile.dll" - File "..\msvcm80.dll" - File "..\msvcp80.dll" - File "..\msvcr80.dll" - File "..\OpenAL32.dll" - File "..\png.dll" File "..\python25.dll" - File "..\SDL.dll" File "..\wrap_oal.dll" File "..\z.dll" File "..\zlib1.dll" @@ -87,6 +93,8 @@ File "..\freeorionca.exe.manifest" File "..\freeoriond.exe.manifest" File "..\freeorion.exe.manifest" + File "..\OISInput.cfg" + File "..\ogre_plugins.cfg" CreateDirectory "$SMPROGRAMS\FreeOrion" CreateShortCut "$SMPROGRAMS\FreeOrion\FreeOrion.lnk" "$INSTDIR\freeorion.exe" "--fullscreen" CreateShortCut "$SMPROGRAMS\FreeOrion\FreeOrion windowed.lnk" "$INSTDIR\freeorion.exe" Modified: trunk/FreeOrion/build_config.py =================================================================== --- trunk/FreeOrion/build_config.py 2009-02-11 23:26:09 UTC (rev 2806) +++ trunk/FreeOrion/build_config.py 2009-02-12 03:51:06 UTC (rev 2807) @@ -1,6 +1,6 @@ # -*- Python -*- -freeorion_version = 'v0.3.11' +freeorion_version = 'v0.3.12' gigi_version = '0.6.0' Modified: trunk/FreeOrion/universe/Universe.cpp =================================================================== --- trunk/FreeOrion/universe/Universe.cpp 2009-02-11 23:26:09 UTC (rev 2806) +++ trunk/FreeOrion/universe/Universe.cpp 2009-02-12 03:51:06 UTC (rev 2807) @@ -391,7 +391,7 @@ // class Universe ///////////////////////////////////////////// // static(s) -const bool Universe::ALL_OBJECTS_VISIBLE = true; +const bool Universe::ALL_OBJECTS_VISIBLE = false; double Universe::s_universe_width = 1000.0; bool Universe::s_inhibit_universe_object_signals = false; int Universe::s_encoding_empire = ALL_EMPIRES; |
From: <geo...@us...> - 2009-02-13 23:01:39
|
Revision: 2813 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2813&view=rev Author: geoffthemedio Date: 2009-02-13 21:53:36 +0000 (Fri, 13 Feb 2009) Log Message: ----------- -Made it possible to define GG::Clr in XML as a hex string with three or four components for RGB or RGBA eg. "FFA300" or "13F3AA02" where the three-component assumes alpha = 255 -Added examples of these to form to empire_colors.xml -Added safety checks to ensure component definitions are present before they're used when defining with <tagged> colour components -Updated MSVC project files' Version.cpp Modified Paths: -------------- trunk/FreeOrion/default/empire_colors.xml trunk/FreeOrion/msvc2008/src/Version.cpp trunk/FreeOrion/util/MultiplayerCommon.cpp Modified: trunk/FreeOrion/default/empire_colors.xml =================================================================== --- trunk/FreeOrion/default/empire_colors.xml 2009-02-13 18:27:11 UTC (rev 2812) +++ trunk/FreeOrion/default/empire_colors.xml 2009-02-13 21:53:36 UTC (rev 2813) @@ -1,18 +1,8 @@ <?xml version="1.0"?> <XMLDoc> +<GG::Clr hex="00FF00"/> +<GG::Clr hex="0000FFFF"/> <GG::Clr> - <red>0</red> - <green>255</green> - <blue>0</blue> - <alpha>255</alpha> -</GG::Clr> -<GG::Clr> - <red>0</red> - <green>0</green> - <blue>255</blue> - <alpha>255</alpha> -</GG::Clr> -<GG::Clr> <red>255</red> <green>0</green> <blue>0</blue> @@ -24,13 +14,8 @@ <blue>0</blue> <alpha>255</alpha> </GG::Clr> +<GG::Clr hex="FF00FFFF"/> <GG::Clr> - <red>255</red> - <green>0</green> - <blue>255</blue> - <alpha>255</alpha> -</GG::Clr> -<GG::Clr> <red>0</red> <green>255</green> <blue>255</blue> Modified: trunk/FreeOrion/msvc2008/src/Version.cpp =================================================================== --- trunk/FreeOrion/msvc2008/src/Version.cpp 2009-02-13 18:27:11 UTC (rev 2812) +++ trunk/FreeOrion/msvc2008/src/Version.cpp 2009-02-13 21:53:36 UTC (rev 2813) @@ -2,6 +2,6 @@ const std::string& FreeOrionVersionString() { - static const std::string retval = "Post-v0.3.11 [Development Build]"; + static const std::string retval = "Post-v0.3.12 [Development Build]"; return retval; } Modified: trunk/FreeOrion/util/MultiplayerCommon.cpp =================================================================== --- trunk/FreeOrion/util/MultiplayerCommon.cpp 2009-02-13 18:27:11 UTC (rev 2812) +++ trunk/FreeOrion/util/MultiplayerCommon.cpp 2009-02-13 21:53:36 UTC (rev 2813) @@ -44,6 +44,18 @@ new StringTable(SettingsDir() + GetOptionsDB().Get<std::string>("stringtable-filename"))); return *string_table; } + + std::string ClrToString(GG::Clr clr) { + unsigned int r = static_cast<int>(clr.r); + unsigned int g = static_cast<int>(clr.g); + unsigned int b = static_cast<int>(clr.b); + unsigned int a = static_cast<int>(clr.a); + std::string retval = "(" + boost::lexical_cast<std::string>(r) + ", " + + boost::lexical_cast<std::string>(g) + ", " + + boost::lexical_cast<std::string>(b) + ", " + + boost::lexical_cast<std::string>(a) + ")"; + return retval; + } } ///////////////////////////////////////////////////// @@ -79,11 +91,41 @@ GG::Clr XMLToClr(const XMLElement& clr) { - GG::Clr retval; - retval.r = boost::lexical_cast<int>(clr.Child("red").Text()); - retval.g = boost::lexical_cast<int>(clr.Child("green").Text()); - retval.b = boost::lexical_cast<int>(clr.Child("blue").Text()); - retval.a = boost::lexical_cast<int>(clr.Child("alpha").Text()); + GG::Clr retval = GG::CLR_BLACK; + if (clr.ContainsAttribute("hex")) { + // get colour components as a single string representing three pairs of hex digits + // from 00 to FF and an optional fourth hex digit pair for alpha + const std::string& hex_colour = clr.Attribute("hex"); + std::istringstream iss(hex_colour); + unsigned long rgba = 0; + if (!(iss >> std::hex >> rgba).fail()) { + if (hex_colour.size() == 6) { + retval.r = (rgba >> 16) & 0xFF; + retval.g = (rgba >> 8) & 0xFF; + retval.b = rgba & 0xFF; + retval.a = 255; + } else { + retval.r = (rgba >> 24) & 0xFF; + retval.g = (rgba >> 16) & 0xFF; + retval.b = (rgba >> 8) & 0xFF; + retval.a = rgba & 0xFF; + } + //std::cout << "hex colour: " << hex_colour << " int: " << rgba << " RGBA: " << ClrToString(retval) << std::endl; + } else { + std::cerr << "XMLToClr could not interpret hex colour string \"" << hex_colour << "\"" << std::endl; + } + } else { + // get colours listed as RGBA components ranging 0 to 255 as integers + if (clr.ContainsChild("red")) + retval.r = boost::lexical_cast<int>(clr.Child("red").Text()); + if (clr.ContainsChild("green")) + retval.g = boost::lexical_cast<int>(clr.Child("green").Text()); + if (clr.ContainsChild("blue")) + retval.b = boost::lexical_cast<int>(clr.Child("blue").Text()); + if (clr.ContainsChild("alpha")) + retval.a = boost::lexical_cast<int>(clr.Child("alpha").Text()); + //std::cout << "non hex colour RGBA: " << ClrToString(retval) << std::endl; + } return retval; } |
From: <geo...@us...> - 2009-02-14 23:05:09
|
Revision: 2815 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2815&view=rev Author: geoffthemedio Date: 2009-02-14 22:47:19 +0000 (Sat, 14 Feb 2009) Log Message: ----------- Added toggle for skybox rendering to combat screen Modified Paths: -------------- trunk/FreeOrion/UI/CombatWnd.cpp trunk/FreeOrion/UI/CombatWnd.h trunk/FreeOrion/UI/OptionsWnd.cpp trunk/FreeOrion/UI/SystemIcon.cpp trunk/FreeOrion/default/eng_stringtable.txt Modified: trunk/FreeOrion/UI/CombatWnd.cpp =================================================================== --- trunk/FreeOrion/UI/CombatWnd.cpp 2009-02-14 03:06:58 UTC (rev 2814) +++ trunk/FreeOrion/UI/CombatWnd.cpp 2009-02-14 22:47:19 UTC (rev 2815) @@ -297,6 +297,8 @@ db.AddFlag("tech-demo", "Try out the 3D combat tech demo."); db.Add("combat.enable-glow", "OPTIONS_DB_COMBAT_ENABLE_GLOW", true, Validator<bool>()); + db.Add("combat.enable-skybox", "OPTIONS_DB_COMBAT_ENABLE_SKYBOX", + true, Validator<bool>()); db.Add("combat.filled-selection", "OPTIONS_DB_COMBAT_FILLED_SELECTION", false, Validator<bool>()); } @@ -495,6 +497,9 @@ GG::Connect(GetOptionsDB().OptionChangedSignal("combat.enable-glow"), &CombatWnd::UpdateStarFromCameraPosition, this); + GG::Connect(GetOptionsDB().OptionChangedSignal("combat.enable-skybox"), + &CombatWnd::UpdateSkyBox, this); + Ogre::Root::getSingleton().addFrameListener(this); m_scene_manager->addRenderQueueListener(m_stencil_op_frame_listener); @@ -555,7 +560,7 @@ star->setPosition(Ogre::Vector3(0.0, 0.0, 0.0)); star->setAttenuation(SYSTEM_RADIUS * 0.51, 1.0, 0.0, 0.0); - m_scene_manager->setSkyBox(true, "backgrounds/sky_box_1", 50.0); + UpdateSkyBox(); m_camera->setNearClipDistance(NEAR_CLIP); m_camera->setFarClipDistance(FAR_CLIP); @@ -1353,6 +1358,17 @@ m_initial_right_horizontal_flare_scroll + m_right_horizontal_flare_scroll_offset); } +void CombatWnd::UpdateSkyBox() +{ + Ogre::String skybox_material_name = "backgrounds/sky_box_1"; + Ogre::Real skybox_distance = 50.0; + if (GetOptionsDB().Get<bool>("combat.enable-skybox")) { + m_scene_manager->setSkyBox(true, skybox_material_name, skybox_distance); + } else { + m_scene_manager->setSkyBox(false, skybox_material_name, skybox_distance); + } +} + void CombatWnd::EndSelectionDrag() { m_selection_drag_start = INVALID_SELECTION_DRAG_POS; Modified: trunk/FreeOrion/UI/CombatWnd.h =================================================================== --- trunk/FreeOrion/UI/CombatWnd.h 2009-02-14 03:06:58 UTC (rev 2814) +++ trunk/FreeOrion/UI/CombatWnd.h 2009-02-14 22:47:19 UTC (rev 2815) @@ -90,6 +90,7 @@ void LookAt(const Ogre::Vector3& look_at_point); void UpdateCameraPosition(); void UpdateStarFromCameraPosition(); + void UpdateSkyBox(); void EndSelectionDrag(); void SelectObjectsInVolume(bool toggle_selected_items); Ogre::MovableObject* GetObjectUnderPt(const GG::Pt& pt); Modified: trunk/FreeOrion/UI/OptionsWnd.cpp =================================================================== --- trunk/FreeOrion/UI/OptionsWnd.cpp 2009-02-14 03:06:58 UTC (rev 2814) +++ trunk/FreeOrion/UI/OptionsWnd.cpp 2009-02-14 22:47:19 UTC (rev 2815) @@ -767,9 +767,11 @@ // combat settings tab BeginPage(UserString("OPTIONS_PAGE_COMBAT")); BoolOption("combat.enable-glow", UserString("OPTIONS_COMBAT_ENABLE_GLOW")); + BoolOption("combat.enable-skybox", UserString("OPTIONS_COMBAT_ENABLE_SKYBOX")); BoolOption("combat.filled-selection", UserString("OPTIONS_COMBAT_FILLED_SELECTION")); EndPage(); + // Misc. settings tab BeginPage(UserString("OPTIONS_PAGE_AUTOSAVE")); BoolOption("autosave.single-player", UserString("OPTIONS_SINGLEPLAYER")); Modified: trunk/FreeOrion/UI/SystemIcon.cpp =================================================================== --- trunk/FreeOrion/UI/SystemIcon.cpp 2009-02-14 03:06:58 UTC (rev 2814) +++ trunk/FreeOrion/UI/SystemIcon.cpp 2009-02-14 22:47:19 UTC (rev 2815) @@ -24,6 +24,21 @@ namespace { bool PlaySounds() {return GetOptionsDB().Get<bool>("UI.sound.enabled");} void PlaySystemIconRolloverSound() {if (PlaySounds()) Sound::GetSound().PlaySound(ClientUI::SoundDir() / GetOptionsDB().Get<std::string>("UI.sound.system-icon-rollover"));} + + void AddOptions(OptionsDB& db) + { + db.Add("UI.system-icon-minimum-size", "OPTIONS_DB_SYSTEM_ICON_MINIMUM_SIZE", , RangedValidator<int>(0, 3600)); + db.Add("UI.chat-edit-history", "OPTIONS_DB_UI_CHAT_EDIT_HISTORY", 50, RangedValidator<int>(0, 1000)); + db.Add("UI.galaxy-gas-background", "OPTIONS_DB_GALAXY_MAP_GAS", true, Validator<bool>()); + db.Add("UI.galaxy-starfields", "OPTIONS_DB_GALAXY_MAP_STARFIELDS", true, Validator<bool>()); + db.Add("UI.optimized-system-rendering", "OPTIONS_DB_OPTIMIZED_SYSTEM_RENDERING", true, Validator<bool>()); + db.Add("UI.starlane-thickness", "OPTIONS_DB_STARLANE_THICKNESS", 2.5, RangedValidator<double>(0.1, 15.0)); + db.Add("UI.resource-starlane-colouring", "OPTIONS_DB_RESOURCE_STARLANE_COLOURING", true, Validator<bool>()); + db.Add("UI.fleet-supply-lines", "OPTIONS_DB_FLEET_SUPPLY_LINES", true, Validator<bool>()); + db.Add("UI.fleet-supply-line-width", "OPTIONS_DB_FLEET_SUPPLY_LINE_WIDTH", 3.0, RangedValidator<double>(0.1, 15.0)); + } + bool temp_bool = RegisterOptions(&AddOptions); + } //////////////////////////////////////////////// Modified: trunk/FreeOrion/default/eng_stringtable.txt =================================================================== --- trunk/FreeOrion/default/eng_stringtable.txt 2009-02-14 03:06:58 UTC (rev 2814) +++ trunk/FreeOrion/default/eng_stringtable.txt 2009-02-14 22:47:19 UTC (rev 2815) @@ -470,6 +470,9 @@ OPTIONS_DB_COMBAT_ENABLE_GLOW Toggles glow effects on and off. +OPTIONS_DB_COMBAT_ENABLE_SKYBOX +Toggles background skybox on and off. + OPTIONS_DB_COMBAT_FILLED_SELECTION Uses a filled-in effect, as opposed to an outline effect, on selected objects. @@ -1087,6 +1090,9 @@ OPTIONS_COMBAT_ENABLE_GLOW Glow +OPTIONS_COMBAT_ENABLE_SKYBOX +Skybox + OPTIONS_COMBAT_FILLED_SELECTION Filled selection |
From: <geo...@us...> - 2009-02-14 23:15:28
|
Revision: 2817 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2817&view=rev Author: geoffthemedio Date: 2009-02-14 23:15:25 +0000 (Sat, 14 Feb 2009) Log Message: ----------- Added options toggle for lens flares on combat screen Modified Paths: -------------- trunk/FreeOrion/UI/CombatWnd.cpp trunk/FreeOrion/UI/CombatWnd.h trunk/FreeOrion/UI/OptionsWnd.cpp trunk/FreeOrion/default/eng_stringtable.txt Modified: trunk/FreeOrion/UI/CombatWnd.cpp =================================================================== --- trunk/FreeOrion/UI/CombatWnd.cpp 2009-02-14 22:51:25 UTC (rev 2816) +++ trunk/FreeOrion/UI/CombatWnd.cpp 2009-02-14 23:15:25 UTC (rev 2817) @@ -299,6 +299,8 @@ true, Validator<bool>()); db.Add("combat.enable-skybox", "OPTIONS_DB_COMBAT_ENABLE_SKYBOX", true, Validator<bool>()); + db.Add("combat.enable-lens-flare", "OPTIONS_DB_COMBAT_ENABLE_LENS_FLARE", + true, Validator<bool>()); db.Add("combat.filled-selection", "OPTIONS_DB_COMBAT_FILLED_SELECTION", false, Validator<bool>()); } @@ -945,6 +947,24 @@ } #endif + RenderLensFlare(); + + if (m_selection_rect.ul != m_selection_rect.lr) { + glColor4f(1.0, 1.0, 1.0, 0.5); + glBegin(GL_LINE_LOOP); + glVertex(m_selection_rect.lr.x, m_selection_rect.ul.y); + glVertex(m_selection_rect.ul.x, m_selection_rect.ul.y); + glVertex(m_selection_rect.ul.x, m_selection_rect.lr.y); + glVertex(m_selection_rect.lr.x, m_selection_rect.lr.y); + glEnd(); + } +} + +void CombatWnd::RenderLensFlare() +{ + if (!GetOptionsDB().Get<bool>("combat.enable-lens-flare")) + return; + // render two small lens flares that oppose the star's position relative to // the center of the viewport GG::Pt star_pt = ProjectToPixel(*m_camera, Ogre::Vector3(0.0, 0.0, 0.0)); @@ -971,16 +991,6 @@ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } } - - if (m_selection_rect.ul != m_selection_rect.lr) { - glColor4f(1.0, 1.0, 1.0, 0.5); - glBegin(GL_LINE_LOOP); - glVertex(m_selection_rect.lr.x, m_selection_rect.ul.y); - glVertex(m_selection_rect.ul.x, m_selection_rect.ul.y); - glVertex(m_selection_rect.ul.x, m_selection_rect.lr.y); - glVertex(m_selection_rect.lr.x, m_selection_rect.lr.y); - glEnd(); - } } void CombatWnd::LButtonDown(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) Modified: trunk/FreeOrion/UI/CombatWnd.h =================================================================== --- trunk/FreeOrion/UI/CombatWnd.h 2009-02-14 22:51:25 UTC (rev 2816) +++ trunk/FreeOrion/UI/CombatWnd.h 2009-02-14 23:15:25 UTC (rev 2817) @@ -86,6 +86,8 @@ virtual bool frameStarted(const Ogre::FrameEvent& event); virtual bool frameEnded(const Ogre::FrameEvent& event); + void RenderLensFlare(); + void LookAt(Ogre::SceneNode* look_at_node); void LookAt(const Ogre::Vector3& look_at_point); void UpdateCameraPosition(); Modified: trunk/FreeOrion/UI/OptionsWnd.cpp =================================================================== --- trunk/FreeOrion/UI/OptionsWnd.cpp 2009-02-14 22:51:25 UTC (rev 2816) +++ trunk/FreeOrion/UI/OptionsWnd.cpp 2009-02-14 23:15:25 UTC (rev 2817) @@ -768,6 +768,7 @@ BeginPage(UserString("OPTIONS_PAGE_COMBAT")); BoolOption("combat.enable-glow", UserString("OPTIONS_COMBAT_ENABLE_GLOW")); BoolOption("combat.enable-skybox", UserString("OPTIONS_COMBAT_ENABLE_SKYBOX")); + BoolOption("combat.enable-lens-flare", UserString("OPTIONS_COMBAT_ENABLE_LENS_FLARES")); BoolOption("combat.filled-selection", UserString("OPTIONS_COMBAT_FILLED_SELECTION")); EndPage(); Modified: trunk/FreeOrion/default/eng_stringtable.txt =================================================================== --- trunk/FreeOrion/default/eng_stringtable.txt 2009-02-14 22:51:25 UTC (rev 2816) +++ trunk/FreeOrion/default/eng_stringtable.txt 2009-02-14 23:15:25 UTC (rev 2817) @@ -473,6 +473,9 @@ OPTIONS_DB_COMBAT_ENABLE_SKYBOX Toggles background skybox on and off. +OPTIONS_DB_COMBAT_ENABLE_LENS_FLARE +Toggles lens flares on and off. + OPTIONS_DB_COMBAT_FILLED_SELECTION Uses a filled-in effect, as opposed to an outline effect, on selected objects. @@ -1093,6 +1096,9 @@ OPTIONS_COMBAT_ENABLE_SKYBOX Skybox +OPTIONS_COMBAT_ENABLE_LENS_FLARES +Lens Flares + OPTIONS_COMBAT_FILLED_SELECTION Filled selection |
From: <tz...@us...> - 2009-02-15 02:51:13
|
Revision: 2818 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2818&view=rev Author: tzlaine Date: 2009-02-15 02:51:09 +0000 (Sun, 15 Feb 2009) Log Message: ----------- - Added first sketch of keyboard interface to CombatWnd. The interface closely follows that in MapWnd. Most of the interface is currently stub functions, though zooming is implemented. - The code that handles adding and removing keyboard accelerators in MapWnd and CombatWnd was changed so that the two windows do not stomp on each others' toes. - Broke the chat window funtionality of MapWnd out into its own new class, ChatWnd, now used by both MapWnd and CombatWnd. - Changed the --tech-demo flag so it is no longer saved in the config file. Modified Paths: -------------- trunk/FreeOrion/SConscript trunk/FreeOrion/UI/CombatWnd.cpp trunk/FreeOrion/UI/CombatWnd.h trunk/FreeOrion/UI/MapWnd.cpp trunk/FreeOrion/UI/MapWnd.h trunk/FreeOrion/client/human/HumanClientFSM.cpp Added Paths: ----------- trunk/FreeOrion/UI/ChatWnd.cpp trunk/FreeOrion/UI/ChatWnd.h Modified: trunk/FreeOrion/SConscript =================================================================== --- trunk/FreeOrion/SConscript 2009-02-14 23:15:25 UTC (rev 2817) +++ trunk/FreeOrion/SConscript 2009-02-15 02:51:09 UTC (rev 2818) @@ -122,6 +122,7 @@ 'network/ClientNetworking.cpp', 'UI/About.cpp', 'UI/BuildDesignatorWnd.cpp', + 'UI/ChatWnd.cpp', 'UI/ClientUI.cpp', 'UI/CUIControls.cpp', 'UI/CUIDrawUtil.cpp', Added: trunk/FreeOrion/UI/ChatWnd.cpp =================================================================== --- trunk/FreeOrion/UI/ChatWnd.cpp (rev 0) +++ trunk/FreeOrion/UI/ChatWnd.cpp 2009-02-15 02:51:09 UTC (rev 2818) @@ -0,0 +1,217 @@ +#include "ChatWnd.h" + +#include "CUIControls.h" +#include "../client/human/HumanClientApp.h" +#include "../Empire/Empire.h" +#include "../Empire/EmpireManager.h" +#include "../network/Message.h" +#include "../universe/Universe.h" +#include "../universe/System.h" +#include "../util/OptionsDB.h" +#include "../util/MultiplayerCommon.h" + +#include <GG/GUI.h> + + +namespace { + const int LAYOUT_MARGIN = 5; + const GG::X CHAT_WIDTH(400); + const GG::Y CHAT_HEIGHT(400); + const GG::Y CHAT_EDIT_HEIGHT(30); + + void AddOptions(OptionsDB& db) + { + db.Add("UI.chat-hide-interval", "OPTIONS_DB_UI_CHAT_HIDE_INTERVAL", + 10, RangedValidator<int>(0, 3600)); + db.Add("UI.chat-edit-history", "OPTIONS_DB_UI_CHAT_EDIT_HISTORY", + 50, RangedValidator<int>(0, 1000)); + } + bool temp_bool = RegisterOptions(&AddOptions); +} + +ChatWnd::ChatWnd() : + Wnd(GG::X0, GG::Y0, GG::GUI::GetGUI()->AppWidth(), GG::GUI::GetGUI()->AppHeight(), GG::ONTOP), + m_display(0), + m_edit(new CUIEdit(GG::X(LAYOUT_MARGIN), GG::GUI::GetGUI()->AppHeight() - CHAT_EDIT_HEIGHT - LAYOUT_MARGIN, CHAT_WIDTH, "", + ClientUI::GetFont(), ClientUI::CtrlBorderColor(), ClientUI::TextColor(), GG::CLR_ZERO)), + m_display_show_time(0), + m_history(), + m_history_position() +{ + std::auto_ptr<CUITurnButton> turn_button( + new CUITurnButton(GG::X0, GG::Y(LAYOUT_MARGIN), GG::X(100), "")); + m_display = new GG::MultiEdit( + GG::X(LAYOUT_MARGIN), turn_button->Height() + LAYOUT_MARGIN, CHAT_WIDTH, CHAT_HEIGHT, "", ClientUI::GetFont(), GG::CLR_ZERO, + GG::MULTI_WORDBREAK | GG::MULTI_READ_ONLY | GG::MULTI_TERMINAL_STYLE | GG::MULTI_INTEGRAL_HEIGHT | GG::MULTI_NO_VSCROLL, + ClientUI::TextColor(), GG::CLR_ZERO, GG::Flags<GG::WndFlag>()); + AttachChild(m_display); + m_display->SetMaxLinesOfHistory(100); + m_display->Hide(); + + AttachChild(m_edit); + m_edit->Hide(); + + m_history.push_front(""); +} + +void ChatWnd::HandlePlayerChatMessage(const std::string& msg) +{ + *m_display += msg; + m_display->Show(); + m_display_show_time = GG::GUI::GetGUI()->Ticks(); +} + +void ChatWnd::Clear() +{ m_display->Clear(); } + +bool ChatWnd::OpenForInput() +{ + bool retval = false; + if (!m_display->Visible() || !m_edit->Visible()) { + m_display->Show(); + m_edit->Show(); + GG::GUI::GetGUI()->SetFocusWnd(m_edit); + m_display_show_time = GG::GUI::GetGUI()->Ticks(); + retval = true; + } + return retval; +} + +void ChatWnd::HideEdit() +{ m_edit->Hide(); } + +void ChatWnd::Render() +{ + unsigned int interval = GetOptionsDB().Get<int>("UI.chat-hide-interval"); + if (!m_edit->Visible() && m_display_show_time && interval && + (interval < (GG::GUI::GetGUI()->Ticks() - m_display_show_time) / 1000)) { + m_display->Hide(); + m_display_show_time = 0; + } +} + +void ChatWnd::KeyPress(GG::Key key, boost::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys) +{ + switch (key) { + case GG::GGK_TAB: { // auto-complete current chat edit word + if (m_edit->Visible()) { + std::string text = m_edit->Text(); + std::pair<GG::CPSize, GG::CPSize> cursor_pos = m_edit->CursorPosn(); + if (cursor_pos.first == cursor_pos.second && 0 < cursor_pos.first && cursor_pos.first <= text.size()) { + std::string::size_type word_start = text.substr(0, Value(cursor_pos.first)).find_last_of(" :"); + if (word_start == std::string::npos) + word_start = 0; + else + ++word_start; + std::string partial_word = text.substr(word_start, Value(cursor_pos.first - word_start)); + if (partial_word == "") + return; + std::set<std::string> names; + // add player and empire names + for (EmpireManager::const_iterator it = Empires().begin(); it != Empires().end(); ++it) { + names.insert(it->second->Name()); + names.insert(it->second->PlayerName()); + } + // add system names + std::vector<System*> systems = GetUniverse().FindObjects<System>(); + for (unsigned int i = 0; i < systems.size(); ++i) { + if (systems[i]->Name() != "") + names.insert(systems[i]->Name()); + } + + if (names.find(partial_word) != names.end()) { // if there's an exact match, just add a space + text.insert(Value(cursor_pos.first), " "); + m_edit->SetText(text); + m_edit->SelectRange(cursor_pos.first + 1, cursor_pos.first + 1); + } else { // no exact match; look for possible completions + // find the range of strings in names that is at least partially matched by partial_word + std::set<std::string>::iterator lower_bound = names.lower_bound(partial_word); + std::set<std::string>::iterator upper_bound = lower_bound; + while (upper_bound != names.end() && upper_bound->find(partial_word) == 0) + ++upper_bound; + if (lower_bound == upper_bound) + return; + + // find the common portion of the strings in (upper_bound, lower_bound) + unsigned int common_end = partial_word.size(); + for ( ; common_end < lower_bound->size(); ++common_end) { + std::set<std::string>::iterator it = lower_bound; + char ch = (*it++)[common_end]; + bool match = true; + for ( ; it != upper_bound; ++it) { + if ((*it)[common_end] != ch) { + match = false; + break; + } + } + if (!match) + break; + } + unsigned int chars_to_add = common_end - partial_word.size(); + bool full_completion = common_end == lower_bound->size(); + text.insert(Value(cursor_pos.first), lower_bound->substr(partial_word.size(), chars_to_add) + (full_completion ? " " : "")); + m_edit->SetText(text); + GG::CPSize move_cursor_to = cursor_pos.first + chars_to_add + (full_completion ? GG::CP1 : GG::CP0); + m_edit->SelectRange(move_cursor_to, move_cursor_to); + } + } + } + break; + } + case GG::GGK_RETURN: + case GG::GGK_KP_ENTER: { // send chat message + if (m_edit->Visible()) { + std::string edit_text = m_edit->Text(); + if (edit_text != "") { + if (m_history.size() == 1 || m_history[1] != edit_text) { + m_history[0] = edit_text; + m_history.push_front(""); + } else { + m_history[0] = ""; + } + while (GetOptionsDB().Get<int>("UI.chat-edit-history") < static_cast<int>(m_history.size()) + 1) + m_history.pop_back(); + m_history_position = 0; + HumanClientApp::GetApp()->Networking().SendMessage(GlobalChatMessage(HumanClientApp::GetApp()->PlayerID(), edit_text)); + } + m_edit->Clear(); + m_edit->Hide(); + m_display_show_time = GG::GUI::GetGUI()->Ticks(); + MessageSentSignal(); + } + break; + } + + case GG::GGK_UP: { + if (m_edit->Visible() && m_history_position < static_cast<int>(m_history.size()) - 1) { + m_history[m_history_position] = m_edit->Text(); + ++m_history_position; + m_edit->SetText(m_history[m_history_position]); + } + break; + } + + case GG::GGK_DOWN: { + if (m_edit->Visible() && 0 < m_history_position) { + m_history[m_history_position] = m_edit->Text(); + --m_history_position; + m_edit->SetText(m_history[m_history_position]); + } + break; + } + + default: + break; + } +} + +ChatWnd* GetChatWnd() +{ + static bool init = false; + static std::auto_ptr<ChatWnd> retval(new ChatWnd); + if (!init) { + GG::GUI::GetGUI()->Register(retval.get()); + init = true; + } + return retval.get(); +} Added: trunk/FreeOrion/UI/ChatWnd.h =================================================================== --- trunk/FreeOrion/UI/ChatWnd.h (rev 0) +++ trunk/FreeOrion/UI/ChatWnd.h 2009-02-15 02:51:09 UTC (rev 2818) @@ -0,0 +1,40 @@ +// -*- C++ -*- +#ifndef _ChatWnd_h_ +#define _ChatWnd_h_ + +#include <GG/Wnd.h> + +#include <deque> +#include <string> + + +namespace GG { class MultiEdit; } +class CUIEdit; + +class ChatWnd : + public GG::Wnd +{ +public: + ChatWnd(); + + void HandlePlayerChatMessage(const std::string& msg); + void Clear(); + bool OpenForInput(); + void HideEdit(); + + virtual void Render(); + virtual void KeyPress(GG::Key key, boost::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys); + + mutable boost::signal<void ()> MessageSentSignal; + +private: + GG::MultiEdit* m_display; + CUIEdit* m_edit; + int m_display_show_time; + std::deque<std::string> m_history; + int m_history_position; +}; + +ChatWnd* GetChatWnd(); + +#endif Modified: trunk/FreeOrion/UI/CombatWnd.cpp =================================================================== --- trunk/FreeOrion/UI/CombatWnd.cpp 2009-02-14 23:15:25 UTC (rev 2817) +++ trunk/FreeOrion/UI/CombatWnd.cpp 2009-02-15 02:51:09 UTC (rev 2818) @@ -1,5 +1,6 @@ #include "CombatWnd.h" +#include "ChatWnd.h" #include "ClientUI.h" #include "CollisionMeshConverter.h" #include "CUIControls.h" @@ -294,7 +295,7 @@ void AddOptions(OptionsDB& db) { - db.AddFlag("tech-demo", "Try out the 3D combat tech demo."); + db.AddFlag("tech-demo", "Try out the 3D combat tech demo.", false); db.Add("combat.enable-glow", "OPTIONS_DB_COMBAT_ENABLE_GLOW", true, Validator<bool>()); db.Add("combat.enable-skybox", "OPTIONS_DB_COMBAT_ENABLE_SKYBOX", @@ -586,7 +587,6 @@ AttachChild(m_fps_text); - ////////////////////////////////////////////////////////////////// // NOTE: Below is temporary code for combat system prototyping! // ////////////////////////////////////////////////////////////////// @@ -721,6 +721,8 @@ delete m_collision_dispatcher; delete m_collision_configuration; + RemoveAccelerators(); + // TODO: delete nodes and materials in m_planet_assets (or maybe everything // via some Ogre function?) } @@ -729,6 +731,8 @@ { // TODO: move all of this to the ctor after prototyping is complete + SetAccelerators(); + // build list of available star textures, by type std::set<std::string> star_textures; { @@ -1046,6 +1050,29 @@ } } +void CombatWnd::Zoom(int move, GG::Flags<GG::ModKey> mod_keys) +{ + Ogre::Sphere bounding_sphere(Ogre::Vector3(), 0.0); + if (m_look_at_scene_node) + bounding_sphere = m_look_at_scene_node->getAttachedObject(0)->getWorldBoundingSphere(); + const Ogre::Real EFFECTIVE_MIN_DISTANCE = + std::max(bounding_sphere.getRadius() * Ogre::Real(1.05), MIN_ZOOM_IN_DISTANCE); + + Ogre::Real move_incr = m_distance_to_look_at_point * 0.25; + Ogre::Real scale_factor = 1.0; + if (mod_keys & GG::MOD_KEY_SHIFT) + scale_factor *= 2.0; + if (mod_keys & GG::MOD_KEY_CTRL) + scale_factor /= 4.0; + Ogre::Real total_move = move_incr * scale_factor * -move; + if (m_distance_to_look_at_point + total_move < EFFECTIVE_MIN_DISTANCE) + total_move += EFFECTIVE_MIN_DISTANCE - (m_distance_to_look_at_point + total_move); + else if (MAX_ZOOM_OUT_DISTANCE < m_distance_to_look_at_point + total_move) + total_move -= (m_distance_to_look_at_point + total_move) - MAX_ZOOM_OUT_DISTANCE; + m_distance_to_look_at_point += total_move; + UpdateCameraPosition(); +} + void CombatWnd::LClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) { if (m_selection_drag_start != INVALID_SELECTION_DRAG_POS) { @@ -1158,43 +1185,15 @@ void CombatWnd::MouseWheel(const GG::Pt& pt, int move, GG::Flags<GG::ModKey> mod_keys) { - Ogre::Sphere bounding_sphere(Ogre::Vector3(), 0.0); - if (m_look_at_scene_node) - bounding_sphere = m_look_at_scene_node->getAttachedObject(0)->getWorldBoundingSphere(); - const Ogre::Real EFFECTIVE_MIN_DISTANCE = - std::max(bounding_sphere.getRadius() * Ogre::Real(1.05), MIN_ZOOM_IN_DISTANCE); - - Ogre::Real move_incr = m_distance_to_look_at_point * 0.25; - Ogre::Real scale_factor = 1.0; - if (mod_keys & GG::MOD_KEY_SHIFT) - scale_factor *= 2.0; - if (mod_keys & GG::MOD_KEY_CTRL) - scale_factor /= 4.0; - Ogre::Real total_move = move_incr * scale_factor * -move; - if (m_distance_to_look_at_point + total_move < EFFECTIVE_MIN_DISTANCE) - total_move += EFFECTIVE_MIN_DISTANCE - (m_distance_to_look_at_point + total_move); - else if (MAX_ZOOM_OUT_DISTANCE < m_distance_to_look_at_point + total_move) - total_move -= (m_distance_to_look_at_point + total_move) - MAX_ZOOM_OUT_DISTANCE; - m_distance_to_look_at_point += total_move; - UpdateCameraPosition(); + if (move) + Zoom(move, mod_keys); } void CombatWnd::KeyPress(GG::Key key, boost::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys) { + // TODO: This quick-quit is for prototyping only. if (key == GG::GGK_q && mod_keys & GG::MOD_KEY_CTRL) m_exit = true; - - if (key == GG::GGK_F10 && !mod_keys && !m_menu_showing) { - m_menu_showing = true; -#if 0 // TODO: Use the full in-game menu when the code is a bit more developed. - InGameMenu menu; - menu.Run(); -#else - OptionsWnd options_wnd; - options_wnd.Run(); -#endif - m_menu_showing = false; - } } bool CombatWnd::frameStarted(const Ogre::FrameEvent& event) @@ -1482,3 +1481,198 @@ m_collision_world->addCollisionObject(&m_collision_objects.back()); m_collision_objects.back().setUserPointer(static_cast<Ogre::MovableObject*>(entity)); } + +bool CombatWnd::OpenChatWindow() +{ + bool retval = true; + if (GetChatWnd()->OpenForInput()) + DisableAlphaNumAccels(); + else + retval = false; + return retval; +} + +bool CombatWnd::EndTurn() +{ + // TODO + return true; +} + +bool CombatWnd::ShowMenu() +{ + if (!m_menu_showing) { + m_menu_showing = true; +#if 0 // TODO: Use the full in-game menu when the code is a bit more developed. + InGameMenu menu; + menu.Run(); +#else + OptionsWnd options_wnd; + options_wnd.Run(); +#endif + m_menu_showing = false; + } + return true; +} + +bool CombatWnd::KeyboardZoomIn() +{ + Zoom(1, GG::Flags<GG::ModKey>()); + return true; +} + +bool CombatWnd::KeyboardZoomOut() +{ + Zoom(-1, GG::Flags<GG::ModKey>()); + return true; +} + +bool CombatWnd::ZoomToPrevIdleUnit() +{ + // TODO + return true; +} + +bool CombatWnd::ZoomToNextIdleUnit() +{ + // TODO + return true; +} + +bool CombatWnd::ZoomToPrevUnit() +{ + // TODO + return true; +} + +bool CombatWnd::ZoomToNextUnit() +{ + // TODO + return true; +} + +void CombatWnd::ConnectKeyboardAcceleratorSignals() +{ + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_RETURN), + &CombatWnd::OpenChatWindow, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_KP_ENTER), + &CombatWnd::OpenChatWindow, this)); + + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_RETURN, GG::MOD_KEY_CTRL), + &CombatWnd::EndTurn, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_KP_ENTER, GG::MOD_KEY_CTRL), + &CombatWnd::EndTurn, this)); + + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_F10), + &CombatWnd::ShowMenu, this)); + + // Keys for zooming + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_e), + &CombatWnd::KeyboardZoomIn, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_KP_PLUS), + &CombatWnd::KeyboardZoomIn, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_r), + &CombatWnd::KeyboardZoomOut, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_KP_MINUS), + &CombatWnd::KeyboardZoomOut, this)); + + // Keys for showing units + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_f), + &CombatWnd::ZoomToPrevIdleUnit, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_g), + &CombatWnd::ZoomToNextIdleUnit, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_v), + &CombatWnd::ZoomToPrevUnit, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_b), + &CombatWnd::ZoomToNextUnit, this)); +} + +void CombatWnd::SetAccelerators() +{ + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_RETURN); + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_KP_ENTER); + + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_RETURN, GG::MOD_KEY_CTRL); + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_KP_ENTER, GG::MOD_KEY_CTRL); + + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_F10); + + // Keys for zooming + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_e); + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_r); + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_KP_PLUS); + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_KP_MINUS); + + // Keys for showing units + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_f); + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_g); + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_v); + GG::GUI::GetGUI()->SetAccelerator(GG::GGK_b); + + ConnectKeyboardAcceleratorSignals(); +} + +void CombatWnd::RemoveAccelerators() +{ + GG::GUI::accel_iterator i = GG::GUI::GetGUI()->accel_begin(); + while (i != GG::GUI::GetGUI()->accel_end()) { + GG::GUI::GetGUI()->RemoveAccelerator(i); + i = GG::GUI::GetGUI()->accel_begin(); + } + m_disabled_accels_list.clear(); + + for (std::set<boost::signals::connection>::iterator it = + m_keyboard_accelerator_signals.begin(); + it != m_keyboard_accelerator_signals.end(); + ++it) { + it->disconnect(); + } + m_keyboard_accelerator_signals.clear(); +} + +void CombatWnd::DisableAlphaNumAccels() +{ + for (GG::GUI::const_accel_iterator i = GG::GUI::GetGUI()->accel_begin(); + i != GG::GUI::GetGUI()->accel_end(); ++i) { + if (i->second != 0) // we only want to disable mod_keys without modifiers + continue; + GG::Key key = i->first; + if ((key >= GG::GGK_a && key <= GG::GGK_z) || + (key >= GG::GGK_0 && key <= GG::GGK_9)) { + m_disabled_accels_list.insert(key); + } + } + for (std::set<GG::Key>::iterator i = m_disabled_accels_list.begin(); + i != m_disabled_accels_list.end(); ++i) { + GG::GUI::GetGUI()->RemoveAccelerator(*i); + } +} + +void CombatWnd::EnableAlphaNumAccels() +{ + for (std::set<GG::Key>::iterator i = m_disabled_accels_list.begin(); + i != m_disabled_accels_list.end(); ++i) { + GG::GUI::GetGUI()->SetAccelerator(*i); + } + m_disabled_accels_list.clear(); +} + +void CombatWnd::ChatMessageSentSlot() +{ + if (!m_disabled_accels_list.empty()) { + EnableAlphaNumAccels(); + GG::GUI::GetGUI()->SetFocusWnd(this); + } +} Modified: trunk/FreeOrion/UI/CombatWnd.h =================================================================== --- trunk/FreeOrion/UI/CombatWnd.h 2009-02-14 23:15:25 UTC (rev 2817) +++ trunk/FreeOrion/UI/CombatWnd.h 2009-02-15 02:51:09 UTC (rev 2818) @@ -48,6 +48,7 @@ virtual ~CombatWnd(); void InitCombat(const System& system); + void HandlePlayerChatMessage(const std::string& msg); virtual void Render(); @@ -90,6 +91,7 @@ void LookAt(Ogre::SceneNode* look_at_node); void LookAt(const Ogre::Vector3& look_at_point); + void Zoom(int move, GG::Flags<GG::ModKey> mod_keys); void UpdateCameraPosition(); void UpdateStarFromCameraPosition(); void UpdateSkyBox(); @@ -99,6 +101,24 @@ void DeselectAll(); void AddShip(const std::string& mesh_name, Ogre::Real x, Ogre::Real y); + // Keyboard accelerator handlers, etc. See MapWnd for implementation + // notes. + bool OpenChatWindow(); + bool EndTurn(); + bool ShowMenu(); + bool KeyboardZoomIn(); + bool KeyboardZoomOut(); + bool ZoomToPrevIdleUnit(); + bool ZoomToNextIdleUnit(); + bool ZoomToPrevUnit(); + bool ZoomToNextUnit(); + void ConnectKeyboardAcceleratorSignals(); + void SetAccelerators(); + void RemoveAccelerators(); + void DisableAlphaNumAccels(); + void EnableAlphaNumAccels(); + void ChatMessageSentSlot(); + Ogre::SceneManager* m_scene_manager; Ogre::Camera* m_camera; Ogre::SceneNode* m_camera_node; @@ -152,6 +172,8 @@ FPSIndicator* m_fps_text; bool m_menu_showing; + std::set<boost::signals::connection> m_keyboard_accelerator_signals; + std::set<GG::Key> m_disabled_accels_list; bool m_exit; // TODO: Remove this; it is only here for prototyping. }; Modified: trunk/FreeOrion/UI/MapWnd.cpp =================================================================== --- trunk/FreeOrion/UI/MapWnd.cpp 2009-02-14 23:15:25 UTC (rev 2817) +++ trunk/FreeOrion/UI/MapWnd.cpp 2009-02-15 02:51:09 UTC (rev 2818) @@ -4,6 +4,7 @@ #include "MapWnd.h" +#include "ChatWnd.h" #include "ClientUI.h" #include "CUIControls.h" #include "../universe/Fleet.h" @@ -46,14 +47,7 @@ const GG::Y SITREP_PANEL_HEIGHT(300); const int MIN_SYSTEM_NAME_SIZE = 10; const int LAYOUT_MARGIN = 5; - const GG::X CHAT_WIDTH(400); - const GG::Y CHAT_HEIGHT(400); - const GG::Y CHAT_EDIT_HEIGHT(30); - int g_chat_display_show_time = 0; - std::deque<std::string> g_chat_edit_history; - int g_history_position = 0; // the current edit contents are in history position 0 - struct BoolToVoidAdapter { BoolToVoidAdapter(const boost::function<bool ()>& fn) : m_fn(fn) {} @@ -63,8 +57,6 @@ void AddOptions(OptionsDB& db) { - db.Add("UI.chat-hide-interval", "OPTIONS_DB_UI_CHAT_HIDE_INTERVAL", 10, RangedValidator<int>(0, 3600)); - db.Add("UI.chat-edit-history", "OPTIONS_DB_UI_CHAT_EDIT_HISTORY", 50, RangedValidator<int>(0, 1000)); db.Add("UI.galaxy-gas-background", "OPTIONS_DB_GALAXY_MAP_GAS", true, Validator<bool>()); db.Add("UI.galaxy-starfields", "OPTIONS_DB_GALAXY_MAP_STARFIELDS", true, Validator<bool>()); db.Add("UI.optimized-system-rendering", "OPTIONS_DB_OPTIMIZED_SYSTEM_RENDERING", true, Validator<bool>()); @@ -307,7 +299,7 @@ m_design_wnd->Hide(); // turn button - m_turn_update = new CUITurnButton(GG::X(LAYOUT_MARGIN), GG::Y(LAYOUT_MARGIN), END_TURN_BTN_WIDTH, "" ); + m_turn_update = new CUITurnButton(GG::X(LAYOUT_MARGIN), GG::Y(LAYOUT_MARGIN), END_TURN_BTN_WIDTH, ""); m_toolbar->AttachChild(m_turn_update); GG::Connect(m_turn_update->ClickedSignal, BoolToVoidAdapter(boost::bind(&MapWnd::EndTurn, this))); @@ -377,30 +369,12 @@ 0,0,3,3,true,true,false,true); m_toolbar->AttachChild(m_food); - // chat display and chat input box - m_chat_display = new GG::MultiEdit(GG::X(LAYOUT_MARGIN), m_turn_update->LowerRight().y + LAYOUT_MARGIN, CHAT_WIDTH, CHAT_HEIGHT, "", ClientUI::GetFont(), GG::CLR_ZERO, - GG::MULTI_WORDBREAK | GG::MULTI_READ_ONLY | GG::MULTI_TERMINAL_STYLE | GG::MULTI_INTEGRAL_HEIGHT | GG::MULTI_NO_VSCROLL, - ClientUI::TextColor(), GG::CLR_ZERO, GG::Flags<GG::WndFlag>()); - AttachChild(m_chat_display); - m_chat_display->SetMaxLinesOfHistory(100); - m_chat_display->Hide(); - - m_chat_edit = new CUIEdit(GG::X(LAYOUT_MARGIN), APP_HEIGHT - CHAT_EDIT_HEIGHT - LAYOUT_MARGIN, CHAT_WIDTH, "", - ClientUI::GetFont(), ClientUI::CtrlBorderColor(), ClientUI::TextColor(), GG::CLR_ZERO); - AttachChild(m_chat_edit); - m_chat_edit->Hide(); - EnableAlphaNumAccels(); - m_menu_showing = false; //clear background images m_backgrounds.clear(); m_bg_scroll_rate.clear(); - ConnectKeyboardAcceleratorSignals(); - - g_chat_edit_history.push_front(""); - #if TEST_BROWSE_INFO boost::shared_ptr<GG::BrowseInfoWnd> browser_wnd(new BrowseFoo()); GG::Wnd::SetDefaultBrowseInfoWnd(browser_wnd); @@ -469,13 +443,6 @@ RenderStarfields(); - unsigned int interval = GetOptionsDB().Get<int>("UI.chat-hide-interval"); - if (!m_chat_edit->Visible() && g_chat_display_show_time && interval && - (interval < (GG::GUI::GetGUI()->Ticks() - g_chat_display_show_time) / 1000)) { - m_chat_display->Hide(); - g_chat_display_show_time = 0; - } - GG::Pt origin_offset = UpperLeft() + GG::Pt(GG::GUI::GetGUI()->AppWidth(), GG::GUI::GetGUI()->AppHeight()); glPushMatrix(); glLoadIdentity(); @@ -506,123 +473,6 @@ glPopMatrix(); } -void MapWnd::KeyPress(GG::Key key, boost::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys) -{ - switch (key) { - case GG::GGK_TAB: { // auto-complete current chat edit word - if (m_chat_edit->Visible()) { - std::string text = m_chat_edit->Text(); - std::pair<GG::CPSize, GG::CPSize> cursor_pos = m_chat_edit->CursorPosn(); - if (cursor_pos.first == cursor_pos.second && 0 < cursor_pos.first && cursor_pos.first <= text.size()) { - std::string::size_type word_start = text.substr(0, Value(cursor_pos.first)).find_last_of(" :"); - if (word_start == std::string::npos) - word_start = 0; - else - ++word_start; - std::string partial_word = text.substr(word_start, Value(cursor_pos.first - word_start)); - if (partial_word == "") - return; - std::set<std::string> names; - // add player and empire names - for (EmpireManager::const_iterator it = Empires().begin(); it != Empires().end(); ++it) { - names.insert(it->second->Name()); - names.insert(it->second->PlayerName()); - } - // add system names - std::vector<System*> systems = GetUniverse().FindObjects<System>(); - for (unsigned int i = 0; i < systems.size(); ++i) { - if (systems[i]->Name() != "") - names.insert(systems[i]->Name()); - } - - if (names.find(partial_word) != names.end()) { // if there's an exact match, just add a space - text.insert(Value(cursor_pos.first), " "); - m_chat_edit->SetText(text); - m_chat_edit->SelectRange(cursor_pos.first + 1, cursor_pos.first + 1); - } else { // no exact match; look for possible completions - // find the range of strings in names that is at least partially matched by partial_word - std::set<std::string>::iterator lower_bound = names.lower_bound(partial_word); - std::set<std::string>::iterator upper_bound = lower_bound; - while (upper_bound != names.end() && upper_bound->find(partial_word) == 0) - ++upper_bound; - if (lower_bound == upper_bound) - return; - - // find the common portion of the strings in (upper_bound, lower_bound) - unsigned int common_end = partial_word.size(); - for ( ; common_end < lower_bound->size(); ++common_end) { - std::set<std::string>::iterator it = lower_bound; - char ch = (*it++)[common_end]; - bool match = true; - for ( ; it != upper_bound; ++it) { - if ((*it)[common_end] != ch) { - match = false; - break; - } - } - if (!match) - break; - } - unsigned int chars_to_add = common_end - partial_word.size(); - bool full_completion = common_end == lower_bound->size(); - text.insert(Value(cursor_pos.first), lower_bound->substr(partial_word.size(), chars_to_add) + (full_completion ? " " : "")); - m_chat_edit->SetText(text); - GG::CPSize move_cursor_to = cursor_pos.first + chars_to_add + (full_completion ? GG::CP1 : GG::CP0); - m_chat_edit->SelectRange(move_cursor_to, move_cursor_to); - } - } - } - break; - } - case GG::GGK_RETURN: - case GG::GGK_KP_ENTER: { // send chat message - if (m_chat_edit->Visible()) { - std::string edit_text = m_chat_edit->Text(); - if (edit_text != "") { - if (g_chat_edit_history.size() == 1 || g_chat_edit_history[1] != edit_text) { - g_chat_edit_history[0] = edit_text; - g_chat_edit_history.push_front(""); - } else { - g_chat_edit_history[0] = ""; - } - while (GetOptionsDB().Get<int>("UI.chat-edit-history") < static_cast<int>(g_chat_edit_history.size()) + 1) - g_chat_edit_history.pop_back(); - g_history_position = 0; - HumanClientApp::GetApp()->Networking().SendMessage(GlobalChatMessage(HumanClientApp::GetApp()->PlayerID(), edit_text)); - } - m_chat_edit->Clear(); - m_chat_edit->Hide(); - EnableAlphaNumAccels(); - - GG::GUI::GetGUI()->SetFocusWnd(this); - g_chat_display_show_time = GG::GUI::GetGUI()->Ticks(); - } - break; - } - - case GG::GGK_UP: { - if (m_chat_edit->Visible() && g_history_position < static_cast<int>(g_chat_edit_history.size()) - 1) { - g_chat_edit_history[g_history_position] = m_chat_edit->Text(); - ++g_history_position; - m_chat_edit->SetText(g_chat_edit_history[g_history_position]); - } - break; - } - - case GG::GGK_DOWN: { - if (m_chat_edit->Visible() && 0 < g_history_position) { - g_chat_edit_history[g_history_position] = m_chat_edit->Text(); - --g_history_position; - m_chat_edit->SetText(g_chat_edit_history[g_history_position]); - } - break; - } - - default: - break; - } -} - void MapWnd::LButtonDown(const GG::Pt &pt, GG::Flags<GG::ModKey> mod_keys) { m_drag_offset = pt - ClientUpperLeft(); @@ -634,8 +484,6 @@ CorrectMapPosition(move_to_pt); GG::Pt final_move = move_to_pt - ClientUpperLeft(); m_side_panel->OffsetMove(-final_move); - m_chat_display->OffsetMove(-final_move); - m_chat_edit->OffsetMove(-final_move); m_sitrep_panel->OffsetMove(-final_move); MoveTo(move_to_pt - GG::Pt(GG::GUI::GetGUI()->AppWidth(), GG::GUI::GetGUI()->AppHeight())); @@ -1082,7 +930,7 @@ ShowSitRep(); - m_chat_edit->Hide(); + GetChatWnd()->HideEdit(); EnableAlphaNumAccels(); @@ -1289,8 +1137,6 @@ GG::Pt map_move = map_ul - ul; OffsetMove(map_move); m_side_panel->OffsetMove(-map_move); - m_chat_display->OffsetMove(-map_move); - m_chat_edit->OffsetMove(-map_move); m_sitrep_panel->OffsetMove(-map_move); // this correction ensures that zooming in doesn't leave too large a margin to the side @@ -1298,8 +1144,6 @@ CorrectMapPosition(move_to_pt); GG::Pt final_move = move_to_pt - ul; m_side_panel->OffsetMove(-final_move); - m_chat_display->OffsetMove(-final_move); - m_chat_edit->OffsetMove(-final_move); m_sitrep_panel->OffsetMove(-final_move); MoveTo(move_to_pt - GG::Pt(GG::GUI::GetGUI()->AppWidth(), GG::GUI::GetGUI()->AppHeight())); @@ -1319,13 +1163,6 @@ } } -void MapWnd::HandlePlayerChatMessage(const std::string& msg) -{ - *m_chat_display += msg; - m_chat_display->Show(); - g_chat_display_show_time = GG::GUI::GetGUI()->Ticks(); -} - void MapWnd::CenterOnMapCoord(double x, double y) { GG::Pt ul = ClientUpperLeft(); @@ -1335,8 +1172,6 @@ static_cast<GG::Y>((current_y - y) * m_zoom_factor)); OffsetMove(map_move); m_side_panel->OffsetMove(-map_move); - m_chat_display->OffsetMove(-map_move); - m_chat_edit->OffsetMove(-map_move); m_sitrep_panel->OffsetMove(-map_move); // this correction ensures that the centering doesn't leave too large a margin to the side @@ -1344,8 +1179,6 @@ CorrectMapPosition(move_to_pt); GG::Pt final_move = move_to_pt - ul; m_side_panel->OffsetMove(-final_move); - m_chat_display->OffsetMove(-final_move); - m_chat_edit->OffsetMove(-final_move); m_sitrep_panel->OffsetMove(-final_move); MoveTo(move_to_pt - GG::Pt(GG::GUI::GetGUI()->AppWidth(), GG::GUI::GetGUI()->AppHeight())); @@ -1652,8 +1485,6 @@ static_cast<GG::Y>((center_y + ul_offset_y) - ul.y)); OffsetMove(map_move); m_side_panel->OffsetMove(-map_move); - m_chat_display->OffsetMove(-map_move); - m_chat_edit->OffsetMove(-map_move); m_sitrep_panel->OffsetMove(-map_move); // this correction ensures that zooming in doesn't leave too large a margin to the side @@ -1661,8 +1492,6 @@ CorrectMapPosition(move_to_pt); GG::Pt final_move = move_to_pt - ul; m_side_panel->OffsetMove(-final_move); - m_chat_display->OffsetMove(-final_move); - m_chat_edit->OffsetMove(-final_move); m_sitrep_panel->OffsetMove(-final_move); MoveTo(move_to_pt - GG::Pt(GG::GUI::GetGUI()->AppWidth(), GG::GUI::GetGUI()->AppHeight())); @@ -2242,9 +2071,6 @@ GG::Pt sp_lr = sp_ul + GG::Pt(SIDEPANEL_WIDTH, m_side_panel->Height()); m_side_panel->SizeMove(sp_ul, sp_lr); - m_chat_display->MoveTo(GG::Pt(GG::X(LAYOUT_MARGIN), m_turn_update->LowerRight().y + LAYOUT_MARGIN)); - m_chat_display->Clear(); - m_chat_edit->MoveTo(GG::Pt(GG::X(LAYOUT_MARGIN), APP_HEIGHT - CHAT_EDIT_HEIGHT - LAYOUT_MARGIN)); m_sitrep_panel->MoveTo(GG::Pt((APP_WIDTH - SITREP_PANEL_WIDTH) / 2, (APP_HEIGHT - SITREP_PANEL_HEIGHT) / 2)); m_sitrep_panel->Resize(GG::Pt(SITREP_PANEL_WIDTH, SITREP_PANEL_HEIGHT)); MoveTo(GG::Pt(-APP_WIDTH, -APP_HEIGHT)); @@ -2274,16 +2100,12 @@ bool MapWnd::OpenChatWindow() { - if (!m_chat_display->Visible() || !m_chat_edit->Visible()) { - EnableAlphaNumAccels(); - m_chat_display->Show(); + bool retval = true; + if (GetChatWnd()->OpenForInput()) DisableAlphaNumAccels(); - m_chat_edit->Show(); - GG::GUI::GetGUI()->SetFocusWnd(m_chat_edit); - g_chat_display_show_time = GG::GUI::GetGUI()->Ticks(); - return true; - } - return false; + else + retval = false; + return retval; } bool MapWnd::EndTurn() @@ -2925,48 +2747,88 @@ void MapWnd::ConnectKeyboardAcceleratorSignals() { - // disconnect and clear old signals - for (std::set<boost::signals::connection>::iterator it = m_keyboard_accelerator_signals.begin(); it != m_keyboard_accelerator_signals.end(); ++it) - it->disconnect(); - m_keyboard_accelerator_signals.clear(); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_ESCAPE), + &MapWnd::ReturnToMap, this)); - // connect new signals - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_ESCAPE), &MapWnd::ReturnToMap, this); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_RETURN), + &MapWnd::OpenChatWindow, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_KP_ENTER), + &MapWnd::OpenChatWindow, this)); - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_RETURN), &MapWnd::OpenChatWindow, this); - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_KP_ENTER), &MapWnd::OpenChatWindow, this); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_RETURN, GG::MOD_KEY_CTRL), + &MapWnd::EndTurn, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_KP_ENTER, GG::MOD_KEY_CTRL), + &MapWnd::EndTurn, this)); - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_RETURN, GG::MOD_KEY_CTRL), &MapWnd::EndTurn, this); - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_KP_ENTER, GG::MOD_KEY_CTRL), &MapWnd::EndTurn, this); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_F2), + &MapWnd::ToggleSitRep, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_F3), + &MapWnd::ToggleResearch, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_F4), + &MapWnd::ToggleProduction, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_F5), + &MapWnd::ToggleDesign, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_F10), + &MapWnd::ShowMenu, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_s), + &MapWnd::CloseSystemView, this)); - 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); - // Keys for zooming - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_e), &MapWnd::KeyboardZoomIn, this); - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_KP_PLUS), &MapWnd::KeyboardZoomIn, this); - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_r), &MapWnd::KeyboardZoomOut, this); - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_KP_MINUS), &MapWnd::KeyboardZoomOut, this); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_e), + &MapWnd::KeyboardZoomIn, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_KP_PLUS), + &MapWnd::KeyboardZoomIn, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_r), + &MapWnd::KeyboardZoomOut, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_KP_MINUS), + &MapWnd::KeyboardZoomOut, this)); // Keys for showing systems - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_d), &MapWnd::ZoomToHomeSystem, this); - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_x), &MapWnd::ZoomToPrevOwnedSystem, this); - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_c), &MapWnd::ZoomToNextOwnedSystem, this); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_d), + &MapWnd::ZoomToHomeSystem, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_x), + &MapWnd::ZoomToPrevOwnedSystem, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_c), + &MapWnd::ZoomToNextOwnedSystem, this)); // Keys for showing fleets - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_f), &MapWnd::ZoomToPrevIdleFleet, this); - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_g), &MapWnd::ZoomToNextIdleFleet, this); - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_v), &MapWnd::ZoomToPrevFleet, this); - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_b), &MapWnd::ZoomToNextFleet, this); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_f), + &MapWnd::ZoomToPrevIdleFleet, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_g), + &MapWnd::ZoomToNextIdleFleet, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_v), + &MapWnd::ZoomToPrevFleet, this)); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_b), + &MapWnd::ZoomToNextFleet, this)); #ifndef FREEORION_RELEASE // Previously-used but presently ignored development-only key combo for dumping // ValueRef, Condition, and Effect regression tests using the current Universe - GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_r, GG::MOD_KEY_CTRL), &RequestRegressionTestDump); + m_keyboard_accelerator_signals.insert( + GG::Connect(GG::GUI::GetGUI()->AcceleratorSignal(GG::GGK_r, GG::MOD_KEY_CTRL), + &RequestRegressionTestDump)); #endif } @@ -3007,6 +2869,8 @@ #ifndef FREEORION_RELEASE GG::GUI::GetGUI()->SetAccelerator(GG::GGK_r, GG::MOD_KEY_CTRL); #endif + + ConnectKeyboardAcceleratorSignals(); } void MapWnd::RemoveAccelerators() @@ -3017,6 +2881,14 @@ i = GG::GUI::GetGUI()->accel_begin(); } m_disabled_accels_list.clear(); + + for (std::set<boost::signals::connection>::iterator it = + m_keyboard_accelerator_signals.begin(); + it != m_keyboard_accelerator_signals.end(); + ++it) { + it->disconnect(); + } + m_keyboard_accelerator_signals.clear(); } void MapWnd::DisableAlphaNumAccels() @@ -3046,6 +2918,14 @@ m_disabled_accels_list.clear(); } +void MapWnd::ChatMessageSentSlot() +{ + if (!m_disabled_accels_list.empty()) { + EnableAlphaNumAccels(); + GG::GUI::GetGUI()->SetFocusWnd(this); + } +} + void MapWnd::CloseAllPopups() { for (std::list<MapWndPopup*>::iterator it = m_popups.begin(); it != m_popups.end(); ) { Modified: trunk/FreeOrion/UI/MapWnd.h =================================================================== --- trunk/FreeOrion/UI/MapWnd.h 2009-02-14 23:15:25 UTC (rev 2817) +++ trunk/FreeOrion/UI/MapWnd.h 2009-02-15 02:51:09 UTC (rev 2818) @@ -74,7 +74,6 @@ //! \name Mutators //!@{ virtual void Render(); - virtual void KeyPress (GG::Key key, boost::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys); virtual void LButtonDown(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys); virtual void LDrag(const GG::Pt& pt, const GG::Pt& move, GG::Flags<GG::ModKey> mod_keys); virtual void LButtonUp(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys); @@ -86,7 +85,6 @@ void RestoreFromSaveData(const SaveGameUIData& data); //!< restores the UI state that was saved in an earlier call to GetSaveGameUIData(). void ShowSystemNames(); //!< enables the system name text void HideSystemNames(); //!< disables the system name text - void HandlePlayerChatMessage(const std::string& msg); //!< displays incoming player chat text mutable SystemLeftClickedSignalType SystemLeftClickedSignal; mutable SystemRightClickedSignalType SystemRightClickedSignal; @@ -226,6 +224,8 @@ void DisableAlphaNumAccels(); void EnableAlphaNumAccels(); //!< Re-enable accelerators disabled by DisableAlphaNumAccels + void ChatMessageSentSlot(); + void CloseAllPopups(); void HideAllPopups(); void ShowAllPopups(); @@ -247,8 +247,6 @@ 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) std::vector<boost::signals::connection> m_fleet_state_change_signals; Modified: trunk/FreeOrion/client/human/HumanClientFSM.cpp =================================================================== --- trunk/FreeOrion/client/human/HumanClientFSM.cpp 2009-02-14 23:15:25 UTC (rev 2817) +++ trunk/FreeOrion/client/human/HumanClientFSM.cpp 2009-02-15 02:51:09 UTC (rev 2818) @@ -4,6 +4,7 @@ #include "../../Empire/Empire.h" #include "../../network/Networking.h" #include "../../util/MultiplayerCommon.h" +#include "../../UI/ChatWnd.h" #include "../../UI/CombatWnd.h" #include "../../UI/IntroScreen.h" #include "../../UI/TurnProgressWnd.h" @@ -507,7 +508,7 @@ else sender_colour = GG::CLR_WHITE; std::string wrapped_text = RgbaTag(sender_colour) + sender_name + ": " + msg.m_message.Text() + "</rgba>\n"; - Client().m_ui->GetMapWnd()->HandlePlayerChatMessage(wrapped_text); + GetChatWnd()->HandlePlayerChatMessage(wrapped_text); return discard_event(); } |
From: <tz...@us...> - 2009-02-18 03:22:24
|
Revision: 2825 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2825&view=rev Author: tzlaine Date: 2009-02-18 02:12:47 +0000 (Wed, 18 Feb 2009) Log Message: ----------- Removed old instrumentation. Modified Paths: -------------- trunk/FreeOrion/client/human/HumanClientApp.cpp trunk/FreeOrion/server/ServerFSM.cpp Modified: trunk/FreeOrion/client/human/HumanClientApp.cpp =================================================================== --- trunk/FreeOrion/client/human/HumanClientApp.cpp 2009-02-18 02:02:06 UTC (rev 2824) +++ trunk/FreeOrion/client/human/HumanClientApp.cpp 2009-02-18 02:12:47 UTC (rev 2825) @@ -77,6 +77,8 @@ namespace { const unsigned int SERVER_CONNECT_TIMEOUT = 30000; // in ms + const bool INSTRUMENT_MESSAGE_HANDLING = false; + // command-line options void AddOptions(OptionsDB& db) { @@ -469,7 +471,8 @@ void HumanClientApp::HandleMessage(Message& msg) { - std::cout << "HumanClientApp::HandleMessage(" << MessageTypeStr(msg.Type()) << ")" << std::endl; + if (INSTRUMENT_MESSAGE_HANDLING) + std::cerr << "HumanClientApp::HandleMessage(" << MessageTypeStr(msg.Type()) << ")\n"; switch (msg.Type()) { case Message::HOST_MP_GAME: m_fsm->process_event(HostMPGame(msg)); break; @@ -498,7 +501,8 @@ void HumanClientApp::HandleSaveGameDataRequest() { - std::cout << "HumanClientApp::HandleSaveGameDataRequest(" << MessageTypeStr(Message::SAVE_GAME) << ")" << std::endl; + if (INSTRUMENT_MESSAGE_HANDLING) + std::cerr << "HumanClientApp::HandleSaveGameDataRequest(" << MessageTypeStr(Message::SAVE_GAME) << ")\n"; SaveGameUIData ui_data; m_ui->GetSaveGameUIData(ui_data); Networking().SendMessage(ClientSaveDataMessage(PlayerID(), Orders(), ui_data)); Modified: trunk/FreeOrion/server/ServerFSM.cpp =================================================================== --- trunk/FreeOrion/server/ServerFSM.cpp 2009-02-18 02:02:06 UTC (rev 2824) +++ trunk/FreeOrion/server/ServerFSM.cpp 2009-02-18 02:12:47 UTC (rev 2825) @@ -723,10 +723,6 @@ order_set.reset(new OrderSet(*existing_orders)); else order_set.reset(new OrderSet(received_orders)); - std::cout << "Received save game data from player " - << player_connection->PlayerName() - << " ... " << std::distance(order_set->begin(), order_set->end()) << " orders received" - << std::endl; if (!ui_data_available) ui_data.reset(); if (!save_state_string_available) |
From: <tz...@us...> - 2009-02-18 03:22:28
|
Revision: 2824 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2824&view=rev Author: tzlaine Date: 2009-02-18 02:02:06 +0000 (Wed, 18 Feb 2009) Log Message: ----------- Added a custom OISInput.cfg that enforces exclusive mouse mode on Win32. This means that the Windows cursor will no longer obscure the FO cursor in windowed mode. Modified Paths: -------------- trunk/FreeOrion/SConstruct Added Paths: ----------- trunk/FreeOrion/OISInput.cfg Added: trunk/FreeOrion/OISInput.cfg =================================================================== --- trunk/FreeOrion/OISInput.cfg (rev 0) +++ trunk/FreeOrion/OISInput.cfg 2009-02-18 02:02:06 UTC (rev 2824) @@ -0,0 +1,19 @@ +# Defines the settings for the OgreGUI OISInput plugin + +# Define Win32 settings +w32_keyboard=DISCL_FOREGROUND +w32_keyboard=DISCL_NONEXCLUSIVE +#w32_keyboard=DISCL_NOWINKEY +w32_mouse=DISCL_FOREGROUND +w32_mouse=DISCL_EXCLUSIVE +w32_joystick=DISCL_FOREGROUND +w32_joystick=DISCL_NONEXCLUSIVE + +# Define X11 settings +x11_mouse_grab=false +x11_mouse_hide=true +x11_keyboard_grab=false +XAutoRepeatOn=true + +# Define Mac settings +MacAutoRepeatOn=true Modified: trunk/FreeOrion/SConstruct =================================================================== --- trunk/FreeOrion/SConstruct 2009-02-17 02:41:47 UTC (rev 2823) +++ trunk/FreeOrion/SConstruct 2009-02-18 02:02:06 UTC (rev 2824) @@ -584,7 +584,6 @@ shutil.copy(os.path.join('..', 'lib', 'GiGi.dll'), '.') shutil.copy(os.path.join('..', 'lib', 'GiGiOgre.dll'), '.') shutil.copy(os.path.join('..', 'lib', 'GiGiOgrePlugin_OIS.dll'), '.') - shutil.copy(os.path.join('GG', 'src', 'Ogre', 'Plugins', 'OISInput.cfg'), '.') # create Ogre plugin config file CreateOgrePluginsFile(['ogre_plugins.cfg'], ['ogre_plugins.cfg.in'], env) |