mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Miscellaneous Additions: Addendum (#723)
* More autogen work
- made the `Pointer_` classes into aliases instead so that they're actually associated with their true type
- "Total constants" metric is now accurate
* High Quality Master Volume
* Audio work
it's 12:55am and there are some bright flashes outside (lightning)
- cracked the code (interpreted the "Acc" in `tempoAcc`)
- added several functions that will help greatly in the Streamed Music department (you can now match sequenced music fading (transitions, eepy, etc.))
- introducing `gMasterVolume`! a variable that is only updated when it needs to be, theoretically improving performance (by some amount). this variable is used in many places in place of recalculations of the same number
- made it so that muting the game skips some audio processing (not the main process since that would linger after unmuting (not good))
- fixed an oversight where lua volumes were not taken into account when `audio_stream_set_volume`
- it's its 😁
- removed additional `#include "audio/external.h"`
it is 1:06am
gn
* Add mouse status functions
you can now check if mouse buttons were held, clicked, or released
* Sorting was a bad idea
disabled sorting for constants so that they are represented more closely to their original defines
* Expose playerlist page index
also noticed that sorting still sucks
* Minor (very important) detail
lalette
* Addressing the PeachyPeachSM64 reviews
* Return of the Forced 4:3 Mode
shoutouts to DISPLAY.FORCE_4BY3 for sticking through the toughest of times, waiting for this day to come
* Added scroll support
- Scrolling added to chat box (hold ctrl to scroll fewer lines, shift to scroll faster)
- Scrolling functions added to smlua
* Addressing the Isaac0-dev review + fixes
- mouse scroll is now accumulated
- djui_gfx_get_dimensions
- forced 4:3 won't kick in if the window isn't wide enough
- game now recognizes horizontal resizing when in 4:3 mode
* Run autogen
* gfx_get_dimensions
works just as well
This commit is contained in:
parent
1bfe9d509c
commit
3bfa75e32b
48 changed files with 62880 additions and 62216 deletions
|
|
@ -22,6 +22,7 @@ in_files = [
|
||||||
"src/game/interaction.c",
|
"src/game/interaction.c",
|
||||||
"src/game/interaction.h",
|
"src/game/interaction.h",
|
||||||
"src/pc/djui/djui_hud_utils.h",
|
"src/pc/djui/djui_hud_utils.h",
|
||||||
|
"src/pc/controller/controller_mouse.h",
|
||||||
"include/behavior_table.h",
|
"include/behavior_table.h",
|
||||||
"src/pc/lua/utils/smlua_model_utils.h",
|
"src/pc/lua/utils/smlua_model_utils.h",
|
||||||
"src/pc/lua/utils/smlua_misc_utils.h",
|
"src/pc/lua/utils/smlua_misc_utils.h",
|
||||||
|
|
@ -105,8 +106,6 @@ def saw_constant(identifier, inIfBlock):
|
||||||
print("SAW DUPLICATE CONSTANT: " + identifier)
|
print("SAW DUPLICATE CONSTANT: " + identifier)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
global totalConstants
|
|
||||||
totalConstants += 1
|
|
||||||
seen_constants.append(identifier)
|
seen_constants.append(identifier)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -335,7 +334,6 @@ def doc_constant_index(processed_files):
|
||||||
for processed_file in processed_files:
|
for processed_file in processed_files:
|
||||||
s += '- [%s](#%s)\n' % (processed_file['filename'], processed_file['filename'].replace('.', ''))
|
s += '- [%s](#%s)\n' % (processed_file['filename'], processed_file['filename'].replace('.', ''))
|
||||||
constants = [x for x in processed_file['constants'] if 'identifier' in x]
|
constants = [x for x in processed_file['constants'] if 'identifier' in x]
|
||||||
constants = sorted(constants, key=lambda d: d['identifier'])
|
|
||||||
for c in constants:
|
for c in constants:
|
||||||
s += ' - [enum %s](#enum-%s)\n' % (c['identifier'], c['identifier'])
|
s += ' - [enum %s](#enum-%s)\n' % (c['identifier'], c['identifier'])
|
||||||
s += '\n<br />\n\n'
|
s += '\n<br />\n\n'
|
||||||
|
|
@ -368,7 +366,7 @@ def doc_constant(processed_constant):
|
||||||
|
|
||||||
def doc_file(processed_file):
|
def doc_file(processed_file):
|
||||||
s = '## [%s](#%s)\n' % (processed_file['filename'], processed_file['filename'])
|
s = '## [%s](#%s)\n' % (processed_file['filename'], processed_file['filename'])
|
||||||
constants = sorted(processed_file['constants'], key=lambda d: 'zzz' + d['identifier'] if 'identifier' in d else d[0])
|
constants = processed_file['constants']
|
||||||
for c in constants:
|
for c in constants:
|
||||||
s += doc_constant(c)
|
s += doc_constant(c)
|
||||||
|
|
||||||
|
|
@ -387,6 +385,7 @@ def doc_files(processed_files):
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
def def_constant(processed_constant):
|
def def_constant(processed_constant):
|
||||||
|
global totalConstants
|
||||||
constants = processed_constant
|
constants = processed_constant
|
||||||
s = ''
|
s = ''
|
||||||
|
|
||||||
|
|
@ -404,6 +403,7 @@ def def_constant(processed_constant):
|
||||||
vlen = max(vlen, len(c[1]))
|
vlen = max(vlen, len(c[1]))
|
||||||
for c in constants:
|
for c in constants:
|
||||||
s += c[0].ljust(klen) + ' = ' + c[1].rjust(vlen) + ' --- @type %s\n' % id
|
s += c[0].ljust(klen) + ' = ' + c[1].rjust(vlen) + ' --- @type %s\n' % id
|
||||||
|
totalConstants += 1
|
||||||
s += '\n--- @alias %s\n' % id
|
s += '\n--- @alias %s\n' % id
|
||||||
for c in constants:
|
for c in constants:
|
||||||
s += '--- | `%s`\n' % c[0]
|
s += '--- | `%s`\n' % c[0]
|
||||||
|
|
@ -417,6 +417,7 @@ def def_constant(processed_constant):
|
||||||
else:
|
else:
|
||||||
s += '\n--- @type integer\n'
|
s += '\n--- @type integer\n'
|
||||||
s += '%s = %s\n' % (c[0], c[1])
|
s += '%s = %s\n' % (c[0], c[1])
|
||||||
|
totalConstants += 1
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
@ -427,7 +428,7 @@ def build_to_def(processed_files):
|
||||||
s += '\n'
|
s += '\n'
|
||||||
|
|
||||||
for file in processed_files:
|
for file in processed_files:
|
||||||
constants = sorted(file['constants'], key=lambda d: 'zzz' + d['identifier'] if 'identifier' in d else d[0])
|
constants = file['constants']
|
||||||
for c in constants:
|
for c in constants:
|
||||||
s += def_constant(c)
|
s += def_constant(c)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ override_allowed_functions = {
|
||||||
"src/game/area.h": [ "area_get_warp_node" ],
|
"src/game/area.h": [ "area_get_warp_node" ],
|
||||||
"src/engine/level_script.h": [ "area_create_warp_node" ],
|
"src/engine/level_script.h": [ "area_create_warp_node" ],
|
||||||
"src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "set_dialog_box_state", ],
|
"src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "set_dialog_box_state", ],
|
||||||
"src/audio/seqplayer.h": [ "sequence_player_set_tempo", "sequence_player_set_tempo_acc", "sequence_player_set_transposition", "sequence_player_get_tempo", "sequence_player_get_tempo_acc", "sequence_player_get_transposition" ]
|
"src/audio/seqplayer.h": [ "sequence_player_set_tempo", "sequence_player_set_tempo_acc", "sequence_player_set_transposition", "sequence_player_get_tempo", "sequence_player_get_tempo_acc", "sequence_player_get_transposition", "sequence_player_get_volume", "sequence_player_get_fade_volume", "sequence_player_get_mute_volume_scale" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
override_disallowed_functions = {
|
override_disallowed_functions = {
|
||||||
|
|
@ -1103,7 +1103,6 @@ def process_functions(fname, file_str, extracted_descriptions):
|
||||||
if fn == None:
|
if fn == None:
|
||||||
continue
|
continue
|
||||||
functions.append(fn)
|
functions.append(fn)
|
||||||
functions = sorted(functions, key=lambda d: d['identifier'])
|
|
||||||
return functions
|
return functions
|
||||||
|
|
||||||
def process_file(fname):
|
def process_file(fname):
|
||||||
|
|
@ -1409,7 +1408,7 @@ def def_files(processed_files):
|
||||||
s += def_function(function)
|
s += def_function(function)
|
||||||
|
|
||||||
for def_pointer in def_pointers:
|
for def_pointer in def_pointers:
|
||||||
s += '--- @class %s\n' % def_pointer
|
s += '--- @alias %s %s\n' % (def_pointer, def_pointer[8:])
|
||||||
|
|
||||||
with open(get_path(out_filename_defs), 'w', newline='\n') as out:
|
with open(get_path(out_filename_defs), 'w', newline='\n') as out:
|
||||||
out.write(s)
|
out.write(s)
|
||||||
|
|
|
||||||
|
|
@ -772,7 +772,7 @@ def def_structs(structs):
|
||||||
|
|
||||||
s += '\n'
|
s += '\n'
|
||||||
for def_pointer in def_pointers:
|
for def_pointer in def_pointers:
|
||||||
s += '--- @class %s\n' % def_pointer
|
s += '--- @alias %s %s\n' % (def_pointer, def_pointer[8:])
|
||||||
|
|
||||||
with open(get_path(out_filename_defs), 'w', newline='\n') as out:
|
with open(get_path(out_filename_defs), 'w', newline='\n') as out:
|
||||||
out.write(s)
|
out.write(s)
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -2453,12 +2453,12 @@
|
||||||
--- @field public g integer
|
--- @field public g integer
|
||||||
--- @field public b integer
|
--- @field public b integer
|
||||||
|
|
||||||
--- @class Pointer_integer
|
--- @alias Pointer_integer integer
|
||||||
--- @class Pointer_Trajectory
|
--- @alias Pointer_Trajectory Trajectory
|
||||||
--- @class Pointer_Gfx
|
--- @alias Pointer_Gfx Gfx
|
||||||
--- @class Pointer_LevelScript
|
--- @alias Pointer_LevelScript LevelScript
|
||||||
--- @class Pointer_ObjectAnimPointer
|
--- @alias Pointer_ObjectAnimPointer ObjectAnimPointer
|
||||||
--- @class Pointer_Collision
|
--- @alias Pointer_Collision Collision
|
||||||
--- @class Pointer_Mat4
|
--- @alias Pointer_Mat4 Mat4
|
||||||
--- @class Pointer_Vec4s
|
--- @alias Pointer_Vec4s Vec4s
|
||||||
--- @class Pointer_BehaviorScript
|
--- @alias Pointer_BehaviorScript BehaviorScript
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
14194
docs/lua/functions-2.md
14194
docs/lua/functions-2.md
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
11593
docs/lua/functions-5.md
11593
docs/lua/functions-5.md
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -3075,4 +3075,16 @@ u16 sequence_player_get_tempo_acc(u8 player) {
|
||||||
|
|
||||||
u16 sequence_player_get_transposition(u8 player) {
|
u16 sequence_player_get_transposition(u8 player) {
|
||||||
return gSequencePlayers[player].transposition;
|
return gSequencePlayers[player].transposition;
|
||||||
|
}
|
||||||
|
|
||||||
|
f32 sequence_player_get_volume(u8 player) {
|
||||||
|
return gSequencePlayers[player].volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
f32 sequence_player_get_fade_volume(u8 player) {
|
||||||
|
return gSequencePlayers[player].fadeVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
f32 sequence_player_get_mute_volume_scale(u8 player) {
|
||||||
|
return gSequencePlayers[player].muteVolumeScale;
|
||||||
}
|
}
|
||||||
|
|
@ -19,13 +19,19 @@ void init_sequence_players(void);
|
||||||
u16 sequence_player_get_tempo(u8 player);
|
u16 sequence_player_get_tempo(u8 player);
|
||||||
/* |description|Sets the `tempo` of `player`. Resets when another sequence is played|descriptionEnd| */
|
/* |description|Sets the `tempo` of `player`. Resets when another sequence is played|descriptionEnd| */
|
||||||
void sequence_player_set_tempo(u8 player, u16 tempo);
|
void sequence_player_set_tempo(u8 player, u16 tempo);
|
||||||
/* |description|Gets the tempoAcc (tempo ???) of `player`|descriptionEnd| */
|
/* |description|Gets the tempoAcc (tempo accumulation) of `player`|descriptionEnd| */
|
||||||
u16 sequence_player_get_tempo_acc(u8 player);
|
u16 sequence_player_get_tempo_acc(u8 player);
|
||||||
/* |description|Sets the `tempoAcc` (tempo ???) of `player`. Resets when another sequence is played|descriptionEnd| */
|
/* |description|Sets the `tempoAcc` (tempo accumulation) of `player`. Resets when another sequence is played|descriptionEnd| */
|
||||||
void sequence_player_set_tempo_acc(u8 player, u16 tempoAcc);
|
void sequence_player_set_tempo_acc(u8 player, u16 tempoAcc);
|
||||||
/* |description|Gets the transposition (pitch) of `player`|descriptionEnd| */
|
/* |description|Gets the transposition (pitch) of `player`|descriptionEnd| */
|
||||||
u16 sequence_player_get_transposition(u8 player);
|
u16 sequence_player_get_transposition(u8 player);
|
||||||
/* |description|Sets the `transposition` (pitch) of `player`. Resets when another sequence is played|descriptionEnd| */
|
/* |description|Sets the `transposition` (pitch) of `player`. Resets when another sequence is played|descriptionEnd| */
|
||||||
void sequence_player_set_transposition(u8 player, u16 transposition);
|
void sequence_player_set_transposition(u8 player, u16 transposition);
|
||||||
|
/* |description|Gets the volume of `player`|descriptionEnd| */
|
||||||
|
f32 sequence_player_get_volume(u8 player);
|
||||||
|
/* |description|Gets the fade volume of `player`|descriptionEnd| */
|
||||||
|
f32 sequence_player_get_fade_volume(u8 player);
|
||||||
|
/* |description|Gets the mute volume scale of `player`|descriptionEnd| */
|
||||||
|
f32 sequence_player_get_mute_volume_scale(u8 player);
|
||||||
|
|
||||||
#endif // AUDIO_SEQPLAYER_H
|
#endif // AUDIO_SEQPLAYER_H
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include <prevent_bss_reordering.h>
|
#include <prevent_bss_reordering.h>
|
||||||
#include "bettercamera.h"
|
#include "bettercamera.h"
|
||||||
#include "hud.h"
|
#include "hud.h"
|
||||||
|
#include "pc/controller/controller_mouse.h"
|
||||||
|
|
||||||
// FIXME: I'm not sure all of these variables belong in this file, but I don't
|
// FIXME: I'm not sure all of these variables belong in this file, but I don't
|
||||||
// know of a good way to split them
|
// know of a good way to split them
|
||||||
|
|
@ -508,6 +509,17 @@ void read_controller_inputs(void) {
|
||||||
gPlayer3Controller->buttonPressed = gPlayer1Controller->buttonPressed;
|
gPlayer3Controller->buttonPressed = gPlayer1Controller->buttonPressed;
|
||||||
gPlayer3Controller->buttonReleased = gPlayer1Controller->buttonReleased;
|
gPlayer3Controller->buttonReleased = gPlayer1Controller->buttonReleased;
|
||||||
gPlayer3Controller->buttonDown = gPlayer1Controller->buttonDown;*/
|
gPlayer3Controller->buttonDown = gPlayer1Controller->buttonDown;*/
|
||||||
|
|
||||||
|
// Mouse Input
|
||||||
|
u32 prev_mouse_window_buttons = mouse_window_buttons;
|
||||||
|
controller_mouse_read_window();
|
||||||
|
mouse_window_buttons_pressed = ~prev_mouse_window_buttons & mouse_window_buttons;
|
||||||
|
mouse_window_buttons_released = ~mouse_window_buttons & prev_mouse_window_buttons;
|
||||||
|
|
||||||
|
if (gGlobalTimer > mouse_scroll_timestamp) {
|
||||||
|
mouse_scroll_x = 0;
|
||||||
|
mouse_scroll_y = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize the controller structs to point at the OSCont information.
|
// initialize the controller structs to point at the OSCont information.
|
||||||
|
|
|
||||||
|
|
@ -87,25 +87,25 @@ static void player_palettes_sort_characters(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void player_palettes_read(const char* palettesPath, bool appendPalettes) {
|
void player_palettes_read(const char* palettesPath, bool appendPalettes) {
|
||||||
// construct lang path
|
// construct palette path
|
||||||
char lpath[SYS_MAX_PATH] = "";
|
char ppath[SYS_MAX_PATH] = "";
|
||||||
if (appendPalettes) {
|
if (appendPalettes) {
|
||||||
snprintf(lpath, SYS_MAX_PATH, "%s/palettes", palettesPath);
|
snprintf(ppath, SYS_MAX_PATH, "%s/palettes", palettesPath);
|
||||||
} else {
|
} else {
|
||||||
snprintf(lpath, SYS_MAX_PATH, "%s", palettesPath);
|
snprintf(ppath, SYS_MAX_PATH, "%s", palettesPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// open directory
|
// open directory
|
||||||
struct dirent* dir = NULL;
|
struct dirent* dir = NULL;
|
||||||
|
|
||||||
DIR* d = opendir(lpath);
|
DIR* d = opendir(ppath);
|
||||||
if (!d) { return; }
|
if (!d) { return; }
|
||||||
|
|
||||||
// iterate
|
// iterate
|
||||||
char path[SYS_MAX_PATH] = { 0 };
|
char path[SYS_MAX_PATH] = { 0 };
|
||||||
while ((dir = readdir(d)) != NULL) {
|
while ((dir = readdir(d)) != NULL) {
|
||||||
// sanity check / fill path[]
|
// sanity check / fill path[]
|
||||||
if (!directory_sanity_check(dir, lpath, path)) { continue; }
|
if (!directory_sanity_check(dir, ppath, path)) { continue; }
|
||||||
snprintf(path, SYS_MAX_PATH, "%s", dir->d_name);
|
snprintf(path, SYS_MAX_PATH, "%s", dir->d_name);
|
||||||
|
|
||||||
// strip the name before the .
|
// strip the name before the .
|
||||||
|
|
@ -154,14 +154,14 @@ void player_palettes_read(const char* palettesPath, bool appendPalettes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void player_palette_export(char* name) {
|
void player_palette_export(char* name) {
|
||||||
// construct lang path
|
// construct palette path
|
||||||
const char* palettesPath = fs_get_write_path(PALETTES_DIRECTORY);
|
const char* palettesPath = fs_get_write_path(PALETTES_DIRECTORY);
|
||||||
char lpath[SYS_MAX_PATH] = "";
|
char ppath[SYS_MAX_PATH] = "";
|
||||||
snprintf(lpath, SYS_MAX_PATH, "%s/%s.ini", palettesPath, name);
|
snprintf(ppath, SYS_MAX_PATH, "%s/%s.ini", palettesPath, name);
|
||||||
fs_sys_mkdir(palettesPath);
|
fs_sys_mkdir(palettesPath);
|
||||||
|
|
||||||
printf("Saving palette as '%s.ini'\n", name);
|
printf("Saving palette as '%s.ini'\n", name);
|
||||||
FILE* file = fopen(lpath, "w");
|
FILE* file = fopen(ppath, "w");
|
||||||
fprintf(file, "[PALETTE]\n\
|
fprintf(file, "[PALETTE]\n\
|
||||||
PANTS_R = %d\n\
|
PANTS_R = %d\n\
|
||||||
PANTS_G = %d\n\
|
PANTS_G = %d\n\
|
||||||
|
|
@ -215,15 +215,15 @@ EMBLEM_B = %d\n",
|
||||||
}
|
}
|
||||||
|
|
||||||
bool player_palette_delete(const char* palettesPath, char* name, bool appendPalettes) {
|
bool player_palette_delete(const char* palettesPath, char* name, bool appendPalettes) {
|
||||||
// construct lang path
|
// construct palette path
|
||||||
char lpath[SYS_MAX_PATH] = "";
|
char ppath[SYS_MAX_PATH] = "";
|
||||||
if (appendPalettes) {
|
if (appendPalettes) {
|
||||||
snprintf(lpath, SYS_MAX_PATH, "%s/palettes/%s.ini", palettesPath, name);
|
snprintf(ppath, SYS_MAX_PATH, "%s/palettes/%s.ini", palettesPath, name);
|
||||||
} else {
|
} else {
|
||||||
snprintf(lpath, SYS_MAX_PATH, "%s/%s.ini", palettesPath, name);
|
snprintf(ppath, SYS_MAX_PATH, "%s/%s.ini", palettesPath, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remove(lpath) == 0) {
|
if (remove(ppath) == 0) {
|
||||||
printf("Deleting palette '%s.ini'\n", name);
|
printf("Deleting palette '%s.ini'\n", name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
#include "djui/djui_hud_utils.h"
|
#include "djui/djui_hud_utils.h"
|
||||||
#include "game/save_file.h"
|
#include "game/save_file.h"
|
||||||
#include "pc/network/network_player.h"
|
#include "pc/network/network_player.h"
|
||||||
|
#include "pc/pc_main.h"
|
||||||
|
|
||||||
#define ARRAY_LEN(arr) (sizeof(arr) / sizeof(arr[0]))
|
#define ARRAY_LEN(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||||
|
|
||||||
|
|
@ -183,6 +184,7 @@ bool configMenuRandom = false;
|
||||||
bool configMenuDemos = false;
|
bool configMenuDemos = false;
|
||||||
bool configDisablePopups = false;
|
bool configDisablePopups = false;
|
||||||
char configLanguage[MAX_CONFIG_STRING] = "";
|
char configLanguage[MAX_CONFIG_STRING] = "";
|
||||||
|
bool configForce4By3 = false;
|
||||||
bool configDynosLocalPlayerModelOnly = false;
|
bool configDynosLocalPlayerModelOnly = false;
|
||||||
unsigned int configPvpType = PLAYER_PVP_CLASSIC;
|
unsigned int configPvpType = PLAYER_PVP_CLASSIC;
|
||||||
// CoopNet settings
|
// CoopNet settings
|
||||||
|
|
@ -332,6 +334,7 @@ static const struct ConfigOption options[] = {
|
||||||
// {.name = "coop_menu_demos", .type = CONFIG_TYPE_BOOL, .boolValue = &configMenuDemos},
|
// {.name = "coop_menu_demos", .type = CONFIG_TYPE_BOOL, .boolValue = &configMenuDemos},
|
||||||
{.name = "disable_popups", .type = CONFIG_TYPE_BOOL, .boolValue = &configDisablePopups},
|
{.name = "disable_popups", .type = CONFIG_TYPE_BOOL, .boolValue = &configDisablePopups},
|
||||||
{.name = "language", .type = CONFIG_TYPE_STRING, .stringValue = (char*)&configLanguage, .maxStringLength = MAX_CONFIG_STRING},
|
{.name = "language", .type = CONFIG_TYPE_STRING, .stringValue = (char*)&configLanguage, .maxStringLength = MAX_CONFIG_STRING},
|
||||||
|
{.name = "force_4by3", .type = CONFIG_TYPE_BOOL, .boolValue = &configForce4By3},
|
||||||
{.name = "dynos_local_player_model_only", .type = CONFIG_TYPE_BOOL, .boolValue = &configDynosLocalPlayerModelOnly},
|
{.name = "dynos_local_player_model_only", .type = CONFIG_TYPE_BOOL, .boolValue = &configDynosLocalPlayerModelOnly},
|
||||||
// CoopNet settings
|
// CoopNet settings
|
||||||
{.name = "coopnet_ip", .type = CONFIG_TYPE_STRING, .stringValue = (char*)&configCoopNetIp, .maxStringLength = MAX_CONFIG_STRING},
|
{.name = "coopnet_ip", .type = CONFIG_TYPE_STRING, .stringValue = (char*)&configCoopNetIp, .maxStringLength = MAX_CONFIG_STRING},
|
||||||
|
|
@ -761,6 +764,8 @@ NEXT_OPTION:
|
||||||
|
|
||||||
if (configFrameLimit < 30) { configFrameLimit = 30; }
|
if (configFrameLimit < 30) { configFrameLimit = 30; }
|
||||||
if (configFrameLimit > 3000) { configFrameLimit = 3000; }
|
if (configFrameLimit > 3000) { configFrameLimit = 3000; }
|
||||||
|
|
||||||
|
gMasterVolume = (f32)configMasterVolume / 127.0f;
|
||||||
|
|
||||||
if (configPlayerModel >= CT_MAX) { configPlayerModel = 0; }
|
if (configPlayerModel >= CT_MAX) { configPlayerModel = 0; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ extern bool configMenuRandom;
|
||||||
extern bool configMenuDemos;
|
extern bool configMenuDemos;
|
||||||
extern bool configDisablePopups;
|
extern bool configDisablePopups;
|
||||||
extern char configLanguage[MAX_CONFIG_STRING];
|
extern char configLanguage[MAX_CONFIG_STRING];
|
||||||
|
extern bool configForce4By3;
|
||||||
extern bool configDynosLocalPlayerModelOnly;
|
extern bool configDynosLocalPlayerModelOnly;
|
||||||
extern unsigned int configPvpType;
|
extern unsigned int configPvpType;
|
||||||
// CoopNet settings
|
// CoopNet settings
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
#include "controller_mouse.h"
|
#include "controller_mouse.h"
|
||||||
|
#include "pc/gfx/gfx_pc.h"
|
||||||
|
#include "pc/djui/djui.h"
|
||||||
|
|
||||||
#ifdef WAPI_DXGI
|
#ifdef WAPI_DXGI
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
|
@ -18,9 +20,15 @@ s32 mouse_x;
|
||||||
s32 mouse_y;
|
s32 mouse_y;
|
||||||
|
|
||||||
u32 mouse_window_buttons;
|
u32 mouse_window_buttons;
|
||||||
|
u32 mouse_window_buttons_pressed;
|
||||||
|
u32 mouse_window_buttons_released;
|
||||||
s32 mouse_window_x;
|
s32 mouse_window_x;
|
||||||
s32 mouse_window_y;
|
s32 mouse_window_y;
|
||||||
|
|
||||||
|
u32 mouse_scroll_timestamp;
|
||||||
|
f32 mouse_scroll_x;
|
||||||
|
f32 mouse_scroll_y;
|
||||||
|
|
||||||
bool mouse_relative_enabled;
|
bool mouse_relative_enabled;
|
||||||
|
|
||||||
#ifdef WAPI_DXGI
|
#ifdef WAPI_DXGI
|
||||||
|
|
@ -30,9 +38,11 @@ bool mouse_dxgi_prev_focus;
|
||||||
|
|
||||||
static u32 controller_mouse_dxgi_button_state(u32* mouse_held, bool has_focus) {
|
static u32 controller_mouse_dxgi_button_state(u32* mouse_held, bool has_focus) {
|
||||||
u32 mouse =
|
u32 mouse =
|
||||||
((GetKeyState(VK_LBUTTON) < 0) ? (1 << 0) : 0) |
|
((GetKeyState(VK_LBUTTON ) < 0) ? MOUSE_BUTTON_1 : 0) |
|
||||||
((GetKeyState(VK_MBUTTON) < 0) ? (1 << 1) : 0) |
|
((GetKeyState(VK_MBUTTON ) < 0) ? MOUSE_BUTTON_2 : 0) |
|
||||||
((GetKeyState(VK_RBUTTON) < 0) ? (1 << 2) : 0);
|
((GetKeyState(VK_RBUTTON ) < 0) ? MOUSE_BUTTON_3 : 0) |
|
||||||
|
((GetKeyState(VK_XBUTTON1) < 0) ? MOUSE_BUTTON_4 : 0) |
|
||||||
|
((GetKeyState(VK_XBUTTON2) < 0) ? MOUSE_BUTTON_5 : 0);
|
||||||
|
|
||||||
bool prev_focus = mouse_dxgi_prev_focus;
|
bool prev_focus = mouse_dxgi_prev_focus;
|
||||||
mouse_dxgi_prev_focus = has_focus;
|
mouse_dxgi_prev_focus = has_focus;
|
||||||
|
|
@ -66,11 +76,12 @@ void controller_mouse_read_window(void) {
|
||||||
|
|
||||||
POINT p;
|
POINT p;
|
||||||
if (GetCursorPos(&p) && ScreenToClient(game_window, &p)) {
|
if (GetCursorPos(&p) && ScreenToClient(game_window, &p)) {
|
||||||
mouse_window_x = p.x;
|
mouse_window_x = p.x - gfx_current_dimensions.x_adjust_4by3;
|
||||||
mouse_window_y = p.y;
|
mouse_window_y = p.y;
|
||||||
}
|
}
|
||||||
#elif defined(CAPI_SDL1) || defined(CAPI_SDL2)
|
#elif defined(CAPI_SDL1) || defined(CAPI_SDL2)
|
||||||
mouse_window_buttons = SDL_GetMouseState(&mouse_window_x, &mouse_window_y);
|
mouse_window_buttons = SDL_GetMouseState(&mouse_window_x, &mouse_window_y);
|
||||||
|
mouse_window_x -= gfx_current_dimensions.x_adjust_4by3;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,3 +154,9 @@ void controller_mouse_leave_relative(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mouse_on_scroll(float x, float y) {
|
||||||
|
djui_interactable_on_scroll(x, y);
|
||||||
|
mouse_scroll_timestamp = gGlobalTimer;
|
||||||
|
mouse_scroll_x += x;
|
||||||
|
mouse_scroll_y += y;
|
||||||
|
}
|
||||||
|
|
@ -10,10 +10,26 @@ extern u32 mouse_buttons;
|
||||||
extern s32 mouse_x;
|
extern s32 mouse_x;
|
||||||
extern s32 mouse_y;
|
extern s32 mouse_y;
|
||||||
|
|
||||||
|
#define MOUSE_BUTTON_1 (1 << 0)
|
||||||
|
#define MOUSE_BUTTON_2 (1 << 1)
|
||||||
|
#define MOUSE_BUTTON_3 (1 << 2)
|
||||||
|
#define MOUSE_BUTTON_4 (1 << 3)
|
||||||
|
#define MOUSE_BUTTON_5 (1 << 4)
|
||||||
|
|
||||||
|
#define L_MOUSE_BUTTON MOUSE_BUTTON_1
|
||||||
|
#define M_MOUSE_BUTTON MOUSE_BUTTON_2
|
||||||
|
#define R_MOUSE_BUTTON MOUSE_BUTTON_3
|
||||||
|
|
||||||
extern u32 mouse_window_buttons;
|
extern u32 mouse_window_buttons;
|
||||||
|
extern u32 mouse_window_buttons_pressed;
|
||||||
|
extern u32 mouse_window_buttons_released;
|
||||||
extern s32 mouse_window_x;
|
extern s32 mouse_window_x;
|
||||||
extern s32 mouse_window_y;
|
extern s32 mouse_window_y;
|
||||||
|
|
||||||
|
extern u32 mouse_scroll_timestamp;
|
||||||
|
extern f32 mouse_scroll_x;
|
||||||
|
extern f32 mouse_scroll_y;
|
||||||
|
|
||||||
extern bool mouse_relative_enabled;
|
extern bool mouse_relative_enabled;
|
||||||
|
|
||||||
void controller_mouse_read_window(void);
|
void controller_mouse_read_window(void);
|
||||||
|
|
@ -22,4 +38,6 @@ void controller_mouse_read_relative(void);
|
||||||
void controller_mouse_enter_relative(void);
|
void controller_mouse_enter_relative(void);
|
||||||
void controller_mouse_leave_relative(void);
|
void controller_mouse_leave_relative(void);
|
||||||
|
|
||||||
|
void mouse_on_scroll(float x, float y);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ char gLastRemoteBhv[256] = "";
|
||||||
#include "pc/debuglog.h"
|
#include "pc/debuglog.h"
|
||||||
#include "pc/pc_main.h"
|
#include "pc/pc_main.h"
|
||||||
#include "controller/controller_keyboard.h"
|
#include "controller/controller_keyboard.h"
|
||||||
|
#include "controller/controller_mouse.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
s32 x, y;
|
s32 x, y;
|
||||||
|
|
@ -652,6 +653,7 @@ static void crash_handler(const int signalNum, siginfo_t *info, UNUSED ucontext_
|
||||||
gfx_init(&WAPI, &RAPI, TITLE);
|
gfx_init(&WAPI, &RAPI, TITLE);
|
||||||
WAPI.set_keyboard_callbacks(keyboard_on_key_down, keyboard_on_key_up, keyboard_on_all_keys_up,
|
WAPI.set_keyboard_callbacks(keyboard_on_key_down, keyboard_on_key_up, keyboard_on_all_keys_up,
|
||||||
keyboard_on_text_input, keyboard_on_text_editing);
|
keyboard_on_text_input, keyboard_on_text_editing);
|
||||||
|
WAPI.set_scroll_callback(mouse_on_scroll);
|
||||||
}
|
}
|
||||||
if (!gGameInited) djui_unicode_init();
|
if (!gGameInited) djui_unicode_init();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -502,6 +502,23 @@ static void djui_chat_box_input_on_text_editing(struct DjuiBase *base, char* tex
|
||||||
djui_inputbox_on_text_editing(base, text, cursorPos);
|
djui_inputbox_on_text_editing(base, text, cursorPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void djui_chat_box_input_on_scroll(UNUSED struct DjuiBase *base, UNUSED float x, float y) {
|
||||||
|
if (gDjuiChatBox == NULL) { return; }
|
||||||
|
|
||||||
|
f32 yMax = gDjuiChatBox->chatContainer->base.elem.height - gDjuiChatBox->chatFlow->base.height.value;
|
||||||
|
f32* yValue = &gDjuiChatBox->chatFlow->base.y.value;
|
||||||
|
bool canScrollUp = (*yValue > yMax);
|
||||||
|
bool canScrollDown = (*yValue < 0);
|
||||||
|
|
||||||
|
y *= 24;
|
||||||
|
if (gDjuiInputHeldControl) { y /= 2; }
|
||||||
|
if (gDjuiInputHeldShift) { y *= 3; }
|
||||||
|
|
||||||
|
gDjuiChatBox->scrolling = true;
|
||||||
|
if (y > 0 && canScrollDown) { *yValue = fmin(*yValue + y, 0); }
|
||||||
|
if (y < 0 && canScrollUp) { *yValue = fmax(*yValue + y, yMax); }
|
||||||
|
}
|
||||||
|
|
||||||
void djui_chat_box_toggle(void) {
|
void djui_chat_box_toggle(void) {
|
||||||
if (gDjuiChatBox == NULL) { return; }
|
if (gDjuiChatBox == NULL) { return; }
|
||||||
if (!gDjuiChatBoxFocus) { sDjuiChatBoxClearText = true; }
|
if (!gDjuiChatBoxFocus) { sDjuiChatBoxClearText = true; }
|
||||||
|
|
@ -555,6 +572,7 @@ struct DjuiChatBox* djui_chat_box_create(void) {
|
||||||
djui_interactable_hook_key(&chatInput->base, djui_chat_box_input_on_key_down, djui_inputbox_on_key_up);
|
djui_interactable_hook_key(&chatInput->base, djui_chat_box_input_on_key_down, djui_inputbox_on_key_up);
|
||||||
djui_interactable_hook_text_input(&chatInput->base, djui_chat_box_input_on_text_input);
|
djui_interactable_hook_text_input(&chatInput->base, djui_chat_box_input_on_text_input);
|
||||||
djui_interactable_hook_text_editing(&chatInput->base, djui_chat_box_input_on_text_editing);
|
djui_interactable_hook_text_editing(&chatInput->base, djui_chat_box_input_on_text_editing);
|
||||||
|
djui_interactable_hook_scroll(&chatInput->base, djui_chat_box_input_on_scroll);
|
||||||
chatBox->chatInput = chatInput;
|
chatBox->chatInput = chatInput;
|
||||||
|
|
||||||
gDjuiChatBox = chatBox;
|
gDjuiChatBox = chatBox;
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ const Gfx dl_djui_simple_rect[] = {
|
||||||
f32 djui_gfx_get_scale(void) {
|
f32 djui_gfx_get_scale(void) {
|
||||||
if (configDjuiScale == 0) { // auto
|
if (configDjuiScale == 0) { // auto
|
||||||
u32 windowWidth, windowHeight;
|
u32 windowWidth, windowHeight;
|
||||||
wm_api->get_dimensions(&windowWidth, &windowHeight);
|
gfx_get_dimensions(&windowWidth, &windowHeight);
|
||||||
if (windowHeight < 768) {
|
if (windowHeight < 768) {
|
||||||
return 0.5f;
|
return 0.5f;
|
||||||
} else if (windowHeight < 1440) {
|
} else if (windowHeight < 1440) {
|
||||||
|
|
@ -165,14 +165,14 @@ void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize,
|
||||||
|
|
||||||
void djui_gfx_position_translate(f32* x, f32* y) {
|
void djui_gfx_position_translate(f32* x, f32* y) {
|
||||||
u32 windowWidth, windowHeight;
|
u32 windowWidth, windowHeight;
|
||||||
wm_api->get_dimensions(&windowWidth, &windowHeight);
|
gfx_get_dimensions(&windowWidth, &windowHeight);
|
||||||
*x = GFX_DIMENSIONS_FROM_LEFT_EDGE(0) + *x * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale();
|
*x = GFX_DIMENSIONS_FROM_LEFT_EDGE(0) + *x * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale();
|
||||||
*y = SCREEN_HEIGHT - *y * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale();
|
*y = SCREEN_HEIGHT - *y * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale();
|
||||||
}
|
}
|
||||||
|
|
||||||
void djui_gfx_scale_translate(f32* width, f32* height) {
|
void djui_gfx_scale_translate(f32* width, f32* height) {
|
||||||
u32 windowWidth, windowHeight;
|
u32 windowWidth, windowHeight;
|
||||||
wm_api->get_dimensions(&windowWidth, &windowHeight);
|
gfx_get_dimensions(&windowWidth, &windowHeight);
|
||||||
|
|
||||||
*width = *width * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale();
|
*width = *width * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale();
|
||||||
*height = *height * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale();
|
*height = *height * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale();
|
||||||
|
|
@ -180,7 +180,7 @@ void djui_gfx_scale_translate(f32* width, f32* height) {
|
||||||
|
|
||||||
void djui_gfx_size_translate(f32* size) {
|
void djui_gfx_size_translate(f32* size) {
|
||||||
u32 windowWidth, windowHeight;
|
u32 windowWidth, windowHeight;
|
||||||
wm_api->get_dimensions(&windowWidth, &windowHeight);
|
gfx_get_dimensions(&windowWidth, &windowHeight);
|
||||||
|
|
||||||
*size = *size * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale();
|
*size = *size * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@ f32 djui_gfx_get_scale(void);
|
||||||
void djui_gfx_render_texture(const u8* texture, u32 w, u32 h, u32 bitSize, bool filter);
|
void djui_gfx_render_texture(const u8* texture, u32 w, u32 h, u32 bitSize, bool filter);
|
||||||
void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize, u32 tileX, u32 tileY, u32 tileW, u32 tileH, bool filter, bool font);
|
void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize, u32 tileX, u32 tileY, u32 tileW, u32 tileH, bool filter, bool font);
|
||||||
|
|
||||||
|
void gfx_get_dimensions(u32* width, u32* height);
|
||||||
|
|
||||||
void djui_gfx_position_translate(f32* x, f32* y);
|
void djui_gfx_position_translate(f32* x, f32* y);
|
||||||
void djui_gfx_scale_translate(f32* width, f32* height);
|
void djui_gfx_scale_translate(f32* width, f32* height);
|
||||||
void djui_gfx_size_translate(f32* size);
|
void djui_gfx_size_translate(f32* size);
|
||||||
|
|
|
||||||
|
|
@ -245,18 +245,16 @@ void djui_hud_set_rotation_interpolated(s32 prevRotation, f32 prevPivotX, f32 pr
|
||||||
|
|
||||||
u32 djui_hud_get_screen_width(void) {
|
u32 djui_hud_get_screen_width(void) {
|
||||||
u32 windowWidth, windowHeight;
|
u32 windowWidth, windowHeight;
|
||||||
wm_api->get_dimensions(&windowWidth, &windowHeight);
|
gfx_get_dimensions(&windowWidth, &windowHeight);
|
||||||
|
|
||||||
if (sResolution == RESOLUTION_N64) {
|
return (sResolution == RESOLUTION_N64)
|
||||||
return (GFX_DIMENSIONS_ASPECT_RATIO) * SCREEN_HEIGHT;
|
? GFX_DIMENSIONS_ASPECT_RATIO * SCREEN_HEIGHT
|
||||||
} else {
|
: (windowWidth / djui_gfx_get_scale());
|
||||||
return (windowWidth / djui_gfx_get_scale());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 djui_hud_get_screen_height(void) {
|
u32 djui_hud_get_screen_height(void) {
|
||||||
u32 windowWidth, windowHeight;
|
u32 windowWidth, windowHeight;
|
||||||
wm_api->get_dimensions(&windowWidth, &windowHeight);
|
gfx_get_dimensions(&windowWidth, &windowHeight);
|
||||||
|
|
||||||
return (sResolution == RESOLUTION_N64)
|
return (sResolution == RESOLUTION_N64)
|
||||||
? SCREEN_HEIGHT
|
? SCREEN_HEIGHT
|
||||||
|
|
@ -285,6 +283,26 @@ void djui_hud_set_mouse_locked(bool locked) {
|
||||||
gDjuiHudLockMouse = locked;
|
gDjuiHudLockMouse = locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8 djui_hud_get_mouse_buttons_down(void) {
|
||||||
|
return mouse_window_buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 djui_hud_get_mouse_buttons_pressed(void) {
|
||||||
|
return mouse_window_buttons_pressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
u8 djui_hud_get_mouse_buttons_released(void) {
|
||||||
|
return mouse_window_buttons_released;
|
||||||
|
}
|
||||||
|
|
||||||
|
f32 djui_hud_get_mouse_scroll_x(void) {
|
||||||
|
return mouse_scroll_x;
|
||||||
|
}
|
||||||
|
|
||||||
|
f32 djui_hud_get_mouse_scroll_y(void) {
|
||||||
|
return mouse_scroll_y;
|
||||||
|
}
|
||||||
|
|
||||||
f32 djui_hud_measure_text(const char* message) {
|
f32 djui_hud_measure_text(const char* message) {
|
||||||
if (message == NULL) { return 0; }
|
if (message == NULL) { return 0; }
|
||||||
const struct DjuiFont* font = gDjuiFonts[sFont];
|
const struct DjuiFont* font = gDjuiFonts[sFont];
|
||||||
|
|
@ -649,7 +667,7 @@ bool djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out) {
|
||||||
screenHeight = SCREEN_HEIGHT;
|
screenHeight = SCREEN_HEIGHT;
|
||||||
} else {
|
} else {
|
||||||
u32 windowWidth, windowHeight;
|
u32 windowWidth, windowHeight;
|
||||||
WAPI.get_dimensions(&windowWidth, &windowHeight);
|
gfx_get_dimensions(&windowWidth, &windowHeight);
|
||||||
screenWidth = (f32) windowWidth;
|
screenWidth = (f32) windowWidth;
|
||||||
screenHeight = (f32) windowHeight;
|
screenHeight = (f32) windowHeight;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,16 @@ f32 djui_hud_get_raw_mouse_x(void);
|
||||||
f32 djui_hud_get_raw_mouse_y(void);
|
f32 djui_hud_get_raw_mouse_y(void);
|
||||||
/* |description|Sets if the cursor is hidden and constrainted to the window|descriptionEnd| */
|
/* |description|Sets if the cursor is hidden and constrainted to the window|descriptionEnd| */
|
||||||
void djui_hud_set_mouse_locked(bool locked);
|
void djui_hud_set_mouse_locked(bool locked);
|
||||||
|
/* |description|Returns the flags of the mouse buttons held down|descriptionEnd| */
|
||||||
|
u8 djui_hud_get_mouse_buttons_down(void);
|
||||||
|
/* |description|Returns the flags of the mouse buttons clicked|descriptionEnd| */
|
||||||
|
u8 djui_hud_get_mouse_buttons_pressed(void);
|
||||||
|
/* |description|Returns the flags of the mouse buttons released|descriptionEnd| */
|
||||||
|
u8 djui_hud_get_mouse_buttons_released(void);
|
||||||
|
/* |description|Returns the amount scrolled horizontally (-left/right+)|descriptionEnd| */
|
||||||
|
f32 djui_hud_get_mouse_scroll_x(void);
|
||||||
|
/* |description|Returns the amount scrolled vertically (-down/up+)|descriptionEnd| */
|
||||||
|
f32 djui_hud_get_mouse_scroll_y(void);
|
||||||
|
|
||||||
/* |description|Measures the length of `message` in the current font|descriptionEnd| */
|
/* |description|Measures the length of `message` in the current font|descriptionEnd| */
|
||||||
f32 djui_hud_measure_text(const char* message);
|
f32 djui_hud_measure_text(const char* message);
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@
|
||||||
#define DJUI_INPUTBOX_MID_BLINK (DJUI_INPUTBOX_MAX_BLINK / 2)
|
#define DJUI_INPUTBOX_MID_BLINK (DJUI_INPUTBOX_MAX_BLINK / 2)
|
||||||
#define DJUI_INPUTBOX_CURSOR_WIDTH (2.0f / 32.0f)
|
#define DJUI_INPUTBOX_CURSOR_WIDTH (2.0f / 32.0f)
|
||||||
|
|
||||||
static u8 sHeldShift = 0;
|
u8 gDjuiInputHeldShift = 0;
|
||||||
static u8 sHeldControl = 0;
|
u8 gDjuiInputHeldControl = 0;
|
||||||
static u8 sHeldAlt = 0;
|
u8 gDjuiInputHeldAlt = 0;
|
||||||
static u8 sCursorBlink = 0;
|
static u8 sCursorBlink = 0;
|
||||||
|
|
||||||
static void djui_inputbox_update_style(struct DjuiBase* base) {
|
static void djui_inputbox_update_style(struct DjuiBase* base) {
|
||||||
|
|
@ -179,58 +179,58 @@ bool djui_inputbox_on_key_down(struct DjuiBase *base, int scancode) {
|
||||||
u16 s2 = fmax(sel[0], sel[1]);
|
u16 s2 = fmax(sel[0], sel[1]);
|
||||||
|
|
||||||
switch (scancode) {
|
switch (scancode) {
|
||||||
case SCANCODE_SHIFT_LEFT: sHeldShift |= (1 << 0); return true;
|
case SCANCODE_SHIFT_LEFT: gDjuiInputHeldShift |= (1 << 0); return true;
|
||||||
case SCANCODE_SHIFT_RIGHT: sHeldShift |= (1 << 1); return true;
|
case SCANCODE_SHIFT_RIGHT: gDjuiInputHeldShift |= (1 << 1); return true;
|
||||||
case SCANCODE_CONTROL_LEFT: sHeldControl |= (1 << 0); return true;
|
case SCANCODE_CONTROL_LEFT: gDjuiInputHeldControl |= (1 << 0); return true;
|
||||||
case SCANCODE_CONTROL_RIGHT: sHeldControl |= (1 << 1); return true;
|
case SCANCODE_CONTROL_RIGHT: gDjuiInputHeldControl |= (1 << 1); return true;
|
||||||
case SCANCODE_ALT_LEFT: sHeldAlt |= (1 << 0); return true;
|
case SCANCODE_ALT_LEFT: gDjuiInputHeldAlt |= (1 << 0); return true;
|
||||||
case SCANCODE_ALT_RIGHT: sHeldAlt |= (1 << 1); return true;
|
case SCANCODE_ALT_RIGHT: gDjuiInputHeldAlt |= (1 << 1); return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Left], [Ctrl]+[Left], [Shift]+[Left], [Ctrl]+[Shift]+[Left]
|
// [Left], [Ctrl]+[Left], [Shift]+[Left], [Ctrl]+[Shift]+[Left]
|
||||||
if (!sHeldAlt && scancode == SCANCODE_LEFT) {
|
if (!gDjuiInputHeldAlt && scancode == SCANCODE_LEFT) {
|
||||||
if (sHeldControl) {
|
if (gDjuiInputHeldControl) {
|
||||||
sel[0] = djui_inputbox_jump_word_left(msg, len, sel[0]);
|
sel[0] = djui_inputbox_jump_word_left(msg, len, sel[0]);
|
||||||
} else if (sel[0] > 0) {
|
} else if (sel[0] > 0) {
|
||||||
sel[0]--;
|
sel[0]--;
|
||||||
}
|
}
|
||||||
if (!sHeldShift) { sel[1] = sel[0]; }
|
if (!gDjuiInputHeldShift) { sel[1] = sel[0]; }
|
||||||
sCursorBlink = 0;
|
sCursorBlink = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Right], [Ctrl]+[Right], [Shift]+[Right], [Ctrl]+[Shift]+[Right]
|
// [Right], [Ctrl]+[Right], [Shift]+[Right], [Ctrl]+[Shift]+[Right]
|
||||||
if (!sHeldAlt && scancode == SCANCODE_RIGHT) {
|
if (!gDjuiInputHeldAlt && scancode == SCANCODE_RIGHT) {
|
||||||
if (sHeldControl) {
|
if (gDjuiInputHeldControl) {
|
||||||
sel[0] = djui_inputbox_jump_word_right(msg, len, sel[0]);
|
sel[0] = djui_inputbox_jump_word_right(msg, len, sel[0]);
|
||||||
} else if (sel[0] < len) {
|
} else if (sel[0] < len) {
|
||||||
sel[0]++;
|
sel[0]++;
|
||||||
}
|
}
|
||||||
if (!sHeldShift) { sel[1] = sel[0]; }
|
if (!gDjuiInputHeldShift) { sel[1] = sel[0]; }
|
||||||
sCursorBlink = 0;
|
sCursorBlink = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Home], [Shift]+[Home]
|
// [Home], [Shift]+[Home]
|
||||||
if (!sHeldAlt && scancode == SCANCODE_HOME) {
|
if (!gDjuiInputHeldAlt && scancode == SCANCODE_HOME) {
|
||||||
sel[0] = 0;
|
sel[0] = 0;
|
||||||
if (!sHeldShift) { sel[1] = sel[0]; }
|
if (!gDjuiInputHeldShift) { sel[1] = sel[0]; }
|
||||||
sCursorBlink = 0;
|
sCursorBlink = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [End], [Shift]+[End]
|
// [End], [Shift]+[End]
|
||||||
if (!sHeldAlt && scancode == SCANCODE_END) {
|
if (!gDjuiInputHeldAlt && scancode == SCANCODE_END) {
|
||||||
sel[0] = len;
|
sel[0] = len;
|
||||||
if (!sHeldShift) { sel[1] = sel[0]; }
|
if (!gDjuiInputHeldShift) { sel[1] = sel[0]; }
|
||||||
sCursorBlink = 0;
|
sCursorBlink = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Backspace], [Ctrl]+[Backspace]
|
// [Backspace], [Ctrl]+[Backspace]
|
||||||
if (!sHeldAlt && scancode == SCANCODE_BACKSPACE) {
|
if (!gDjuiInputHeldAlt && scancode == SCANCODE_BACKSPACE) {
|
||||||
if (sel[0] == sel[1]) {
|
if (sel[0] == sel[1]) {
|
||||||
if (sHeldControl) {
|
if (gDjuiInputHeldControl) {
|
||||||
sel[0] = djui_inputbox_jump_word_left(msg, len, sel[0]);
|
sel[0] = djui_inputbox_jump_word_left(msg, len, sel[0]);
|
||||||
} else if (sel[0] > 0) {
|
} else if (sel[0] > 0) {
|
||||||
sel[0]--;
|
sel[0]--;
|
||||||
|
|
@ -244,9 +244,9 @@ bool djui_inputbox_on_key_down(struct DjuiBase *base, int scancode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Delete], [Ctrl]+[Delete]
|
// [Delete], [Ctrl]+[Delete]
|
||||||
if (!sHeldAlt && scancode == SCANCODE_DELETE) {
|
if (!gDjuiInputHeldAlt && scancode == SCANCODE_DELETE) {
|
||||||
if (sel[0] == sel[1]) {
|
if (sel[0] == sel[1]) {
|
||||||
if (sHeldControl) {
|
if (gDjuiInputHeldControl) {
|
||||||
sel[1] = djui_inputbox_jump_word_right(msg, len, sel[1]);
|
sel[1] = djui_inputbox_jump_word_right(msg, len, sel[1]);
|
||||||
} else if (sel[1] < len) {
|
} else if (sel[1] < len) {
|
||||||
sel[1]++;
|
sel[1]++;
|
||||||
|
|
@ -260,16 +260,16 @@ bool djui_inputbox_on_key_down(struct DjuiBase *base, int scancode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Ctrl]+[V], [Shift]+[Insert]
|
// [Ctrl]+[V], [Shift]+[Insert]
|
||||||
if (!sHeldAlt &&
|
if (!gDjuiInputHeldAlt &&
|
||||||
((!sHeldShift && sHeldControl && scancode == SCANCODE_V) ||
|
((!gDjuiInputHeldShift && gDjuiInputHeldControl && scancode == SCANCODE_V) ||
|
||||||
(!sHeldControl && sHeldShift && scancode == SCANCODE_INSERT))) {
|
(!gDjuiInputHeldControl && gDjuiInputHeldShift && scancode == SCANCODE_INSERT))) {
|
||||||
djui_interactable_on_text_input(wm_api->get_clipboard_text());
|
djui_interactable_on_text_input(wm_api->get_clipboard_text());
|
||||||
sCursorBlink = 0;
|
sCursorBlink = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Ctrl]+[C], [Ctrl]+[X]
|
// [Ctrl]+[C], [Ctrl]+[X]
|
||||||
if (!sHeldAlt && !sHeldShift && sHeldControl &&
|
if (!gDjuiInputHeldAlt && !gDjuiInputHeldShift && gDjuiInputHeldControl &&
|
||||||
(scancode == SCANCODE_C || scancode == SCANCODE_X)) {
|
(scancode == SCANCODE_C || scancode == SCANCODE_X)) {
|
||||||
if (sel[0] != sel[1]) {
|
if (sel[0] != sel[1]) {
|
||||||
char clipboardText[256] = { 0 };
|
char clipboardText[256] = { 0 };
|
||||||
|
|
@ -286,7 +286,7 @@ bool djui_inputbox_on_key_down(struct DjuiBase *base, int scancode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Ctrl]+[A]
|
// [Ctrl]+[A]
|
||||||
if (!sHeldAlt && !sHeldShift && sHeldControl && scancode == SCANCODE_A) {
|
if (!gDjuiInputHeldAlt && !gDjuiInputHeldShift && gDjuiInputHeldControl && scancode == SCANCODE_A) {
|
||||||
inputbox->selection[0] = djui_unicode_len(msg);
|
inputbox->selection[0] = djui_unicode_len(msg);
|
||||||
inputbox->selection[1] = 0;
|
inputbox->selection[1] = 0;
|
||||||
sCursorBlink = 0;
|
sCursorBlink = 0;
|
||||||
|
|
@ -294,7 +294,7 @@ bool djui_inputbox_on_key_down(struct DjuiBase *base, int scancode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Esc]
|
// [Esc]
|
||||||
if (!sHeldAlt && !sHeldShift && !sHeldControl && scancode == SCANCODE_ESCAPE) {
|
if (!gDjuiInputHeldAlt && !gDjuiInputHeldShift && !gDjuiInputHeldControl && scancode == SCANCODE_ESCAPE) {
|
||||||
djui_interactable_set_input_focus(NULL);
|
djui_interactable_set_input_focus(NULL);
|
||||||
if (inputbox->on_escape_press) {
|
if (inputbox->on_escape_press) {
|
||||||
inputbox->on_escape_press(inputbox);
|
inputbox->on_escape_press(inputbox);
|
||||||
|
|
@ -303,7 +303,7 @@ bool djui_inputbox_on_key_down(struct DjuiBase *base, int scancode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// [Enter]
|
// [Enter]
|
||||||
if (!sHeldAlt && !sHeldShift && !sHeldControl && scancode == SCANCODE_ENTER) {
|
if (!gDjuiInputHeldAlt && !gDjuiInputHeldShift && !gDjuiInputHeldControl && scancode == SCANCODE_ENTER) {
|
||||||
djui_interactable_set_input_focus(NULL);
|
djui_interactable_set_input_focus(NULL);
|
||||||
if (inputbox->on_enter_press) {
|
if (inputbox->on_enter_press) {
|
||||||
inputbox->on_enter_press(inputbox);
|
inputbox->on_enter_press(inputbox);
|
||||||
|
|
@ -316,19 +316,19 @@ bool djui_inputbox_on_key_down(struct DjuiBase *base, int scancode) {
|
||||||
|
|
||||||
void djui_inputbox_on_key_up(UNUSED struct DjuiBase *base, int scancode) {
|
void djui_inputbox_on_key_up(UNUSED struct DjuiBase *base, int scancode) {
|
||||||
switch (scancode) {
|
switch (scancode) {
|
||||||
case SCANCODE_SHIFT_LEFT: sHeldShift &= ~(1 << 0); break;
|
case SCANCODE_SHIFT_LEFT: gDjuiInputHeldShift &= ~(1 << 0); break;
|
||||||
case SCANCODE_SHIFT_RIGHT: sHeldShift &= ~(1 << 1); break;
|
case SCANCODE_SHIFT_RIGHT: gDjuiInputHeldShift &= ~(1 << 1); break;
|
||||||
case SCANCODE_CONTROL_LEFT: sHeldControl &= ~(1 << 0); break;
|
case SCANCODE_CONTROL_LEFT: gDjuiInputHeldControl &= ~(1 << 0); break;
|
||||||
case SCANCODE_CONTROL_RIGHT: sHeldControl &= ~(1 << 1); break;
|
case SCANCODE_CONTROL_RIGHT: gDjuiInputHeldControl &= ~(1 << 1); break;
|
||||||
case SCANCODE_ALT_LEFT: sHeldAlt &= ~(1 << 0); break;
|
case SCANCODE_ALT_LEFT: gDjuiInputHeldAlt &= ~(1 << 0); break;
|
||||||
case SCANCODE_ALT_RIGHT: sHeldAlt &= ~(1 << 1); break;
|
case SCANCODE_ALT_RIGHT: gDjuiInputHeldAlt &= ~(1 << 1); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void djui_inputbox_on_focus_begin(UNUSED struct DjuiBase* base) {
|
void djui_inputbox_on_focus_begin(UNUSED struct DjuiBase* base) {
|
||||||
sHeldShift = 0;
|
gDjuiInputHeldShift = 0;
|
||||||
sHeldControl = 0;
|
gDjuiInputHeldControl = 0;
|
||||||
sHeldAlt = 0;
|
gDjuiInputHeldAlt = 0;
|
||||||
wm_api->start_text_input();
|
wm_api->start_text_input();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,10 @@ struct DjuiInputbox {
|
||||||
u16 imePos;
|
u16 imePos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern u8 gDjuiInputHeldShift;
|
||||||
|
extern u8 gDjuiInputHeldControl;
|
||||||
|
extern u8 gDjuiInputHeldAlt;
|
||||||
|
|
||||||
void djui_inputbox_on_focus_begin(UNUSED struct DjuiBase* base);
|
void djui_inputbox_on_focus_begin(UNUSED struct DjuiBase* base);
|
||||||
void djui_inputbox_on_focus_end(UNUSED struct DjuiBase* base);
|
void djui_inputbox_on_focus_end(UNUSED struct DjuiBase* base);
|
||||||
void djui_inputbox_set_text_color(struct DjuiInputbox* inputbox, u8 r, u8 g, u8 b, u8 a);
|
void djui_inputbox_set_text_color(struct DjuiInputbox* inputbox, u8 r, u8 g, u8 b, u8 a);
|
||||||
|
|
|
||||||
|
|
@ -335,6 +335,13 @@ void djui_interactable_on_text_editing(char* text, int cursorPos) {
|
||||||
gInteractableFocus->interactable->on_text_editing(gInteractableFocus, text, cursorPos);
|
gInteractableFocus->interactable->on_text_editing(gInteractableFocus, text, cursorPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void djui_interactable_on_scroll(float x, float y) {
|
||||||
|
if (gInteractableFocus == NULL) { return; }
|
||||||
|
if (gInteractableFocus->interactable == NULL) { return; }
|
||||||
|
if (gInteractableFocus->interactable->on_scroll == NULL) { return; }
|
||||||
|
gInteractableFocus->interactable->on_scroll(gInteractableFocus, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
void djui_interactable_update_pad(void) {
|
void djui_interactable_update_pad(void) {
|
||||||
OSContPad* pad = &gInteractablePad;
|
OSContPad* pad = &gInteractablePad;
|
||||||
|
|
||||||
|
|
@ -486,9 +493,9 @@ void djui_interactable_hook_cursor_down(struct DjuiBase* base,
|
||||||
}
|
}
|
||||||
|
|
||||||
void djui_interactable_hook_focus(struct DjuiBase* base,
|
void djui_interactable_hook_focus(struct DjuiBase* base,
|
||||||
void (*on_focus_begin)(struct DjuiBase*),
|
void (*on_focus_begin)(struct DjuiBase*),
|
||||||
void (*on_focus)(struct DjuiBase*, OSContPad*),
|
void (*on_focus)(struct DjuiBase*, OSContPad*),
|
||||||
void (*on_focus_end)(struct DjuiBase*)) {
|
void (*on_focus_end)(struct DjuiBase*)) {
|
||||||
struct DjuiInteractable* interactable = base->interactable;
|
struct DjuiInteractable* interactable = base->interactable;
|
||||||
interactable->on_focus_begin = on_focus_begin;
|
interactable->on_focus_begin = on_focus_begin;
|
||||||
interactable->on_focus = on_focus;
|
interactable->on_focus = on_focus;
|
||||||
|
|
@ -514,8 +521,8 @@ void djui_interactable_hook_bind(struct DjuiBase* base,
|
||||||
}
|
}
|
||||||
|
|
||||||
void djui_interactable_hook_key(struct DjuiBase* base,
|
void djui_interactable_hook_key(struct DjuiBase* base,
|
||||||
bool (*on_key_down)(struct DjuiBase*, int),
|
bool (*on_key_down)(struct DjuiBase*, int),
|
||||||
void (*on_key_up)(struct DjuiBase*, int)) {
|
void (*on_key_up)(struct DjuiBase*, int)) {
|
||||||
struct DjuiInteractable *interactable = base->interactable;
|
struct DjuiInteractable *interactable = base->interactable;
|
||||||
interactable->on_key_down = on_key_down;
|
interactable->on_key_down = on_key_down;
|
||||||
interactable->on_key_up = on_key_up;
|
interactable->on_key_up = on_key_up;
|
||||||
|
|
@ -529,11 +536,17 @@ void djui_interactable_hook_text_input(struct DjuiBase *base,
|
||||||
}
|
}
|
||||||
|
|
||||||
void djui_interactable_hook_text_editing(struct DjuiBase* base,
|
void djui_interactable_hook_text_editing(struct DjuiBase* base,
|
||||||
void (*on_text_editing)(struct DjuiBase*, char*, int)) {
|
void (*on_text_editing)(struct DjuiBase*, char*, int)) {
|
||||||
struct DjuiInteractable *interactable = base->interactable;
|
struct DjuiInteractable *interactable = base->interactable;
|
||||||
interactable->on_text_editing = on_text_editing;
|
interactable->on_text_editing = on_text_editing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void djui_interactable_hook_scroll(struct DjuiBase* base,
|
||||||
|
void (*on_scroll)(struct DjuiBase*, float, float)) {
|
||||||
|
struct DjuiInteractable *interactable = base->interactable;
|
||||||
|
interactable->on_scroll = on_scroll;
|
||||||
|
}
|
||||||
|
|
||||||
void djui_interactable_hook_enabled_change(struct DjuiBase *base,
|
void djui_interactable_hook_enabled_change(struct DjuiBase *base,
|
||||||
void (*on_enabled_change)(struct DjuiBase*)) {
|
void (*on_enabled_change)(struct DjuiBase*)) {
|
||||||
struct DjuiInteractable *interactable = base->interactable;
|
struct DjuiInteractable *interactable = base->interactable;
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,6 @@
|
||||||
#define PAD_BUTTON_Z ((u16)(1 << 13))
|
#define PAD_BUTTON_Z ((u16)(1 << 13))
|
||||||
#define PAD_BUTTON_START ((u16)(1 << 12))
|
#define PAD_BUTTON_START ((u16)(1 << 12))
|
||||||
|
|
||||||
#define MOUSE_BUTTON_1 ((u16)(1 << 0))
|
|
||||||
|
|
||||||
#define SCANCODE_UP 328
|
#define SCANCODE_UP 328
|
||||||
#define SCANCODE_DOWN 336
|
#define SCANCODE_DOWN 336
|
||||||
#define SCANCODE_LEFT 331
|
#define SCANCODE_LEFT 331
|
||||||
|
|
@ -43,6 +41,7 @@ struct DjuiInteractable {
|
||||||
void (*on_key_up)(struct DjuiBase*, int scancode);
|
void (*on_key_up)(struct DjuiBase*, int scancode);
|
||||||
void (*on_text_input)(struct DjuiBase*, char* text);
|
void (*on_text_input)(struct DjuiBase*, char* text);
|
||||||
void (*on_text_editing)(struct DjuiBase*, char* text, int cursorPos);
|
void (*on_text_editing)(struct DjuiBase*, char* text, int cursorPos);
|
||||||
|
void (*on_scroll)(struct DjuiBase*, float x, float y);
|
||||||
void (*on_enabled_change)(struct DjuiBase*);
|
void (*on_enabled_change)(struct DjuiBase*);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -64,6 +63,7 @@ bool djui_interactable_on_key_down(int scancode);
|
||||||
void djui_interactable_on_key_up(int scancode);
|
void djui_interactable_on_key_up(int scancode);
|
||||||
void djui_interactable_on_text_input(char *text);
|
void djui_interactable_on_text_input(char *text);
|
||||||
void djui_interactable_on_text_editing(char* text, int cursorPos);
|
void djui_interactable_on_text_editing(char* text, int cursorPos);
|
||||||
|
void djui_interactable_on_scroll(float x, float y);
|
||||||
|
|
||||||
void djui_interactable_update(void);
|
void djui_interactable_update(void);
|
||||||
|
|
||||||
|
|
@ -91,14 +91,17 @@ void djui_interactable_hook_bind(struct DjuiBase* base,
|
||||||
void (*on_bind)(struct DjuiBase*));
|
void (*on_bind)(struct DjuiBase*));
|
||||||
|
|
||||||
void djui_interactable_hook_key(struct DjuiBase* base,
|
void djui_interactable_hook_key(struct DjuiBase* base,
|
||||||
bool (*on_key_down)(struct DjuiBase*, int),
|
bool (*on_key_down)(struct DjuiBase*, int),
|
||||||
void (*on_key_up)(struct DjuiBase*, int));
|
void (*on_key_up)(struct DjuiBase*, int));
|
||||||
|
|
||||||
void djui_interactable_hook_text_input(struct DjuiBase* base,
|
void djui_interactable_hook_text_input(struct DjuiBase* base,
|
||||||
void (*on_text_input)(struct DjuiBase*, char*));
|
void (*on_text_input)(struct DjuiBase*, char*));
|
||||||
|
|
||||||
void djui_interactable_hook_text_editing(struct DjuiBase* base,
|
void djui_interactable_hook_text_editing(struct DjuiBase* base,
|
||||||
void (*on_text_editing)(struct DjuiBase*, char*, int));
|
void (*on_text_editing)(struct DjuiBase*, char*, int));
|
||||||
|
|
||||||
|
void djui_interactable_hook_scroll(struct DjuiBase* base,
|
||||||
|
void (*on_scroll)(struct DjuiBase*, float, float));
|
||||||
|
|
||||||
void djui_interactable_hook_enabled_change(struct DjuiBase *base,
|
void djui_interactable_hook_enabled_change(struct DjuiBase *base,
|
||||||
void (*on_enabled_change)(struct DjuiBase*));
|
void (*on_enabled_change)(struct DjuiBase*));
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ void djui_panel_display_create(struct DjuiBase* caller) {
|
||||||
|
|
||||||
{
|
{
|
||||||
djui_checkbox_create(body, DLANG(DISPLAY, FULLSCREEN), &configWindow.fullscreen, djui_panel_display_apply);
|
djui_checkbox_create(body, DLANG(DISPLAY, FULLSCREEN), &configWindow.fullscreen, djui_panel_display_apply);
|
||||||
|
djui_checkbox_create(body, DLANG(DISPLAY, FORCE_4BY3), &configForce4By3, djui_panel_display_apply);
|
||||||
djui_checkbox_create(body, DLANG(DISPLAY, SHOW_FPS), &configShowFPS, NULL);
|
djui_checkbox_create(body, DLANG(DISPLAY, SHOW_FPS), &configShowFPS, NULL);
|
||||||
djui_checkbox_create(body, DLANG(DISPLAY, VSYNC), &configWindow.vsync, djui_panel_display_apply);
|
djui_checkbox_create(body, DLANG(DISPLAY, VSYNC), &configWindow.vsync, djui_panel_display_apply);
|
||||||
djui_checkbox_create(body, DLANG(DISPLAY, UNCAPPED_FRAMERATE), &configUncappedFramerate, djui_panel_display_uncapped_change);
|
djui_checkbox_create(body, DLANG(DISPLAY, UNCAPPED_FRAMERATE), &configUncappedFramerate, djui_panel_display_uncapped_change);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
static bool djui_root_render(struct DjuiBase* base) {
|
static bool djui_root_render(struct DjuiBase* base) {
|
||||||
// grab window height
|
// grab window height
|
||||||
u32 windowWidth, windowHeight;
|
u32 windowWidth, windowHeight;
|
||||||
wm_api->get_dimensions(&windowWidth, &windowHeight);
|
gfx_get_dimensions(&windowWidth, &windowHeight);
|
||||||
|
|
||||||
// fill the screen
|
// fill the screen
|
||||||
djui_base_set_location(base, 0, 0);
|
djui_base_set_location(base, 0, 0);
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,9 @@ static void gfx_dummy_wm_set_keyboard_callbacks(UNUSED kb_callback_t on_key_down
|
||||||
UNUSED void (*on_text_input)(char*), UNUSED void (*on_text_editing)(char*, int)) {
|
UNUSED void (*on_text_input)(char*), UNUSED void (*on_text_editing)(char*, int)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gfx_dummy_wm_set_scroll_callback(UNUSED void (*on_scroll)(float, float)) {
|
||||||
|
}
|
||||||
|
|
||||||
static void gfx_dummy_wm_set_fullscreen_changed_callback(UNUSED void (*on_fullscreen_changed)(bool is_now_fullscreen)) {
|
static void gfx_dummy_wm_set_fullscreen_changed_callback(UNUSED void (*on_fullscreen_changed)(bool is_now_fullscreen)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -201,6 +204,7 @@ static void gfx_dummy_renderer_shutdown(void) {
|
||||||
struct GfxWindowManagerAPI gfx_dummy_wm_api = {
|
struct GfxWindowManagerAPI gfx_dummy_wm_api = {
|
||||||
gfx_dummy_wm_init,
|
gfx_dummy_wm_init,
|
||||||
gfx_dummy_wm_set_keyboard_callbacks,
|
gfx_dummy_wm_set_keyboard_callbacks,
|
||||||
|
gfx_dummy_wm_set_scroll_callback,
|
||||||
gfx_dummy_wm_main_loop,
|
gfx_dummy_wm_main_loop,
|
||||||
gfx_dummy_wm_get_dimensions,
|
gfx_dummy_wm_get_dimensions,
|
||||||
gfx_dummy_wm_handle_events,
|
gfx_dummy_wm_handle_events,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <windowsx.h>
|
||||||
#include <wrl/client.h>
|
#include <wrl/client.h>
|
||||||
#include <dxgi1_3.h>
|
#include <dxgi1_3.h>
|
||||||
#include <versionhelpers.h>
|
#include <versionhelpers.h>
|
||||||
|
|
@ -93,6 +94,8 @@ static struct {
|
||||||
bool (*on_key_up)(int scancode);
|
bool (*on_key_up)(int scancode);
|
||||||
void (*on_all_keys_up)(void);
|
void (*on_all_keys_up)(void);
|
||||||
void (*on_text_input)(char*);
|
void (*on_text_input)(char*);
|
||||||
|
|
||||||
|
void (*on_scroll)(float x, float y);
|
||||||
} dxgi;
|
} dxgi;
|
||||||
|
|
||||||
static void load_dxgi_library(void) {
|
static void load_dxgi_library(void) {
|
||||||
|
|
@ -272,6 +275,10 @@ static void gfx_dxgi_on_text_input(wchar_t code_unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gfx_dxgi_on_scroll(WPARAM w_param) {
|
||||||
|
dxgi.on_scroll(0, GET_WHEEL_DELTA_WPARAM(w_param)/120);
|
||||||
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_param, LPARAM l_param) {
|
static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_param, LPARAM l_param) {
|
||||||
WCHAR wcsFileName[MAX_PATH];
|
WCHAR wcsFileName[MAX_PATH];
|
||||||
char szFileName[MAX_PATH];
|
char szFileName[MAX_PATH];
|
||||||
|
|
@ -310,6 +317,10 @@ static LRESULT CALLBACK gfx_dxgi_wnd_proc(HWND h_wnd, UINT message, WPARAM w_par
|
||||||
gfx_dxgi_on_text_input((wchar_t)w_param);
|
gfx_dxgi_on_text_input((wchar_t)w_param);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
case WM_MOUSEWHEEL: {
|
||||||
|
gfx_dxgi_on_scroll(w_param);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
case WM_SYSKEYDOWN: {
|
case WM_SYSKEYDOWN: {
|
||||||
if ((w_param == VK_RETURN) && ((l_param & 1 << 30) == 0)) {
|
if ((w_param == VK_RETURN) && ((l_param & 1 << 30) == 0)) {
|
||||||
toggle_borderless_window_full_screen(!dxgi.is_full_screen);
|
toggle_borderless_window_full_screen(!dxgi.is_full_screen);
|
||||||
|
|
@ -425,6 +436,10 @@ static void gfx_dxgi_set_keyboard_callbacks(bool (*on_key_down)(int scancode), b
|
||||||
dxgi.on_text_input = on_text_input;
|
dxgi.on_text_input = on_text_input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gfx_dxgi_set_scroll_callback(void (*on_scroll)(float, float)) {
|
||||||
|
dxgi.on_scroll = on_scroll;
|
||||||
|
}
|
||||||
|
|
||||||
static void gfx_dxgi_main_loop(void (*run_one_game_iter)(void)) {
|
static void gfx_dxgi_main_loop(void (*run_one_game_iter)(void)) {
|
||||||
run_one_game_iter();
|
run_one_game_iter();
|
||||||
}
|
}
|
||||||
|
|
@ -778,6 +793,7 @@ void ThrowIfFailed(HRESULT res, HWND h_wnd, const char *message) {
|
||||||
struct GfxWindowManagerAPI gfx_dxgi = {
|
struct GfxWindowManagerAPI gfx_dxgi = {
|
||||||
gfx_dxgi_init,
|
gfx_dxgi_init,
|
||||||
gfx_dxgi_set_keyboard_callbacks,
|
gfx_dxgi_set_keyboard_callbacks,
|
||||||
|
gfx_dxgi_set_scroll_callback,
|
||||||
gfx_dxgi_main_loop,
|
gfx_dxgi_main_loop,
|
||||||
gfx_dxgi_get_dimensions,
|
gfx_dxgi_get_dimensions,
|
||||||
gfx_dxgi_handle_events,
|
gfx_dxgi_handle_events,
|
||||||
|
|
|
||||||
|
|
@ -993,17 +993,21 @@ static void OPTIMIZE_O3 gfx_sp_tri1(uint8_t vtx1_idx, uint8_t vtx2_idx, uint8_t
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rdp.viewport_or_scissor_changed) {
|
if (rdp.viewport_or_scissor_changed) {
|
||||||
if (memcmp(&rdp.viewport, &rendering_state.viewport, sizeof(rdp.viewport)) != 0) {
|
static uint32_t x_adjust_4by3_prev;
|
||||||
|
if (memcmp(&rdp.viewport, &rendering_state.viewport, sizeof(rdp.viewport)) != 0
|
||||||
|
|| x_adjust_4by3_prev != gfx_current_dimensions.x_adjust_4by3) {
|
||||||
gfx_flush();
|
gfx_flush();
|
||||||
gfx_rapi->set_viewport(rdp.viewport.x, rdp.viewport.y, rdp.viewport.width, rdp.viewport.height);
|
gfx_rapi->set_viewport(rdp.viewport.x + gfx_current_dimensions.x_adjust_4by3, rdp.viewport.y, rdp.viewport.width, rdp.viewport.height);
|
||||||
rendering_state.viewport = rdp.viewport;
|
rendering_state.viewport = rdp.viewport;
|
||||||
}
|
}
|
||||||
if (memcmp(&rdp.scissor, &rendering_state.scissor, sizeof(rdp.scissor)) != 0) {
|
if (memcmp(&rdp.scissor, &rendering_state.scissor, sizeof(rdp.scissor)) != 0
|
||||||
|
|| x_adjust_4by3_prev != gfx_current_dimensions.x_adjust_4by3) {
|
||||||
gfx_flush();
|
gfx_flush();
|
||||||
gfx_rapi->set_scissor(rdp.scissor.x, rdp.scissor.y, rdp.scissor.width, rdp.scissor.height);
|
gfx_rapi->set_scissor(rdp.scissor.x + gfx_current_dimensions.x_adjust_4by3, rdp.scissor.y, rdp.scissor.width, rdp.scissor.height);
|
||||||
rendering_state.scissor = rdp.scissor;
|
rendering_state.scissor = rdp.scissor;
|
||||||
}
|
}
|
||||||
rdp.viewport_or_scissor_changed = false;
|
rdp.viewport_or_scissor_changed = false;
|
||||||
|
x_adjust_4by3_prev = gfx_current_dimensions.x_adjust_4by3;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CombineMode* cm = &rdp.combine_mode;
|
struct CombineMode* cm = &rdp.combine_mode;
|
||||||
|
|
@ -1842,6 +1846,9 @@ static void gfx_sp_reset(void) {
|
||||||
|
|
||||||
void gfx_get_dimensions(uint32_t *width, uint32_t *height) {
|
void gfx_get_dimensions(uint32_t *width, uint32_t *height) {
|
||||||
gfx_wapi->get_dimensions(width, height);
|
gfx_wapi->get_dimensions(width, height);
|
||||||
|
if (configForce4By3) {
|
||||||
|
*width = gfx_current_dimensions.aspect_ratio * *height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, const char *window_title) {
|
void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, const char *window_title) {
|
||||||
|
|
@ -1871,6 +1878,11 @@ void gfx_start_frame(void) {
|
||||||
// Avoid division by zero
|
// Avoid division by zero
|
||||||
gfx_current_dimensions.height = 1;
|
gfx_current_dimensions.height = 1;
|
||||||
}
|
}
|
||||||
|
if (configForce4By3
|
||||||
|
&& ((4.0f / 3.0f) * gfx_current_dimensions.height) < gfx_current_dimensions.width) {
|
||||||
|
gfx_current_dimensions.x_adjust_4by3 = (gfx_current_dimensions.width - (4.0f / 3.0f) * gfx_current_dimensions.height) / 2;
|
||||||
|
gfx_current_dimensions.width = (4.0f / 3.0f) * gfx_current_dimensions.height;
|
||||||
|
} else { gfx_current_dimensions.x_adjust_4by3 = 0; }
|
||||||
gfx_current_dimensions.aspect_ratio = ((float)gfx_current_dimensions.width / (float)gfx_current_dimensions.height);
|
gfx_current_dimensions.aspect_ratio = ((float)gfx_current_dimensions.width / (float)gfx_current_dimensions.height);
|
||||||
gfx_current_dimensions.x_adjust_ratio = (4.0f / 3.0f) / gfx_current_dimensions.aspect_ratio;
|
gfx_current_dimensions.x_adjust_ratio = (4.0f / 3.0f) / gfx_current_dimensions.aspect_ratio;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ struct GfxDimensions {
|
||||||
uint32_t width, height;
|
uint32_t width, height;
|
||||||
float aspect_ratio;
|
float aspect_ratio;
|
||||||
float x_adjust_ratio;
|
float x_adjust_ratio;
|
||||||
|
uint32_t x_adjust_4by3;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct GfxDimensions gfx_current_dimensions;
|
extern struct GfxDimensions gfx_current_dimensions;
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,8 @@ static void (*kb_all_keys_up)(void) = NULL;
|
||||||
static void (*kb_text_input)(char*) = NULL;
|
static void (*kb_text_input)(char*) = NULL;
|
||||||
static void (*kb_text_editing)(char*, int) = NULL;
|
static void (*kb_text_editing)(char*, int) = NULL;
|
||||||
|
|
||||||
|
static void (*m_scroll)(float, float) = NULL;
|
||||||
|
|
||||||
#define IS_FULLSCREEN() ((SDL_GetWindowFlags(wnd) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0)
|
#define IS_FULLSCREEN() ((SDL_GetWindowFlags(wnd) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0)
|
||||||
|
|
||||||
static inline void gfx_sdl_set_vsync(const bool enabled) {
|
static inline void gfx_sdl_set_vsync(const bool enabled) {
|
||||||
|
|
@ -186,6 +188,11 @@ static void gfx_sdl_onkeyup(int scancode) {
|
||||||
kb_key_up(translate_sdl_scancode(scancode));
|
kb_key_up(translate_sdl_scancode(scancode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gfx_sdl_onscroll(float x, float y) {
|
||||||
|
if (m_scroll)
|
||||||
|
m_scroll(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
static void gfx_sdl_ondropfile(char* path) {
|
static void gfx_sdl_ondropfile(char* path) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char portable_path[SYS_MAX_PATH];
|
char portable_path[SYS_MAX_PATH];
|
||||||
|
|
@ -221,6 +228,9 @@ static void gfx_sdl_handle_events(void) {
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
gfx_sdl_onkeyup(event.key.keysym.scancode);
|
gfx_sdl_onkeyup(event.key.keysym.scancode);
|
||||||
break;
|
break;
|
||||||
|
case SDL_MOUSEWHEEL:
|
||||||
|
gfx_sdl_onscroll(event.wheel.preciseX, event.wheel.preciseY);
|
||||||
|
break;
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
if (!IS_FULLSCREEN()) {
|
if (!IS_FULLSCREEN()) {
|
||||||
switch (event.window.event) {
|
switch (event.window.event) {
|
||||||
|
|
@ -263,6 +273,10 @@ void (*on_all_keys_up)(void), void (*on_text_input)(char*), void (*on_text_editi
|
||||||
kb_text_editing = on_text_editing;
|
kb_text_editing = on_text_editing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gfx_sdl_set_scroll_callback(void (*on_scroll)(float, float)) {
|
||||||
|
m_scroll = on_scroll;
|
||||||
|
}
|
||||||
|
|
||||||
static bool gfx_sdl_start_frame(void) {
|
static bool gfx_sdl_start_frame(void) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -329,6 +343,7 @@ static void gfx_sdl_set_cursor_visible(bool visible) { SDL_ShowCursor(visible ?
|
||||||
struct GfxWindowManagerAPI gfx_sdl = {
|
struct GfxWindowManagerAPI gfx_sdl = {
|
||||||
gfx_sdl_init,
|
gfx_sdl_init,
|
||||||
gfx_sdl_set_keyboard_callbacks,
|
gfx_sdl_set_keyboard_callbacks,
|
||||||
|
gfx_sdl_set_scroll_callback,
|
||||||
gfx_sdl_main_loop,
|
gfx_sdl_main_loop,
|
||||||
gfx_sdl_get_dimensions,
|
gfx_sdl_get_dimensions,
|
||||||
gfx_sdl_handle_events,
|
gfx_sdl_handle_events,
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ struct GfxWindowManagerAPI {
|
||||||
void (*init)(const char *window_title);
|
void (*init)(const char *window_title);
|
||||||
void (*set_keyboard_callbacks)(kb_callback_t on_key_down, kb_callback_t on_key_up, void (*on_all_keys_up)(void),
|
void (*set_keyboard_callbacks)(kb_callback_t on_key_down, kb_callback_t on_key_up, void (*on_all_keys_up)(void),
|
||||||
void (*on_text_input)(char*), void (*on_text_editing)(char*, int));
|
void (*on_text_input)(char*), void (*on_text_editing)(char*, int));
|
||||||
|
void (*set_scroll_callback)(void (*on_scroll)(float, float));
|
||||||
void (*main_loop)(void (*run_one_game_iter)(void));
|
void (*main_loop)(void (*run_one_game_iter)(void));
|
||||||
void (*get_dimensions)(uint32_t *width, uint32_t *height);
|
void (*get_dimensions)(uint32_t *width, uint32_t *height);
|
||||||
void (*handle_events)(void);
|
void (*handle_events)(void);
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ static bool loading_screen_on_render(struct DjuiBase* base) {
|
||||||
MUTEX_LOCK(gLoadingThread);
|
MUTEX_LOCK(gLoadingThread);
|
||||||
|
|
||||||
u32 windowWidth, windowHeight;
|
u32 windowWidth, windowHeight;
|
||||||
WAPI.get_dimensions(&windowWidth, &windowHeight);
|
gfx_get_dimensions(&windowWidth, &windowHeight);
|
||||||
f32 scale = djui_gfx_get_scale();
|
f32 scale = djui_gfx_get_scale();
|
||||||
windowWidth /= scale;
|
windowWidth /= scale;
|
||||||
windowHeight /= scale;
|
windowHeight /= scale;
|
||||||
|
|
|
||||||
|
|
@ -1076,6 +1076,14 @@ char gSmluaConstants[] = ""
|
||||||
"CHAR_SOUND_LETS_A_GO=42\n"
|
"CHAR_SOUND_LETS_A_GO=42\n"
|
||||||
"CHAR_SOUND_OKEY_DOKEY=43\n"
|
"CHAR_SOUND_OKEY_DOKEY=43\n"
|
||||||
"CHAR_SOUND_MAX=44\n"
|
"CHAR_SOUND_MAX=44\n"
|
||||||
|
"MOUSE_BUTTON_1=(1 << 0)\n"
|
||||||
|
"MOUSE_BUTTON_2=(1 << 1)\n"
|
||||||
|
"MOUSE_BUTTON_3=(1 << 2)\n"
|
||||||
|
"MOUSE_BUTTON_4=(1 << 3)\n"
|
||||||
|
"MOUSE_BUTTON_5=(1 << 4)\n"
|
||||||
|
"L_MOUSE_BUTTON=MOUSE_BUTTON_1\n"
|
||||||
|
"M_MOUSE_BUTTON=MOUSE_BUTTON_2\n"
|
||||||
|
"R_MOUSE_BUTTON=MOUSE_BUTTON_3\n"
|
||||||
"DIALOG_000=0\n"
|
"DIALOG_000=0\n"
|
||||||
"DIALOG_001=1\n"
|
"DIALOG_001=1\n"
|
||||||
"DIALOG_002=2\n"
|
"DIALOG_002=2\n"
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -17,7 +17,6 @@
|
||||||
#include "pc/debuglog.h"
|
#include "pc/debuglog.h"
|
||||||
#include "pc/pc_main.h"
|
#include "pc/pc_main.h"
|
||||||
#include "pc/fs/fmem.h"
|
#include "pc/fs/fmem.h"
|
||||||
#include "audio/external.h"
|
|
||||||
|
|
||||||
struct AudioOverride {
|
struct AudioOverride {
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
|
@ -336,9 +335,8 @@ void audio_stream_play(struct ModAudio* audio, bool restart, f32 volume) {
|
||||||
if (configMuteFocusLoss && !WAPI.has_focus()) {
|
if (configMuteFocusLoss && !WAPI.has_focus()) {
|
||||||
ma_sound_set_volume(&audio->sound, 0);
|
ma_sound_set_volume(&audio->sound, 0);
|
||||||
} else {
|
} else {
|
||||||
f32 masterVolume = (f32)configMasterVolume / 127.0f * (f32)gLuaVolumeMaster / 127.0f;
|
|
||||||
f32 musicVolume = (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f;
|
f32 musicVolume = (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f;
|
||||||
ma_sound_set_volume(&audio->sound, masterVolume * musicVolume * volume);
|
ma_sound_set_volume(&audio->sound, gMasterVolume * musicVolume * volume);
|
||||||
}
|
}
|
||||||
audio->baseVolume = volume;
|
audio->baseVolume = volume;
|
||||||
if (restart || !ma_sound_is_playing(&audio->sound)) { ma_sound_seek_to_pcm_frame(&audio->sound, 0); }
|
if (restart || !ma_sound_is_playing(&audio->sound)) { ma_sound_seek_to_pcm_frame(&audio->sound, 0); }
|
||||||
|
|
@ -430,9 +428,8 @@ void audio_stream_set_volume(struct ModAudio* audio, f32 volume) {
|
||||||
if (configMuteFocusLoss && !WAPI.has_focus()) {
|
if (configMuteFocusLoss && !WAPI.has_focus()) {
|
||||||
ma_sound_set_volume(&audio->sound, 0);
|
ma_sound_set_volume(&audio->sound, 0);
|
||||||
} else {
|
} else {
|
||||||
f32 masterVolume = (f32)configMasterVolume / 127.0f;
|
f32 musicVolume = (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f;
|
||||||
f32 musicVolume = (f32)configMusicVolume / 127.0f;
|
ma_sound_set_volume(&audio->sound, gMasterVolume * musicVolume * volume);
|
||||||
ma_sound_set_volume(&audio->sound, masterVolume * musicVolume * volume);
|
|
||||||
}
|
}
|
||||||
audio->baseVolume = volume;
|
audio->baseVolume = volume;
|
||||||
}
|
}
|
||||||
|
|
@ -445,14 +442,14 @@ void audio_stream_set_volume(struct ModAudio* audio, f32 volume) {
|
||||||
|
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
|
||||||
// MA calls the end callback from it's audio thread
|
// MA calls the end callback from its audio thread
|
||||||
// Use mutexes to be sure we don't try to delete the same memory at the same time
|
// Use mutexes to be sure we don't try to delete the same memory at the same time
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
static pthread_mutex_t sSampleCopyMutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t sSampleCopyMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static struct ModAudioSampleCopies *sSampleCopyFreeTail = NULL;
|
static struct ModAudioSampleCopies *sSampleCopyFreeTail = NULL;
|
||||||
|
|
||||||
// Called whenever a sample copy finishes playback (called from the miniaudio thread)
|
// Called whenever a sample copy finishes playback (called from the miniaudio thread)
|
||||||
// removes the copy from it's linked list, and adds it to the pending list
|
// removes the copy from its linked list, and adds it to the pending list
|
||||||
static void audio_sample_copy_end_callback(void* userData, UNUSED ma_sound* sound) {
|
static void audio_sample_copy_end_callback(void* userData, UNUSED ma_sound* sound) {
|
||||||
pthread_mutex_lock(&sSampleCopyMutex);
|
pthread_mutex_lock(&sSampleCopyMutex);
|
||||||
|
|
||||||
|
|
@ -570,9 +567,8 @@ void audio_sample_play(struct ModAudio* audio, Vec3f position, f32 volume) {
|
||||||
ma_sound_set_volume(sound, 0);
|
ma_sound_set_volume(sound, 0);
|
||||||
} else {
|
} else {
|
||||||
f32 intensity = sound_get_level_intensity(dist);
|
f32 intensity = sound_get_level_intensity(dist);
|
||||||
f32 masterVolume = (f32)configMasterVolume / 127.0f * (f32)gLuaVolumeMaster / 127.0f;
|
|
||||||
f32 sfxVolume = (f32)configSfxVolume / 127.0f * (f32)gLuaVolumeSfx / 127.0f;
|
f32 sfxVolume = (f32)configSfxVolume / 127.0f * (f32)gLuaVolumeSfx / 127.0f;
|
||||||
ma_sound_set_volume(sound, masterVolume * sfxVolume * volume * intensity);
|
ma_sound_set_volume(sound, gMasterVolume * sfxVolume * volume * intensity);
|
||||||
}
|
}
|
||||||
ma_sound_set_pan(sound, pan);
|
ma_sound_set_pan(sound, pan);
|
||||||
audio->baseVolume = volume;
|
audio->baseVolume = volume;
|
||||||
|
|
@ -581,7 +577,9 @@ void audio_sample_play(struct ModAudio* audio, Vec3f position, f32 volume) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_custom_update_volume(void) {
|
void audio_custom_update_volume(void) {
|
||||||
|
gMasterVolume = (f32)configMasterVolume / 127.0f * (f32)gLuaVolumeMaster / 127.0f;
|
||||||
if (!sModAudioPool) { return; }
|
if (!sModAudioPool) { return; }
|
||||||
|
f32 musicVolume = (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f;
|
||||||
struct DynamicPoolNode* node = sModAudioPool->tail;
|
struct DynamicPoolNode* node = sModAudioPool->tail;
|
||||||
while (node) {
|
while (node) {
|
||||||
struct DynamicPoolNode* prev = node->prev;
|
struct DynamicPoolNode* prev = node->prev;
|
||||||
|
|
@ -589,9 +587,7 @@ void audio_custom_update_volume(void) {
|
||||||
if (configMuteFocusLoss && !WAPI.has_focus()) {
|
if (configMuteFocusLoss && !WAPI.has_focus()) {
|
||||||
ma_sound_set_volume(&audio->sound, 0);
|
ma_sound_set_volume(&audio->sound, 0);
|
||||||
} else if (audio->isStream) {
|
} else if (audio->isStream) {
|
||||||
f32 masterVolume = (f32)configMasterVolume / 127.0f * (f32)gLuaVolumeMaster / 127.0f;
|
ma_sound_set_volume(&audio->sound, gMasterVolume * musicVolume * audio->baseVolume);
|
||||||
f32 musicVolume = (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f;
|
|
||||||
ma_sound_set_volume(&audio->sound, masterVolume * musicVolume * audio->baseVolume);
|
|
||||||
}
|
}
|
||||||
node = prev;
|
node = prev;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,11 @@ bool djui_attempting_to_open_playerlist(void) {
|
||||||
return gAttemptingToOpenPlayerlist;
|
return gAttemptingToOpenPlayerlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8 djui_get_playerlist_page_index(void) {
|
||||||
|
extern u8 sPageIndex;
|
||||||
|
return sPageIndex;
|
||||||
|
}
|
||||||
|
|
||||||
enum DjuiFontType djui_menu_get_font(void) {
|
enum DjuiFontType djui_menu_get_font(void) {
|
||||||
return configDjuiThemeFont == 0 ? FONT_NORMAL : FONT_ALIASED;
|
return configDjuiThemeFont == 0 ? FONT_NORMAL : FONT_ALIASED;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,8 @@ void djui_reset_popup_disabled_override(void);
|
||||||
bool djui_is_playerlist_open(void);
|
bool djui_is_playerlist_open(void);
|
||||||
/* |description|Checks if the DJUI playerlist is attempting to be opened|descriptionEnd| */
|
/* |description|Checks if the DJUI playerlist is attempting to be opened|descriptionEnd| */
|
||||||
bool djui_attempting_to_open_playerlist(void);
|
bool djui_attempting_to_open_playerlist(void);
|
||||||
|
/* |description|Gets the DJUI playerlist's page index|descriptionEnd| */
|
||||||
|
u8 djui_get_playerlist_page_index(void);
|
||||||
/* |description|Gets the DJUI menu font|descriptionEnd| */
|
/* |description|Gets the DJUI menu font|descriptionEnd| */
|
||||||
enum DjuiFontType djui_menu_get_font(void);
|
enum DjuiFontType djui_menu_get_font(void);
|
||||||
/* |description|Gets the DJUI menu theme|descriptionEnd| */
|
/* |description|Gets the DJUI menu theme|descriptionEnd| */
|
||||||
|
|
|
||||||
|
|
@ -73,14 +73,13 @@ void mumble_init(void) {
|
||||||
|
|
||||||
void mumble_update(void) {
|
void mumble_update(void) {
|
||||||
|
|
||||||
if (! lm) {
|
if (!lm) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lm->uiTick++;
|
lm->uiTick++;
|
||||||
|
|
||||||
if (gDjuiInMainMenu)
|
if (gDjuiInMainMenu) {
|
||||||
{
|
|
||||||
mumble_update_menu();
|
mumble_update_menu();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -173,7 +172,7 @@ bool should_update_context() {
|
||||||
if (gCurrLevelNum == LEVEL_CASTLE) {
|
if (gCurrLevelNum == LEVEL_CASTLE) {
|
||||||
// main floor
|
// main floor
|
||||||
if (gCurrAreaIndex == 1) {
|
if (gCurrAreaIndex == 1) {
|
||||||
return gMarioState->currentRoom < 10;
|
return gMarioState->currentRoom < 10;
|
||||||
}
|
}
|
||||||
// upstairs
|
// upstairs
|
||||||
if (gCurrAreaIndex == 2) {
|
if (gCurrAreaIndex == 2) {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "controller/controller_api.h"
|
#include "controller/controller_api.h"
|
||||||
#include "controller/controller_keyboard.h"
|
#include "controller/controller_keyboard.h"
|
||||||
|
#include "controller/controller_mouse.h"
|
||||||
#include "fs/fs.h"
|
#include "fs/fs.h"
|
||||||
|
|
||||||
#include "game/display.h" // for gGlobalTimer
|
#include "game/display.h" // for gGlobalTimer
|
||||||
|
|
@ -96,6 +97,8 @@ static u32 sDrawnFrames = 0;
|
||||||
bool gGameInited = false;
|
bool gGameInited = false;
|
||||||
bool gGfxInited = false;
|
bool gGfxInited = false;
|
||||||
|
|
||||||
|
f32 gMasterVolume;
|
||||||
|
|
||||||
u8 gLuaVolumeMaster = 127;
|
u8 gLuaVolumeMaster = 127;
|
||||||
u8 gLuaVolumeLevel = 127;
|
u8 gLuaVolumeLevel = 127;
|
||||||
u8 gLuaVolumeSfx = 127;
|
u8 gLuaVolumeSfx = 127;
|
||||||
|
|
@ -256,18 +259,25 @@ void produce_interpolation_frames_and_delay(void) {
|
||||||
static s16 sAudioBuffer[SAMPLES_HIGH * 2 * 2] = { 0 };
|
static s16 sAudioBuffer[SAMPLES_HIGH * 2 * 2] = { 0 };
|
||||||
|
|
||||||
inline static void buffer_audio(void) {
|
inline static void buffer_audio(void) {
|
||||||
bool shouldMute = configMuteFocusLoss && !WAPI.has_focus();
|
bool shouldMute = (configMuteFocusLoss && !WAPI.has_focus()) || (gMasterVolume == 0);
|
||||||
const f32 masterMod = (f32)configMasterVolume / 127.0f * (f32)gLuaVolumeMaster / 127.0f;
|
if (!shouldMute) {
|
||||||
set_sequence_player_volume(SEQ_PLAYER_LEVEL, shouldMute ? 0 : (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f * masterMod);
|
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f);
|
||||||
set_sequence_player_volume(SEQ_PLAYER_SFX, shouldMute ? 0 : (f32)configSfxVolume / 127.0f * (f32)gLuaVolumeSfx / 127.0f * masterMod);
|
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * (f32)gLuaVolumeSfx / 127.0f);
|
||||||
set_sequence_player_volume(SEQ_PLAYER_ENV, shouldMute ? 0 : (f32)configEnvVolume / 127.0f * (f32)gLuaVolumeEnv / 127.0f * masterMod);
|
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * (f32)gLuaVolumeEnv / 127.0f);
|
||||||
|
}
|
||||||
|
|
||||||
int samplesLeft = audio_api->buffered();
|
int samplesLeft = audio_api->buffered();
|
||||||
u32 numAudioSamples = samplesLeft < audio_api->get_desired_buffered() ? SAMPLES_HIGH : SAMPLES_LOW;
|
u32 numAudioSamples = samplesLeft < audio_api->get_desired_buffered() ? SAMPLES_HIGH : SAMPLES_LOW;
|
||||||
for (s32 i = 0; i < 2; i++) {
|
for (s32 i = 0; i < 2; i++) {
|
||||||
create_next_audio_buffer(sAudioBuffer + i * (numAudioSamples * 2), numAudioSamples);
|
create_next_audio_buffer(sAudioBuffer + i * (numAudioSamples * 2), numAudioSamples);
|
||||||
}
|
}
|
||||||
audio_api->play((u8 *)sAudioBuffer, 2 * numAudioSamples * 4);
|
|
||||||
|
if (!shouldMute) {
|
||||||
|
for (u16 i=0; i < ARRAY_COUNT(sAudioBuffer); i++) {
|
||||||
|
sAudioBuffer[i] *= gMasterVolume;
|
||||||
|
}
|
||||||
|
audio_api->play((u8 *)sAudioBuffer, 2 * numAudioSamples * 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *audio_thread(UNUSED void *arg) {
|
void *audio_thread(UNUSED void *arg) {
|
||||||
|
|
@ -453,6 +463,7 @@ int main(int argc, char *argv[]) {
|
||||||
gfx_init(&WAPI, &RAPI, TITLE);
|
gfx_init(&WAPI, &RAPI, TITLE);
|
||||||
WAPI.set_keyboard_callbacks(keyboard_on_key_down, keyboard_on_key_up, keyboard_on_all_keys_up,
|
WAPI.set_keyboard_callbacks(keyboard_on_key_down, keyboard_on_key_up, keyboard_on_all_keys_up,
|
||||||
keyboard_on_text_input, keyboard_on_text_editing);
|
keyboard_on_text_input, keyboard_on_text_editing);
|
||||||
|
WAPI.set_scroll_callback(mouse_on_scroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
// render the rom setup screen
|
// render the rom setup screen
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,8 @@ extern "C" {
|
||||||
extern bool gGameInited;
|
extern bool gGameInited;
|
||||||
extern bool gGfxInited;
|
extern bool gGfxInited;
|
||||||
|
|
||||||
|
extern f32 gMasterVolume;
|
||||||
|
|
||||||
extern u8 gLuaVolumeMaster;
|
extern u8 gLuaVolumeMaster;
|
||||||
extern u8 gLuaVolumeLevel;
|
extern u8 gLuaVolumeLevel;
|
||||||
extern u8 gLuaVolumeSfx;
|
extern u8 gLuaVolumeSfx;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue