mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-09-14 13:32:08 +00:00
hacks
This commit is contained in:
parent
e07ba43106
commit
347ed3681b
3 changed files with 4827 additions and 3817 deletions
4001
Data/Sys/GameSettings/GALE01r2 - Copy.ini
Normal file
4001
Data/Sys/GameSettings/GALE01r2 - Copy.ini
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -205,7 +205,7 @@ bool ButtonCustom(const char* label, const ImVec2& size_arg, ImGuiButtonFlags fl
|
||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SliderCustomBehavior(const ImRect& bb, ImGuiID id, int* v, int v_min, int v_max, float power, ImGuiSliderFlags flags, ImVec4 color, ImVec2 valuesize, const char* label, char* value)
|
bool SeekBarBehavior(const ImRect& bb, ImGuiID id, int* v, int v_min, int v_max, float power, ImGuiSliderFlags flags, ImVec4 color, ImVec2 valuesize, const char* label, char* value)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
|
@ -343,7 +343,136 @@ bool SliderCustomBehavior(const ImRect& bb, ImGuiID id, int* v, int v_min, int v
|
||||||
return value_changed;
|
return value_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SliderCustom(const char* label, ImVec4 color, int* v, int v_min, int v_max, float power, const char* format)
|
bool VolumeBarBehavior(const ImRect& bb, ImGuiID id, int* v, int v_min, int v_max, float power,
|
||||||
|
ImGuiSliderFlags flags, ImVec4 color, ImVec2 valuesize, const char* label,
|
||||||
|
char* value)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
const ImGuiStyle& style = g.Style;
|
||||||
|
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||||
|
const ImGuiAxis axis = (flags & ImGuiSliderFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X;
|
||||||
|
const bool is_decimal = false; // TODO handle other types
|
||||||
|
const bool is_power = (power != 1.0f) && is_decimal;
|
||||||
|
|
||||||
|
const float slider_sz = (bb.Max[axis] - bb.Min[axis]);
|
||||||
|
const float slider_usable_pos_min = bb.Min[axis];
|
||||||
|
const float slider_usable_pos_max = bb.Max[axis];
|
||||||
|
|
||||||
|
float linear_zero_pos = 0.0f;
|
||||||
|
if (is_power && v_min * v_max < 0.0f)
|
||||||
|
{
|
||||||
|
const float linear_dist_min_to_0 =
|
||||||
|
ImPow(v_min >= 0 ? (float)v_min : -(float)v_min, (float)1.0f / power);
|
||||||
|
const float linear_dist_max_to_0 =
|
||||||
|
ImPow(v_max >= 0 ? (float)v_max : -(float)v_max, (float)1.0f / power);
|
||||||
|
linear_zero_pos = (float)(linear_dist_min_to_0 / (linear_dist_min_to_0 + linear_dist_max_to_0));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
linear_zero_pos = v_min < 0.0f ? 1.0f : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool isDown = g.IO.MouseDown[0];
|
||||||
|
bool value_changed = false;
|
||||||
|
bool isActive = g.ActiveId == id;
|
||||||
|
|
||||||
|
if (!isDown && isActive)
|
||||||
|
ImGui::ClearActiveID();
|
||||||
|
|
||||||
|
// Calculate mouse position if clicked or held
|
||||||
|
int new_value = 0;
|
||||||
|
if (isDown)
|
||||||
|
{
|
||||||
|
const float mouse_abs_pos = g.IO.MousePos[axis];
|
||||||
|
float clicked_t = (slider_sz > 0.0f) ?
|
||||||
|
ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_sz, 0.0f, 1.0f) :
|
||||||
|
0.0f;
|
||||||
|
if (axis == ImGuiAxis_Y)
|
||||||
|
clicked_t = 1.0f - clicked_t;
|
||||||
|
|
||||||
|
if (is_power)
|
||||||
|
{
|
||||||
|
if (clicked_t < linear_zero_pos)
|
||||||
|
{
|
||||||
|
float a = 1.0f - (clicked_t / linear_zero_pos);
|
||||||
|
a = ImPow(a, power);
|
||||||
|
new_value = ImLerp(ImMin(v_max, 0), v_min, a);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float a;
|
||||||
|
if (ImFabs(linear_zero_pos - 1.0f) > 1.e-6f)
|
||||||
|
a = (clicked_t - linear_zero_pos) / (1.0f - linear_zero_pos);
|
||||||
|
else
|
||||||
|
a = clicked_t;
|
||||||
|
a = ImPow(a, power);
|
||||||
|
new_value = ImLerp(ImMax(v_min, 0), v_max, a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*v = ImLerp(v_min, v_max, clicked_t);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only change value if left mouse button is actually down
|
||||||
|
if (*v != new_value && isDown)
|
||||||
|
{
|
||||||
|
*v = new_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float new_grab_t = ImGui::SliderCalcRatioFromValueT<int, float>(
|
||||||
|
ImGuiDataType_S32, new_value, v_min, v_max, power, linear_zero_pos);
|
||||||
|
float curr_grab_t = ImGui::SliderCalcRatioFromValueT<int, float>(ImGuiDataType_S32, *v, v_min,
|
||||||
|
v_max, power, linear_zero_pos);
|
||||||
|
if (axis == ImGuiAxis_Y)
|
||||||
|
{
|
||||||
|
new_grab_t = 1.0f - new_grab_t;
|
||||||
|
curr_grab_t = 1.0f - curr_grab_t;
|
||||||
|
}
|
||||||
|
const float new_grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, new_grab_t);
|
||||||
|
const float curr_grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, curr_grab_t);
|
||||||
|
ImRect new_grab_bb;
|
||||||
|
ImRect curr_grab_bb;
|
||||||
|
if (axis == ImGuiAxis_X)
|
||||||
|
{
|
||||||
|
new_grab_bb = ImRect(ImVec2(new_grab_pos, bb.Min.y), ImVec2(new_grab_pos, bb.Max.y));
|
||||||
|
curr_grab_bb = ImRect(ImVec2(curr_grab_pos, bb.Min.y), ImVec2(curr_grab_pos, bb.Max.y));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new_grab_bb = ImRect(ImVec2(bb.Min.x, new_grab_pos), ImVec2(bb.Max.x, new_grab_pos));
|
||||||
|
curr_grab_bb = ImRect(ImVec2(bb.Min.x, curr_grab_pos), ImVec2(bb.Max.x, curr_grab_pos));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw all the things
|
||||||
|
|
||||||
|
// Grey background line
|
||||||
|
window->DrawList->AddLine(
|
||||||
|
ImVec2(bb.Min.x, bb.Max.y - 6), ImVec2(bb.Max.x, bb.Max.y - 6),
|
||||||
|
ImGui::ColorConvertFloat4ToU32(ImVec4(1.0f, 1.0f, 1.0f, 0.5f * style.Alpha)), 4);
|
||||||
|
|
||||||
|
|
||||||
|
if (isDown)
|
||||||
|
window->DrawList->AddText(ImVec2(new_grab_bb.GetCenter().x - valuesize.x / 2, bb.Max.y - 30),
|
||||||
|
ImColor(255, 255, 255), GetTimeForFrame(new_value).c_str());
|
||||||
|
|
||||||
|
// Colored line, circle indicator, and text
|
||||||
|
if (isDown)
|
||||||
|
{
|
||||||
|
window->DrawList->AddCircleFilled(
|
||||||
|
ImVec2(new_grab_bb.Min.x, new_grab_bb.Max.y - 6), 6,
|
||||||
|
ImGui::ColorConvertFloat4ToU32(ImVec4(0.0f, 1.0f, 0.0f, 1.0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
window->DrawList->AddLine(
|
||||||
|
ImVec2(bb.Min.x, bb.Max.y - 6), ImVec2(curr_grab_bb.Min.x, bb.Max.y - 6),
|
||||||
|
ImGui::ColorConvertFloat4ToU32(ImVec4(0.0f, 1.0f, 0.0f, style.Alpha)), 4);
|
||||||
|
|
||||||
|
return value_changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SeekBar(const char* label, ImVec4 color, int* v, int v_min, int v_max, float power, const char* format)
|
||||||
{
|
{
|
||||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||||
if (window->SkipItems)
|
if (window->SkipItems)
|
||||||
|
@ -382,7 +511,7 @@ bool SliderCustom(const char* label, ImVec4 color, int* v, int v_min, int v_max,
|
||||||
|
|
||||||
char value_buf[64];
|
char value_buf[64];
|
||||||
const char* value_buf_end = value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), format, *v);
|
const char* value_buf_end = value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), format, *v);
|
||||||
const bool value_changed = SliderCustomBehavior(frame_bb, id, v, v_min, v_max, power, ImGuiSliderFlags_None, color, ImGui::CalcTextSize(value_buf, NULL, true), value_buf_end, value_buf);
|
const bool value_changed = SeekBarBehavior(frame_bb, id, v, v_min, v_max, power, ImGuiSliderFlags_None, color, ImGui::CalcTextSize(value_buf, NULL, true), value_buf_end, value_buf);
|
||||||
|
|
||||||
if (label_size.x > 0.0f)
|
if (label_size.x > 0.0f)
|
||||||
ImGui::RenderText(ImVec2(frame_bb.Min.x + style.ItemInnerSpacing.x, frame_bb.Min.y + 25), label);
|
ImGui::RenderText(ImVec2(frame_bb.Min.x + style.ItemInnerSpacing.x, frame_bb.Min.y + 25), label);
|
||||||
|
@ -390,6 +519,58 @@ bool SliderCustom(const char* label, ImVec4 color, int* v, int v_min, int v_max,
|
||||||
return value_changed;
|
return value_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VolumeBar(const char* label, ImVec4 color, int* v, int v_min, int v_max, float power,
|
||||||
|
const char* format)
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||||
|
if (window->SkipItems)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
const ImGuiStyle& style = g.Style;
|
||||||
|
const ImGuiID id = window->GetID(label);
|
||||||
|
const float w = ImGui::CalcItemWidth();
|
||||||
|
|
||||||
|
const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true) * 1.0f;
|
||||||
|
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y));
|
||||||
|
|
||||||
|
const bool hovered = ImGui::ItemHoverable(frame_bb, id);
|
||||||
|
if (hovered)
|
||||||
|
ImGui::SetHoveredID(id);
|
||||||
|
|
||||||
|
if (!format)
|
||||||
|
format = "%d";
|
||||||
|
|
||||||
|
bool start_text_input = false;
|
||||||
|
const bool tab_focus_requested = ImGui::FocusableItemRegister(window, g.ActiveId == id);
|
||||||
|
if (tab_focus_requested || (hovered && g.IO.MouseClicked[0]))
|
||||||
|
{
|
||||||
|
ImGui::SetActiveID(id, window);
|
||||||
|
ImGui::FocusWindow(window);
|
||||||
|
|
||||||
|
if (tab_focus_requested || g.IO.KeyCtrl)
|
||||||
|
{
|
||||||
|
start_text_input = true;
|
||||||
|
g.ScalarAsInputTextId = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (start_text_input || (g.ActiveId == id && g.ScalarAsInputTextId == id))
|
||||||
|
return ImGui::InputScalarAsWidgetReplacement(frame_bb, id, label, ImGuiDataType_S32, v, format);
|
||||||
|
|
||||||
|
char value_buf[64];
|
||||||
|
const char* value_buf_end =
|
||||||
|
value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), format, *v);
|
||||||
|
const bool value_changed =
|
||||||
|
VolumeBarBehavior(frame_bb, id, v, v_min, v_max, power, ImGuiSliderFlags_Vertical, color,
|
||||||
|
ImGui::CalcTextSize(value_buf, NULL, true), value_buf_end, value_buf);
|
||||||
|
|
||||||
|
if (label_size.x > 0.0f)
|
||||||
|
ImGui::RenderText(ImVec2(frame_bb.Min.x + style.ItemInnerSpacing.x, frame_bb.Min.y + 25),
|
||||||
|
label);
|
||||||
|
|
||||||
|
return value_changed;
|
||||||
|
}
|
||||||
|
|
||||||
void DrawSlippiPlaybackControls()
|
void DrawSlippiPlaybackControls()
|
||||||
{
|
{
|
||||||
const auto height = ImGui::GetWindowHeight();
|
const auto height = ImGui::GetWindowHeight();
|
||||||
|
@ -423,7 +604,7 @@ void DrawSlippiPlaybackControls()
|
||||||
{
|
{
|
||||||
ImGui::PushItemWidth(ImGui::GetWindowWidth());
|
ImGui::PushItemWidth(ImGui::GetWindowWidth());
|
||||||
ImGui::SetCursorPos(ImVec2(0.0f, ImGui::GetWindowHeight() - 44));
|
ImGui::SetCursorPos(ImVec2(0.0f, ImGui::GetWindowHeight() - 44));
|
||||||
if (SliderCustom("", ImVec4(1.0f, 0.0f, 0.0f, 1.0f), &frame, Slippi::PLAYBACK_FIRST_SAVE, g_playbackStatus->lastFrame, 1.0, "%d")) {
|
if (SeekBar("", ImVec4(1.0f, 0.0f, 0.0f, 1.0f), &frame, Slippi::PLAYBACK_FIRST_SAVE, g_playbackStatus->lastFrame, 1.0, "%d")) {
|
||||||
INFO_LOG(SLIPPI, "seeking to %d", g_playbackStatus->targetFrameNum);
|
INFO_LOG(SLIPPI, "seeking to %d", g_playbackStatus->targetFrameNum);
|
||||||
Host_PlaybackSeek();
|
Host_PlaybackSeek();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue