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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
secsome committed Mar 3, 2023
2 parents 3b2451b + 157627b commit d3bd58f
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 32 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# FINALALERT2 - SP CHANGELOG

## RELEASE 1.6.0 (2023-XX-XX)
- Reimplemented file reading system

## RELEASE 1.5.2 (2023-03-03)
- Fixed the bug that money calculation is incorrect
- Now SHP Vehicles more than 8 facings are supported
- New ***ExtConfig*** : `EnableMultiSelection` = **BOOLEAN**, defaults to false

## RELEASE 1.5.1 (2023-01-12)
- Fixed the bug that Preview was incorrectly saved in version 1.5.0
- Built-in script params can be translated
Expand Down
10 changes: 7 additions & 3 deletions DOCUMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
- Now you can also join Discord server https://discord.gg/k4SVuMm, and found `map-editors` under `DEDICATED PROJECTS`.
- For now, I cannot ensure the stability of it, so save your maps frequently before heavy loss! XD

~~The multiple selection function is now available. Press Ctrl key to select tiles and press Ctrl+Shift key to deselect them. Ctrl+D can clear all selected tiles.
The multiple selection function is now available. Press Ctrl key to select tiles and press Ctrl+Shift key to deselect them. Ctrl+D can clear all selected tiles.
Now this feature supports RaiseSingleTile/LowerSingleTile (though they are not "Single" anymore) and calucate selected area ore value.
NOTICE THAT UNDOREDO AND COPYPASTE HASN'T BEEN SUPPORTED YET!~~
NOTICE THAT UNDOREDO AND COPYPASTE HASN'T BEEN SUPPORTED YET!

