diff options
-rw-r--r-- | builtin/misc_helpers.lua | 56 | ||||
-rw-r--r-- | builtin/modmgr.lua | 72 | ||||
-rw-r--r-- | doc/lua_api.txt | 8 | ||||
-rw-r--r-- | src/guiFormSpecMenu.cpp | 9 |
4 files changed, 129 insertions, 16 deletions
diff --git a/builtin/misc_helpers.lua b/builtin/misc_helpers.lua index 38909ec1d..55c5798d7 100644 --- a/builtin/misc_helpers.lua +++ b/builtin/misc_helpers.lua @@ -205,6 +205,62 @@ function tbl.formspec_escape(text) return text end + +function tbl.splittext(text,charlimit) + local retval = {} + + local current_idx = 1 + + local start,stop = string.find(text," ",current_idx) + local nl_start,nl_stop = string.find(text,"\n",current_idx) + local gotnewline = false + if nl_start ~= nil and (start == nil or nl_start < start) then + start = nl_start + stop = nl_stop + gotnewline = true + end + local last_line = "" + while start ~= nil do + if string.len(last_line) + (stop-start) > charlimit then + table.insert(retval,last_line) + last_line = "" + end + + if last_line ~= "" then + last_line = last_line .. " " + end + + last_line = last_line .. string.sub(text,current_idx,stop -1) + + if gotnewline then + table.insert(retval,last_line) + last_line = "" + gotnewline = false + end + current_idx = stop+1 + + start,stop = string.find(text," ",current_idx) + nl_start,nl_stop = string.find(text,"\n",current_idx) + + if nl_start ~= nil and (start == nil or nl_start < start) then + start = nl_start + stop = nl_stop + gotnewline = true + end + end + + --add last part of text + if string.len(last_line) + (string.len(text) - current_idx) > charlimit then + table.insert(retval,last_line) + table.insert(retval,string.sub(text,current_idx)) + else + last_line = last_line .. " " .. string.sub(text,current_idx) + table.insert(retval,last_line) + end + + return retval +end + -------------------------------------------------------------------------------- if minetest then diff --git a/builtin/modmgr.lua b/builtin/modmgr.lua index d9579c652..04f19ec86 100644 --- a/builtin/modmgr.lua +++ b/builtin/modmgr.lua @@ -235,13 +235,14 @@ function modmgr.tab() local retval = "vertlabel[0,-0.25;".. fgettext("MODS") .. "]" .. "label[0.8,-0.25;".. fgettext("Installed Mods:") .. "]" .. - "textlist[0.75,0.25;4.5,4.3;modlist;" .. + "textlist[0.75,0.25;4.5,4;modlist;" .. modmgr.render_modlist(modmgr.global_mods) .. ";" .. modmgr.selected_mod .. "]" retval = retval .. - "button[1,4.85;2,0.5;btn_mod_mgr_install_local;".. fgettext("Install") .. "]" .. - "button[3,4.85;2,0.5;btn_mod_mgr_download;".. fgettext("Download") .. "]" + "label[0.8,4.2;" .. fgettext("Add mod:") .. "]" .. + "button[0.75,4.85;1.8,0.5;btn_mod_mgr_install_local;".. fgettext("Local install") .. "]" .. + "button[2.45,4.85;3.05,0.5;btn_mod_mgr_download;".. fgettext("Online mod repository") .. "]" local selected_mod = nil @@ -250,25 +251,66 @@ function modmgr.tab() end if selected_mod ~= nil then + local modscreenshot = nil + + --check for screenshot beeing available + local screenshotfilename = selected_mod.path .. DIR_DELIM .. "screenshot.png" + local error = nil + screenshotfile,error = io.open(screenshotfilename,"r") + if error == nil then + screenshotfile:close() + modscreenshot = screenshotfilename + end + + if modscreenshot == nil then + modscreenshot = modstore.basetextur
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "sha1.h"
// print out memory in hexadecimal
void SHA1::hexPrinter( unsigned char* c, int l )
{
assert( c );
assert( l > 0 );
while( l > 0 )
{
printf( " %02x", *c );
l--;
c++;
}
}
// circular left bit rotation. MSB wraps around to LSB
Uint32 SHA1::lrot( Uint32 x, int bits )
{
return (x<<bits) | (x>>(32 - bits));
};
// Save a 32-bit unsigned integer to memory, in big-endian order
void SHA1::storeBigEndianUint32( unsigned char* byte, Uint32 num )
{
assert( byte );
byte[0] = (unsigned char)(num>>24);
byte[1] = (unsigned char)(num>>16);
byte[2] = (unsigned char)(num>>8);
byte[3] = (unsigned char)num;
}
// Constructor *******************************************************
SHA1::SHA1()
{
// make sure that the data type is the right size
assert( sizeof( Uint32 ) * 5 == 20 );
// initialize
H0 = 0x67452301;
H1 = 0xefcdab89;
H2 = 0x98badcfe;
H3 = 0x10325476;
H4 = 0xc3d2e1f0;
unprocessedBytes = 0;
size = 0;
}
// Destructor ********************************************************
SHA1::~SHA1()
{
// erase data
H0 = H1 = H2 = H3 = H4 = 0;
for( int c = 0; c < 64; c++ ) bytes[c] = 0;
unprocessedBytes = size = 0;
}
// process ***********************************************************
void SHA1:: |