Skip to content

Commit

Permalink
Add an SDF picker for selecting a stuff done flag and optionally givi…
Browse files Browse the repository at this point in the history
…ng it a name.

In effect, this is a combination of two of the previous pickers:
the location picker, and the editable string picker.

This required quite a significant rework of how the tilemap places its children.

Currently it's only used in special node editing.
I plan to add its use in many other places too though.
  • Loading branch information
CelticMinstrel committed Mar 2, 2025
1 parent f3ebadb commit e3b81b6
Show file tree
Hide file tree
Showing 27 changed files with 504 additions and 62 deletions.
2 changes: 2 additions & 0 deletions proj/vs2013/ScenEdit/Scen Editor.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
<ClCompile Include="..\..\..\src\scenedit\scen.locpicker.cpp" />
<ClCompile Include="..\..\..\src\scenedit\scen.main.cpp" />
<ClCompile Include="..\..\..\src\scenedit\scen.menus.win.cpp" />
<ClCompile Include="..\..\..\src\scenedit\scen.sdfpicker.cpp" />
<ClCompile Include="..\..\..\src\scenedit\scen.townout.cpp" />
</ItemGroup>
<ItemGroup>
Expand All @@ -122,6 +123,7 @@
<ClInclude Include="..\..\..\src\scenedit\scen.keydlgs.hpp" />
<ClInclude Include="..\..\..\src\scenedit\scen.locpicker.hpp" />
<ClInclude Include="..\..\..\src\scenedit\scen.menus.hpp" />
<ClInclude Include="..\..\..\src\scenedit\scen.sdfpicker.hpp" />
<ClInclude Include="..\..\..\src\scenedit\scen.townout.hpp" />
<ClInclude Include="..\..\..\rsrc\menus\scenresource.h" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions proj/vs2013/ScenEdit/Scen Editor.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<ClCompile Include="..\..\..\src\scenedit\scen.townout.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\scenedit\scen.sdfpicker.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\scenedit\scen.menus.win.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -53,6 +56,9 @@
<ClInclude Include="..\..\..\src\scenedit\scen.townout.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\scenedit\scen.sdfpicker.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\scenedit\scen.menus.hpp">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
2 changes: 2 additions & 0 deletions proj/vs2017/Scenario Editor/Scenario Editor.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
<ClCompile Include="..\..\..\src\scenedit\scen.locpicker.cpp" />
<ClCompile Include="..\..\..\src\scenedit\scen.main.cpp" />
<ClCompile Include="..\..\..\src\scenedit\scen.menus.win.cpp" />
<ClCompile Include="..\..\..\src\scenedit\scen.sdfpicker.cpp" />
<ClCompile Include="..\..\..\src\scenedit\scen.townout.cpp" />
<ClCompile Include="..\..\..\src\fileio\fileio_party.cpp" />
<ClCompile Include="..\..\..\src\universe\universe.cpp" />
Expand All @@ -179,6 +180,7 @@
<ClInclude Include="..\..\..\src\scenedit\scen.graphics.hpp" />
<ClInclude Include="..\..\..\src\scenedit\scen.keydlgs.hpp" />
<ClInclude Include="..\..\..\src\scenedit\scen.locpicker.hpp" />
<ClInclude Include="..\..\..\src\scenedit\scen.sdfpicker.hpp" />
<ClInclude Include="..\..\..\src\scenedit\scen.menus.hpp" />
<ClInclude Include="..\..\..\src\scenedit\scen.townout.hpp" />
</ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions proj/vs2017/Scenario Editor/Scenario Editor.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
<ClCompile Include="..\..\..\src\scenedit\scen.menus.win.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ClCompile>
<ClCompile Include="..\..\..\src\scenedit\scen.sdfpicker.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\scenedit\scen.townout.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -83,6 +87,9 @@
<ClInclude Include="..\..\..\src\scenedit\scen.menus.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\scenedit\scen.sdfpicker.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\scenedit\scen.townout.hpp">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
6 changes: 6 additions & 0 deletions proj/xc12/BoE.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
915AF9E81BBF8B5C008AEF49 /* scrollpane.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 919B13A81BBE2B54009905A4 /* scrollpane.cpp */; };
9170C50F2D717F24009B6E7C /* scen.locpicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9170C50C2D717F24009B6E7C /* scen.locpicker.cpp */; };
9170C5102D717F24009B6E7C /* scen.locpicker.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 9170C50D2D717F24009B6E7C /* scen.locpicker.hpp */; };
9170C5272D74237A009B6E7C /* scen.sdfpicker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9170C5252D74237A009B6E7C /* scen.sdfpicker.cpp */; };
9176FEC71D550EFE006EF694 /* out_legacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9176FEC01D550EFC006EF694 /* out_legacy.cpp */; };
9176FEC81D550EFE006EF694 /* scen_legacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9176FEC11D550EFC006EF694 /* scen_legacy.cpp */; };
9176FECB1D550EFE006EF694 /* talk_legacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9176FEC41D550EFD006EF694 /* talk_legacy.cpp */; };
Expand Down Expand Up @@ -738,6 +739,8 @@
9169C31F1B37A5D50041002B /* BoE Scenario Editor.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "BoE Scenario Editor.app"; sourceTree = BUILT_PRODUCTS_DIR; };
9170C50C2D717F24009B6E7C /* scen.locpicker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = scen.locpicker.cpp; sourceTree = "<group>"; };
9170C50D2D717F24009B6E7C /* scen.locpicker.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = scen.locpicker.hpp; sourceTree = "<group>"; };
9170C5252D74237A009B6E7C /* scen.sdfpicker.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = scen.sdfpicker.cpp; sourceTree = "<group>"; };
9170C5262D74237A009B6E7C /* scen.sdfpicker.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = scen.sdfpicker.hpp; sourceTree = "<group>"; };
9176FEC01D550EFC006EF694 /* out_legacy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = out_legacy.cpp; sourceTree = "<group>"; };
9176FEC11D550EFC006EF694 /* scen_legacy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = scen_legacy.cpp; sourceTree = "<group>"; };
9176FEC41D550EFD006EF694 /* talk_legacy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = talk_legacy.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1452,6 +1455,7 @@
91B3EEE00F969BA700BF5B67 /* scen.keydlgs.hpp */,
9170C50D2D717F24009B6E7C /* scen.locpicker.hpp */,
914CA4641909B00100B6ADD1 /* scen.menus.hpp */,
9170C5262D74237A009B6E7C /* scen.sdfpicker.hpp */,
91B3EEE60F969BA700BF5B67 /* scen.townout.hpp */,
);
name = headers;
Expand All @@ -1470,6 +1474,7 @@
91B3EEEB0F969BA700BF5B67 /* scen.main.cpp */,
9170C50C2D717F24009B6E7C /* scen.locpicker.cpp */,
914CA45719074D0A00B6ADD1 /* scen.menus.mac.mm */,
9170C5252D74237A009B6E7C /* scen.sdfpicker.cpp */,
91B3EEF40F969BA700BF5B67 /* scen.townout.cpp */,
);
name = src;
Expand Down Expand Up @@ -2206,6 +2211,7 @@
413AAF652D38A48E002E9BF1 /* pc.cpp in Sources */,
413AAF642D38A47C002E9BF1 /* population.cpp in Sources */,
9170C50F2D717F24009B6E7C /* scen.locpicker.cpp in Sources */,
9170C5272D74237A009B6E7C /* scen.sdfpicker.cpp in Sources */,
413AAF632D38A1B8002E9BF1 /* party.cpp in Sources */,
413AAF622D38A076002E9BF1 /* universe.cpp in Sources */,
413AAF612D389F94002E9BF1 /* fileio_party.cpp in Sources */,
Expand Down
25 changes: 25 additions & 0 deletions rsrc/dialogs/choose-sdf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
<dialog defbtn='done'>
<pict name='mainpic' type='dlog' num='16' top='6' left='6'/>
<text name='prompt' anchor='mainpic' relative='pos pos-in' size='large' top='0' left='12' width='248' height='14'>Select a Stuff Done Flag:</text>
<tilemap name='cols' anchor='mainpic' relative='pos' top='8' left='0' rows='1' cols='5' cellspacing='10'>
<text name='col' size='large' left='0' top='0' width='120' height='14' framed='false'>A</text>
</tilemap>
<tilemap name='rows' anchor='mainpic' relative='pos-in pos' top='24' left='0' rows='10' cols='1' cellspacing='10'>
<text name='row' size='large' left='0' top='0' width='35' height='14' framed='false'>1</text>
</tilemap>
<tilemap name='map' anchor='mainpic' relative='pos' framed='true' top='24' left='0' rows='10' cols='5' cellspacing='10'>
<mapgroup name='choice'>
<led name='select' left='0' top='2'/>
</mapgroup>
<field name='name' anchor='select' relative='pos neg' left='6' top='2' height='14' width='100'/>
</tilemap>
<text name='help' anchor='left' relative='pos-in pos' top='0' left='6' width='422' height='16'>Click button to left of graphic to select.<br/>Use arrows to change pages.</text>
<button name='left' anchor='map' relative='pos-in pos' type='left' top='10' left='0' def-key='left'/>
<button name='down' anchor='left' relative='pos pos-in' type='down' top='0' left='228' def-key='down'/>
<button name='right' anchor='down' relative='pos pos-in' type='right' top='0' left='228' def-key='right'/>
<button name='cancel' anchor='done' relative='neg pos-in' type='regular' top='0' left='67' def-key='esc'>Cancel</button>
<button name='done' anchor='right' relative='pos-in pos' type='done' top='4' left='0'/>
<button name='up' anchor='down' relative='pos-in neg' type='up' top='284' left='0' def-key='up'/>
</dialog>
1 change: 1 addition & 0 deletions rsrc/schemas/dialog.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@
<xs:element name="button" type="button"/>
<xs:element name="led" type="led"/>
<xs:element name="group" type="ledGroup"/>
<xs:element name="mapgroup" type="ledGroup"/>
<xs:element name="slider" type="slider"/>
</xs:choice>
<xs:attribute name="name" type="xs:token"/>
Expand Down
1 change: 1 addition & 0 deletions rsrc/schemas/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ attribute specifies which sound it applies to.
* `<event>` - (max unbounded) Gives a name to a major event flag. These names are shown (and editable) when showing the Pick Event dialog in various places. The required `id` attribute specifies which event.
* `<item-class>` - (max unbounded) Gives a name to an item special class. These names are shown (and editable) when showing the Pick Item Class dialog in various places. The required `id` attribute specifies which class.
* `<item-typeflag>` - (max unbounded) Gives a name to an item type flag. These names are shown (and editable) when showing the Pick Item Type Flag dialog in the item editor. The required `id` attribute specifies which flag.
* `<sdf>` - (max unbounded) Gives a name to a Stuff Done Flag. These names are shown (and editable) when showing the Pick Stuff Done Flag dialog in the item editor. The required `row` and `col` attributes specify which flag.

