mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-09-07 10:11:43 -04:00
Merge branch 'main' into 26-03-28-movie-player
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
#if _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
#elif __APPLE__
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
@@ -682,6 +684,8 @@ void OSSetCurrentThreadName(const char* name) {
|
||||
if (!SUCCEEDED(result)) {
|
||||
CRASH("OSSetThreadName: SetThreadDescription failed");
|
||||
}
|
||||
#elif __APPLE__
|
||||
pthread_setname_np(name);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ static int ReadChannelSamplesChunk(
|
||||
renderData + skipSamples,
|
||||
static_cast<int>(renderSize - skipSamples * sizeof(u16)));
|
||||
|
||||
assert(channel.mSamplePosition % channel.mSamplesPerBlock == 0 || channel.mSamplesLeft == 0);
|
||||
assert(curSamplePosition % channel.mSamplesPerBlock == 0 || channel.mSamplesLeft == 0);
|
||||
|
||||
return static_cast<int>(renderSamples - skipSamples);
|
||||
}
|
||||
|
||||
@@ -174,6 +174,7 @@ namespace dusk {
|
||||
|
||||
void ImGuiConsole::draw() {
|
||||
if (CheckMenuViewToggle(ImGuiKey_F1, m_isHidden)) {
|
||||
m_menuTools.afterDraw();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -187,6 +188,8 @@ namespace dusk {
|
||||
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
||||
m_menuTools.afterDraw();
|
||||
}
|
||||
|
||||
bool ImGuiConsole::CheckMenuViewToggle(ImGuiKey key, bool& active) {
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
#include <array>
|
||||
#include <optional>
|
||||
|
||||
#include "JSystem/JFramework/JFWSystem.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "imgui.h"
|
||||
#include "ImGuiConsole.hpp"
|
||||
#include "ImGuiMenuTools.hpp"
|
||||
#include "JSystem/JFramework/JFWSystem.h"
|
||||
#include "JSystem/JKernel/JKRExpHeap.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "imgui.h"
|
||||
|
||||
struct OpenHeapData {
|
||||
bool Safe;
|
||||
bool HeapCheckRan;
|
||||
bool HeapCheckFailed;
|
||||
};
|
||||
|
||||
static absl::flat_hash_map<JKRHeap*, OpenHeapData> OpenHeapWindows;
|
||||
|
||||
namespace dusk {
|
||||
static void DrawTableCore();
|
||||
void ShowHeapDetailed(JKRHeap* heap, OpenHeapData& data, bool& open);
|
||||
|
||||
void ImGuiMenuTools::ShowHeapOverlay() {
|
||||
if (!ImGuiConsole::CheckMenuViewToggle(ImGuiKey_F4, m_showHeapOverlay)) {
|
||||
@@ -16,9 +27,13 @@ namespace dusk {
|
||||
}
|
||||
|
||||
if (ImGui::Begin("Heaps", &m_showHeapOverlay)) {
|
||||
for (auto& x : OpenHeapWindows) {
|
||||
x.second.Safe = false;
|
||||
}
|
||||
|
||||
if (ImGui::BeginTable(
|
||||
"heaps",
|
||||
5,
|
||||
6,
|
||||
ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable)) {
|
||||
|
||||
DrawTableCore();
|
||||
@@ -28,6 +43,19 @@ namespace dusk {
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
std::vector<JKRHeap*> closeQueue;
|
||||
for (auto& [heap, safe] : OpenHeapWindows) {
|
||||
auto open = true;
|
||||
ShowHeapDetailed(heap, safe, open);
|
||||
if (!open) {
|
||||
closeQueue.push_back(heap);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto toRemove : closeQueue) {
|
||||
OpenHeapWindows.erase(toRemove);
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawHeap(JKRHeap* heap, int depth = 0);
|
||||
@@ -44,6 +72,7 @@ namespace dusk {
|
||||
ImGui::TextUnformatted("Total");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted("Type");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
DrawHeap(reinterpret_cast<JKRHeap*>(JFWSystem::rootHeap));
|
||||
}
|
||||
@@ -70,8 +99,15 @@ namespace dusk {
|
||||
|
||||
static void DrawHeap(JKRHeap* heap, const int depth) {
|
||||
ImGui::TableNextRow();
|
||||
char idBuf[32];
|
||||
snprintf(idBuf, sizeof(idBuf), "%p", heap);
|
||||
ImGui::PushID(idBuf);
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
if (OpenHeapWindows.find(heap) != OpenHeapWindows.end()) {
|
||||
OpenHeapWindows[heap].Safe = true;
|
||||
}
|
||||
|
||||
auto indentSize = depth * 16;
|
||||
if (indentSize != 0)
|
||||
ImGui::Indent(indentSize);
|
||||
@@ -103,9 +139,134 @@ namespace dusk {
|
||||
auto typeString = GetHeapType(heap);
|
||||
ImGui::TextUnformatted(typeString.data(), typeString.data() + 4);
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Button("View")) {
|
||||
OpenHeapWindows[heap].Safe = true;
|
||||
}
|
||||
|
||||
const JSUTree<JKRHeap>& tree = heap->getHeapTree();
|
||||
for (JSUTreeIterator iter(tree.getFirstChild()); iter != tree.getEndChild(); ++iter) {
|
||||
DrawHeap(*iter, depth + 1);
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
struct MemBlockPair {
|
||||
JKRExpHeap::CMemBlock* block;
|
||||
bool used;
|
||||
|
||||
auto& operator->() {
|
||||
return block;
|
||||
}
|
||||
};
|
||||
|
||||
static std::vector<MemBlockPair> FindAllHeapBlocks(JKRExpHeap* heap) {
|
||||
std::vector<MemBlockPair> result;
|
||||
|
||||
for (JKRExpHeap::CMemBlock* b = heap->getFreeHead(); b; b = b->getNextBlock()) {
|
||||
result.push_back({b, false});
|
||||
}
|
||||
|
||||
for (JKRExpHeap::CMemBlock* b = heap->getUsedHead(); b; b = b->getNextBlock()) {
|
||||
result.push_back({b, true});
|
||||
}
|
||||
|
||||
std::ranges::sort(result, [](auto a, auto b) { return a.block < b.block; });
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void ShowHeapDetailed(JKRHeap* heap, OpenHeapData& data, bool& open) {
|
||||
char title[128];
|
||||
const char* name = data.Safe ? heap->getName() : "INVALID";
|
||||
snprintf(title, sizeof(title), "Heap %s##%p", heap->getName(), static_cast<const void*>(heap));
|
||||
|
||||
if (!ImGui::Begin(name, &open)) {
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.Safe) {
|
||||
ImGui::TextUnformatted("Heap no longer exists");
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
heap->lock();
|
||||
|
||||
ImGui::Text("Name: %s", heap->getName());
|
||||
const auto size = BytesToString(heap->getSize());
|
||||
const auto freeSize = BytesToString(heap->getFreeSize());
|
||||
ImGui::Text("Size: %08X (%s), free: %08X (%s)", heap->getSize(), size.c_str(), heap->getFreeSize(), freeSize.c_str());
|
||||
|
||||
if (ImGui::Button("Check")) {
|
||||
data.HeapCheckFailed = !heap->check();
|
||||
data.HeapCheckRan = true;
|
||||
}
|
||||
|
||||
if (data.HeapCheckFailed) {
|
||||
ImGui::SameLine();
|
||||
ImColor red = IM_COL32(0xFF, 0, 0, 0xFF);
|
||||
ImGui::TextColored(red, "Heap check failed");
|
||||
} else if (data.HeapCheckRan) {
|
||||
ImGui::SameLine();
|
||||
ImColor red = IM_COL32(0, 0xFF, 0, 0xFF);
|
||||
ImGui::TextColored(red, "Heap check passed");
|
||||
}
|
||||
|
||||
if (heap->getHeapType() == 'EXPH') {
|
||||
auto expHeap = dynamic_cast<JKRExpHeap*>(heap);
|
||||
|
||||
ImGui::SeparatorText("Blocks");
|
||||
|
||||
if (ImGui::BeginTable("Blocks", 5, ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable)) {
|
||||
ImGui::TableSetupColumn("Start", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableSetupColumn("End", ImGuiTableColumnFlags_WidthFixed);
|
||||
ImGui::TableSetupColumn("Size");
|
||||
ImGui::TableSetupColumn("Allocated", ImGuiTableColumnFlags_WidthFixed, ImGui::CalcTextSize("Allocated").x);
|
||||
ImGui::TableSetupColumn("IsValid", ImGuiTableColumnFlags_WidthFixed, ImGui::CalcTextSize("IsValid").x);
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
const auto blocks = FindAllHeapBlocks(expHeap);
|
||||
|
||||
for (auto block : blocks) {
|
||||
assert(block->getSize() != 0);
|
||||
ImGui::TableNextRow();
|
||||
|
||||
if (block.used) {
|
||||
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, IM_COL32(0xFF, 0, 0, 0x44));
|
||||
} else {
|
||||
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1, IM_COL32(0, 0xFF, 0, 0x44));
|
||||
}
|
||||
|
||||
char bufId[32];
|
||||
snprintf(bufId, sizeof(bufId), "%p", block);
|
||||
ImGui::PushID(bufId);
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%08X", (u32)((uintptr_t)block.block - (uintptr_t)expHeap->getStartAddr()));
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%08X", (u32)((uintptr_t)block.block + block->getSize() - (uintptr_t)expHeap->getStartAddr()));
|
||||
ImGui::TableNextColumn();
|
||||
auto sizeNice = BytesToString(block->getSize());
|
||||
ImGui::Text("%08X (%s)", block->getSize(), sizeNice.c_str());
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(block.used ? "True" : "False");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(block->isValid() ? "True" : "False");
|
||||
if (block->isValid() != block.used) {
|
||||
ImGui::SameLine();
|
||||
ImGui::TextUnformatted("(!!!)");
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
heap->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "ImGuiConsole.hpp"
|
||||
#include "ImGuiMenuTools.hpp"
|
||||
#include "dusk/map_loader_definitions.h"
|
||||
#include "fmt/format.h"
|
||||
|
||||
namespace dusk {
|
||||
void ImGuiMenuTools::ShowMapLoader() {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <imgui_internal.h>
|
||||
|
||||
#include "JSystem/JUtility/JUTGamePad.h"
|
||||
#include "d/actor/d_a_alink.h"
|
||||
#include "dusk/audio/DuskAudioSystem.h"
|
||||
#include "m_Do/m_Do_audio.h"
|
||||
#include "m_Do/m_Do_controller_pad.h"
|
||||
@@ -23,12 +24,20 @@ namespace dusk {
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::BeginMenu("Graphics")) {
|
||||
if (ImGui::MenuItem("Toggle Fullscreen", "F11")) {
|
||||
m_graphicsSettings.m_fullscreen = !m_graphicsSettings.m_fullscreen;
|
||||
VISetWindowFullscreen(m_graphicsSettings.m_fullscreen);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Checkbox("Native Bloom", &m_graphicsSettings.m_enableBloom);
|
||||
ImGui::Checkbox("Water Projection Offset", &m_graphicsSettings.m_waterProjectionOffset);
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip("Adds GC-specific -0.01 transS offset\n"
|
||||
"that causes ~6px ghost artifacts in water reflections");
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
@@ -67,6 +76,11 @@ namespace dusk {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Tweaks")) {
|
||||
ImGui::MenuItem("Fast iron boots", nullptr, &tweaks::FastIronBoots);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
@@ -76,6 +90,11 @@ namespace dusk {
|
||||
if ((ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) && ImGui::IsKeyPressed(ImGuiKey_R)) {
|
||||
JUTGamePad::C3ButtonReset::sResetSwitchPushing = true;
|
||||
}
|
||||
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_F11)) {
|
||||
m_graphicsSettings.m_fullscreen = !m_graphicsSettings.m_fullscreen;
|
||||
VISetWindowFullscreen(m_graphicsSettings.m_fullscreen);
|
||||
}
|
||||
}
|
||||
|
||||
static void drawVirtualStick(const char* id, const ImVec2& stick) {
|
||||
@@ -102,17 +121,38 @@ namespace dusk {
|
||||
return;
|
||||
}
|
||||
|
||||
// if pending for an input mapping, check to set new input
|
||||
if (m_controllerConfig.m_pendingMapping != nullptr) {
|
||||
// if pending for a button mapping, check to set new input
|
||||
if (m_controllerConfig.m_pendingButtonMapping != nullptr) {
|
||||
s32 nativeButton = PADGetNativeButtonPressed(m_controllerConfig.m_pendingPort);
|
||||
if (nativeButton != -1) {
|
||||
m_controllerConfig.m_pendingMapping->nativeButton = nativeButton;
|
||||
m_controllerConfig.m_pendingMapping = nullptr;
|
||||
m_controllerConfig.m_pendingButtonMapping->nativeButton = nativeButton;
|
||||
m_controllerConfig.m_pendingButtonMapping = nullptr;
|
||||
m_controllerConfig.m_pendingPort = -1;
|
||||
PADBlockInput(false);
|
||||
}
|
||||
}
|
||||
|
||||
// if pending for an axis mapping, check to set new input
|
||||
if (m_controllerConfig.m_pendingAxisMapping != nullptr) {
|
||||
auto nativeAxis = PADGetNativeAxisPulled(m_controllerConfig.m_pendingPort);
|
||||
if (nativeAxis.nativeAxis != -1) {
|
||||
m_controllerConfig.m_pendingAxisMapping->nativeAxis = nativeAxis;
|
||||
m_controllerConfig.m_pendingAxisMapping->nativeButton = -1;
|
||||
m_controllerConfig.m_pendingAxisMapping = nullptr;
|
||||
m_controllerConfig.m_pendingPort = -1;
|
||||
PADBlockInput(false);
|
||||
} else {
|
||||
auto nativeButton = PADGetNativeButtonPressed(m_controllerConfig.m_pendingPort);
|
||||
if (nativeButton != -1) {
|
||||
m_controllerConfig.m_pendingAxisMapping->nativeAxis = {-1, AXIS_SIGN_POSITIVE};
|
||||
m_controllerConfig.m_pendingAxisMapping->nativeButton = nativeButton;
|
||||
m_controllerConfig.m_pendingAxisMapping = nullptr;
|
||||
m_controllerConfig.m_pendingPort = -1;
|
||||
PADBlockInput(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiWindowFlags windowFlags =
|
||||
ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_AlwaysAutoResize;
|
||||
@@ -136,10 +176,12 @@ namespace dusk {
|
||||
ImGui::EndTabBar();
|
||||
|
||||
// if tab is changed while waiting for input, cancel pending
|
||||
if (m_controllerConfig.m_pendingMapping != nullptr &&
|
||||
if ((m_controllerConfig.m_pendingButtonMapping != nullptr ||
|
||||
m_controllerConfig.m_pendingAxisMapping != nullptr) &&
|
||||
m_controllerConfig.m_pendingPort != m_controllerConfig.m_selectedPort)
|
||||
{
|
||||
m_controllerConfig.m_pendingMapping = nullptr;
|
||||
m_controllerConfig.m_pendingButtonMapping = nullptr;
|
||||
m_controllerConfig.m_pendingAxisMapping = nullptr;
|
||||
m_controllerConfig.m_pendingPort = -1;
|
||||
PADBlockInput(false);
|
||||
}
|
||||
@@ -197,34 +239,78 @@ namespace dusk {
|
||||
}
|
||||
|
||||
// buttons panel
|
||||
constexpr float buttonSize = 40;
|
||||
constexpr float uiButtonSize = 40;
|
||||
|
||||
ImGuiBeginGroupPanel("Buttons", ImVec2(150, 20));
|
||||
|
||||
u32 buttonCount;
|
||||
PADButtonMapping* mappingList = PADGetButtonMappings(m_controllerConfig.m_selectedPort, &buttonCount);
|
||||
if (mappingList != nullptr) {
|
||||
PADButtonMapping* btnMappingList = PADGetButtonMappings(m_controllerConfig.m_selectedPort, &buttonCount);
|
||||
if (btnMappingList != nullptr) {
|
||||
for (int i = 0; i < buttonCount; i++) {
|
||||
const char* btnName = PADGetButtonName(mappingList[i].padButton);
|
||||
const char* btnName = PADGetButtonName(btnMappingList[i].padButton);
|
||||
ImVec2 len = ImGui::CalcTextSize(btnName);
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
|
||||
ImGui::SetCursorPosY(pos.y + len.y / 4);
|
||||
ImGui::SetCursorPosX(pos.x + abs(len.x - buttonSize));
|
||||
ImGui::SetCursorPosX(pos.x + abs(len.x - uiButtonSize));
|
||||
ImGui::Text("%s", btnName);
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::SetCursorPosY(pos.y);
|
||||
|
||||
bool pressed = ImGui::Button(m_controllerConfig.m_isReading && m_controllerConfig.m_pendingMapping == &mappingList[i]
|
||||
? fmt::format("Press a Key...##{}", btnName).c_str()
|
||||
: fmt::format("{0}##-{1}", PADGetNativeButtonName(mappingList[i].nativeButton), i).c_str(),
|
||||
std::string dispName;
|
||||
if (m_controllerConfig.m_isReading && m_controllerConfig.m_pendingButtonMapping == &btnMappingList[i]) {
|
||||
dispName = fmt::format("Press a Key...##{}", btnName);
|
||||
} else {
|
||||
dispName = fmt::format("{0}##-{1}", PADGetNativeButtonName(btnMappingList[i].nativeButton), i);
|
||||
}
|
||||
bool pressed = ImGui::Button(dispName.c_str(),
|
||||
ImVec2(100.0f, 20.0f));
|
||||
|
||||
if (pressed) {
|
||||
m_controllerConfig.m_isReading = true;
|
||||
m_controllerConfig.m_pendingPort = m_controllerConfig.m_selectedPort;
|
||||
m_controllerConfig.m_pendingMapping = &mappingList[i];
|
||||
m_controllerConfig.m_pendingButtonMapping = &btnMappingList[i];
|
||||
PADBlockInput(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiEndGroupPanel();
|
||||
ImGui::SameLine();
|
||||
|
||||
uint32_t axisCount;
|
||||
PADAxisMapping* axisMappingList = PADGetAxisMappings(m_controllerConfig.m_selectedPort, &axisCount);
|
||||
|
||||
ImGuiBeginGroupPanel("Triggers", ImVec2(150, 20));
|
||||
|
||||
PADAxis triggers[] = {PAD_AXIS_TRIGGER_L, PAD_AXIS_TRIGGER_R};
|
||||
if (axisMappingList != nullptr) {
|
||||
for (PADAxis trigger : triggers) {
|
||||
const char* axisName = PADGetAxisName(axisMappingList[trigger].padAxis);
|
||||
ImVec2 len = ImGui::CalcTextSize(axisName);
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
|
||||
ImGui::SetCursorPosY(pos.y + len.y / 4);
|
||||
ImGui::SetCursorPosX(pos.x + abs(len.x - uiButtonSize));
|
||||
ImGui::Text("%s", axisName);
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::SetCursorPosY(pos.y);
|
||||
|
||||
std::string dispName;
|
||||
if (m_controllerConfig.m_isReading && m_controllerConfig.m_pendingAxisMapping == &axisMappingList[trigger]) {
|
||||
dispName = fmt::format("Press a Key...##{}", axisName);
|
||||
} else {
|
||||
dispName = fmt::format("{0}##-{1}", PADGetNativeAxisName(axisMappingList[trigger].nativeAxis), trigger);
|
||||
}
|
||||
bool pressed = ImGui::Button(dispName.c_str(),
|
||||
ImVec2(100.0f, 20.0f));
|
||||
|
||||
if (pressed) {
|
||||
m_controllerConfig.m_isReading = true;
|
||||
m_controllerConfig.m_pendingPort = m_controllerConfig.m_selectedPort;
|
||||
m_controllerConfig.m_pendingAxisMapping = &axisMappingList[trigger];
|
||||
PADBlockInput(true);
|
||||
}
|
||||
}
|
||||
@@ -235,32 +321,52 @@ namespace dusk {
|
||||
|
||||
int port = m_controllerConfig.m_selectedPort;
|
||||
|
||||
const char* stickDirections[] = {
|
||||
"Up",
|
||||
"Down",
|
||||
"Left",
|
||||
"Right",
|
||||
};
|
||||
|
||||
// main stick panel
|
||||
ImGuiBeginGroupPanel("Control Stick", ImVec2(150, 20));
|
||||
|
||||
drawVirtualStick("##mainStick", ImVec2{ mDoCPd_c::getStickX(port), mDoCPd_c::getStickY(port) });
|
||||
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
const char* label = stickDirections[i];
|
||||
if (axisMappingList != nullptr) {
|
||||
const PADAxis lStickAxes[] = {PAD_AXIS_LEFT_Y_POS, PAD_AXIS_LEFT_Y_NEG, PAD_AXIS_LEFT_X_NEG, PAD_AXIS_LEFT_X_POS};
|
||||
for (auto axis : lStickAxes) {
|
||||
const char* label = PADGetAxisDirectionLabel(axis);
|
||||
ImVec2 len = ImGui::CalcTextSize(label);
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
|
||||
ImGui::SetCursorPosY(pos.y + len.y / 4);
|
||||
ImGui::SetCursorPosX(pos.x + abs(len.x - buttonSize));
|
||||
ImGui::SetCursorPosX(pos.x + abs(len.x - uiButtonSize));
|
||||
ImGui::Text("%s", label);
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::SetCursorPosY(pos.y);
|
||||
|
||||
bool pressed = ImGui::Button(fmt::format("Temp##{}", label).c_str(), ImVec2(100.0f, 20.0f));
|
||||
std::string dispName;
|
||||
if (m_controllerConfig.m_isReading && m_controllerConfig.m_pendingAxisMapping == &axisMappingList[axis]) {
|
||||
dispName = fmt::format("Press a Key...##{}", label);
|
||||
} else {
|
||||
if (axisMappingList[axis].nativeAxis.nativeAxis != -1) {
|
||||
const char* signStr;
|
||||
if (axis == PAD_AXIS_TRIGGER_L || axis == PAD_AXIS_TRIGGER_R) {
|
||||
signStr = "";
|
||||
} else if (axisMappingList[axis].nativeAxis.sign == AXIS_SIGN_POSITIVE) {
|
||||
signStr = "+";
|
||||
} else {
|
||||
signStr = "-";
|
||||
}
|
||||
dispName = fmt::format("{0}{1}##-{2}", PADGetNativeAxisName(axisMappingList[axis].nativeAxis), signStr, axis);
|
||||
} else {
|
||||
assert(axisMappingList[axis].nativeButton != -1);
|
||||
dispName = fmt::format("{0}##-{1}", PADGetNativeButtonName(axisMappingList[axis].nativeButton), axis);
|
||||
}
|
||||
}
|
||||
bool pressed = ImGui::Button(dispName.c_str(), ImVec2(100.0f, 20.0f));
|
||||
|
||||
if (pressed) {
|
||||
m_controllerConfig.m_isReading = true;
|
||||
m_controllerConfig.m_pendingPort = m_controllerConfig.m_selectedPort;
|
||||
m_controllerConfig.m_pendingAxisMapping = &axisMappingList[axis];
|
||||
PADBlockInput(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,20 +390,47 @@ namespace dusk {
|
||||
|
||||
drawVirtualStick("##subStick", ImVec2{ mDoCPd_c::getSubStickX(port), mDoCPd_c::getSubStickY(port) });
|
||||
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
const char* label = stickDirections[i];
|
||||
if (axisMappingList != nullptr) {
|
||||
const PADAxis rStickAxes[] = {PAD_AXIS_RIGHT_Y_POS, PAD_AXIS_RIGHT_Y_NEG, PAD_AXIS_RIGHT_X_NEG, PAD_AXIS_RIGHT_X_POS};
|
||||
for (auto axis : rStickAxes) {
|
||||
const char* label = PADGetAxisDirectionLabel(axisMappingList[axis].padAxis);
|
||||
ImVec2 len = ImGui::CalcTextSize(label);
|
||||
ImVec2 pos = ImGui::GetCursorPos();
|
||||
|
||||
ImGui::SetCursorPosY(pos.y + len.y / 4);
|
||||
ImGui::SetCursorPosX(pos.x + abs(len.x - buttonSize));
|
||||
ImGui::SetCursorPosX(pos.x + abs(len.x - uiButtonSize));
|
||||
ImGui::Text("%s", label);
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::SetCursorPosY(pos.y);
|
||||
|
||||
bool pressed = ImGui::Button(fmt::format("Temp##sub{}", label).c_str(), ImVec2(100.0f, 20.0f));
|
||||
std::string dispName;
|
||||
if (m_controllerConfig.m_isReading && m_controllerConfig.m_pendingAxisMapping == &axisMappingList[axis]) {
|
||||
dispName = fmt::format("Press a Key...##sub{}", label);
|
||||
} else {
|
||||
if (axisMappingList[axis].nativeAxis.nativeAxis != -1) {
|
||||
const char* signStr;
|
||||
if (axis == PAD_AXIS_TRIGGER_L || axis == PAD_AXIS_TRIGGER_R) {
|
||||
signStr = "";
|
||||
} else if (axisMappingList[axis].nativeAxis.sign == AXIS_SIGN_POSITIVE) {
|
||||
signStr = "+";
|
||||
} else {
|
||||
signStr = "-";
|
||||
}
|
||||
dispName = fmt::format("{0}{1}##-{2}", PADGetNativeAxisName(axisMappingList[axis].nativeAxis), signStr, axis);
|
||||
} else {
|
||||
assert(axisMappingList[axis].nativeButton != -1);
|
||||
dispName = fmt::format("{0}##-{1}", PADGetNativeButtonName(axisMappingList[axis].nativeButton), axis);
|
||||
}
|
||||
}
|
||||
bool pressed = ImGui::Button(fmt::format("{0}##sub{1}", dispName, label).c_str(), ImVec2(100.0f, 20.0f));
|
||||
|
||||
if (pressed) {
|
||||
m_controllerConfig.m_isReading = true;
|
||||
m_controllerConfig.m_pendingPort = m_controllerConfig.m_selectedPort;
|
||||
m_controllerConfig.m_pendingAxisMapping = &axisMappingList[axis];
|
||||
PADBlockInput(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,15 @@ namespace dusk {
|
||||
struct {
|
||||
int m_selectedPort = 0;
|
||||
bool m_isReading = false;
|
||||
PADButtonMapping* m_pendingMapping = nullptr;
|
||||
PADButtonMapping* m_pendingButtonMapping = nullptr;
|
||||
PADAxisMapping* m_pendingAxisMapping = nullptr;
|
||||
int m_pendingPort = -1;
|
||||
} m_controllerConfig;
|
||||
|
||||
struct {
|
||||
bool m_enableBloom = 1;
|
||||
bool m_waterProjectionOffset = false;
|
||||
bool m_fullscreen = false;
|
||||
} m_graphicsSettings;
|
||||
|
||||
bool m_showControllerConfig = false;
|
||||
|
||||
@@ -25,8 +25,7 @@ namespace dusk {
|
||||
|
||||
if (ImGui::BeginMenu("Collision View")) {
|
||||
ImGui::Checkbox("Enable Terrain view", &m_collisionViewSettings.m_enableTerrainView);
|
||||
// can't use wireframe atm because aurora doesn't support GX_LINES
|
||||
//ImGui::Checkbox("Enable wireframe view", &m_collisionViewSettings.m_enableWireframe);
|
||||
ImGui::Checkbox("Enable wireframe view", &m_collisionViewSettings.m_enableWireframe);
|
||||
ImGui::SliderFloat("Opacity##terrain", &m_collisionViewSettings.m_terrainViewOpacity, 0.0f, 100.0f);
|
||||
ImGui::SliderFloat("Draw Range", &m_collisionViewSettings.m_drawRange, 0.0f, 1000.0f);
|
||||
ImGui::Separator();
|
||||
@@ -46,6 +45,7 @@ namespace dusk {
|
||||
ImGui::MenuItem("Player Info", nullptr, &m_showPlayerInfo);
|
||||
ImGui::MenuItem("Save Editor", nullptr, &m_showSaveEditor);
|
||||
ImGui::MenuItem("Audio Debug", "F7", &m_showAudioDebug);
|
||||
ImGui::MenuItem("OSReport Force", nullptr, &OSReportReallyForceEnable);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
@@ -124,10 +124,13 @@ namespace dusk {
|
||||
BytesToString(stats->lastIndexSize)));
|
||||
ImGuiStringViewText(fmt::format(FMT_STRING("Storage size: {}\n"),
|
||||
BytesToString(stats->lastStorageSize)));
|
||||
ImGuiStringViewText(fmt::format(FMT_STRING("Tex upload size: {}\n"),
|
||||
BytesToString(stats->lastTextureUploadSize)));
|
||||
ImGuiStringViewText(fmt::format(
|
||||
FMT_STRING("Total: {}\n"),
|
||||
BytesToString(stats->lastVertSize + stats->lastUniformSize +
|
||||
stats->lastIndexSize + stats->lastStorageSize)));
|
||||
stats->lastIndexSize + stats->lastStorageSize +
|
||||
stats->lastTextureUploadSize)));
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
@@ -189,4 +192,4 @@ namespace dusk {
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace dusk {
|
||||
|
||||
ImGuiMenuTools();
|
||||
void draw();
|
||||
void afterDraw();
|
||||
|
||||
void ShowDebugOverlay();
|
||||
void ShowCameraOverlay();
|
||||
|
||||
@@ -36,18 +36,20 @@ namespace dusk {
|
||||
|
||||
std::lock_guard lock(StubLogMutex);
|
||||
|
||||
if (StubLogBuffer.size() > 1024 * 1024) {
|
||||
DuskLog.warn("Stub log FULL. Dropping logs!");
|
||||
return;
|
||||
}
|
||||
|
||||
LineOffsets.push_back(StubLogBuffer.size());
|
||||
const auto levelName = LogLevelName(level);
|
||||
StubLogBuffer.appendf("[%s | %s] %s\n", levelName, module, message);
|
||||
}
|
||||
|
||||
static void ClearPastFrame();
|
||||
|
||||
void ImGuiMenuTools::ShowStubLog() {
|
||||
std::lock_guard lock(StubLogMutex);
|
||||
|
||||
if (!ImGuiConsole::CheckMenuViewToggle(ImGuiKey_F5, m_showStubLog)) {
|
||||
ClearPastFrame();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,7 +80,6 @@ namespace dusk {
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
ClearPastFrame();
|
||||
}
|
||||
|
||||
void ClearPastFrame() {
|
||||
@@ -88,4 +89,10 @@ namespace dusk {
|
||||
StubLogBuffer.clear();
|
||||
LineOffsets.clear();
|
||||
}
|
||||
|
||||
void ImGuiMenuTools::afterDraw() {
|
||||
std::lock_guard lock(StubLogMutex);
|
||||
|
||||
ClearPastFrame();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#include <aurora/main.h>
|
||||
|
||||
int game_main(int argc, char* argv[]);
|
||||
|
||||
void WindowsSetupConsole();
|
||||
|
||||
Reference in New Issue
Block a user