Cleaned some tools up
Some checks failed
Build Dusk / run-tests (push) Failing after 2m13s
Build Dusk / build-linux (push) Successful in 2m4s
Build Dusk / build-psp (push) Failing after 1m47s

This commit is contained in:
2026-01-27 08:40:13 -06:00
parent 81b08b2eba
commit fb93453482
17 changed files with 61 additions and 143 deletions

View File

@@ -25,4 +25,13 @@ elseif(DUSK_TARGET_SYSTEM STREQUAL "psp")
INPUT_SDL2=1
INPUT_GAMEPAD=1
)
endif()
endif()
# CSV
dusk_run_python(
dusk_input_csv_defs
tools.input.csv
--csv ${CMAKE_CURRENT_SOURCE_DIR}/input.csv
--output ${DUSK_GENERATED_HEADERS_DIR}/input/inputactiondefs.h
)
add_dependencies(${DUSK_LIBRARY_TARGET_NAME} dusk_input_csv_defs)

8
src/input/input.csv Normal file
View File

@@ -0,0 +1,8 @@
id,
UP,
DOWN,
LEFT,
RIGHT,
ACCEPT,
CANCEL,
RAGEQUIT
1 id,
2 UP,
3 DOWN,
4 LEFT,
5 RIGHT,
6 ACCEPT,
7 CANCEL,
8 RAGEQUIT

View File

@@ -7,12 +7,7 @@
#pragma once
#include "time/time.h"
#ifndef INPUT_CSV_GENERATED
#error "Input CSV has not been generated. Run dusk_input_csv in CMake."
#endif
#include "input/inputactiontype.h"
// #include "input/inputactionname.h"
#include "input/inputactiondefs.h"
typedef struct {
inputaction_t action;

View File

@@ -8,4 +8,12 @@ target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
inventory.c
backpack.c
)
)
dusk_run_python(
dusk_item_csv_defs
tools.item.csv
--csv ${CMAKE_CURRENT_SOURCE_DIR}/item.csv
--output ${DUSK_GENERATED_HEADERS_DIR}/item/item.h
)
add_dependencies(${DUSK_LIBRARY_TARGET_NAME} dusk_item_csv_defs)

4
src/item/item.csv Normal file
View File

@@ -0,0 +1,4 @@
id,type,weight
POTION,MEDICINE,1.0
POTATO,FOOD,0.5
APPLE,FOOD,0.3
1 id type weight
2 POTION MEDICINE 1.0
3 POTATO FOOD 0.5
4 APPLE FOOD 0.3

View File

@@ -45,16 +45,10 @@ int moduleInputBind(lua_State *L) {
}
void moduleInput(scriptcontext_t *context) {
char_t buffer[128];
assertNotNull(context, "Script context cannot be NULL");
// Set input information
for(inputaction_t act = INPUT_ACTION_NULL + 1; act < INPUT_ACTION_COUNT; act++) {
const char_t *actId = INPUT_ACTION_IDS[act];
assertStrLenMax(actId, 64, "Input action name too long for buffer");
snprintf(buffer, sizeof(buffer), "INPUT_ACTION_%s = %d\n", actId, act);
scriptContextExec(context, buffer);
}
// Setup enums.
scriptContextExec(context, INPUT_ACTION_SCRIPT);
// Input values.
scriptContextExec(context,

View File

@@ -238,16 +238,10 @@ int moduleInventorySort(lua_State *L) {
}
void moduleItem(scriptcontext_t *context) {
char_t buffer[128];
assertNotNull(context, "Script context cannot be NULL");
// Set item information
for(itemid_t itemId = ITEM_ID_NULL + 1; itemId < ITEM_ID_COUNT; itemId++) {
const char_t *itemName = ITEMS[itemId].name;
assertStrLenMax(itemName, 64, "Item name too long for buffer");
snprintf(buffer, sizeof(buffer), "ITEM_ID_%s = %d\n", itemName, itemId);
scriptContextExec(context, buffer);
}
scriptContextExec(context, ITEM_SCRIPT);
// Bind BACKPACK const pointer
scriptContextRegPointer(context, "BACKPACK", (void *)&BACKPACK);