Terrain Types
-------------
Expand Down
22 changes: 22 additions & 0 deletions rsrc/schemas/scenario.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,28 @@
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="sdf" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="row" use="required">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:maxExclusive value="350"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="row" use="required">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:maxExclusive value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="scenario">
Expand Down
12 changes: 10 additions & 2 deletions src/dialogxml/dialogs/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,21 @@ void cDialog::loadFromFile(const DialogDefn& file){
}
});
if(!all_children_resolved) return;
pane->recalcRect();
pane->postChildrenResolve();
}
ctrl.relocateRelative(ctrl.frame.topLeft(), anchor, ctrl.horz, ctrl.vert);
ctrl.anchor.clear();
ctrl.horz = ctrl.vert = POS_ABS;
} else if(auto pane = dynamic_cast<cContainer*>(&ctrl)) {
pane->forEach(process_ctrl);
bool all_children_resolved = true;
pane->forEach([&process_ctrl, &all_children_resolved](std::string id, cControl& ctrl) {
if(!ctrl.anchor.empty()) {
all_children_resolved = false;
}
process_ctrl(id, ctrl);
});
if(!all_children_resolved) return;
pane->postChildrenResolve();
}
};

Expand Down
10 changes: 10 additions & 0 deletions src/dialogxml/widgets/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,13 @@ void cContainer::callHandler(event_fcn<EVT_CLICK>::type onClick, cDialog& me, st
if(!which_clicked.empty())
getChild(which_clicked).triggerClickHandler(me, which_clicked, mods);
}

