Skip to content

Commit 5fedb00

Browse files
committed
GeneralDev
1 parent a301a87 commit 5fedb00

6 files changed

Lines changed: 51 additions & 36 deletions

File tree

MarathonRecomp/api/Marathon.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
#include "Sonicteam/DocState.h"
2828
#include "Sonicteam/GameImp.h"
2929
#include "Sonicteam/GameMode.h"
30-
#include "Sonicteam/StageSelectMode.h"
31-
#include "Sonicteam/StageMap.h"
30+
#include "Sonicteam/PicBase.h"
31+
#include "Sonicteam/PictureTitle.h"
3232
#include "Sonicteam/Player/IDynamicLink.h"
3333
#include "Sonicteam/Player/IExportPostureRequestFlag.h"
3434
#include "Sonicteam/Player/IExportWeaponRequestFlag.h"
@@ -58,11 +58,14 @@
5858
#include "Sonicteam/SoX/Engine/Doc.h"
5959
#include "Sonicteam/SoX/Engine/DocMode.h"
6060
#include "Sonicteam/SoX/Engine/Task.h"
61+
#include "Sonicteam/SoX/Input/Listener.h"
6162
#include "Sonicteam/SoX/MessageReceiver.h"
6263
#include "Sonicteam/SoX/Object.h"
6364
#include "Sonicteam/SoX/Physics/Havok/WorldHavok.h"
6465
#include "Sonicteam/SoX/Physics/World.h"
6566
#include "Sonicteam/SoX/RefCountObject.h"
67+
#include "Sonicteam/StageMap.h"
68+
#include "Sonicteam/StageSelectMode.h"
6669
#include "Sonicteam/System/CreateStatic.h"
6770
#include "Sonicteam/System/Singleton.h"
6871
#include "Sonicteam/TitleTask.h"

MarathonRecomp/api/Sonicteam/DevTitleMode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace
1414
xpointer<Sonicteam::PictureTitle> m_PictureTitle;
1515
};
1616
}
17+
1718
namespace Sonicteam
1819
{
1920
class DevTitleMode : public SoX::Engine::DocMode

MarathonRecomp/api/Sonicteam/StageMap.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace stdx
88
{
9+
//Gauge PR :|
910
template <typename Type>
1011
struct vector
1112
{
@@ -14,28 +15,29 @@ namespace stdx
1415
xpointer<Type> _MyLast;
1516
xpointer<Type> _MyEnd;
1617

17-
Type& operator[](uint32_t index)
18+
Type& operator[](size_t pos)
1819
{
19-
return *(Type*)((uint64_t)_MyFirst.get() + (index * sizeof(Type)));
20+
return _MyFirst.get()[pos];
2021
}
21-
size_t size()
22+
23+
size_t size()
2224
{
23-
return (_MyLast.ptr.get() - _MyFirst.ptr.get()) / sizeof(Type);
25+
return _MyLast.get() - _MyFirst.get();
2426
}
25-
};
2627

28+
};
2729
}
30+
2831
namespace Sonicteam
2932
{
30-
//Already in SonicGaugeCode (full)
31-
33+
3234
class StageMap : public SoX::Component
3335
{
3436
public:
3537

3638
stdx::string m_Name;
3739
stdx::string m_Text;
38-
stdx::vector<xpointer<StageMap>> m_sStageMap;
39-
40+
stdx::vector<xpointer<StageMap>> m_vpStageMap;
41+
4042
};
4143
}

MarathonRecomp/ui/devtitle_menu.cpp

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ struct DevTitleMenuSTable
3737
} m_state[5];
3838
};
3939

