VERSIÓ 1.4.3
- [NEW] key.text() - [NEW] key.utf8char() - [NEW] pal.trans() ara torna el color transparent - [NEW] pal.subpal(index) i pal.subpal(index,color) ara tornen el color al que estaba abans asignat el index
This commit is contained in:
20
lua.cpp
20
lua.cpp
@@ -310,12 +310,16 @@ extern "C" {
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
index = luaL_checkinteger(L, 1);
|
index = luaL_checkinteger(L, 1);
|
||||||
subpal(index,index);
|
const uint8_t old = subpal(index,index);
|
||||||
|
lua_pushinteger(L, old);
|
||||||
|
return 1;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
index = luaL_checkinteger(L, 1);
|
index = luaL_checkinteger(L, 1);
|
||||||
color = luaL_checkinteger(L, 2);
|
color = luaL_checkinteger(L, 2);
|
||||||
subpal(index, color);
|
const uint8_t old = subpal(index, color);
|
||||||
|
lua_pushinteger(L, old);
|
||||||
|
return 1;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
index = luaL_checkinteger(L, 1);
|
index = luaL_checkinteger(L, 1);
|
||||||
@@ -956,6 +960,16 @@ extern "C" {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cpp_key_text(lua_State *L) {
|
||||||
|
textenable(lua_toboolean(L, 1));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int cpp_key_utf8char(lua_State *L) {
|
||||||
|
lua_pushstring(L, textinput());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// pad
|
// pad
|
||||||
// ===============================================
|
// ===============================================
|
||||||
@@ -1134,6 +1148,8 @@ void push_lua_funcs() {
|
|||||||
lua_pushcfunction(L,cpp_key_down); lua_setfield(L, -2, "down");
|
lua_pushcfunction(L,cpp_key_down); lua_setfield(L, -2, "down");
|
||||||
lua_pushcfunction(L,cpp_key_press); lua_setfield(L, -2, "press");
|
lua_pushcfunction(L,cpp_key_press); lua_setfield(L, -2, "press");
|
||||||
lua_pushcfunction(L,cpp_key_any); lua_setfield(L, -2, "any");
|
lua_pushcfunction(L,cpp_key_any); lua_setfield(L, -2, "any");
|
||||||
|
lua_pushcfunction(L,cpp_key_text); lua_setfield(L, -2, "text");
|
||||||
|
lua_pushcfunction(L,cpp_key_utf8char); lua_setfield(L, -2, "utf8char");
|
||||||
//lua_setglobal(L, "key");
|
//lua_setglobal(L, "key");
|
||||||
|
|
||||||
//lua_newtable(L);
|
//lua_newtable(L);
|
||||||
|
|||||||
38
mini.cpp
38
mini.cpp
@@ -109,6 +109,8 @@ char base64glyphs[193] = "/h/AqV/hhhh/GMYYMGz/t/eS33H477wsjjswY4IOPHEFFVVVAVAVAV
|
|||||||
//Uint8 keymapping[6] = { SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_Z, SDL_SCANCODE_X };
|
//Uint8 keymapping[6] = { SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT, SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_Z, SDL_SCANCODE_X };
|
||||||
const bool *keys;
|
const bool *keys;
|
||||||
Uint8 key_just_pressed = 0;
|
Uint8 key_just_pressed = 0;
|
||||||
|
static char text_input_buffer[10];
|
||||||
|
static bool has_text_input = false;
|
||||||
|
|
||||||
int mouse_x, mouse_y, mouse_wheel;
|
int mouse_x, mouse_y, mouse_wheel;
|
||||||
Uint32 mouse_buttons;
|
Uint32 mouse_buttons;
|
||||||
@@ -544,26 +546,17 @@ int main(int argc,char*argv[]){
|
|||||||
mouse_just_pressed = 0;
|
mouse_just_pressed = 0;
|
||||||
mouse_wheel = 0;
|
mouse_wheel = 0;
|
||||||
double_click = false;
|
double_click = false;
|
||||||
|
has_text_input = false;
|
||||||
while(!should_exit) {
|
while(!should_exit) {
|
||||||
if (update_mode==UPDATE_WAIT) SDL_WaitEvent(NULL);
|
if (update_mode==UPDATE_WAIT) SDL_WaitEvent(NULL);
|
||||||
else if (update_mode==UPDATE_TIMEOUT) SDL_WaitEventTimeout(NULL, timeout);
|
else if (update_mode==UPDATE_TIMEOUT) SDL_WaitEventTimeout(NULL, timeout);
|
||||||
while(SDL_PollEvent(&mini_eve)) {
|
while(SDL_PollEvent(&mini_eve)) {
|
||||||
if (mini_eve.type == SDL_EVENT_QUIT) { should_exit=true; should_quit=true; break; }
|
if (mini_eve.type == SDL_EVENT_QUIT) { should_exit=true; should_quit=true; break; }
|
||||||
|
if (mini_eve.type == SDL_EVENT_TEXT_INPUT) {
|
||||||
|
SDL_strlcpy(text_input_buffer, mini_eve.text.text, sizeof(text_input_buffer));
|
||||||
|
has_text_input = true;
|
||||||
|
}
|
||||||
if (mini_eve.type == SDL_EVENT_KEY_DOWN) {
|
if (mini_eve.type == SDL_EVENT_KEY_DOWN) {
|
||||||
/*
|
|
||||||
if (mini_eve.key.keysym.scancode == SDL_SCANCODE_F2) {
|
|
||||||
screen_zoom+=2; if (screen_zoom>=10) screen_zoom=2;
|
|
||||||
destroyDisplay();
|
|
||||||
createDisplay();
|
|
||||||
char strzoom[3];
|
|
||||||
file_setconfigvalue("zoom", SDL_itoa(screen_zoom, strzoom, 10));
|
|
||||||
} else if (mini_eve.key.keysym.scancode == SDL_SCANCODE_F3) {
|
|
||||||
screen_fullscreen = !screen_fullscreen;
|
|
||||||
destroyDisplay();
|
|
||||||
createDisplay();
|
|
||||||
file_setconfigvalue("fullscreen", screen_fullscreen?"true":"false");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (mini_eve.key.scancode == SDL_SCANCODE_F12) {
|
if (mini_eve.key.scancode == SDL_SCANCODE_F12) {
|
||||||
if (lua_is_playing()) {
|
if (lua_is_playing()) {
|
||||||
@@ -626,6 +619,8 @@ int main(int argc,char*argv[]){
|
|||||||
if (beats>0)beats--;
|
if (beats>0)beats--;
|
||||||
key_just_pressed = 0;
|
key_just_pressed = 0;
|
||||||
mouse_just_pressed = 0;
|
mouse_just_pressed = 0;
|
||||||
|
has_text_input = false;
|
||||||
|
text_input_buffer[0] = '\0';
|
||||||
double_click = false;
|
double_click = false;
|
||||||
mouse_wheel = 0;
|
mouse_wheel = 0;
|
||||||
pad_just_pressed = SDL_GAMEPAD_BUTTON_INVALID;
|
pad_just_pressed = SDL_GAMEPAD_BUTTON_INVALID;
|
||||||
@@ -734,8 +729,10 @@ uint8_t gettrans() {
|
|||||||
return ds::trans;
|
return ds::trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subpal(uint8_t index, uint8_t color) {
|
uint8_t subpal(uint8_t index, uint8_t color) {
|
||||||
|
const uint8_t old = ds::draw_palette[SDL_clamp(index,0,255)];
|
||||||
ds::draw_palette[SDL_clamp(index,0,255)] = SDL_clamp(color,0,255);
|
ds::draw_palette[SDL_clamp(index,0,255)] = SDL_clamp(color,0,255);
|
||||||
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_subpal() {
|
void reset_subpal() {
|
||||||
@@ -1343,6 +1340,17 @@ bool anykey() {
|
|||||||
return something_pressed;
|
return something_pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void textenable(const bool enable) {
|
||||||
|
if (enable)
|
||||||
|
SDL_StartTextInput(mini_win);
|
||||||
|
else
|
||||||
|
SDL_StopTextInput(mini_win);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* textinput() {
|
||||||
|
return has_text_input ? text_input_buffer : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool pad(int8_t i) {
|
bool pad(int8_t i) {
|
||||||
if (!gamepad) return false;
|
if (!gamepad) return false;
|
||||||
return SDL_GetGamepadButton(gamepad, SDL_GamepadButton(i)) == 1;
|
return SDL_GetGamepadButton(gamepad, SDL_GamepadButton(i)) == 1;
|
||||||
|
|||||||
4
mini.h
4
mini.h
@@ -152,7 +152,7 @@ void setcolor(uint8_t index, uint32_t color);
|
|||||||
uint32_t getcolor(uint8_t index);
|
uint32_t getcolor(uint8_t index);
|
||||||
void settrans(uint8_t index);
|
void settrans(uint8_t index);
|
||||||
uint8_t gettrans();
|
uint8_t gettrans();
|
||||||
void subpal(uint8_t index, uint8_t color);
|
uint8_t subpal(uint8_t index, uint8_t color);
|
||||||
void reset_subpal();
|
void reset_subpal();
|
||||||
|
|
||||||
void set_draw_mode(uint8_t mode);
|
void set_draw_mode(uint8_t mode);
|
||||||
@@ -225,6 +225,8 @@ bool btn(uint8_t i);
|
|||||||
int wbtnp();
|
int wbtnp();
|
||||||
bool btnp(uint8_t i);
|
bool btnp(uint8_t i);
|
||||||
bool anykey();
|
bool anykey();
|
||||||
|
void textenable(const bool enable);
|
||||||
|
const char *textinput();
|
||||||
|
|
||||||
bool pad(int8_t i);
|
bool pad(int8_t i);
|
||||||
bool padp(int8_t i);
|
bool padp(int8_t i);
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define MINI_VERSION "1.4.2"
|
#define MINI_VERSION "1.4.3"
|
||||||
|
|||||||
@@ -122,6 +122,10 @@ function pal.color(index) end
|
|||||||
---Set (r,g,b) color for the specified index in the current palette
|
---Set (r,g,b) color for the specified index in the current palette
|
||||||
function pal.color(index, r, g, b) end
|
function pal.color(index, r, g, b) end
|
||||||
|
|
||||||
|
---@return number index
|
||||||
|
---Get the index specified as transparent color
|
||||||
|
function pal.trans() end
|
||||||
|
|
||||||
---@param index number
|
---@param index number
|
||||||
---Set the index specified as transparent color
|
---Set the index specified as transparent color
|
||||||
function pal.trans(index) end
|
function pal.trans(index) end
|
||||||
@@ -130,12 +134,16 @@ function pal.trans(index) end
|
|||||||
function pal.subpal() end
|
function pal.subpal() end
|
||||||
|
|
||||||
---@param index number
|
---@param index number
|
||||||
---Reset the specified subpalette index to its default palette index
|
---@return number index
|
||||||
|
---Reset the specified subpalette index to its default palette index,
|
||||||
|
---returns the previously mapped index
|
||||||
function pal.subpal(index) end
|
function pal.subpal(index) end
|
||||||
|
|
||||||
---@param index number
|
---@param index number
|
||||||
---@param color number
|
---@param color number
|
||||||
---Set the specified subpalette index to the specified palette index
|
---@return number index
|
||||||
|
---Set the specified subpalette index to the specified palette index,
|
||||||
|
---returns the previously mapped index
|
||||||
function pal.subpal(index, color) end
|
function pal.subpal(index, color) end
|
||||||
|
|
||||||
---@param index1 number
|
---@param index1 number
|
||||||
@@ -601,6 +609,14 @@ function key.press(key) end
|
|||||||
---Returns whether any keyboard key has just been pressed
|
---Returns whether any keyboard key has just been pressed
|
||||||
function key.any() end
|
function key.any() end
|
||||||
|
|
||||||
|
---@param enable boolean
|
||||||
|
---Enable or disable utf8 text input
|
||||||
|
function key.text(enable) end
|
||||||
|
|
||||||
|
---@return string
|
||||||
|
---Returns a string with the utf-8 character sequence pressed. Only when utf8 is enabled
|
||||||
|
function key.utf8char() end
|
||||||
|
|
||||||
|
|
||||||
---@class pad
|
---@class pad
|
||||||
---@field pad.INVALID number
|
---@field pad.INVALID number
|
||||||
|
|||||||
Reference in New Issue
Block a user