void cContainer::validatePostParse(ticpp::Element& who, std::string fname, const std::set<std::string>& attrs, const std::multiset<std::string>& nodes) {
cControl::validatePostParse(who, fname, attrs, nodes);
if(!anchor.empty()) return;
bool allResolved = true;
forEach([&allResolved](std::string, cControl& ctrl) {
if(!ctrl.anchor.empty()) allResolved = false;
});
if(allResolved) postChildrenResolve();
}
4 changes: 4 additions & 0 deletions src/dialogxml/widgets/container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,15 @@ class cContainer : public cControl, public iNameGiver {
/// This may be called more than once, so it should not return the same value twice in a row,
/// unless it can guarantee the value is not already assigned to another control.
virtual std::string generateId(const std::string& explicitId) const override;
virtual void postChildrenResolve() {
recalcRect();
}
/// @copydoc getChild()
cControl& operator[](std::string id) {return getChild(id);}
const cControl& operator[](std::string id) const {return const_cast<cContainer&>(*this).getChild(id);}
bool isContainer() const override {return true;}
bool handleClick(location where, cFramerateLimiter& fps_limiter) override;
void validatePostParse(ticpp::Element& who, std::string fname, const std::set<std::string>& attrs, const std::multiset<std::string>& nodes) override;
private:
std::pair<std::string,cControl*> prevCtrl{"", nullptr};
};
Expand Down
13 changes: 13 additions & 0 deletions src/dialogxml/widgets/control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,19 @@ class cControl : public iComponent {
virtual void draw() = 0;
cControl& operator=(cControl& other) = delete;
cControl(cControl& other) = delete;
/// Sets the positioning method of this control.
/// Note: this only has an effect when called from another control's parse function.
void setPositioning(const std::string& anchor_id, ePosition h, ePosition v) {
anchor = anchor_id;
horz = h;
vert = v;
}
/// Get the positioning method of this control.
/// Note: After the parse stage, this information is lost and replaced with (ABS,ABS).
std::pair<ePosition, ePosition> getPositioning(std::string* anchor_id = nullptr) {
if(anchor_id) *anchor_id = anchor;
return {horz, vert};
}
protected:
/// Create a new control attached to a dialog.
/// @param t The type of the control.
Expand Down
1 change: 1 addition & 0 deletions src/dialogxml/widgets/ledgroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
/// However, when the focus handler of the LED group is called, the selection _has_ been updated.,
/// so getSelected() will return the new selection. (This is the reason for the getPreviousSelection() method.)
class cLedGroup : public cContainer {
friend class cTilemap; // So it can call parseAttribute
std::map<std::string,cLed*> choices;
std::string fromList;
std::string curSelect, prevSelect;
Expand Down
Loading

0 comments on commit e3b81b6

Please sign in to comment.