From: <geo...@us...> - 2013-10-13 22:24:04
|
Revision: 6444 http://sourceforge.net/p/freeorion/code/6444 Author: geoffthemedio Date: 2013-10-13 22:24:00 +0000 (Sun, 13 Oct 2013) Log Message: ----------- Added "core" slot type, with parsing and background art. Modified Paths: -------------- trunk/FreeOrion/UI/DesignWnd.cpp trunk/FreeOrion/default/stringtables/en.txt trunk/FreeOrion/parse/EnumParser.cpp trunk/FreeOrion/parse/Tokens.h trunk/FreeOrion/universe/Enums.h Added Paths: ----------- trunk/FreeOrion/default/data/art/icons/ship_parts/core_part.png trunk/FreeOrion/default/data/art/icons/ship_parts/core_slot.png Modified: trunk/FreeOrion/UI/DesignWnd.cpp =================================================================== --- trunk/FreeOrion/UI/DesignWnd.cpp 2013-10-12 23:58:32 UTC (rev 6443) +++ trunk/FreeOrion/UI/DesignWnd.cpp 2013-10-13 22:24:00 UTC (rev 6444) @@ -43,6 +43,8 @@ return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "ship_parts" / "external_slot.png", true); else if (slot_type == SL_INTERNAL) return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "ship_parts" / "internal_slot.png", true); + else if (slot_type == SL_CORE) + return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "ship_parts" / "core_slot.png", true); else return ClientUI::GetTexture(ClientUI::ArtDir() / "misc" / "missing.png", true); } @@ -53,6 +55,7 @@ if (part) { bool ex = part->CanMountInSlotType(SL_EXTERNAL); bool in = part->CanMountInSlotType(SL_INTERNAL); + bool co = part->CanMountInSlotType(SL_CORE); if (ex && in) return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "ship_parts" / "independent_part.png", true); @@ -60,6 +63,8 @@ return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "ship_parts" / "external_part.png", true); else if (in) return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "ship_parts" / "internal_part.png", true); + else if (co) + return ClientUI::GetTexture(ClientUI::ArtDir() / "icons" / "ship_parts" / "core_part.png", true); } return ClientUI::GetTexture(ClientUI::ArtDir() / "misc" / "missing.png", true); } @@ -1556,9 +1561,16 @@ SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); // set up empty slot tool tip + std::string title_text; + if (slot_type == SL_EXTERNAL) + title_text = UserString("SL_EXTERNAL"); + else if (slot_type == SL_INTERNAL) + title_text = UserString("SL_INTERNAL"); + else if (slot_type == SL_CORE) + title_text = UserString("SL_CORE"); + SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>( - new IconTextBrowseWnd(SlotBackgroundTexture(m_slot_type), ((slot_type == SL_EXTERNAL) ? UserString("SL_EXTERNAL") : UserString("SL_INTERNAL")), UserString("SL_TOOLTIP_DESC")))); - + new IconTextBrowseWnd(SlotBackgroundTexture(m_slot_type), title_text, UserString("SL_TOOLTIP_DESC")))); } void SlotControl::DropsAcceptable(DropsAcceptableIter first, DropsAcceptableIter last, const GG::Pt& pt) const { @@ -1684,9 +1696,19 @@ boost::bind(&SlotControl::EmitNullSlotContentsAlteredSignal, this)); SetBrowseModeTime(GetOptionsDB().Get<int>("UI.tooltip-delay")); - // set part occupying slot's tool tip to say slot type as well + // set part occupying slot's tool tip to say slot type + std::string title_text; + if (m_slot_type == SL_EXTERNAL) + title_text = UserString("SL_EXTERNAL"); + else if (m_slot_type == SL_INTERNAL) + title_text = UserString("SL_INTERNAL"); + else if (m_slot_type == SL_CORE) + title_text = UserString("SL_CORE"); + m_part_control->SetBrowseInfoWnd(boost::shared_ptr<GG::BrowseInfoWnd>( - new IconTextBrowseWnd(ClientUI::PartIcon(part_type->Name()), UserString(part_type->Name()) + " (" + ((m_slot_type == SL_EXTERNAL) ? UserString("SL_EXTERNAL") : UserString("SL_INTERNAL")) + ")", UserString(part_type->Description())))); + new IconTextBrowseWnd(ClientUI::PartIcon(part_type->Name()), + UserString(part_type->Name()) + " (" + title_text + ")", + UserString(part_type->Description())))); } } @@ -1939,12 +1961,11 @@ return true; } -int DesignWnd::MainPanel::FindEmptySlotForPart(const PartType* part) -{ +int DesignWnd::MainPanel::FindEmptySlotForPart(const PartType* part) { int result = -1; - if (!part) return result; + for (unsigned int i = 0; i < m_slots.size(); ++i) { // scan through slots to find one that can mount part const ShipSlotType slot_type = m_slots[i]->SlotType(); const PartType* part_type = m_slots[i]->GetPart(); // check if this slot is empty @@ -1957,12 +1978,12 @@ return result; } -std::pair<int, int> DesignWnd::MainPanel::FindSlotForPartWithSwapping(const PartType* part) -{ +std::pair<int, int> DesignWnd::MainPanel::FindSlotForPartWithSwapping(const PartType* part) { // result.first = swap_slot, result.second = empty_slot std::pair<int, int> result = std::make_pair(-1, -1); - if (!part) + // TODO: allow for swapping of core slot parts + if (!part || (!part->CanMountInSlotType(SL_EXTERNAL) && !part->CanMountInSlotType(SL_INTERNAL))) return result; for (unsigned int i = 0; i < m_slots.size(); ++i) { // scan through slots to find one that can mount part @@ -1973,11 +1994,12 @@ result.second = i; // Find a slot that has a part that can be mounted in both slots - // And that we are compatible with - if (part_type && part_type->CanMountInSlotType(SL_EXTERNAL) && part_type->CanMountInSlotType(SL_INTERNAL) - && part->CanMountInSlotType(slot_type)) { - result.first = i; - } + // And that we are compatible with + if (part_type && + part_type->CanMountInSlotType(SL_EXTERNAL) && + part_type->CanMountInSlotType(SL_INTERNAL) && + part->CanMountInSlotType(slot_type)) + { result.first = i; } } return result; } Added: trunk/FreeOrion/default/data/art/icons/ship_parts/core_part.png =================================================================== (Binary files differ) Index: trunk/FreeOrion/default/data/art/icons/ship_parts/core_part.png =================================================================== --- trunk/FreeOrion/default/data/art/icons/ship_parts/core_part.png 2013-10-12 23:58:32 UTC (rev 6443) +++ trunk/FreeOrion/default/data/art/icons/ship_parts/core_part.png 2013-10-13 22:24:00 UTC (rev 6444) Property changes on: trunk/FreeOrion/default/data/art/icons/ship_parts/core_part.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: trunk/FreeOrion/default/data/art/icons/ship_parts/core_slot.png =================================================================== (Binary files differ) Index: trunk/FreeOrion/default/data/art/icons/ship_parts/core_slot.png =================================================================== --- trunk/FreeOrion/default/data/art/icons/ship_parts/core_slot.png 2013-10-12 23:58:32 UTC (rev 6443) +++ trunk/FreeOrion/default/data/art/icons/ship_parts/core_slot.png 2013-10-13 22:24:00 UTC (rev 6444) Property changes on: trunk/FreeOrion/default/data/art/icons/ship_parts/core_slot.png ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Modified: trunk/FreeOrion/default/stringtables/en.txt =================================================================== --- trunk/FreeOrion/default/stringtables/en.txt 2013-10-12 23:58:32 UTC (rev 6443) +++ trunk/FreeOrion/default/stringtables/en.txt 2013-10-13 22:24:00 UTC (rev 6444) @@ -5291,6 +5291,8 @@ External Slot SL_INTERNAL Internal Slot +SL_CORE +Core Slot SL_TOOLTIP_DESC Empty Modified: trunk/FreeOrion/parse/EnumParser.cpp =================================================================== --- trunk/FreeOrion/parse/EnumParser.cpp 2013-10-12 23:58:32 UTC (rev 6443) +++ trunk/FreeOrion/parse/EnumParser.cpp 2013-10-13 22:24:00 UTC (rev 6444) @@ -205,6 +205,7 @@ static enum_parser_rule<ShipSlotType>::type retval = tok.External_ [ _val = SL_EXTERNAL ] | tok.Internal_ [ _val = SL_INTERNAL ] + | tok.Core_ [ _val = SL_CORE ] ; static bool once = true; if (once) { Modified: trunk/FreeOrion/parse/Tokens.h =================================================================== --- trunk/FreeOrion/parse/Tokens.h 2013-10-12 23:58:32 UTC (rev 6443) +++ trunk/FreeOrion/parse/Tokens.h 2013-10-13 22:24:00 UTC (rev 6444) @@ -58,6 +58,7 @@ (Construction) \ (ContainedBy) \ (Contains) \ + (Core) \ (Cos) \ (Count) \ (CountUnique) \ Modified: trunk/FreeOrion/universe/Enums.h =================================================================== --- trunk/FreeOrion/universe/Enums.h 2013-10-12 23:58:32 UTC (rev 6443) +++ trunk/FreeOrion/universe/Enums.h 2013-10-13 22:24:00 UTC (rev 6444) @@ -561,6 +561,7 @@ INVALID_SHIP_SLOT_TYPE = -1, SL_EXTERNAL, ///< external slots. more easily damaged SL_INTERNAL, ///< internal slots. more protected, fewer in number + SL_CORE, NUM_SHIP_SLOT_TYPES }; @@ -569,6 +570,7 @@ GG_ENUM_MAP_INSERT(INVALID_SHIP_SLOT_TYPE) GG_ENUM_MAP_INSERT(SL_EXTERNAL) GG_ENUM_MAP_INSERT(SL_INTERNAL) + GG_ENUM_MAP_INSERT(SL_CORE) GG_ENUM_MAP_END } GG_ENUM_STREAM_IN(ShipSlotType) |