Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Commit 2884dbb

Browse files
committed
Implement MapTool NavigateToCoord
1 parent 9f595d5 commit 2884dbb

File tree

14 files changed

+221
-119
lines changed

14 files changed

+221
-119
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# FINALALERT2 - SP CHANGELOG
22

3+
## RELEASE 1.6.1 (2023-XX-XX)
4+
- New Map Tool: Navigate to coordinate, can be translated by `Menu.MapTools.NavigateCoordinate`, more locolization tags could be found in the document
5+
36
## RELEASE 1.6.0 (2023-04-30)
47
- **ONLY YURI's REVENGE WILL BE SUPPORTED SINCE FA2SP 1.6.0**
58
- Reimplemented file reading system

DOCUMENT.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ Now this feature supports RaiseSingleTile/LowerSingleTile (though they are not "
425425
Menu.MapTools.PaintCliffFront = TEXT
426426
Menu.MapTools.PaintCliffBack = TEXT
427427
Menu.MapTools.SearchWaypoint = TEXT
428+
Menu.MapTools.NavigateCoordinate = TEXT
428429
Menu.MapTools.ToolScripts = TEXT
429430
Menu.Online = TEXT
430431
Menu.Online.Westwood = TEXT
@@ -643,6 +644,11 @@ Now this feature supports RaiseSingleTile/LowerSingleTile (though they are not "
643644
AllieEditorOK = TEXT
644645
AllieEditorCancel = TEXT
645646
TileManagerTitle = TEXT
647+
NavigateCoordTitle = TEXT
648+
NavigateCoordMessage = TEXT
649+
NavigateCoordInvalidFormat = TEXT
650+
NavigateCoordInvalidCoord = TEXT
651+
NavigateCoordInvalidTitle = TEXT
646652
; Script params
647653
; For example, ScriptParam.Status.0
648654
ScriptParam.Target.[0 - 11] = TEXT

FA2sp.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@
197197
<ClCompile Include="FA2sp\Helpers\ControlHelpers.cpp" />
198198
<ClCompile Include="FA2sp\Helpers\InstructionSet.cpp" />
199199
<ClCompile Include="FA2sp\Helpers\MultimapHelper.cpp" />
200+
<ClCompile Include="FA2sp\Helpers\STDHelpers.cpp" />
200201
<ClCompile Include="FA2sp\Hooks.Debug.cpp" />
201202
<ClCompile Include="FA2sp\MFCWindow\Hooks.cpp" />
202203
<ClCompile Include="FA2sp\Miscs\Hooks.DirectDraw.cpp" />

FA2sp.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,9 @@
515515
<ClCompile Include="FA2sp\Helpers\InstructionSet.cpp">
516516
<Filter>源文件</Filter>
517517
</ClCompile>
518+
<ClCompile Include="FA2sp\Helpers\STDHelpers.cpp">
519+
<Filter>源文件</Filter>
520+
</ClCompile>
518521
</ItemGroup>
519522
<ItemGroup>
520523
<ResourceCompile Include="FA2sp\FA2sp.rc">

FA2sp/Ext/CFinalSunDlg/Body.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
#include "../CFinalSunApp/Body.h"
66

77
#include <CLoading.h>
8+
#include <CInputMessageBox.h>
89
#include "../../Miscs/Palettes.h"
10+
#include "../../Helpers/STDHelpers.h"
11+
12+
#include "../../Helpers/Translations.h"
913

1014
int CFinalSunDlgExt::CurrentLighting = 31000;
1115

@@ -132,6 +136,54 @@ BOOL CFinalSunDlgExt::OnCommandExt(WPARAM wParam, LPARAM lParam)
132136
this->LoadMap(file.c_str());
133137
}
134138

139+
// navigate to coordinate
140+
if (wmID == 40134 && CMapData::Instance->MapWidthPlusHeight)
141+
{
142+
while (true)
143+
{
144+
const ppmfc::CString title = Translations::TranslateOrDefault(
145+
"NavigateCoordTitle", "Navigate to coordinate"
146+
);
147+
const ppmfc::CString message = Translations::TranslateOrDefault(
148+
"NavigateCoordMessage", "Please input the coordinate in the format like X,Y"
149+
);
150+
const ppmfc::CString invalid_title = Translations::TranslateOrDefault(
151+
"NavigateCoordInvalidTitle", "Error!"
152+
);
153+
154+
const auto result = CInputMessageBox::GetString(message, title);
155+
156+
// canceled
157+
if (STDHelpers::IsNullOrWhitespace(result))
158+
break;
159+
160+
const auto data = STDHelpers::SplitString(result);
161+
if (data.size() != 2)
162+
{
163+
const ppmfc::CString invalid_format = Translations::TranslateOrDefault(
164+
"NavigateCoordInvalidFormat", "Invalid format!"
165+
);
166+
::MessageBox(NULL, invalid_format, invalid_title, MB_OK | MB_ICONERROR);
167+
continue;
168+
}
169+
170+
const int x = atoi(data[0]);
171+
const int y = atoi(data[1]);
172+
173+
if (!CMapData::Instance->IsCoordInMap(x, y))
174+
{
175+
const ppmfc::CString invalid_coord = Translations::TranslateOrDefault(
176+
"NavigateCoordInvalidCoord", "Invalid coordinate!"
177+
);
178+
::MessageBox(NULL, invalid_coord, invalid_title, MB_OK | MB_ICONERROR);
179+
continue;
180+
}
181+
182+
CIsoView::GetInstance()->MoveToMapCoord(x, y);
183+
break;
184+
}
185+
}
186+
135187
return this->ppmfc::CDialog::OnCommand(wParam, lParam);
136188
}
137189

