mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 09:47:43 +00:00
RumbleFxTable and final FrontEnd options functions
This commit is contained in:
@@ -1,36 +1,120 @@
|
||||
#include "CGuiSliderGroup.hpp"
|
||||
#include "Input/CFinalInput.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CGuiSliderGroup::CGuiSliderGroup(const CGuiWidgetParms& parms, float a, float b, float c, float d)
|
||||
: CGuiCompoundWidget(parms), xf8_minVal(a), xfc_maxVal(b), x100_curVal(c), x104_increment(d)
|
||||
CGuiSliderGroup::CGuiSliderGroup(const CGuiWidgetParms& parms, float min, float max, float def, float inc)
|
||||
: CGuiCompoundWidget(parms), xb8_minVal(min), xbc_maxVal(max),
|
||||
xc0_roundedCurVal(def), xc4_curVal(def), xc8_increment(inc)
|
||||
{
|
||||
}
|
||||
|
||||
void CGuiSliderGroup::SetSelectionChangedCallback
|
||||
(std::function<void(CGuiSliderGroup*, float)>&& func)
|
||||
{
|
||||
x114_changeCallback = std::move(func);
|
||||
xd8_changeCallback = std::move(func);
|
||||
}
|
||||
|
||||
void CGuiSliderGroup::SetCurVal(float cur)
|
||||
{
|
||||
x100_curVal = zeus::clamp(xf8_minVal, cur, xfc_maxVal);
|
||||
float factor = 0.f;
|
||||
if (xfc_maxVal != xf8_minVal)
|
||||
factor = (x100_curVal - xf8_minVal) / (xfc_maxVal - xf8_minVal);
|
||||
xc0_roundedCurVal = zeus::clamp(xb8_minVal, cur, xbc_maxVal);
|
||||
xc4_curVal = xc0_roundedCurVal;
|
||||
}
|
||||
|
||||
const zeus::CVector3f& w0Idle = x10c_workers[0]->GetIdlePosition();
|
||||
const zeus::CVector3f& w1Idle = x10c_workers[1]->GetIdlePosition();
|
||||
x10c_workers[0]->SetLocalPosition(zeus::CVector3f::lerp(w0Idle, w1Idle, factor));
|
||||
void CGuiSliderGroup::StartDecreasing()
|
||||
{
|
||||
xf0_state = EState::Decreasing;
|
||||
xf4_24_inputPending = true;
|
||||
}
|
||||
|
||||
void CGuiSliderGroup::StartIncreasing()
|
||||
{
|
||||
xf0_state = EState::Increasing;
|
||||
xf4_24_inputPending = true;
|
||||
}
|
||||
|
||||
void CGuiSliderGroup::ProcessUserInput(const CFinalInput& input)
|
||||
{
|
||||
if (input.DLALeft())
|
||||
{
|
||||
StartDecreasing();
|
||||
return;
|
||||
}
|
||||
if (input.DLARight())
|
||||
{
|
||||
StartIncreasing();
|
||||
return;
|
||||
}
|
||||
if (input.PDPLeft())
|
||||
{
|
||||
StartDecreasing();
|
||||
return;
|
||||
}
|
||||
if (input.PDPRight())
|
||||
{
|
||||
StartIncreasing();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CGuiSliderGroup::Update(float dt)
|
||||
{
|
||||
float fullRange = xbc_maxVal - xb8_minVal;
|
||||
float t1 = fullRange * dt;
|
||||
|
||||
float incCurVal;
|
||||
for (incCurVal = xb8_minVal ; incCurVal <= xc4_curVal ; incCurVal += xc8_increment) {}
|
||||
|
||||
float upperIncVal = std::min(incCurVal, xbc_maxVal);
|
||||
float lowerIncVal = upperIncVal - xc8_increment;
|
||||
|
||||
float oldCurVal = xc4_curVal;
|
||||
if (xf0_state == EState::Decreasing)
|
||||
{
|
||||
if (xf4_24_inputPending)
|
||||
xc4_curVal = std::max(oldCurVal - t1, xb8_minVal);
|
||||
else
|
||||
xc4_curVal = std::max(oldCurVal - t1, lowerIncVal);
|
||||
}
|
||||
else if (xf0_state == EState::Increasing)
|
||||
{
|
||||
if (xf4_24_inputPending)
|
||||
xc4_curVal = std::min(oldCurVal + t1, xbc_maxVal);
|
||||
else if (xc4_curVal != lowerIncVal)
|
||||
xc4_curVal = std::min(oldCurVal + t1, upperIncVal);
|
||||
}
|
||||
|
||||
if (xc4_curVal == oldCurVal)
|
||||
xf0_state = EState::None;
|
||||
|
||||
oldCurVal = xc0_roundedCurVal;
|
||||
if (upperIncVal - xc4_curVal <= xc4_curVal - lowerIncVal)
|
||||
xc0_roundedCurVal = upperIncVal;
|
||||
else
|
||||
xc0_roundedCurVal = lowerIncVal;
|
||||
|
||||
if (oldCurVal != xc0_roundedCurVal && xd8_changeCallback)
|
||||
xd8_changeCallback(this, oldCurVal);
|
||||
|
||||
float fac;
|
||||
if (xbc_maxVal == xb8_minVal)
|
||||
fac = 0.f;
|
||||
else
|
||||
fac = (xc4_curVal - xb8_minVal) / (xbc_maxVal - xb8_minVal);
|
||||
|
||||
const zeus::CVector3f& s0 = xcc_sliderRangeWidgets[0]->GetIdlePosition();
|
||||
const zeus::CVector3f& s1 = xcc_sliderRangeWidgets[1]->GetIdlePosition();
|
||||
|
||||
xcc_sliderRangeWidgets[0]->SetLocalPosition(s1 * fac + s0 * (1.f - fac));
|
||||
xf4_24_inputPending = false;
|
||||
}
|
||||
|
||||
bool CGuiSliderGroup::AddWorkerWidget(CGuiWidget* worker)
|
||||
{
|
||||
if (worker->GetWorkerId() < 0 || worker->GetWorkerId() > 1)
|
||||
return true;
|
||||
x10c_workers[worker->GetWorkerId()] = worker;
|
||||
xcc_sliderRangeWidgets[worker->GetWorkerId()] = worker;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,7 +122,7 @@ CGuiWidget* CGuiSliderGroup::GetWorkerWidget(int id)
|
||||
{
|
||||
if (id < 0 || id > 1)
|
||||
return nullptr;
|
||||
return x10c_workers[id];
|
||||
return xcc_sliderRangeWidgets[id];
|
||||
}
|
||||
|
||||
CGuiSliderGroup* CGuiSliderGroup::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
||||
|
||||
Reference in New Issue
Block a user