Cleaned some tools up
This commit is contained in:
@@ -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
8
src/input/input.csv
Normal file
@@ -0,0 +1,8 @@
|
||||
id,
|
||||
UP,
|
||||
DOWN,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
ACCEPT,
|
||||
CANCEL,
|
||||
RAGEQUIT
|
||||
|
@@ -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;
|
||||
|
||||
@@ -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
4
src/item/item.csv
Normal file
@@ -0,0 +1,4 @@
|
||||
id,type,weight
|
||||
POTION,MEDICINE,1.0
|
||||
POTATO,FOOD,0.5
|
||||
APPLE,FOOD,0.3
|
||||
|
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user