FA2sp/Ext/CFinalSunDlg/Hooks.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ DEFINE_HOOK(43209D, CFinalSunDlg_Update_TranslateMenuItems, A)
159159
translateMenuItem(40092, "Menu.MapTools.PaintCliffFront");
160160
translateMenuItem(40093, "Menu.MapTools.PaintCliffBack");
161161
translateMenuItem(40133, "Menu.MapTools.SearchWaypoint");
162+
translateMenuItem(40134, "Menu.MapTools.NavigateCoordinate");
162163
translateMenuItem(40135, "Menu.MapTools.ToolScripts");
163164

164165
if (0)

FA2sp/Ext/CScriptTypes/Functional.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static void CScriptTypes_LoadParams_Waypoint(ppmfc::CComboBox& comboBox)
145145
memset(waypoints, -1, sizeof waypoints);
146146
if (auto entries = doc.GetSection("Waypoints"))
147147
for (auto& x : entries->GetEntities())
148-
if (x.first != "Name" && !STDHelpers::IsNullOrEmpty(x.second))
148+
if (x.first != "Name" && !STDHelpers::IsNoneOrEmpty(x.second))
149149
{
150150
int l = atoi(x.first);
151151
if (l <= 701 && l >= 0)
@@ -167,7 +167,7 @@ static void CScriptTypes_LoadParams_Waypoint(ppmfc::CComboBox& comboBox)
167167
std::map<int, int> waypoints;
168168
if (auto entries = doc.GetSection("Waypoints"))
169169
for (auto& x : entries->GetEntities())
170-
if (x.first != "Name" && !STDHelpers::IsNullOrEmpty(x.second))
170+
if (x.first != "Name" && !STDHelpers::IsNoneOrEmpty(x.second))
171171
{
172172
int l = atoi(x.first);
173173
if (l >= 0)
@@ -239,7 +239,7 @@ static void CScriptTypes_LoadParams_GlobalVariables(ppmfc::CComboBox& comboBox)
239239
CString text;
240240
for (auto& x : entities->GetEntities())
241241
{
242-
if (x.first != "Name" && !STDHelpers::IsNullOrEmpty(x.first))
242+
if (x.first != "Name" && !STDHelpers::IsNoneOrEmpty(x.first))
243243
{
244244
int l = atoi(x.first);
245245
text.Format("%d - %s", l, x.second);
@@ -260,7 +260,7 @@ static void CScriptTypes_LoadParams_ScriptTypes(ppmfc::CComboBox& comboBox)
260260
CString text, finaltext = "";
261261
for (auto& ent : entities->GetEntities())
262262
{
263-
if (doc.SectionExists(ent.second) && !STDHelpers::IsNullOrEmpty(ent.second))
263+
if (doc.SectionExists(ent.second) && !STDHelpers::IsNoneOrEmpty(ent.second))
264264
{
265265
int id = atoi(ent.first);
266266
text = doc.GetString(ent.second, "Name");
@@ -283,7 +283,7 @@ static void CScriptTypes_LoadParams_TeamTypes(ppmfc::CComboBox& comboBox)
283283
CString text, finaltext = "";
284284
for (auto& ent : entities->GetEntities())
285285
{
286-
if (doc.SectionExists(ent.second) && !STDHelpers::IsNullOrEmpty(ent.second))
286+
if (doc.SectionExists(ent.second) && !STDHelpers::IsNoneOrEmpty(ent.second))
287287
{
288288
int id = atoi(ent.first);
289289
text = doc.GetString(ent.second, "Name");
@@ -334,7 +334,7 @@ static void CScriptTypes_LoadParams_Sounds(ppmfc::CComboBox& comboBox)
334334
CString text;
335335
for (auto& ent : entities->GetEntities())
336336
{
337-
if (sound.SectionExists(ent.second) && !STDHelpers::IsNullOrEmpty(ent.second))
337+
if (sound.SectionExists(ent.second) && !STDHelpers::IsNoneOrEmpty(ent.second))
338338
{
339339
int id = atoi(ent.first);
340340
text.Format("%d - %s", id, ent.second);
@@ -376,7 +376,7 @@ static void CScriptTypes_LoadParams_Themes(ppmfc::CComboBox& comboBox)
376376
CString text;
377377
for (auto& ent : entities->GetEntities())
378378
{
379-
if (theme.SectionExists(ent.second) && !STDHelpers::IsNullOrEmpty(ent.second))
379+
if (theme.SectionExists(ent.second) && !STDHelpers::IsNoneOrEmpty(ent.second))
380380
{
381381
int id = atoi(ent.first);
382382
text.Format("%d - %s", id, ent.second);
@@ -403,7 +403,7 @@ static void CScriptTypes_LoadParams_LocalVariables(ppmfc::CComboBox& comboBox)
403403
CString text;
404404
for (auto& x : entities->GetEntities())
405405
{
406-
if (STDHelpers::IsNullOrEmpty(x.first) || x.first == "Name")
406+
if (STDHelpers::IsNoneOrEmpty(x.first) || x.first == "Name")
407407
continue;
408408
int l = atoi(x.first);
409409
text.Format("%d - %s", l, x.second);

FA2sp/ExtraWindow/CAllieEditor/CAllieEditor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ BOOL CALLBACK CAllieEditor::DlgProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM l
2929
std::set<ppmfc::CString> allies;
3030
cHouses.CETAllies.GetWindowText(FA2sp::Buffer);
3131
for (auto& str : STDHelpers::SplitString(FA2sp::Buffer))
32-
if (!STDHelpers::IsNullOrEmpty(str))
32+
if (!STDHelpers::IsNoneOrEmpty(str))
3333
{
3434
str.Trim();
3535
allies.insert(str);

FA2sp/FA2sp.Constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#define PRODUCT_MAJOR 1
77
#define PRODUCT_MINOR 6
8-
#define PRODUCT_REVISION 0
8+
#define PRODUCT_REVISION 1
99

1010
#ifdef NDEBUG
1111
#define PRODUCT_STR __str(PRODUCT_MAJOR) "." __str(PRODUCT_MINOR) "." __str(PRODUCT_REVISION)

FA2sp/Helpers/MultimapHelper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ std::map<ppmfc::CString, ppmfc::CString, INISectionEntriesComparator> MultimapHe
129129
{
130130
for (auto& pair : section->GetEntities())
131131
{
132-
if (STDHelpers::IsNullOrEmpty(pair.first) ||
133-
STDHelpers::IsNullOrEmpty(pair.second) ||
132+
if (STDHelpers::IsNoneOrEmpty(pair.first) ||
133+
STDHelpers::IsNoneOrEmpty(pair.second) ||
134134
pair.first == "Name")
135135
{
136136
++index;

0 commit comments

Comments
 (0)