diff options
author | sapier <Sapier at GMX dot net> | 2014-04-21 14:10:59 +0200 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2014-06-29 18:17:56 +0200 |
commit | 1cc40c0a7c260f0562572bc99f39a666a12f1b09 (patch) | |
tree | c5af6b9787f4c69faa634e82f6484ca4540a7f88 /builtin | |
parent | ff36071d93266c1dd18708f8924d80aa1af5b33e (diff) | |
download | minetest-1cc40c0a7c260f0562572bc99f39a666a12f1b09.tar.gz minetest-1cc40c0a7c260f0562572bc99f39a666a12f1b09.tar.bz2 minetest-1cc40c0a7c260f0562572bc99f39a666a12f1b09.zip |
Add support for Android 2.3+
There have been plenty of ppl involved in creating this version.
I don't wanna mention names as I'm sure I'd forget someone so I
just tell where help has been done:
- The partial android versions done by various ppl
- Testing on different android devices
- reviewing code (especially the in core changes)
- testing controls
- reviewing texts
A big thank you to everyone helping this to be completed!
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/mainmenu/dlg_delete_world.lua | 10 | ||||
-rw-r--r-- | builtin/mainmenu/init_android.lua | 102 | ||||
-rw-r--r-- | builtin/mainmenu/tab_settings.lua | 75 | ||||
-rw-r--r-- | builtin/mainmenu/tab_simple_main.lua | 34 |
4 files changed, 187 insertions, 34 deletions
diff --git a/builtin/mainmenu/dlg_delete_world.lua b/builtin/mainmenu/dlg_delete_world.lua index e979bd555..aa710ef3b 100644 --- a/builtin/mainmenu/dlg_delete_world.lua +++ b/builtin/mainmenu/dlg_delete_world.lua @@ -16,7 +16,7 @@ --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -local function create_world_formspec(dialogdata) +local function delete_world_formspec(dialogdata) local retval = "size[12,6,true]" .. @@ -27,7 +27,7 @@ local function create_world_formspec(dialogdata) return retval end -local function create_world_buttonhandler(this, fields) +local function delete_world_buttonhandler(this, fields) if fields["world_delete_confirm"] then if this.data.delete_index > 0 and @@ -53,9 +53,9 @@ function create_delete_world_dlg(name_to_del,index_to_del) assert(name_to_del ~= nil and type(name_to_del) == "string" and name_to_del ~= "") assert(index_to_del ~= nil and type(index_to_del) == "number") - local retval = dialog_create("sp_create_world", - create_world_formspec, - create_world_buttonhandler, + local retval = dialog_create("delete_world", + delete_world_formspec, + delete_world_buttonhandler, nil) retval.data.delete_name = name_to_del retval.data.delete_index = index_to_del diff --git a/builtin/mainmenu/init_android.lua b/builtin/mainmenu/init_android.lua new file mode 100644 index 000000000..348923fa5 --- /dev/null +++ b/builtin/mainmenu/init_android.lua @@ -0,0 +1,102 @@ +--Minetest +--Copyright (C) 2014 sapier +-- +--This program is free software; you can redistribute it and/or modify +--it under the terms of the GNU Lesser General Public License as published by +--the Free Software Foundation; either version 2.1 of the License, or +--(at your option) any later version. +-- +--This program is distributed in the hope that it will be useful, +--but WITHOUT ANY WARRANTY; without even the implied warranty of +--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +--GNU Lesser General Public License for more details. +-- +--You should have received a copy of the GNU Lesser General Public License along +--with this program; if not, write to the Free Software Foundation, Inc., +--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +mt_color_grey = "#AAAAAA" +mt_color_blue = "#0000DD" +mt_color_green = "#00DD00" +mt_color_dark_green = "#003300" + +--marker for android specific code +ANDROID = true + +local menupath = core.get_mainmenu_path() +local basepath = core.get_builtin_path() +defaulttexturedir = core.get_texturepath_share() .. DIR_DELIM .. "base" .. + DIR_DELIM .. "pack" .. DIR_DELIM + +dofile(basepath .. DIR_DELIM .. "common" .. DIR_DELIM .. "async_event.lua") +dofile(basepath .. DIR_DELIM .. "common" .. DIR_DELIM .. "filterlist.lua") +dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "buttonbar.lua") +dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "dialog.lua") +dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "tabview.lua") +dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "ui.lua") +dofile(menupath .. DIR_DELIM .. "common.lua") +dofile(menupath .. DIR_DELIM .. "gamemgr.lua") +dofile(menupath .. DIR_DELIM .. "modmgr.lua") +dofile(menupath .. DIR_DELIM .. "store.lua") +dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua") +dofile(menupath .. DIR_DELIM .. "tab_simple_main.lua") +dofile(menupath .. DIR_DELIM .. "tab_credits.lua") +dofile(menupath .. DIR_DELIM .. "tab_mods.lua") +dofile(menupath .. DIR_DELIM .. "tab_settings.lua") + +-------------------------------------------------------------------------------- +local function main_event_handler(tabview,event) + if event == "MenuQuit" then + core.close() + end + return true +end + +local function init_globals() + --init gamedata + gamedata.worldindex = 0 + + local worldlist = core.get_worlds() + + local found_singleplayerworld = false + + for i=1,#worldlist,1 do + if worldlist[i].name == "singleplayerworld" then + found_singleplayerworld = true + gamedata.worldindex = i + end + end + + if not found_singleplayerworld then + core.create_world("singleplayerworld", 1) + + local worldlist = core.get_worlds() + + for i=1,#worldlist,1 do + if worldlist[i].name == "singleplayerworld" then + gamedata.worldindex = i + end + end + end + + --create main tabview + local tv_main = tabview_create("maintab",{x=12,y=5.2},{x=-0,y=-0}) + tv_main:add(tab_simple_main) + tv_main:add(tab_mods) + tv_main:add(tab_settings) + tv_main:add(tab_credits) + tv_main:set_global_event_handler(main_event_handler) + tv_main:set_fixed_size(false) + ui.set_default("maintab") + tv_main:show() + + --create modstore ui + modstore.init({x=12,y=6},3,2) + + ui.update() + + core.sound_play("main_menu", true) +end + +init_globals() + diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua index b6ffa86ed..dec28a961 100644 --- a/builtin/mainmenu/tab_settings.lua +++ b/builtin/mainmenu/tab_settings.lua @@ -31,7 +31,6 @@ end local function dlg_confirm_reset_btnhandler(this, fields, dialogdata) if fields["dlg_reset_singleplayer_confirm"] ~= nil then - local worldlist = core.get_worlds() local found_singleplayerworld = false @@ -63,19 +62,43 @@ local function dlg_confirm_reset_btnhandler(this, fields, dialogdata) this.parent:show() this:hide() this:delete() + return true end local function showconfirm_reset(tabview) local new_dlg = dialog_create("reset_spworld", dlg_confirm_reset_formspec, dlg_confirm_reset_btnhandler, - nil, - tabview) + nil) + new_dlg:set_parent(tabview) tabview:hide() new_dlg:show() end +local function gui_scale_index() + + local current_value = tonumber(core.setting_get("gui_scaling")) + if (current_value == nil) then + return 0 + elseif current_value <= 0.5 then + return 1 + elseif current_value <= 0.625 then + return 2 + elseif current_value <= 0.75 then + return 3 + elseif current_value <= 0.875 then + return 4 + elseif current_value <= 1.0 then + return 5 + elseif current_value <= 1.25 then + return 6 + elseif current_value <= 1.5 then + return 7 + else + return 8 + end +end local function formspec(tabview, name, tabdata) local tab_string = @@ -93,8 +116,6 @@ local function formspec(tabview, name, tabdata) .. dump(core.setting_getbool("preload_item_visuals")) .. "]".. "checkbox[1,2.5;cb_particles;".. fgettext("Enable Particles") .. ";" .. dump(core.setting_getbool("enable_particles")) .. "]".. - "checkbox[1,3.0;cb_finite_liquid;".. fgettext("Finite Liquid") .. ";" - .. dump(core.setting_getbool("liquid_finite")) .. "]".. "box[4.25,0;3.25,2.5;#999999]" .. "checkbox[4.5,0;cb_mipmapping;".. fgettext("Mip-Mapping") .. ";" .. dump(core.setting_getbool("mip_map")) .. "]".. @@ -106,16 +127,25 @@ local function formspec(tabview, name, tabdata) .. dump(core.setting_getbool("trilinear_filter")) .. "]".. "box[7.75,0;4,4;#999999]" .. "checkbox[8,0;cb_shaders;".. fgettext("Shaders") .. ";" - .. dump(core.setting_getbool("enable_shaders")) .. "]".. - "button[1,4.5;2.25,0.5;btn_change_keys;".. fgettext("Change keys") .. "]" + .. dump(core.setting_getbool("enable_shaders")) .. "]" + if not ANDROID then + tab_string = tab_string .. + "button[8,4.75;3.75,0.5;btn_change_keys;".. fgettext("Change keys") .. "]" + else + tab_string = tab_string .. + "button[8,4.75;3.75,0.5;btn_reset_singleplayer;".. fgettext("Reset singleplayer world") .. "]" + end + tab_string = tab_string .. + "box[0.75,4.25;3.25,1.25;#999999]" .. + "label[1,4.25;" .. fgettext("GUI scale factor") .. "]" .. + "dropdown[1,4.75;3.0;dd_gui_scaling;0.5,0.625,0.75,0.875,1.0,1.25,1.5,2.0;" + .. gui_scale_index() .. "]" - local android = false - if android then + if ANDROID then tab_string = tab_string .. - "box[4.25,2.75;3.25,2.5;#999999]" .. + "box[4.25,2.75;3.25,2.15;#999999]" .. "checkbox[4.5,2.75;cb_touchscreen_target;".. fgettext("Touch free target") .. ";" - .. dump(core.setting_getbool("touchtarget")) .. "]" .. - "button[8,4.5;3.75,0.5;btn_reset_singleplayer;".. fgettext("Reset singleplayer world") .. "]" + .. dump(core.setting_getbool("touchtarget")) .. "]" end if core.setting_get("touchscreen_threshold") ~= nil then @@ -202,10 +232,6 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) core.setting_set("enable_particles", fields["cb_particles"]) return true end - if fields["cb_finite_liquid"] then - core.setting_set("liquid_finite", fields["cb_finite_liquid"]) - return true - end if fields["cb_bumpmapping"] then core.setting_set("enable_bumpmapping", fields["cb_bumpmapping"]) end @@ -235,14 +261,23 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) core.setting_set("touchtarget", fields["cb_touchscreen_target"]) return true end - if fields["dd_touchthreshold"] then - core.setting_set("touchscreen_threshold",fields["dd_touchthreshold"]) - return true - end if fields["btn_reset_singleplayer"] then + print("sp reset") showconfirm_reset(this) return true end + --Note dropdowns have to be handled LAST! + local ddhandled = false + if fields["dd_touchthreshold"] then + core.setting_set("touchscreen_threshold",fields["dd_touchthreshold"]) + ddhandled = true + end + if fields["dd_gui_scaling"] then + core.setting_set("gui_scaling",fields["dd_gui_scaling"]) + ddhandled = true + end + + return ddhandled end tab_settings = { diff --git a/builtin/mainmenu/tab_simple_main.lua b/builtin/mainmenu/tab_simple_main.lua index 46f4b6190..09cd685ce 100644 --- a/builtin/mainmenu/tab_simple_main.lua +++ b/builtin/mainmenu/tab_simple_main.lua @@ -22,7 +22,6 @@ local function get_formspec(tabview, name, tabdata) local render_details = dump(core.setting_getbool("public_serverlist")) retval = retval .. - "label[0,3.0;".. fgettext("Address/Port") .. "]".. "label[8,0.5;".. fgettext("Name/Password") .. "]" .. "field[0.25,3.25;5.5,0.5;te_address;;" ..core.setting_get("address") .."]" .. "field[5.75,3.25;2.25,0.5;te_port;;" ..core.setting_get("remote_port") .."]" .. @@ -66,7 +65,8 @@ local function get_formspec(tabview, name, tabdata) dump(core.setting_getbool("free_move")) .. "]" -- buttons retval = retval .. - "button[3.0,4.5;6,1.5;btn_start_singleplayer;" .. fgettext("Start Singleplayer") .. "]" + "button[2.0,4.5;6,1.5;btn_start_singleplayer;" .. fgettext("Start Singleplayer") .. "]" .. + "button[8.25,4.5;2.5,1.5;btn_config_sp_world;" .. fgettext("Config MODs") .. "]" return retval end @@ -74,19 +74,21 @@ end -------------------------------------------------------------------------------- local function main_button_handler(tabview, fields, name, tabdata) + if fields["btn_start_singleplayer"] then gamedata.selected_world = gamedata.worldindex gamedata.singleplayer = true core.start() + return true end if fields["favourites"] ~= nil then local event = core.explode_textlist_event(fields["favourites"]) if event.type == "CHG" then - if event.index <= #maintab_favorites then - local address = maintab_favorites[event.index].address - local port = maintab_favorites[event.index].port + if event.index <= #menudata.favorites then + local address = menudata.favorites[event.index].address + local port = menudata.favorites[event.index].port if address ~= nil and port ~= nil then @@ -97,7 +99,7 @@ local function main_button_handler(tabview, fields, name, tabdata) tabdata.fav_selected = event.index end end - return + return true end if fields["cb_public_serverlist"] ~= nil then @@ -106,21 +108,24 @@ local function main_button_handler(tabview, fields, name, tabdata) if core.setting_getbool("public_serverlist") then asyncOnlineFavourites() else - maintab_favorites = core.get_favorites("local") + menudata.favorites = core.get_favorites("local") end - return + return true end if fields["cb_creative"] then core.setting_set("creative_mode", fields["cb_creative"]) + return true end if fields["cb_damage"] then core.setting_set("enable_damage", fields["cb_damage"]) + return true end if fields["cb_fly_mode"] then core.setting_set("free_move", fields["cb_fly_mode"]) + return true end if fields["btn_mp_connect"] ~= nil or @@ -150,7 +155,18 @@ local function main_button_handler(tabview, fields, name, tabdata) core.setting_set("remote_port",fields["te_port"]) core.start() - return + return true + end + + if fields["btn_config_sp_world"] ~= nil then + local configdialog = create_configure_world_dlg(1) + + if (configdialog ~= nil) then + configdialog:set_parent(tabview) + tabview:hide() + configdialog:show() + end + return true end end |