40+
static ImVec2 GetMousePos()
41+
{
42+
return ImGui::GetIO().MousePos;
43+
}
44+
4045
static void DrawBackgroundDev()
4146
{
4247
auto& res = ImGui::GetIO().DisplaySize;
@@ -117,9 +122,9 @@ static bool Sonic06Button(ImVec2 pos, const char* label, bool& hovered, const Im
117122
const auto label_size = g_mnewRodinFont->CalcTextSizeA(font_size, FLT_MAX, 0, label);
118123
const auto size = ImVec2(size_arg.x ? size_arg.x : label_size.x, size_arg.y ? size_arg.y : label_size.y);
119124
const float skew = size.y * skew_amount;
120-
125+
121126
const ImRect bb(pos, { pos.x + size.x + skew, pos.y + size.y });
122-
hovered = bb.Contains(io.MousePos);
127+
hovered = bb.Contains(GetMousePos());
123128
bool pressed = hovered && ImGui::IsMouseClicked(ImGuiMouseButton_Left);
124129

125130
// Colors
@@ -184,11 +189,11 @@ static void DrawStageMapSelector()
184189
(res.y - WINDOW_HEIGHT) * 0.45f
185190
};
186191

187-
auto& items = pMode->m_CurrentStageMap->m_sStageMap;
192+
auto& items = pMode->m_CurrentStageMap->m_vpStageMap;
188193
const int itemCount = static_cast<int>(items.size());
189194
int currentIdx = pMode->m_CurrentStageMapIndex.get();
190195

191-
// Input handling
196+
// Input handling (Mouse)
192197
auto pMsgRec = reinterpret_cast<uintptr_t>(static_cast<Sonicteam::SoX::MessageReceiver*>(pMode));
193198

194199
if (abs(io.MouseWheel) > ScrollAmount) {
@@ -205,7 +210,7 @@ static void DrawStageMapSelector()
205210
const int start_idx = std::max(0, currentIdx - VISIBLE_ITEMS / 2);
206211
const int end_idx = std::min(itemCount, start_idx + VISIBLE_ITEMS);
207212

208-
// Draw visible items with absolute positioning
213+
// Draw visible items
209214
for (int i = start_idx; i < end_idx; ++i) {
210215
const auto& item = items[i];
211216
if (!item) continue;
@@ -230,9 +235,9 @@ static void DrawStageMapSelector()
230235
}
231236

232237
// Tooltip with stage information
233-
if (hovered && item->m_sStageMap.size() > 0) {
238+
if (hovered && item->m_vpStageMap.size() > 0) {
234239
ImDrawList* draw_list = ImGui::GetForegroundDrawList();
235-
const ImVec2 mouse_pos = ImGui::GetIO().MousePos;
240+
const ImVec2 mouse_pos = GetMousePos();
236241
const float font_size = ImGui::GetFontSize();
237242
const float line_spacing = 2.0f;
238243

@@ -242,8 +247,8 @@ static void DrawStageMapSelector()
242247
float total_height = 0.0f;
243248
std::vector<std::pair<std::string, std::string>> entries;
244249

245-
for (int j = 0; j < item->m_sStageMap.size(); ++j) {
246-
const auto& stage = item->m_sStageMap[j];
250+
for (int j = 0; j < item->m_vpStageMap.size(); ++j) {
251+
const auto& stage = item->m_vpStageMap[j];
247252
if (!stage.ptr.get()) continue;
248253

249254
std::string nameUtf8 = ConvertShiftJISToUTF8(stage->m_Name.c_str());
@@ -319,7 +324,7 @@ static void DrawStageMapSelector()
319324
const float dot_radius = 7.5f;
320325
const ImU32 dot_color = IM_COL32(0, 150, 255, 220);
321326
const ImU32 outline_color = IM_COL32(255, 255, 255, 180);
322-
ImVec2 mouse_pos = io.MousePos;
327+
ImVec2 mouse_pos = GetMousePos();
323328

324329
ImGui::GetBackgroundDrawList()->AddCircleFilled(
325330
mouse_pos, dot_radius, dot_color, 12
@@ -352,11 +357,6 @@ static void DrawDevTitle() {
352357
GuestToHostFunction<void>(sub_824A0E38, static_cast<uint32_t>(pMsgRec), vMsgRec.get());
353358
}
354359

355-
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
356-
{
357-
guest_stack_var<DevMessage> vMsgRec(0x10002, 0, 0);
358-
GuestToHostFunction<void>(sub_824A0E38, static_cast<uint32_t>(pMsgRec), vMsgRec.get());
359-
}
360360
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
361361
{
362362
guest_stack_var<DevMessage> vMsgRec(0x10002, 0, 1);
@@ -382,8 +382,6 @@ static void DevTitleAudioCommon(DevMessage* message)
382382
if (!message->id3)
383383
Game_PlaySound("window_close");
384384
break;
385-
386-
387385
}
388386
}
389387

@@ -412,9 +410,7 @@ PPC_FUNC(sub_824A0E38)
412410
if (pMessage->id2 == 0x5A || pMessage->id3)
413411
{
414412
auto pPocture = pTitle->m_PictureTitle;
415-
416413
pTitle->m_PictureTitle->m_State3 = 4;
417-
418414
DevTitleDelay = DevTitleDelayDefault;
419415
}
420416
else
@@ -430,6 +426,12 @@ PPC_FUNC(sub_824A0E38)
430426
PPC_FUNC_IMPL(__imp__sub_82161AB8);
431427
PPC_FUNC(sub_82161AB8)
432428
{
429+
if (!Config::DevTitle)
430+
{
431+
__imp__sub_82161AB8(ctx, base);
432+
return;
433+
}
434+
433435
auto pDoc = (Sonicteam::DocMarathonImp*)(base + ctx.r3.u32);
434436
GuestToHostFunction<void>(sub_825E9E28, ctx.r3.u32, ctx.r4.u32);
435437

@@ -443,19 +445,19 @@ PPC_FUNC(sub_82161AB8)
443445

444446
auto pDevMode = (*(be<uint32_t>*)(base + 0x82D35E78)).get();
445447

446-
//nah vft call
448+
//nah vft call, sub_825E8D78 should do it
447449
//DocSetMode
448450
GuestToHostFunction<void>(sub_825E8D78, ctx.r3.u32, pDevMode);
449451

450452
}
451453

454+
//tateDevTitle, vft + 8
452455
PPC_FUNC_IMPL(__imp__sub_82162298);
453456
PPC_FUNC(sub_82162298)
454457
{
455458
auto pDoc = (Sonicteam::DocMarathonState*)(base + ctx.r4.u32);
456459
auto pTitle = (StateDevTitle*)(base + ctx.r3.u32);
457460

458-
459461
if (ctx.r3.u32 && pTitle->m_PictureTitle && pTitle->m_PictureTitle->m_State3 > 4)
460462
{
461463
DevTitleDelay = std::clamp(DevTitleDelay - 0.016666668f, 0.0f, DevTitleDelay);
@@ -464,6 +466,7 @@ PPC_FUNC(sub_82162298)
464466
{
465467
DevTitleDelay = DevTitleDelayDefault;
466468
}
469+
467470
if (!GuestToHostFunction<uint32_t>(sub_82581C68, ctx.r4.u32))
468471
{
469472
//Wait for transistion
@@ -481,11 +484,18 @@ PPC_FUNC(sub_82162298)
481484

482485
void DevTitleMenu::Init()
483486
{
487+
if (!Config::DevTitle)
488+
return;
489+
484490
g_mrodinFont = ImFontAtlasSnapshot::GetFont("FOT-RodinPro-DB.otf");
485491
g_mnewRodinFont = ImFontAtlasSnapshot::GetFont("FOT-NewRodinPro-UB.otf");
486492

487493
}
488-
void DevTitleMenu::Draw() {
494+
void DevTitleMenu::Draw()
495+
{
496+
497+
if (!Config::DevTitle)
498+
return;
489499

490500
if (!App::s_pApp)
491501
return;
@@ -509,7 +519,7 @@ void DevTitleMenu::Draw() {
509519
DrawDevTitle();
510520
};
511521
break;
512-
//StageSelect
522+
//StageSelect/StoreSelect
513523
case 0x820336A4:
514524
{
515525
DevTitleMenu::IsVisible = true;

MarathonRecomp/ui/devtitle_menu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ class DevTitleMenu
88

99
static bool IsVisible;
1010

11-
12-
1311
static void Init();
1412
static void Draw();
1513

MarathonRecomp/user/config_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ CONFIG_DEFINE_HIDDEN("Codes", bool, DisableLowResolutionFontOnCustomUI, false);
8080
CONFIG_DEFINE_HIDDEN("Codes", bool, RestoreContextualHUDColours, false);
8181
CONFIG_DEFINE_HIDDEN("Codes", bool, DisableEdgeGrabLeftover, false);
8282
CONFIG_DEFINE_HIDDEN("Codes", bool, TailsGauge, false);
83+
CONFIG_DEFINE_HIDDEN("Codes", bool, DevTitle, false);
8384
CONFIG_DEFINE_HIDDEN("Codes", bool, MidairControlForMachSpeed, false);
8485
CONFIG_DEFINE_HIDDEN("Codes", bool, MidairControlForSnowboards, false);
8586

0 commit comments

Comments
 (0)