mirror of
https://github.com/mwpenny/portal64-still-alive.git
synced 2024-10-20 10:37:37 -04:00
Start work on joystick options
This commit is contained in:
parent
da4f5e6a8f
commit
3fe76c2d30
2
Makefile
2
Makefile
|
@ -257,6 +257,8 @@ build/src/menu/landing_menu.o: build/assets/materials/ui.h build/src/audio/clips
|
||||||
|
|
||||||
build/src/menu/options_menu.o: build/assets/materials/ui.h
|
build/src/menu/options_menu.o: build/assets/materials/ui.h
|
||||||
|
|
||||||
|
build/src/menu/joystick_options.o: build/assets/materials/ui.h
|
||||||
|
|
||||||
build/src/menu/controls.o: build/assets/materials/ui.h build/src/audio/clips.h
|
build/src/menu/controls.o: build/assets/materials/ui.h build/src/audio/clips.h
|
||||||
|
|
||||||
build/assets/models/player/chell.h: assets/materials/chell.skm.yaml
|
build/assets/models/player/chell.h: assets/materials/chell.skm.yaml
|
||||||
|
|
|
@ -136,12 +136,13 @@ Where `/home/james/Blender/blender-2.93.1-linux-x64` is the folder where Blender
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
## Current New Feature TODO List
|
## Current New Feature TODO List
|
||||||
|
- [ ] Adding y-axis/x-axis inverting options #55
|
||||||
|
- [ ] Adding look axis sensitivity setting
|
||||||
- [ ] rotate auto uv
|
- [ ] rotate auto uv
|
||||||
- [ ] disable portal surfaces manually on some surfaces #135
|
- [ ] disable portal surfaces manually on some surfaces #135
|
||||||
- [ ] Portal not rendering recursively sometimes #138
|
- [ ] Portal not rendering recursively sometimes #138
|
||||||
- [ ] Correct elevator timing
|
- [ ] Correct elevator timing
|
||||||
- [ ] Presort portal gun polygon order #102
|
- [ ] Presort portal gun polygon order #102
|
||||||
- [ ] Adding y-axis/x-axis inverting options #55
|
|
||||||
- [ ] Adding loading notice between levels #45
|
- [ ] Adding loading notice between levels #45
|
||||||
- [ ] Vertex lighting #39
|
- [ ] Vertex lighting #39
|
||||||
- [x] Adding a menu to game #47
|
- [x] Adding a menu to game #47
|
||||||
|
|
|
@ -338,9 +338,11 @@ void controlsMenuRender(struct ControlsMenu* controlsMenu, struct RenderState* r
|
||||||
|
|
||||||
gSPDisplayList(renderState->dl++, ui_material_list[SOLID_ENV_INDEX]);
|
gSPDisplayList(renderState->dl++, ui_material_list[SOLID_ENV_INDEX]);
|
||||||
gSPDisplayList(renderState->dl++, controlsMenu->scrollOutline);
|
gSPDisplayList(renderState->dl++, controlsMenu->scrollOutline);
|
||||||
|
gDPPipeSync(renderState->dl++);
|
||||||
gDPSetEnvColor(renderState->dl++, 0, 0, 0, 255);
|
gDPSetEnvColor(renderState->dl++, 0, 0, 0, 255);
|
||||||
renderStateInlineBranch(renderState, controlsMenu->headerSeparators);
|
renderStateInlineBranch(renderState, controlsMenu->headerSeparators);
|
||||||
|
|
||||||
|
|
||||||
if (controlsMenu->selectedRow >= 0 && controlsMenu->selectedRow < ControllerActionCount) {
|
if (controlsMenu->selectedRow >= 0 && controlsMenu->selectedRow < ControllerActionCount) {
|
||||||
struct ControlsMenuRow* selectedAction = &controlsMenu->actionRows[controlsMenu->selectedRow];
|
struct ControlsMenuRow* selectedAction = &controlsMenu->actionRows[controlsMenu->selectedRow];
|
||||||
|
|
||||||
|
@ -377,6 +379,7 @@ void controlsMenuRender(struct ControlsMenu* controlsMenu, struct RenderState* r
|
||||||
|
|
||||||
gDPSetScissor(renderState->dl++, G_SC_NON_INTERLACE, CONTROLS_X, CONTROLS_Y, CONTROLS_X + CONTROLS_WIDTH, CONTROLS_Y + CONTROLS_HEIGHT);
|
gDPSetScissor(renderState->dl++, G_SC_NON_INTERLACE, CONTROLS_X, CONTROLS_Y, CONTROLS_X + CONTROLS_WIDTH, CONTROLS_Y + CONTROLS_HEIGHT);
|
||||||
|
|
||||||
|
|
||||||
gSPDisplayList(renderState->dl++, ui_material_list[DEJAVU_SANS_INDEX]);
|
gSPDisplayList(renderState->dl++, ui_material_list[DEJAVU_SANS_INDEX]);
|
||||||
|
|
||||||
gDPPipeSync(renderState->dl++);
|
gDPPipeSync(renderState->dl++);
|
||||||
|
|
52
src/menu/joystick_options.c
Normal file
52
src/menu/joystick_options.c
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#include "joystick_options.h"
|
||||||
|
|
||||||
|
#include "../controls/controller.h"
|
||||||
|
#include "../font/dejavusans.h"
|
||||||
|
|
||||||
|
#include "../build/assets/materials/ui.h"
|
||||||
|
|
||||||
|
#define JOYSTICK_Y 54
|
||||||
|
#define JOYSTICK_WIDTH 252
|
||||||
|
#define JOYSTICK_HEIGHT 124
|
||||||
|
|
||||||
|
#define JOYSTICK_X ((SCREEN_WD - JOYSTICK_WIDTH) / 2)
|
||||||
|
|
||||||
|
void joystickOptionsInit(struct JoystickOptions* joystickOptions) {
|
||||||
|
joystickOptions->selectedItem = 0;
|
||||||
|
|
||||||
|
joystickOptions->invertControls = menuBuildCheckbox(&gDejaVuSansFont, "Invert Camera", JOYSTICK_X + 8, JOYSTICK_Y + 8);
|
||||||
|
joystickOptions->lookSensitivity = menuBuildSlider(JOYSTICK_X + 8, JOYSTICK_Y + 20, 80, 8, 13);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum MenuDirection joystickOptionsUpdate(struct JoystickOptions* joystickOptions) {
|
||||||
|
int controllerDir = controllerGetDirectionDown(0);
|
||||||
|
|
||||||
|
if (controllerGetButtonDown(0, B_BUTTON)) {
|
||||||
|
return MenuDirectionUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (controllerDir & ControllerDirectionLeft) {
|
||||||
|
return MenuDirectionLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (controllerDir & ControllerDirectionRight) {
|
||||||
|
return MenuDirectionRight;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MenuDirectionStay;
|
||||||
|
}
|
||||||
|
|
||||||
|
void joystickOptionsRender(struct JoystickOptions* joystickOptions, struct RenderState* renderState, struct GraphicsTask* task) {
|
||||||
|
gSPDisplayList(renderState->dl++, ui_material_list[SOLID_ENV_INDEX]);
|
||||||
|
|
||||||
|
gSPDisplayList(renderState->dl++, joystickOptions->invertControls.outline);
|
||||||
|
gSPDisplayList(renderState->dl++, joystickOptions->lookSensitivity.back);
|
||||||
|
|
||||||
|
gSPDisplayList(renderState->dl++, ui_material_revert_list[SOLID_ENV_INDEX]);
|
||||||
|
|
||||||
|
gSPDisplayList(renderState->dl++, ui_material_list[DEJAVU_SANS_INDEX]);
|
||||||
|
|
||||||
|
gSPDisplayList(renderState->dl++, joystickOptions->invertControls.text);
|
||||||
|
|
||||||
|
gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]);
|
||||||
|
}
|
17
src/menu/joystick_options.h
Normal file
17
src/menu/joystick_options.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef __MENU_JOYSTICK_OPTIONS_H__
|
||||||
|
#define __MENU_JOYSTICK_OPTIONS_H__
|
||||||
|
|
||||||
|
#include "./menu.h"
|
||||||
|
#include "../graphics/graphics.h"
|
||||||
|
|
||||||
|
struct JoystickOptions {
|
||||||
|
struct MenuCheckbox invertControls;
|
||||||
|
struct MenuSlider lookSensitivity;
|
||||||
|
short selectedItem;
|
||||||
|
};
|
||||||
|
|
||||||
|
void joystickOptionsInit(struct JoystickOptions* joystickOptions);
|
||||||
|
enum MenuDirection joystickOptionsUpdate(struct JoystickOptions* joystickOptions);
|
||||||
|
void joystickOptionsRender(struct JoystickOptions* joystickOptions, struct RenderState* renderState, struct GraphicsTask* task);
|
||||||
|
|
||||||
|
#endif
|
|
@ -121,10 +121,7 @@ Gfx* menuBuildSolidBorder(int x, int y, int w, int h, int nx, int ny, int nw, in
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx* menuBuildOutline(int x, int y, int width, int height, int invert) {
|
Gfx* menuRenderOutline(int x, int y, int width, int height, int invert, Gfx* dl) {
|
||||||
Gfx* result = malloc(sizeof(Gfx) * 9);
|
|
||||||
Gfx* dl = result;
|
|
||||||
|
|
||||||
gDPPipeSync(dl++);
|
gDPPipeSync(dl++);
|
||||||
if (invert) {
|
if (invert) {
|
||||||
gDPSetEnvColor(dl++, gBorderDark.r, gBorderDark.g, gBorderDark.b, gBorderDark.a);
|
gDPSetEnvColor(dl++, gBorderDark.r, gBorderDark.g, gBorderDark.b, gBorderDark.a);
|
||||||
|
@ -141,8 +138,14 @@ Gfx* menuBuildOutline(int x, int y, int width, int height, int invert) {
|
||||||
}
|
}
|
||||||
gDPFillRectangle(dl++, x, y + height - 1, x + width, y + height);
|
gDPFillRectangle(dl++, x, y + height - 1, x + width, y + height);
|
||||||
gDPFillRectangle(dl++, x + width - 1, y, x + width, y + height - 1);
|
gDPFillRectangle(dl++, x + width - 1, y, x + width, y + height - 1);
|
||||||
gSPEndDisplayList(dl++);
|
|
||||||
|
|
||||||
|
return dl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Gfx* menuBuildOutline(int x, int y, int width, int height, int invert) {
|
||||||
|
Gfx* result = malloc(sizeof(Gfx) * 9);
|
||||||
|
Gfx* dl = menuRenderOutline(x, y, width, height, invert, result);
|
||||||
|
gSPEndDisplayList(dl++);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,4 +170,63 @@ void menuSetRenderColor(struct RenderState* renderState, int isSelected, struct
|
||||||
} else {
|
} else {
|
||||||
gDPSetEnvColor(renderState->dl++, defaultColor->r, defaultColor->g, defaultColor->b, defaultColor->a);
|
gDPSetEnvColor(renderState->dl++, defaultColor->r, defaultColor->g, defaultColor->b, defaultColor->a);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CHECKBOX_SIZE 12
|
||||||
|
|
||||||
|
struct MenuCheckbox menuBuildCheckbox(struct Font* font, char* message, int x, int y) {
|
||||||
|
struct MenuCheckbox result;
|
||||||
|
|
||||||
|
result.x = x;
|
||||||
|
result.y = y;
|
||||||
|
|
||||||
|
result.outline = malloc(sizeof(Gfx) * 12);
|
||||||
|
|
||||||
|
Gfx* dl = result.outline;
|
||||||
|
|
||||||
|
gDPPipeSync(dl++);
|
||||||
|
gDPSetEnvColor(dl++, 93, 96, 97, 255);
|
||||||
|
gDPFillRectangle(dl++, x, y, x + CHECKBOX_SIZE, y + CHECKBOX_SIZE);
|
||||||
|
dl = menuRenderOutline(x, y, CHECKBOX_SIZE, CHECKBOX_SIZE, 1, dl);
|
||||||
|
gSPEndDisplayList(dl++);
|
||||||
|
|
||||||
|
result.text = menuBuildText(font, message, x + CHECKBOX_SIZE + 6, y);
|
||||||
|
|
||||||
|
result.checked = 0;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SLIDER_CENTER_HEIGHT 4
|
||||||
|
|
||||||
|
struct MenuSlider menuBuildSlider(int x, int y, int w, int h, int tickCount) {
|
||||||
|
struct MenuSlider result;
|
||||||
|
|
||||||
|
result.x = x;
|
||||||
|
result.y = y;
|
||||||
|
result.w = w;
|
||||||
|
result.h = h;
|
||||||
|
|
||||||
|
result.back = malloc(sizeof(Gfx) * 12 + tickCount + 2);
|
||||||
|
|
||||||
|
Gfx* dl = result.back;
|
||||||
|
|
||||||
|
int sliderX = x;
|
||||||
|
int sliderY = y + (h >> 1) - (SLIDER_CENTER_HEIGHT >> 1);
|
||||||
|
|
||||||
|
gDPPipeSync(dl++);
|
||||||
|
gDPSetEnvColor(dl++, 93, 96, 97, 255);
|
||||||
|
gDPFillRectangle(
|
||||||
|
dl++,
|
||||||
|
sliderX,
|
||||||
|
sliderY,
|
||||||
|
sliderX + w,
|
||||||
|
sliderY + SLIDER_CENTER_HEIGHT
|
||||||
|
);
|
||||||
|
dl = menuRenderOutline(sliderX, sliderY, w, SLIDER_CENTER_HEIGHT, 1, dl);
|
||||||
|
gSPEndDisplayList(dl++);
|
||||||
|
|
||||||
|
result.value = 0;
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
|
@ -13,6 +13,21 @@ struct MenuButton {
|
||||||
short w, h;
|
short w, h;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MenuCheckbox {
|
||||||
|
Gfx* outline;
|
||||||
|
Gfx* text;
|
||||||
|
Gfx* checkedIndicator;
|
||||||
|
short x, y;
|
||||||
|
short checked;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MenuSlider {
|
||||||
|
Gfx* back;
|
||||||
|
float value;
|
||||||
|
short x, y;
|
||||||
|
short w, h;
|
||||||
|
};
|
||||||
|
|
||||||
enum MenuDirection {
|
enum MenuDirection {
|
||||||
MenuDirectionStay,
|
MenuDirectionStay,
|
||||||
MenuDirectionUp,
|
MenuDirectionUp,
|
||||||
|
@ -39,4 +54,7 @@ Gfx* menuBuildOutline(int x, int y, int width, int height, int invert);
|
||||||
struct MenuButton menuBuildButton(struct Font* font, char* message, int x, int y, int width, int height);
|
struct MenuButton menuBuildButton(struct Font* font, char* message, int x, int y, int width, int height);
|
||||||
void menuSetRenderColor(struct RenderState* renderState, int isSelected, struct Coloru8* selected, struct Coloru8* defaultColor);
|
void menuSetRenderColor(struct RenderState* renderState, int isSelected, struct Coloru8* selected, struct Coloru8* defaultColor);
|
||||||
|
|
||||||
|
struct MenuCheckbox menuBuildCheckbox(struct Font* font, char* message, int x, int y);
|
||||||
|
struct MenuSlider menuBuildSlider(int x, int y, int w, int h, int tickCount);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -14,6 +14,9 @@ struct Tab gOptionTabs[] = {
|
||||||
{
|
{
|
||||||
.message = "Controls",
|
.message = "Controls",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.message = "Joystick",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.message = "Audio",
|
.message = "Audio",
|
||||||
},
|
},
|
||||||
|
@ -42,6 +45,7 @@ void optionsMenuInit(struct OptionsMenu* options) {
|
||||||
);
|
);
|
||||||
|
|
||||||
controlsMenuInit(&options->controlsMenu);
|
controlsMenuInit(&options->controlsMenu);
|
||||||
|
joystickOptionsInit(&options->joystickOptions);
|
||||||
audioOptionsInit(&options->audioOptions);
|
audioOptionsInit(&options->audioOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,9 +53,12 @@ enum MenuDirection optionsMenuUpdate(struct OptionsMenu* options) {
|
||||||
enum MenuDirection menuDirection = MenuDirectionStay;
|
enum MenuDirection menuDirection = MenuDirectionStay;
|
||||||
|
|
||||||
switch (options->tabs.selectedTab) {
|
switch (options->tabs.selectedTab) {
|
||||||
case OptionsMenuTabsControls:
|
case OptionsMenuTabsControlMapping:
|
||||||
menuDirection = controlsMenuUpdate(&options->controlsMenu);
|
menuDirection = controlsMenuUpdate(&options->controlsMenu);
|
||||||
break;
|
break;
|
||||||
|
case OptionsMenuTabsControlJoystick:
|
||||||
|
menuDirection = joystickOptionsUpdate(&options->joystickOptions);
|
||||||
|
break;
|
||||||
case OptionsMenuTabsAudio:
|
case OptionsMenuTabsAudio:
|
||||||
menuDirection = audioOptionsUpdate(&options->audioOptions);
|
menuDirection = audioOptionsUpdate(&options->audioOptions);
|
||||||
break;
|
break;
|
||||||
|
@ -104,9 +111,12 @@ void optionsMenuRender(struct OptionsMenu* options, struct RenderState* renderSt
|
||||||
gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]);
|
gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]);
|
||||||
|
|
||||||
switch (options->tabs.selectedTab) {
|
switch (options->tabs.selectedTab) {
|
||||||
case OptionsMenuTabsControls:
|
case OptionsMenuTabsControlMapping:
|
||||||
controlsMenuRender(&options->controlsMenu, renderState, task);
|
controlsMenuRender(&options->controlsMenu, renderState, task);
|
||||||
break;
|
break;
|
||||||
|
case OptionsMenuTabsControlJoystick:
|
||||||
|
joystickOptionsRender(&options->joystickOptions, renderState, task);
|
||||||
|
break;
|
||||||
case OptionsMenuTabsAudio:
|
case OptionsMenuTabsAudio:
|
||||||
audioOptionsRender(&options->audioOptions, renderState, task);
|
audioOptionsRender(&options->audioOptions, renderState, task);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -6,9 +6,11 @@
|
||||||
#include "./tabs.h"
|
#include "./tabs.h"
|
||||||
#include "./controls.h"
|
#include "./controls.h"
|
||||||
#include "./audio_options.h"
|
#include "./audio_options.h"
|
||||||
|
#include "./joystick_options.h"
|
||||||
|
|
||||||
enum OptionsMenuTabs {
|
enum OptionsMenuTabs {
|
||||||
OptionsMenuTabsControls,
|
OptionsMenuTabsControlMapping,
|
||||||
|
OptionsMenuTabsControlJoystick,
|
||||||
OptionsMenuTabsAudio,
|
OptionsMenuTabsAudio,
|
||||||
|
|
||||||
OptionsMenuTabsCount,
|
OptionsMenuTabsCount,
|
||||||
|
@ -21,6 +23,7 @@ struct OptionsMenu {
|
||||||
struct Tabs tabs;
|
struct Tabs tabs;
|
||||||
|
|
||||||
struct ControlsMenu controlsMenu;
|
struct ControlsMenu controlsMenu;
|
||||||
|
struct JoystickOptions joystickOptions;
|
||||||
struct AudioOptions audioOptions;
|
struct AudioOptions audioOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue