Lua: Add basename'd forms for gui.bitmap_load{,_png,_pal}
This commit is contained in:
parent
750608ad56
commit
9f546c38a9
3 changed files with 28 additions and 14 deletions
21
lua.lyx
21
lua.lyx
|
@ -1102,7 +1102,7 @@ gui.bitmap_load/gui.bitmap_load_str: Load a bitmap from file or string
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Itemize
|
\begin_layout Itemize
|
||||||
Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load(string file)
|
Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load(string file[, string base])
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Itemize
|
\begin_layout Itemize
|
||||||
|
@ -1110,12 +1110,9 @@ Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_str(string content)
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Standard
|
\begin_layout Standard
|
||||||
Reads file <file> or string <content> and returns loaded bitmap/dbitmap
|
Reads file <file> (resolved relative to <base>) or string <content> and
|
||||||
(if bitmap, the second return value is palette for bitmap).
|
returns loaded bitmap/dbitmap (if bitmap, the second return value is palette
|
||||||
\end_layout
|
for bitmap).
|
||||||
|
|
||||||
\begin_layout Itemize
|
|
||||||
|
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Subsection
|
\begin_layout Subsection
|
||||||
|
@ -1123,7 +1120,8 @@ gui.bitmap_load_png/gui.bitmap_load_png_str: Load a bitmap from PNG
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Itemize
|
\begin_layout Itemize
|
||||||
Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png(string file)
|
Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png(string file[, string
|
||||||
|
base])
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Itemize
|
\begin_layout Itemize
|
||||||
|
@ -1131,7 +1129,8 @@ Syntax: DBITMAP/(BITMAP, PALETTE) gui.bitmap_load_png_str(string content)
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Standard
|
\begin_layout Standard
|
||||||
Load a bitmap from PNG file <file> or BASE64 encoded content <content>.
|
Load a bitmap from PNG file <file> (resolved relative to <base>) or BASE64
|
||||||
|
encoded content <content>.
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Itemize
|
\begin_layout Itemize
|
||||||
|
@ -1150,7 +1149,7 @@ gui.bitmap_load_pal/gui.bitmap_load_pal_str: Load a palette
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Itemize
|
\begin_layout Itemize
|
||||||
Syntax: PALETTE gui.bitmap_load_pal(string file)
|
Syntax: PALETTE gui.bitmap_load_pal(string file[, string base])
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Itemize
|
\begin_layout Itemize
|
||||||
|
@ -1158,7 +1157,7 @@ Syntax: PALETTE gui.bitmap_load_pal_str(string content)
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Standard
|
\begin_layout Standard
|
||||||
Load a palette from file <file> or string <content>.
|
Load a palette from file <file>(resolved relative to <base>) or string <content>.
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Itemize
|
\begin_layout Itemize
|
||||||
|
|
BIN
lua.pdf
BIN
lua.pdf
Binary file not shown.
|
@ -323,8 +323,14 @@ namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
function_ptr_luafun gui_loadbitmap(LS, "gui.bitmap_load", [](lua_state& L, const std::string& fname) -> int {
|
function_ptr_luafun gui_loadbitmap(LS, "gui.bitmap_load", [](lua_state& L, const std::string& fname) -> int {
|
||||||
|
std::string name2;
|
||||||
std::string name = L.get_string(1, fname.c_str());
|
std::string name = L.get_string(1, fname.c_str());
|
||||||
return bitmap_load_fn(L, [&name]() -> lua_loaded_bitmap { return lua_loaded_bitmap::load(name); });
|
if(L.type(2) != LUA_TNIL && L.type(2) != LUA_TNONE)
|
||||||
|
name2 = L.get_string(2, fname.c_str());
|
||||||
|
return bitmap_load_fn(L, [&name, &name2]() -> lua_loaded_bitmap {
|
||||||
|
std::string name3 = resolve_file_relative(name, name2);
|
||||||
|
return lua_loaded_bitmap::load(name3);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function_ptr_luafun gui_loadbitmap2(LS, "gui.bitmap_load_str", [](lua_state& L, const std::string& fname)
|
function_ptr_luafun gui_loadbitmap2(LS, "gui.bitmap_load_str", [](lua_state& L, const std::string& fname)
|
||||||
|
@ -417,8 +423,14 @@ namespace
|
||||||
|
|
||||||
function_ptr_luafun gui_loadbitmappng(LS, "gui.bitmap_load_png", [](lua_state& L, const std::string& fname)
|
function_ptr_luafun gui_loadbitmappng(LS, "gui.bitmap_load_png", [](lua_state& L, const std::string& fname)
|
||||||
-> int {
|
-> int {
|
||||||
|
std::string name2;
|
||||||
std::string name = L.get_string(1, fname.c_str());
|
std::string name = L.get_string(1, fname.c_str());
|
||||||
return bitmap_load_png_fn(L, [&name](png_decoded_image& img) { decode_png(name, img); });
|
if(L.type(2) != LUA_TNIL && L.type(2) != LUA_TNONE)
|
||||||
|
name2 = L.get_string(2, fname.c_str());
|
||||||
|
return bitmap_load_png_fn(L, [&name, &name2](png_decoded_image& img) {
|
||||||
|
std::string name3 = resolve_file_relative(name, name2);
|
||||||
|
decode_png(name3, img);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function_ptr_luafun gui_loadbitmappng2(LS, "gui.bitmap_load_png_str", [](lua_state& L,
|
function_ptr_luafun gui_loadbitmappng2(LS, "gui.bitmap_load_png_str", [](lua_state& L,
|
||||||
|
@ -466,8 +478,11 @@ namespace
|
||||||
|
|
||||||
function_ptr_luafun gui_loadpalette(LS, "gui.bitmap_load_pal", [](lua_state& L, const std::string& fname)
|
function_ptr_luafun gui_loadpalette(LS, "gui.bitmap_load_pal", [](lua_state& L, const std::string& fname)
|
||||||
-> int {
|
-> int {
|
||||||
|
std::string name2;
|
||||||
std::string name = L.get_string(1, fname.c_str());
|
std::string name = L.get_string(1, fname.c_str());
|
||||||
std::istream& s = open_file_relative(name, "");
|
if(L.type(2) != LUA_TNIL && L.type(2) != LUA_TNONE)
|
||||||
|
name2 = L.get_string(2, fname.c_str());
|
||||||
|
std::istream& s = open_file_relative(name, name2);
|
||||||
try {
|
try {
|
||||||
int r = bitmap_palette_fn(L, s);
|
int r = bitmap_palette_fn(L, s);
|
||||||
delete &s;
|
delete &s;
|
||||||
|
|
Loading…
Add table
Reference in a new issue