## BASIC TYPES
- **INTEGER**
Expand Down Expand Up @@ -68,6 +68,7 @@ NOTICE THAT UNDOREDO AND COPYPASTE HASN'T BEEN SUPPORTED YET!~~
- `DDrawInVideoMem` = **BOOLEAN** ; Determines if FA2 will allocate DirectDraw surface in the video memory, defaults to true
- `DDrawEmulation` = **BOOLEAN** ; Determines if FA2 will use emulation mode for DirectDrawCreate, defaults to false
- `NoHouseNameTranslation` = **BOOLEAN** ; Determines if FA2 will translate house to their UIName, defaults to false
- `EnableMultiSelection` = **BOOLEAN** ; Determines if FA2sp will enable expermental multi-selection features, defaults to false
- **`[Sides]`** (**x** means this item is **essensial**, fa2sp need this section to work properly)
- Contains a list of sides registered in rules
```ini
Expand Down Expand Up @@ -575,6 +576,9 @@ NOTICE THAT UNDOREDO AND COPYPASTE HASN'T BEEN SUPPORTED YET!~~
TriggerActionParameter = TEXT
TriggerActionParamValue = TEXT
TriggerActionDesc = TEXT
TriggerRepeatType.OneTimeOr= TEXT
TriggerRepeatType.OneTimeAnd= TEXT
TriggerRepeatType.RepeatingOr= TEXT
ScriptTypesTitle = TEXT
ScriptTypesDesc = TEXT
ScriptTypesSelectedScript = TEXT
Expand Down Expand Up @@ -632,7 +636,7 @@ NOTICE THAT UNDOREDO AND COPYPASTE HASN'T BEEN SUPPORTED YET!~~
TileManagerTitle = TEXT
; Script params
; For example, ScriptParam.Status.0
ScriptParam.Target.[0 - 11, except 8] = TEXT
ScriptParam.Target.[0 - 11] = TEXT
ScriptParam.SplitGroup.[0 - 3] = TEXT
ScriptParam.Facing.[0 - 7] = TEXT
ScriptParam.TalkBubble.[0 - 3] = TEXT
Expand Down
9 changes: 6 additions & 3 deletions FA2sp/Ext/CLoading/Body.LoadObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,20 +582,23 @@ void CLoadingExt::LoadVehicleOrAircraft(ppmfc::CString ID)
}
else // As SHP
{
int facingCount = CINI::Art->GetInteger(ArtID, "Facings", 8);
if (facingCount % 8 != 0)
facingCount = (facingCount + 7) / 8 * 8;
int framesToRead[8];
if (CINI::Art->KeyExists(ArtID, "StandingFrames"))
{
int nStartStandFrame = CINI::Art->GetInteger(ArtID, "StartStandFrame", 0);
int nStandingFrames = CINI::Art->GetInteger(ArtID, "StandingFrames", 1);
for (int i = 0; i < 8; ++i)
framesToRead[i] = nStartStandFrame + i * nStandingFrames;
framesToRead[i] = nStartStandFrame + (i * facingCount / 8) * nStandingFrames;
}
else
{
int nStartWalkFrame = CINI::Art->GetInteger(ArtID, "StartWalkFrame", 0);
int nWalkFrames = CINI::Art->GetInteger(ArtID, "WalkFrames", 1);
for (int i = 0; i < 8; ++i) {
framesToRead[i] = nStartWalkFrame + i * nWalkFrames;
framesToRead[i] = nStartWalkFrame + (i * facingCount / 8) * nWalkFrames;
}
}
// fix from cmcc
Expand Down Expand Up @@ -628,7 +631,7 @@ void CLoadingExt::LoadVehicleOrAircraft(ppmfc::CString ID)
int turretFramesToRead[8];

// fix from cmcc
turretFramesToRead[i] = nStartWalkFrame + 8 * nWalkFrames + 4 * ((i + 1) % 8);
turretFramesToRead[i] = nStartWalkFrame + 8 * nWalkFrames + 4 * (((i * facingCount / 8) + 1) % 8);

CShpFile::LoadFrame(turretFramesToRead[i], 1, &FramesBuffers[1]);
UnionSHP_Add(FramesBuffers[0], header.Width, header.Height);
Expand Down
8 changes: 4 additions & 4 deletions FA2sp/Ext/CMapData/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ std::vector<OverlayTypeData> CMapDataExt::OverlayTypeDatas;
int CMapDataExt::GetOreValue(unsigned char nOverlay, unsigned char nOverlayData)
{
if (nOverlay >= 0x66 && nOverlay <= 0x79)
return (nOverlayData + 1) * OreValue[OreType::Riparius];
return nOverlayData * OreValue[OreType::Riparius];
else if (nOverlay >= 0x1B && nOverlay <= 0x26)
return (nOverlayData + 1) * OreValue[OreType::Cruentus];
return nOverlayData * OreValue[OreType::Cruentus];
else if (nOverlay >= 0x7F && nOverlay <= 0x92)
return (nOverlayData + 1) * OreValue[OreType::Vinifera];
return nOverlayData * OreValue[OreType::Vinifera];
else if (nOverlay >= 0x93 && nOverlay <= 0xA6)
return (nOverlayData + 1) * OreValue[OreType::Aboreus];
return nOverlayData * OreValue[OreType::Aboreus];
else
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions FA2sp/Ext/CScriptTypes/Functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ static void CScriptTypes_LoadParams_Target(ppmfc::CComboBox& comboBox)
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.5", "5 - Vehicles")), 5);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.6", "6 - Factories")), 6);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.7", "7 - Base defenses")), 7);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.8", "8 - Base threats")), 7);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.9", "9 - Power plants")), 9);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.10", "10 - Occupiables")), 10);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.11", "11 - Tech Buildings")), 11);
Expand Down
2 changes: 1 addition & 1 deletion FA2sp/FA2sp.Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#define PRODUCT_MAJOR 1
#define PRODUCT_MINOR 5
#define PRODUCT_REVISION 1
#define PRODUCT_REVISION 2

#ifdef NDEBUG
#define PRODUCT_STR __str(PRODUCT_MAJOR) "." __str(PRODUCT_MINOR) "." __str(PRODUCT_REVISION)
Expand Down
3 changes: 3 additions & 0 deletions FA2sp/FA2sp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ int ExtConfigs::MaxVoxelFacing;
bool ExtConfigs::DDrawInVideoMem;
bool ExtConfigs::DDrawEmulation;
bool ExtConfigs::NoHouseNameTranslation;
bool ExtConfigs::EnableMultiSelection;

MultimapHelper Variables::Rules = { &CINI::Rules(), &CINI::CurrentDocument() };
MultimapHelper Variables::FAData = { &CINI::FAData() };
Expand Down Expand Up @@ -145,6 +146,8 @@ void FA2sp::ExtConfigsInitialize()
ExtConfigs::DDrawEmulation = CINI::FAData->GetBool("ExtConfigs", "DDrawEmulation");

ExtConfigs::NoHouseNameTranslation = CINI::FAData->GetBool("ExtConfigs", "NoHouseNameTranslation");

ExtConfigs::EnableMultiSelection = CINI::FAData->GetBool("ExtConfigs", "EnableMultiSelection");
}

// DllMain
Expand Down
1 change: 1 addition & 0 deletions FA2sp/FA2sp.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ExtConfigs
static bool DDrawInVideoMem;
static bool DDrawEmulation;
static bool NoHouseNameTranslation;
static bool EnableMultiSelection;
};

class Variables
Expand Down
66 changes: 49 additions & 17 deletions FA2sp/Miscs/MultiSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

std::set<MapCoord> MultiSelection::SelectedCoords;
bool MultiSelection::ShiftKeyIsDown = false;
BGRStruct MultiSelection::ColorHolder[0x200];
BGRStruct MultiSelection::ColorHolder[0x1000];
MapCoord MultiSelection::CurrentCoord;

bool MultiSelection::AddCoord(int X, int Y)
Expand Down Expand Up @@ -72,11 +72,12 @@ inline bool MultiSelection::IsSelected(int X, int Y)
return SelectedCoords.find(MapCoord{ X,Y }) != SelectedCoords.end();
}

/*

DEFINE_HOOK(456EFC, CIsoView_OnMouseMove_MultiSelect_ReverseStatus, 6)
{
if (!ExtConfigs::EnableMultiSelection)
return 0;

GET_STACK(UINT, eFlags, STACK_OFFS(0x3D528, -0x4));
REF_STACK(const CPoint, point, STACK_OFFS(0x3D528, -0x8));

Expand All @@ -100,6 +101,9 @@ DEFINE_HOOK(456EFC, CIsoView_OnMouseMove_MultiSelect_ReverseStatus, 6)

DEFINE_HOOK(469470, CIsoView_OnKeyDown, 5)
{
if (!ExtConfigs::EnableMultiSelection)
return 0;

GET(CIsoView*, pThis, ECX);
GET_STACK(UINT, nChar, 0x4);

Expand All @@ -126,6 +130,9 @@ DEFINE_HOOK(469470, CIsoView_OnKeyDown, 5)

DEFINE_HOOK(46BC30, CIsoView_OnKeyUp, 5)
{
if (!ExtConfigs::EnableMultiSelection)
return 0;

GET(CIsoView*, pThis, ECX);
GET_STACK(UINT, nChar, 0x4);

Expand All @@ -141,13 +148,19 @@ DEFINE_HOOK(46BC30, CIsoView_OnKeyUp, 5)

DEFINE_HOOK(46EAFA, CIsoView_Draw_TileCurrentCoord_1, 5)
{
if (!ExtConfigs::EnableMultiSelection)
return 0;

MultiSelection::CurrentCoord.X = R->EBP();
MultiSelection::CurrentCoord.Y = R->EBX();
return 0;
}

DEFINE_HOOK(46F680, CIsoView_Draw_TileCurrentCoord_2, 5)
{
if (!ExtConfigs::EnableMultiSelection)
return 0;

MultiSelection::CurrentCoord.X = R->EDI();
MultiSelection::CurrentCoord.Y = R->EBP();
return 0;
Expand All @@ -163,6 +176,9 @@ DEFINE_HOOK_AGAIN(46FF71, CIsoView_Draw_MultiSelect, 7)
DEFINE_HOOK_AGAIN(470081, CIsoView_Draw_MultiSelect, 7)
DEFINE_HOOK(470710, CIsoView_Draw_MultiSelect, 7)
{
if (!ExtConfigs::EnableMultiSelection)
return 0;

if (MultiSelection::IsSelected(MultiSelection::CurrentCoord.X, MultiSelection::CurrentCoord.Y))
{
GET(BGRStruct*, pColors, ESI);
Expand All @@ -187,6 +203,9 @@ DEFINE_HOOK(470710, CIsoView_Draw_MultiSelect, 7)

DEFINE_HOOK(433DA0, CFinalSunDlg_Tools_RaiseSingleTile, 5)
{
if (!ExtConfigs::EnableMultiSelection)
return 0;

GET(CFinalSunDlg*, pThis, ECX);

if (CMapData::Instance->MapWidthPlusHeight)
Expand Down Expand Up @@ -222,6 +241,9 @@ DEFINE_HOOK(433DA0, CFinalSunDlg_Tools_RaiseSingleTile, 5)

DEFINE_HOOK(433D30, CFinalSunDlg_Tools_LowerSingleTile, 5)
{
if (!ExtConfigs::EnableMultiSelection)
return 0;

GET(CFinalSunDlg*, pThis, ECX);

if (CMapData::Instance->MapWidthPlusHeight)
Expand Down Expand Up @@ -257,6 +279,9 @@ DEFINE_HOOK(433D30, CFinalSunDlg_Tools_LowerSingleTile, 5)

DEFINE_HOOK(433F70, CFinalSunDlg_Tools_HideSingleField, 5)
{
if (!ExtConfigs::EnableMultiSelection)
return 0;

GET(CFinalSunDlg*, pThis, ECX);

if (CMapData::Instance->MapWidthPlusHeight)
Expand Down Expand Up @@ -322,19 +347,22 @@ DEFINE_HOOK(474FE0, CIsoView_Draw_MultiSelectionMoney, 5)
buffer.Format("Money on map: %d", CMapData::Instance->MoneyCount);
::TextOut(hDC, rect.left + 10, rect.top + 10, buffer, buffer.GetLength());

if (MultiSelection::GetCount())
if (ExtConfigs::EnableMultiSelection)
{
int nCount = 0;
auto pExt = CMapDataExt::GetExtension();
pExt->InitOreValue();
MultiSelection::ApplyForEach(
[&nCount, pExt](CellData& cell) {
nCount += pExt->GetOreValueAt(cell);
}
);
buffer.Format("Selected money: %d", nCount);
::TextOut(hDC, rect.left + 10, rect.top + 30, buffer, buffer.GetLength());
if (MultiSelection::GetCount())
{
int nCount = 0;
auto pExt = CMapDataExt::GetExtension();
pExt->InitOreValue();
MultiSelection::ApplyForEach(
[&nCount, pExt](CellData& cell) {
nCount += pExt->GetOreValueAt(cell);
}
);

buffer.Format("Selected money: %d", nCount);
::TextOut(hDC, rect.left + 10, rect.top + 30, buffer, buffer.GetLength());
}
}
}

Expand All @@ -343,16 +371,20 @@ DEFINE_HOOK(474FE0, CIsoView_Draw_MultiSelectionMoney, 5)

DEFINE_HOOK(4B9F7A, CreateMap_ClearUp_MultiSelection, 5)
{
if (!ExtConfigs::EnableMultiSelection)
return 0;

MultiSelection::Clear();

return 0;
}

DEFINE_HOOK(49D2C0, LoadMap_ClearUp_MultiSelection, 5)
{
if (!ExtConfigs::EnableMultiSelection)
return 0;

MultiSelection::Clear();

return 0;
}
*/
2 changes: 1 addition & 1 deletion FA2sp/Miscs/MultiSelection.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MultiSelection
}

static bool ShiftKeyIsDown;
static BGRStruct ColorHolder[0x200];
static BGRStruct ColorHolder[0x1000];
static MapCoord CurrentCoord;

private:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Github All Releases](https://img.shields.io/github/downloads/secsome/FA2sp/total.svg)](https://github.com/secsome/FA2sp/releases)
[![Workflow](https://img.shields.io/github/workflow/status/secsome/FA2sp/Nightly%20Build.svg)](https://github.com/secsome/FA2sp/actions)
[![license](https://img.shields.io/github/license/secsome/FA2sp.svg)](https://www.gnu.org/licenses/agpl-3.0.en.html)
[![Github All Releases](https://img.shields.io/github/downloads/secsome/FA2sp/total.svg?label=Downloads&style=flat-square)](https://github.com/secsome/FA2sp/releases)
[![Workflow](https://img.shields.io/github/actions/workflow/status/secsome/FA2sp/nighty.yml?label=Nighty%20Build&style=flat-square)](https://github.com/secsome/FA2sp/actions)
[![license](https://img.shields.io/github/license/secsome/FA2sp?label=License&style=flat-square)](https://www.gnu.org/licenses/agpl-3.0.en.html)

# FA2sp
...is an engine extension project launched by secsome and aimed at providing a set of new features and fixes for FinalAlert2 based on [FA2pp](https://github.com/secsome/FA2pp) and [Syringe](https://github.com/Ares-Developers/Syringe) to allow injecting code.
Expand Down

0 comments on commit d3bd58f

Please sign in to comment.