mirror of https://github.com/sm64pc/sm64pc.git
[WIP] Changed colors and added scale fix
This commit is contained in:
parent
671af8b836
commit
239c9c1be5
|
@ -25,19 +25,30 @@ void MoonTest::Init(){
|
||||||
//printf("%s\n", res.body.c_str());
|
//printf("%s\n", res.body.c_str());
|
||||||
MoonScreen::Init();
|
MoonScreen::Init();
|
||||||
}
|
}
|
||||||
bool b = true;
|
|
||||||
bool c = true;
|
|
||||||
bool d = true;
|
|
||||||
float e = 0;
|
|
||||||
|
|
||||||
|
bool b = true;
|
||||||
|
float e = 0;
|
||||||
int bIndex = 0;
|
int bIndex = 0;
|
||||||
|
|
||||||
|
int rIndex = 0;
|
||||||
|
|
||||||
vector<string> test = {"Val zero", "Val uwo", "Val owu"};
|
vector<string> test = {"Val zero", "Val uwo", "Val owu"};
|
||||||
|
vector<string> randomize = {"owo", "awa", "uwu", "wololo", "idk"};
|
||||||
|
|
||||||
|
MWValue * testBtn;
|
||||||
|
|
||||||
|
void testF(){
|
||||||
|
rIndex = rand() % randomize.size();
|
||||||
|
testBtn->title = randomize[rIndex];
|
||||||
|
cout << rIndex << endl;
|
||||||
|
}
|
||||||
|
|
||||||
void MoonTest::Mount(){
|
void MoonTest::Mount(){
|
||||||
this->widgets.clear();
|
this->widgets.clear();
|
||||||
this->widgets.push_back(new MWValue({.index = &bIndex, .values = &test}, "Toggle 3 owo", 25, 95));
|
this->widgets.push_back(new MWValue(22, 57, "Bool:", {.bvar = &b}));
|
||||||
this->widgets.push_back(new MWValue({.bvar = &b}, "Toggle owo", 25, 55));
|
this->widgets.push_back(new MWValue(22, 74, "Number:", {.fvar = &e, .max = 10, .min = 0, .step = 0.1f}));
|
||||||
this->widgets.push_back(new MWValue({.fvar = &e, .max = 10, .min = 0, .step = 0.1f}, "Toggle 2 owo", 25, 75));
|
this->widgets.push_back(new MWValue(22, 91, "Array:", {.index = &bIndex, .values = &test}));
|
||||||
|
this->widgets.push_back(testBtn = new MWValue(22, 108, "Randomize", {.btn = testF}));
|
||||||
MoonScreen::Mount();
|
MoonScreen::Mount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +56,7 @@ int x = 0;
|
||||||
int y = 20;
|
int y = 20;
|
||||||
|
|
||||||
void MoonTest::Draw(){
|
void MoonTest::Draw(){
|
||||||
MoonDrawText(0, 0, "Test text", 1.0, {255, 255, 255, 255}, true, false);
|
MoonDrawText(0, 0, "Hi uwu", 0.5, {255, 255, 255, 255}, true, false);
|
||||||
|
|
||||||
string menuTitle = "Placeholder";
|
string menuTitle = "Placeholder";
|
||||||
float txtWidth = MoonGetTextWidth(menuTitle, 1.0, true);
|
float txtWidth = MoonGetTextWidth(menuTitle, 1.0, true);
|
||||||
|
|
|
@ -11,7 +11,7 @@ void MoonDrawText(float x, float y, std::string text, float scale, struct Color
|
||||||
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
|
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
|
||||||
if(dropShadow){
|
if(dropShadow){
|
||||||
gDPSetEnvColor(gDisplayListHead++, 10, 10, 10, 255);
|
gDPSetEnvColor(gDisplayListHead++, 10, 10, 10, 255);
|
||||||
moon_draw_text(x, SCREEN_HEIGHT - y - 1, getTranslatedText(text.c_str()), scale);
|
moon_draw_text(x, SCREEN_HEIGHT - y - 1 * scale, getTranslatedText(text.c_str()), scale);
|
||||||
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
|
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
|
||||||
}
|
}
|
||||||
gDPSetEnvColor(gDisplayListHead++, color.r, color.g, color.b, color.a);
|
gDPSetEnvColor(gDisplayListHead++, color.r, color.g, color.b, color.a);
|
||||||
|
|
|
@ -9,26 +9,40 @@ using namespace std;
|
||||||
|
|
||||||
bool mwvStickExecuted;
|
bool mwvStickExecuted;
|
||||||
|
|
||||||
MWValue::MWValue(MWValueBind bind, std::string title, float x, float y){
|
MWValue::MWValue(float x, float y, std::string title, MWValueBind bind){
|
||||||
this->x = x;
|
this->x = x;
|
||||||
this->y = y;
|
this->y = y;
|
||||||
this->bind = bind;
|
this->bind = bind;
|
||||||
this->title = title;
|
this->title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int focusAnimRange = 80;
|
||||||
|
float focusAnimation = focusAnimRange / 2;
|
||||||
|
int focusAnimationPingPong;
|
||||||
|
|
||||||
void MWValue::Init(){
|
void MWValue::Init(){
|
||||||
mwvStickExecuted = false;
|
mwvStickExecuted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWValue::Draw(){
|
void MWValue::Draw(){
|
||||||
|
|
||||||
|
float step = 0.6;
|
||||||
|
|
||||||
|
if(focusAnimation >= focusAnimRange)
|
||||||
|
focusAnimationPingPong = 1;
|
||||||
|
else if (focusAnimation <= focusAnimRange / 2)
|
||||||
|
focusAnimationPingPong = 0;
|
||||||
|
|
||||||
|
focusAnimation += step * (focusAnimationPingPong ? -1 : 1);
|
||||||
|
|
||||||
float scale = 1;
|
float scale = 1;
|
||||||
float titleWidth = MoonGetTextWidth(this->title + " ", scale, false);
|
float titleWidth = MoonGetTextWidth(this->title + " ", scale, false);
|
||||||
int barWidth = SCREEN_WIDTH - 50 - 20;
|
int barWidth = SCREEN_WIDTH - 50 - 14;
|
||||||
float tmpWidth = titleWidth;
|
float tmpWidth = titleWidth;
|
||||||
|
|
||||||
|
|
||||||
Color focusColors[] = {
|
Color focusColors[] = {
|
||||||
{255, 255, 255, 80},
|
{255, 255, 255, 40 + focusAnimation / 2},
|
||||||
{255, 247, 0, 80},
|
{255, 247, 0, 40 + focusAnimation / 2},
|
||||||
{0, 0, 0, 0},
|
{0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,8 +54,8 @@ void MWValue::Draw(){
|
||||||
if(this->bind.bvar != NULL){
|
if(this->bind.bvar != NULL){
|
||||||
bool status = *this->bind.bvar;
|
bool status = *this->bind.bvar;
|
||||||
Color toggleColors[] = {
|
Color toggleColors[] = {
|
||||||
{32, 255, 3, 255},
|
{61, 255, 113, 255},
|
||||||
{255, 32, 3, 255}
|
{255, 61, 61, 255}
|
||||||
};
|
};
|
||||||
string statusText = status ? Moon_GetKey("TEXT_OPT_ENABLED") : Moon_GetKey("TEXT_OPT_DISABLED");
|
string statusText = status ? Moon_GetKey("TEXT_OPT_ENABLED") : Moon_GetKey("TEXT_OPT_DISABLED");
|
||||||
|
|
||||||
|
@ -53,7 +67,7 @@ void MWValue::Draw(){
|
||||||
string text = (*this->bind.values)[index];
|
string text = (*this->bind.values)[index];
|
||||||
|
|
||||||
tmpWidth += MoonGetTextWidth(text, scale, false);
|
tmpWidth += MoonGetTextWidth(text, scale, false);
|
||||||
MoonDrawText(this->x + ( 10 + barWidth / 2 ) - tmpWidth / 2 + titleWidth, this->y, text, scale, {100, 100, 255, 255}, true, true);
|
MoonDrawText(this->x + ( 10 + barWidth / 2 ) - tmpWidth / 2 + titleWidth, this->y, text, scale, {58, 249, 252, 255}, true, true);
|
||||||
} else if(isFloat || isInt){
|
} else if(isFloat || isInt){
|
||||||
float value = isFloat ? *this->bind.fvar : *this->bind.ivar;
|
float value = isFloat ? *this->bind.fvar : *this->bind.ivar;
|
||||||
float max = this->bind.max;
|
float max = this->bind.max;
|
||||||
|
@ -61,9 +75,12 @@ void MWValue::Draw(){
|
||||||
string text = to_string((int)(100 * (value / max))) + "%";
|
string text = to_string((int)(100 * (value / max))) + "%";
|
||||||
|
|
||||||
tmpWidth += MoonGetTextWidth(text, scale, false);
|
tmpWidth += MoonGetTextWidth(text, scale, false);
|
||||||
MoonDrawText(this->x + ( 10 + barWidth / 2 ) - tmpWidth / 2 + titleWidth, this->y, text, scale, {100, 100, 255, 255}, true, true);
|
MoonDrawText(this->x + ( 10 + barWidth / 2 ) - tmpWidth / 2 + titleWidth, this->y, text, scale, {58, 249, 252, 255}, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this->bind.btn != NULL)
|
||||||
|
tmpWidth = titleWidth;
|
||||||
|
|
||||||
MoonDrawText(this->x + ( 10 + barWidth / 2 ) - tmpWidth / 2, this->y, this->title, scale, {255, 255, 255, 255}, true, true);
|
MoonDrawText(this->x + ( 10 + barWidth / 2 ) - tmpWidth / 2, this->y, this->title, scale, {255, 255, 255, 255}, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,22 +90,25 @@ void MWValue::Update(){
|
||||||
float xStick = GetStickValue(MoonButtons::L_STICK, false);
|
float xStick = GetStickValue(MoonButtons::L_STICK, false);
|
||||||
bool isBool = this->bind.bvar != NULL;
|
bool isBool = this->bind.bvar != NULL;
|
||||||
bool isArray = this->bind.values != NULL && this->bind.index != NULL;
|
bool isArray = this->bind.values != NULL && this->bind.index != NULL;
|
||||||
|
|
||||||
bool isFloat = this->bind.fvar != NULL;
|
bool isFloat = this->bind.fvar != NULL;
|
||||||
bool isInt = this->bind.ivar != NULL;
|
bool isInt = this->bind.ivar != NULL;
|
||||||
|
bool isBtn = this->bind.btn != NULL;
|
||||||
|
|
||||||
float maxValue = isArray ? (*this->bind.values).size() - 1 : this->bind.max;
|
float maxValue = isArray ? (*this->bind.values).size() - 1 : this->bind.max;
|
||||||
float minValue = isArray ? 0 : this->bind.min;
|
float minValue = isArray ? 0 : this->bind.min;
|
||||||
float step = isArray ? 1 : this->bind.step;
|
float step = isArray ? 1 : this->bind.step;
|
||||||
|
|
||||||
|
if(isBtn && IsBtnPressed(MoonButtons::A_BTN)){
|
||||||
|
this->bind.btn();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(xStick < 0) {
|
if(xStick < 0) {
|
||||||
if(mwvStickExecuted) return;
|
if(mwvStickExecuted) return;
|
||||||
if(isBool) {
|
if(isBool) {
|
||||||
*this->bind.bvar = !*this->bind.bvar;
|
*this->bind.bvar = !*this->bind.bvar;
|
||||||
std::cout << "Executed" << std::endl;
|
|
||||||
} else if(isArray || isFloat || isInt) {
|
} else if(isArray || isFloat || isInt) {
|
||||||
float cIndex = isArray ? (int) *this->bind.index : isFloat ? *this->bind.fvar : *this->bind.ivar;
|
float cIndex = isArray ? (int) *this->bind.index : isFloat ? *this->bind.fvar : *this->bind.ivar;
|
||||||
cout << "Test" << endl;
|
|
||||||
if(cIndex > minValue){
|
if(cIndex > minValue){
|
||||||
if(isArray) *this->bind.index -= (int)step;
|
if(isArray) *this->bind.index -= (int)step;
|
||||||
if(isFloat) *this->bind.fvar -= step;
|
if(isFloat) *this->bind.fvar -= step;
|
||||||
|
@ -98,7 +118,6 @@ void MWValue::Update(){
|
||||||
if(isFloat) *this->bind.fvar = maxValue;
|
if(isFloat) *this->bind.fvar = maxValue;
|
||||||
if(isInt) *this->bind.ivar = (int)maxValue;
|
if(isInt) *this->bind.ivar = (int)maxValue;
|
||||||
}
|
}
|
||||||
std::cout << "Executed x2" << std::endl;
|
|
||||||
}
|
}
|
||||||
mwvStickExecuted = true;
|
mwvStickExecuted = true;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +137,6 @@ void MWValue::Update(){
|
||||||
if(isFloat) *this->bind.fvar = minValue;
|
if(isFloat) *this->bind.fvar = minValue;
|
||||||
if(isInt) *this->bind.ivar = (int)minValue;
|
if(isInt) *this->bind.ivar = (int)minValue;
|
||||||
}
|
}
|
||||||
std::cout << "Executed x3" << std::endl;
|
|
||||||
}
|
}
|
||||||
mwvStickExecuted = true;
|
mwvStickExecuted = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,17 +13,17 @@ struct MWValueBind{
|
||||||
float max;
|
float max;
|
||||||
float min;
|
float min;
|
||||||
float step;
|
float step;
|
||||||
|
void (*btn)();
|
||||||
|
|
||||||
int *index;
|
int *index;
|
||||||
std::vector<std::string>* values;
|
std::vector<std::string>* values;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MWValue : public MoonWidget {
|
class MWValue : public MoonWidget {
|
||||||
private:
|
public:
|
||||||
MWValueBind bind;
|
MWValueBind bind;
|
||||||
std::string title;
|
std::string title;
|
||||||
public:
|
MWValue(float x, float y, std::string title, MWValueBind bind);
|
||||||
MWValue(MWValueBind bind, std::string title, float x, float y);
|
|
||||||
void Init();
|
void Init();
|
||||||
void Draw();
|
void Draw();
|
||||||
void Update();
|
void Update();
|
||||||
|
|
|
@ -45,7 +45,7 @@ void moon_draw_text(f32 x, f32 y, const u8 *str, float scale) {
|
||||||
UNUSED s8 mark = DIALOG_MARK_NONE;
|
UNUSED s8 mark = DIALOG_MARK_NONE;
|
||||||
s32 strPos = 0;
|
s32 strPos = 0;
|
||||||
u8 lineNum = 1;
|
u8 lineNum = 1;
|
||||||
y -= 16;
|
y -= 16 * scale;
|
||||||
|
|
||||||
Mtx *_Matrix = (Mtx *) alloc_display_list(sizeof(Mtx));
|
Mtx *_Matrix = (Mtx *) alloc_display_list(sizeof(Mtx));
|
||||||
if (!_Matrix) return;
|
if (!_Matrix) return;
|
||||||
|
|
Loading…
Reference in New Issue