Very big update! MultiCraft 1.1 | Part 1/3
Joystick. environment.cpp improve (thanks @Bremaweb) Improving the management interface. The new font. Settings to improve performance. Improvements ellementov size on larger phones. A lot of small fixes and improvements.
This commit is contained in:
parent
4327fab167
commit
1ac7f0dbc5
|
@ -27,13 +27,13 @@ VERSION_PATCH := $(shell cat $(ROOT)/../../CMakeLists.txt | \
|
||||||
ANDROID_VERSION_CODE = 1
|
ANDROID_VERSION_CODE = 1
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# toolchain config for arm new processors
|
# toolchain config for ARMv7
|
||||||
################################################################################
|
################################################################################
|
||||||
TARGET_HOST = arm-linux
|
TARGET_HOST = arm-linux
|
||||||
TARGET_ABI = armeabi-v7a
|
TARGET_ABI = armeabi-v7a
|
||||||
TARGET_LIBDIR = armeabi-v7a
|
TARGET_LIBDIR = armeabi-v7a
|
||||||
TARGET_TOOLCHAIN = arm-linux-androideabi-
|
TARGET_TOOLCHAIN = arm-linux-androideabi-
|
||||||
TARGET_CFLAGS_ADDON = -mfloat-abi=softfp -mfpu=vfpv3 -O3
|
TARGET_CFLAGS_ADDON = -mfloat-abi=softfp -mfpu=vfpv3 -Ofast
|
||||||
TARGET_CXXFLAGS_ADDON = $(TARGET_CFLAGS_ADDON)
|
TARGET_CXXFLAGS_ADDON = $(TARGET_CFLAGS_ADDON)
|
||||||
TARGET_ARCH = armv7
|
TARGET_ARCH = armv7
|
||||||
CROSS_PREFIX = arm-linux-androideabi-
|
CROSS_PREFIX = arm-linux-androideabi-
|
||||||
|
@ -839,4 +839,4 @@ manifest :
|
||||||
clean_manifest :
|
clean_manifest :
|
||||||
rm -rf ${ROOT}/AndroidManifest.xml
|
rm -rf ${ROOT}/AndroidManifest.xml
|
||||||
|
|
||||||
clean : clean_apk clean_assets
|
clean : clean_apk clean_assets
|
|
@ -80,7 +80,7 @@ LOCAL_CFLAGS := -D_IRR_ANDROID_PLATFORM_ \
|
||||||
ifndef NDEBUG
|
ifndef NDEBUG
|
||||||
LOCAL_CFLAGS += -g -D_DEBUG -O0 -fno-omit-frame-pointer
|
LOCAL_CFLAGS += -g -D_DEBUG -O0 -fno-omit-frame-pointer
|
||||||
else
|
else
|
||||||
LOCAL_CFLAGS += -fexpensive-optimizations -O3
|
LOCAL_CFLAGS += -O3
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef GPROF
|
ifdef GPROF
|
||||||
|
|
|
@ -391,6 +391,7 @@ void RemoteClient::SentBlock(v3s16 p)
|
||||||
void RemoteClient::SetBlockNotSent(v3s16 p)
|
void RemoteClient::SetBlockNotSent(v3s16 p)
|
||||||
{
|
{
|
||||||
m_nearest_unsent_d = 0;
|
m_nearest_unsent_d = 0;
|
||||||
|
m_nothing_to_send_pause_timer = 0.1;
|
||||||
|
|
||||||
if(m_blocks_sending.find(p) != m_blocks_sending.end())
|
if(m_blocks_sending.find(p) != m_blocks_sending.end())
|
||||||
m_blocks_sending.erase(p);
|
m_blocks_sending.erase(p);
|
||||||
|
@ -401,6 +402,7 @@ void RemoteClient::SetBlockNotSent(v3s16 p)
|
||||||
void RemoteClient::SetBlocksNotSent(std::map<v3s16, MapBlock*> &blocks)
|
void RemoteClient::SetBlocksNotSent(std::map<v3s16, MapBlock*> &blocks)
|
||||||
{
|
{
|
||||||
m_nearest_unsent_d = 0;
|
m_nearest_unsent_d = 0;
|
||||||
|
m_nothing_to_send_pause_timer=0.1;
|
||||||
|
|
||||||
for(std::map<v3s16, MapBlock*>::iterator
|
for(std::map<v3s16, MapBlock*>::iterator
|
||||||
i = blocks.begin();
|
i = blocks.begin();
|
||||||
|
|
|
@ -129,14 +129,14 @@ void set_default_settings(Settings *settings)
|
||||||
settings->setDefault("view_bobbing_amount", "1.0");
|
settings->setDefault("view_bobbing_amount", "1.0");
|
||||||
settings->setDefault("fall_bobbing_amount", "1.0");
|
settings->setDefault("fall_bobbing_amount", "1.0");
|
||||||
settings->setDefault("enable_3d_clouds", "true");
|
settings->setDefault("enable_3d_clouds", "true");
|
||||||
settings->setDefault("cloud_height", "120");
|
settings->setDefault("cloud_height", "180");
|
||||||
settings->setDefault("cloud_radius", "12");
|
settings->setDefault("cloud_radius", "12");
|
||||||
settings->setDefault("menu_clouds", "false");
|
settings->setDefault("menu_clouds", "false");
|
||||||
settings->setDefault("opaque_water", "false");
|
settings->setDefault("opaque_water", "false");
|
||||||
settings->setDefault("console_color", "(0,0,0)");
|
settings->setDefault("console_color", "(0,0,0)");
|
||||||
settings->setDefault("console_alpha", "200");
|
settings->setDefault("console_alpha", "200");
|
||||||
settings->setDefault("selectionbox_color", "(0,0,0)");
|
settings->setDefault("selectionbox_color", "(0,0,0)");
|
||||||
settings->setDefault("enable_node_highlighting", "false");
|
settings->setDefault("enable_node_highlighting", "true");
|
||||||
settings->setDefault("crosshair_color", "(255,255,255)");
|
settings->setDefault("crosshair_color", "(255,255,255)");
|
||||||
settings->setDefault("crosshair_alpha", "255");
|
settings->setDefault("crosshair_alpha", "255");
|
||||||
settings->setDefault("hud_scaling", "1.0");
|
settings->setDefault("hud_scaling", "1.0");
|
||||||
|
@ -150,7 +150,6 @@ void set_default_settings(Settings *settings)
|
||||||
settings->setDefault("selectionbox_width","2");
|
settings->setDefault("selectionbox_width","2");
|
||||||
settings->setDefault("hud_hotbar_max_width","1.0");
|
settings->setDefault("hud_hotbar_max_width","1.0");
|
||||||
settings->setDefault("enable_local_map_saving", "false");
|
settings->setDefault("enable_local_map_saving", "false");
|
||||||
settings->setDefault("screen_dpi", "72");
|
|
||||||
|
|
||||||
settings->setDefault("mip_map", "false");
|
settings->setDefault("mip_map", "false");
|
||||||
settings->setDefault("anisotropic_filter", "false");
|
settings->setDefault("anisotropic_filter", "false");
|
||||||
|
@ -201,7 +200,7 @@ void set_default_settings(Settings *settings)
|
||||||
|
|
||||||
#if USE_FREETYPE
|
#if USE_FREETYPE
|
||||||
settings->setDefault("freetype", "true");
|
settings->setDefault("freetype", "true");
|
||||||
settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "liberationsans.ttf"));
|
settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "basis33.ttf"));
|
||||||
settings->setDefault("font_shadow", "1");
|
settings->setDefault("font_shadow", "1");
|
||||||
settings->setDefault("font_shadow_alpha", "128");
|
settings->setDefault("font_shadow_alpha", "128");
|
||||||
settings->setDefault("mono_font_path", porting::getDataPath("fonts" DIR_DELIM "liberationmono.ttf"));
|
settings->setDefault("mono_font_path", porting::getDataPath("fonts" DIR_DELIM "liberationmono.ttf"));
|
||||||
|
@ -234,7 +233,7 @@ void set_default_settings(Settings *settings)
|
||||||
settings->setDefault("max_packets_per_iteration","1024");
|
settings->setDefault("max_packets_per_iteration","1024");
|
||||||
settings->setDefault("port", "30000");
|
settings->setDefault("port", "30000");
|
||||||
settings->setDefault("bind_address", "");
|
settings->setDefault("bind_address", "");
|
||||||
settings->setDefault("default_game", "MultiCraft_game");
|
settings->setDefault("default_game", "default");
|
||||||
settings->setDefault("motd", "");
|
settings->setDefault("motd", "");
|
||||||
settings->setDefault("max_users", "15");
|
settings->setDefault("max_users", "15");
|
||||||
settings->setDefault("strict_protocol_version_checking", "false");
|
settings->setDefault("strict_protocol_version_checking", "false");
|
||||||
|
@ -285,7 +284,7 @@ void set_default_settings(Settings *settings)
|
||||||
settings->setDefault("emergequeue_limit_total", "256");
|
settings->setDefault("emergequeue_limit_total", "256");
|
||||||
settings->setDefault("emergequeue_limit_diskonly", "32");
|
settings->setDefault("emergequeue_limit_diskonly", "32");
|
||||||
settings->setDefault("emergequeue_limit_generate", "32");
|
settings->setDefault("emergequeue_limit_generate", "32");
|
||||||
settings->setDefault("num_emerge_threads", "1");
|
settings->setDefault("num_emerge_threads", "2");
|
||||||
settings->setDefault("secure.enable_security", "false");
|
settings->setDefault("secure.enable_security", "false");
|
||||||
settings->setDefault("secure.trusted_mods", "");
|
settings->setDefault("secure.trusted_mods", "");
|
||||||
|
|
||||||
|
@ -340,26 +339,32 @@ void set_default_settings(Settings *settings)
|
||||||
settings->setDefault("TMPFolder","/sdcard/tmp/");
|
settings->setDefault("TMPFolder","/sdcard/tmp/");
|
||||||
settings->setDefault("touchscreen_threshold","20");
|
settings->setDefault("touchscreen_threshold","20");
|
||||||
settings->setDefault("smooth_lighting", "false");
|
settings->setDefault("smooth_lighting", "false");
|
||||||
settings->setDefault("emergequeue_limit_diskonly", "4");
|
settings->setDefault("emergequeue_limit_diskonly", "8");
|
||||||
settings->setDefault("emergequeue_limit_generate", "4");
|
settings->setDefault("emergequeue_limit_generate", "8");
|
||||||
settings->setDefault("max_block_generate_distance", "3");
|
settings->setDefault("max_block_generate_distance", "3");
|
||||||
settings->setDefault("preload_item_visuals", "false");
|
settings->setDefault("preload_item_visuals", "false");
|
||||||
settings->setDefault("viewing_range_nodes_max", "50");
|
settings->setDefault("viewing_range_nodes_max", "50");
|
||||||
settings->setDefault("viewing_range_nodes_min", "5");
|
settings->setDefault("viewing_range_nodes_min", "5");
|
||||||
settings->setDefault("enable_node_highlighting", "true");
|
|
||||||
settings->setDefault("inventory_image_hack", "true");
|
settings->setDefault("inventory_image_hack", "true");
|
||||||
settings->setDefault("mouse_sensitivity", "0.05");
|
settings->setDefault("mouse_sensitivity", "0.05");
|
||||||
settings->setDefault("enable_3d_clouds", "false");
|
settings->setDefault("enable_3d_clouds", "false");
|
||||||
settings->setDefault("wanted_fps", "25");
|
settings->setDefault("wanted_fps", "25");
|
||||||
settings->setDefault("fps_max", "35");
|
settings->setDefault("fps_max", "35");
|
||||||
settings->setDefault("pause_fps_max", "10");
|
settings->setDefault("pause_fps_max", "10");
|
||||||
float x_inches = ((double) porting::getDisplaySize().X /
|
settings->setDefault("max_objects_per_block", "32");
|
||||||
(160 * porting::getDisplayDensity()));
|
settings->setDefault("sqlite_synchronous", "1");
|
||||||
if (x_inches < 4.5) {
|
settings->setDefault("screen_dpi", "72");
|
||||||
settings->setDefault("hud_scaling", "0.7");
|
|
||||||
}
|
|
||||||
settings->setDefault("gui_scaling", "1.1");
|
settings->setDefault("gui_scaling", "1.1");
|
||||||
settings->setDefault("curl_verify_cert","false");
|
settings->setDefault("curl_verify_cert","false");
|
||||||
|
//check for device with small screen
|
||||||
|
float x_inches = ((double) porting::getDisplaySize().X /
|
||||||
|
(160 * porting::getDisplayDensity()));
|
||||||
|
if (x_inches < 3.5) {
|
||||||
|
settings->setDefault("hud_scaling", "0.6");
|
||||||
|
}
|
||||||
|
else if (x_inches < 5) {
|
||||||
|
settings->setDefault("hud_scaling", "0.7");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1114,12 +1114,16 @@ void ServerEnvironment::step(float dtime)
|
||||||
/*
|
/*
|
||||||
Mess around in active blocks
|
Mess around in active blocks
|
||||||
*/
|
*/
|
||||||
|
const float abm_interval = 1.0;
|
||||||
if(m_active_blocks_nodemetadata_interval.step(dtime, 1.0))
|
if(m_active_blocks_nodemetadata_interval.step(dtime, 1.0))
|
||||||
{
|
{
|
||||||
ScopeProfiler sp(g_profiler, "SEnv: mess in act. blocks avg /1s", SPT_AVG);
|
ScopeProfiler sp(g_profiler, "SEnv: mess in act. blocks avg /1s", SPT_AVG);
|
||||||
|
|
||||||
float dtime = 1.0;
|
float dtime = 1.0;
|
||||||
|
|
||||||
|
// Initialize handling of ActiveBlockModifiers
|
||||||
|
ABMHandler abmhandler(m_abms, abm_interval, this, true);
|
||||||
|
|
||||||
for(std::set<v3s16>::iterator
|
for(std::set<v3s16>::iterator
|
||||||
i = m_active_blocks.m_list.begin();
|
i = m_active_blocks.m_list.begin();
|
||||||
i != m_active_blocks.m_list.end(); ++i)
|
i != m_active_blocks.m_list.end(); ++i)
|
||||||
|
@ -1138,6 +1142,9 @@ void ServerEnvironment::step(float dtime)
|
||||||
|
|
||||||
// Set current time as timestamp
|
// Set current time as timestamp
|
||||||
block->setTimestampNoChangedFlag(m_game_time);
|
block->setTimestampNoChangedFlag(m_game_time);
|
||||||
|
|
||||||
|
abmhandler.apply(block);
|
||||||
|
|
||||||
// If time has changed much from the one on disk,
|
// If time has changed much from the one on disk,
|
||||||
// set block to be saved when it is unloaded
|
// set block to be saved when it is unloaded
|
||||||
if(block->getTimestamp() > block->getDiskTimestamp() + 60)
|
if(block->getTimestamp() > block->getDiskTimestamp() + 60)
|
||||||
|
@ -1161,50 +1168,6 @@ void ServerEnvironment::step(float dtime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const float abm_interval = 1.0;
|
|
||||||
if(m_active_block_modifier_interval.step(dtime, abm_interval))
|
|
||||||
do{ // breakable
|
|
||||||
if(m_active_block_interval_overload_skip > 0){
|
|
||||||
ScopeProfiler sp(g_profiler, "SEnv: ABM overload skips");
|
|
||||||
m_active_block_interval_overload_skip--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ScopeProfiler sp(g_profiler, "SEnv: modify in blocks avg /1s", SPT_AVG);
|
|
||||||
TimeTaker timer("modify in active blocks");
|
|
||||||
|
|
||||||
// Initialize handling of ActiveBlockModifiers
|
|
||||||
ABMHandler abmhandler(m_abms, abm_interval, this, true);
|
|
||||||
|
|
||||||
for(std::set<v3s16>::iterator
|
|
||||||
i = m_active_blocks.m_list.begin();
|
|
||||||
i != m_active_blocks.m_list.end(); ++i)
|
|
||||||
{
|
|
||||||
v3s16 p = *i;
|
|
||||||
|
|
||||||
/*infostream<<"Server: Block ("<<p.X<<","<<p.Y<<","<<p.Z
|
|
||||||
<<") being handled"<<std::endl;*/
|
|
||||||
|
|
||||||
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
|
|
||||||
if(block == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Set current time as timestamp
|
|
||||||
block->setTimestampNoChangedFlag(m_game_time);
|
|
||||||
|
|
||||||
/* Handle ActiveBlockModifiers */
|
|
||||||
abmhandler.apply(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 time_ms = timer.stop(true);
|
|
||||||
u32 max_time_ms = 200;
|
|
||||||
if(time_ms > max_time_ms){
|
|
||||||
warningstream<<"active block modifiers took "
|
|
||||||
<<time_ms<<"ms (longer than "
|
|
||||||
<<max_time_ms<<"ms)"<<std::endl;
|
|
||||||
m_active_block_interval_overload_skip = (time_ms / max_time_ms) + 1;
|
|
||||||
}
|
|
||||||
}while(0);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Step script environment (run global on_step())
|
Step script environment (run global on_step())
|
||||||
*/
|
*/
|
||||||
|
@ -1677,7 +1640,7 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s)
|
||||||
<<" objects)"<<std::endl;
|
<<" objects)"<<std::endl;
|
||||||
bool large_amount = (block->m_static_objects.m_stored.size() > g_settings->getU16("max_objects_per_block"));
|
bool large_amount = (block->m_static_objects.m_stored.size() > g_settings->getU16("max_objects_per_block"));
|
||||||
if (large_amount) {
|
if (large_amount) {
|
||||||
errorstream<<"suspiciously large amount of objects detected: "
|
verbosestream<<"suspiciously large amount of objects detected: "
|
||||||
<<block->m_static_objects.m_stored.size()<<" in "
|
<<block->m_static_objects.m_stored.size()<<" in "
|
||||||
<<PP(block->getPos())
|
<<PP(block->getPos())
|
||||||
<<"; removing all of them."<<std::endl;
|
<<"; removing all of them."<<std::endl;
|
||||||
|
|
18
src/game.cpp
18
src/game.cpp
|
@ -1035,7 +1035,7 @@ static inline void create_formspec_menu(GUIFormSpecMenu **cur_formspec,
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
# define SIZE_TAG "size[11,5.5]"
|
# define SIZE_TAG "size[11,5.5]"
|
||||||
# define PAUSE_MENU_SIZE_TAG "size[6,3.5]"
|
# define PAUSE_MENU_SIZE_TAG "size[5,3.5]"
|
||||||
# define PAUSE_MENU_BUTTON_LEFT 1.5
|
# define PAUSE_MENU_BUTTON_LEFT 1.5
|
||||||
#else
|
#else
|
||||||
# define SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop
|
# define SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop
|
||||||
|
@ -1124,23 +1124,23 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec,
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
|
|
||||||
os << FORMSPEC_VERSION_STRING << PAUSE_MENU_SIZE_TAG
|
os << FORMSPEC_VERSION_STRING << PAUSE_MENU_SIZE_TAG
|
||||||
<< "button_exit[4," << (ypos++) << ";3,0.5;btn_continue;"
|
<< "button_exit[1," << (ypos++) << ";3,0.5;btn_continue;"
|
||||||
<< strgettext("Continue") << "]";
|
<< strgettext("Continue") << "]";
|
||||||
|
|
||||||
if (!singleplayermode) {
|
if (!singleplayermode) {
|
||||||
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_change_password;"
|
os << "button_exit[1," << (ypos++) << ";3,0.5;btn_change_password;"
|
||||||
<< strgettext("Change Password") << "]";
|
<< strgettext("Change Password") << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_sound;"
|
os << "button_exit[1," << (ypos++) << ";3,0.5;btn_sound;"
|
||||||
<< strgettext("Sound Volume") << "]";
|
<< strgettext("Sound Volume") << "]";
|
||||||
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_key_config;"
|
os << "button_exit[1," << (ypos++) << ";3,0.5;btn_key_config;"
|
||||||
<< strgettext("Change Keys") << "]";
|
<< strgettext("Change Keys") << "]";
|
||||||
#endif
|
#endif
|
||||||
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_menu;"
|
os << "button_exit[1," << (ypos++) << ";3,0.5;btn_exit_menu;"
|
||||||
<< strgettext("Exit to Menu") << "]";
|
<< strgettext("Exit to Menu") << "]";
|
||||||
os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_os;"
|
os << "button_exit[1," << (ypos++) << ";3,0.5;btn_exit_os;"
|
||||||
<< strgettext("Close game") << "]"
|
<< strgettext("Close game") << "]"
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
<< "textarea[7.5,0.25;3.9,6.25;;" << control_text << ";]"
|
<< "textarea[7.5,0.25;3.9,6.25;;" << control_text << ";]"
|
||||||
|
@ -2809,7 +2809,7 @@ void Game::openConsole()
|
||||||
|
|
||||||
void Game::toggleFreeMove(float *statustext_time)
|
void Game::toggleFreeMove(float *statustext_time)
|
||||||
{
|
{
|
||||||
static const wchar_t *msg[] = { L"free_move disabled", L"free_move enabled" };
|
static const wchar_t *msg[] = { L"Fly mode disabled", L"Fly mode enabled" };
|
||||||
|
|
||||||
bool free_move = !g_settings->getBool("free_move");
|
bool free_move = !g_settings->getBool("free_move");
|
||||||
g_settings->set("free_move", bool_to_cstr(free_move));
|
g_settings->set("free_move", bool_to_cstr(free_move));
|
||||||
|
@ -2830,7 +2830,7 @@ void Game::toggleFreeMoveAlt(float *statustext_time, float *jump_timer)
|
||||||
|
|
||||||
void Game::toggleFast(float *statustext_time)
|
void Game::toggleFast(float *statustext_time)
|
||||||
{
|
{
|
||||||
static const wchar_t *msg[] = { L"fast_move disabled", L"fast_move enabled" };
|
static const wchar_t *msg[] = { L"Fast move disabled", L"Fast move enabled" };
|
||||||
bool fast_move = !g_settings->getBool("fast_move");
|
bool fast_move = !g_settings->getBool("fast_move");
|
||||||
g_settings->set("fast_move", bool_to_cstr(fast_move));
|
g_settings->set("fast_move", bool_to_cstr(fast_move));
|
||||||
|
|
||||||
|
|
|
@ -40,41 +40,57 @@ using namespace irr::core;
|
||||||
extern Settings *g_settings;
|
extern Settings *g_settings;
|
||||||
|
|
||||||
const char *touchgui_button_imagenames[] = {
|
const char *touchgui_button_imagenames[] = {
|
||||||
"up_arrow.png",
|
"up_one.png",
|
||||||
"down_arrow.png",
|
"up_two.png",
|
||||||
"left_arrow.png",
|
"up_three.png",
|
||||||
"right_arrow.png",
|
"down_one.png",
|
||||||
"inventory_btn.png",
|
"down_two.png",
|
||||||
"drop_btn.png",
|
"down_three.png",
|
||||||
"jump_btn.png",
|
"left.png",
|
||||||
|
"right.png",
|
||||||
|
"inventory.png",
|
||||||
|
"drop.png",
|
||||||
|
"jump.png",
|
||||||
"down.png",
|
"down.png",
|
||||||
#ifdef ENABLE_ANDROID_NOCLIP
|
/*#ifdef ENABLE_ANDROID_NOCLIP
|
||||||
"fly_btn.png",
|
"fly_btn.png",
|
||||||
"noclip_btn.png",
|
"noclip_btn.png",
|
||||||
#endif
|
#endif*/
|
||||||
// "minimap_btn.png",
|
// "minimap_btn.png",
|
||||||
"debug_btn.png",
|
// "debug_btn.png",
|
||||||
"chat_btn.png",
|
"chat.png",
|
||||||
// "camera_btn.png",
|
// "camera.png",
|
||||||
"rangeview_btn.png"
|
"rangeview.png"
|
||||||
};
|
};
|
||||||
|
|
||||||
static irr::EKEY_CODE id2keycode(touch_gui_button_id id)
|
static irr::EKEY_CODE id2keycode(touch_gui_button_id id)
|
||||||
{
|
{
|
||||||
std::string key = "";
|
std::string key = "";
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case forward_id:
|
case forward_one:
|
||||||
key = "forward";
|
key = "forward";
|
||||||
break;
|
break;
|
||||||
|
case forward_two:
|
||||||
|
key = "forward";
|
||||||
|
break;
|
||||||
|
case forward_three:
|
||||||
|
key = "forward";
|
||||||
|
break;
|
||||||
|
case backward_one:
|
||||||
|
key = "backward";
|
||||||
|
break;
|
||||||
|
case backward_two:
|
||||||
|
key = "backward";
|
||||||
|
break;
|
||||||
|
case backward_three:
|
||||||
|
key = "backward";
|
||||||
|
break;
|
||||||
case left_id:
|
case left_id:
|
||||||
key = "left";
|
key = "left";
|
||||||
break;
|
break;
|
||||||
case right_id:
|
case right_id:
|
||||||
key = "right";
|
key = "right";
|
||||||
break;
|
break;
|
||||||
case backward_id:
|
|
||||||
key = "backward";
|
|
||||||
break;
|
|
||||||
case inventory_id:
|
case inventory_id:
|
||||||
key = "inventory";
|
key = "inventory";
|
||||||
break;
|
break;
|
||||||
|
@ -87,7 +103,7 @@ static irr::EKEY_CODE id2keycode(touch_gui_button_id id)
|
||||||
case crunch_id:
|
case crunch_id:
|
||||||
key = "sneak";
|
key = "sneak";
|
||||||
break;
|
break;
|
||||||
#ifdef ENABLE_ANDROID_NOCLIP
|
/*#ifdef ENABLE_ANDROID_NOCLIP
|
||||||
case fly_id:
|
case fly_id:
|
||||||
key = "freemove";
|
key = "freemove";
|
||||||
break;
|
break;
|
||||||
|
@ -98,16 +114,16 @@ static irr::EKEY_CODE id2keycode(touch_gui_button_id id)
|
||||||
key = "fast";
|
key = "fast";
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
/* case minimap_id:
|
case minimap_id:
|
||||||
key = "minimap";
|
key = "minimap";
|
||||||
break;*/
|
break;
|
||||||
case debug_id:
|
case debug_id:
|
||||||
key = "toggle_debug";
|
key = "toggle_debug";
|
||||||
break;
|
break;*/
|
||||||
case chat_id:
|
case chat_id:
|
||||||
key = "chat";
|
key = "chat";
|
||||||
break;
|
break;
|
||||||
/* case camera_id:
|
/*case camera_id:
|
||||||
key = "camera_mode";
|
key = "camera_mode";
|
||||||
break;*/
|
break;*/
|
||||||
case range_id:
|
case range_id:
|
||||||
|
@ -177,7 +193,7 @@ void TouchScreenGUI::initButton(touch_gui_button_id id, rect<s32> button_rect,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getMaxControlPadSize(float density) {
|
static int getMaxControlPadSize(float density) {
|
||||||
return 235 * density * g_settings->getFloat("hud_scaling");
|
return 220 * density * g_settings->getFloat("hud_scaling");
|
||||||
}
|
}
|
||||||
|
|
||||||
int TouchScreenGUI::getGuiButtonSize()
|
int TouchScreenGUI::getGuiButtonSize()
|
||||||
|
@ -192,18 +208,16 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
|
||||||
{
|
{
|
||||||
assert(tsrc != 0);
|
assert(tsrc != 0);
|
||||||
|
|
||||||
const u32 spacing = 7;
|
|
||||||
|
|
||||||
u32 control_pad_size =
|
u32 control_pad_size =
|
||||||
MYMIN((2 * m_screensize.Y + spacing * 2) / 3,
|
MYMIN((2 * m_screensize.Y) / 3,
|
||||||
getMaxControlPadSize(porting::getDisplayDensity()));
|
getMaxControlPadSize(porting::getDisplayDensity()));
|
||||||
|
|
||||||
u32 button_size = getGuiButtonSize();
|
u32 button_size = getGuiButtonSize();
|
||||||
m_visible = true;
|
m_visible = true;
|
||||||
m_texturesource = tsrc;
|
m_texturesource = tsrc;
|
||||||
m_control_pad_rect = rect<s32>(
|
m_control_pad_rect = rect<s32>(
|
||||||
spacing, m_screensize.Y - control_pad_size - spacing,
|
0, m_screensize.Y - control_pad_size,
|
||||||
spacing + control_pad_size, m_screensize.Y - spacing);
|
0 + control_pad_size, m_screensize.Y);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
draw control pad
|
draw control pad
|
||||||
|
@ -211,46 +225,55 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
|
||||||
1 4 7
|
1 4 7
|
||||||
2 5 8
|
2 5 8
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int number = 0;
|
int number = 0;
|
||||||
|
|
||||||
for (int y = 0; y < 3; ++y)
|
for (int y = 0; y < 3; ++y)
|
||||||
for (int x = 0; x < 3; ++x, ++number) {
|
for (int x = 0; x < 3; ++x, ++number) {
|
||||||
v2s32 tl;
|
v2s32 tl;
|
||||||
tl.X = y * (button_size + spacing) + spacing;
|
tl.X = y * button_size;
|
||||||
tl.Y = m_screensize.Y - (button_size + spacing) * (3 - x);
|
tl.Y = m_screensize.Y - button_size * (3 - x);
|
||||||
|
|
||||||
rect<s32> button_rect(tl.X, tl.Y, tl.X + button_size, tl.Y + button_size);
|
rect<s32> button_rect(tl.X, tl.Y, tl.X + button_size, tl.Y + button_size);
|
||||||
touch_gui_button_id id = after_last_element_id;
|
touch_gui_button_id id = after_last_element_id;
|
||||||
std::wstring caption;
|
std::wstring caption;
|
||||||
switch (number) {
|
switch (number) {
|
||||||
case 0:
|
case 0:
|
||||||
|
id = forward_one;
|
||||||
|
caption = L"^";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
id = forward_two;
|
||||||
|
caption = L"^";
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
id = forward_three;
|
||||||
|
caption = L"^";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
id = left_id;
|
id = left_id;
|
||||||
caption = L"<";
|
caption = L"<";
|
||||||
break;
|
break;
|
||||||
case 2:
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
id = forward_id;
|
|
||||||
caption = L"^";
|
|
||||||
break;
|
|
||||||
case 4:
|
case 4:
|
||||||
id = jump_id;
|
id = jump_id;
|
||||||
caption = L"x";
|
caption = L"x";
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 2:
|
||||||
id = backward_id;
|
id = backward_one;
|
||||||
caption = L"v";
|
caption = L"v";
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 5:
|
||||||
|
id = backward_two;
|
||||||
|
caption = L"v";
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
id = backward_three;
|
||||||
|
caption = L"v";
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
id = right_id;
|
id = right_id;
|
||||||
caption = L">";
|
caption = L">";
|
||||||
break;
|
break;
|
||||||
case 8:
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (id != after_last_element_id) {
|
if (id != after_last_element_id) {
|
||||||
|
@ -262,28 +285,28 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
|
||||||
initButton(inventory_id,
|
initButton(inventory_id,
|
||||||
rect<s32>(m_screensize.X-(button_size),
|
rect<s32>(m_screensize.X-(button_size),
|
||||||
m_screensize.Y - (button_size),
|
m_screensize.Y - (button_size),
|
||||||
m_screensize.X-(0.0 * button_size),
|
m_screensize.X,
|
||||||
m_screensize.Y),
|
m_screensize.Y),
|
||||||
L"inv", true);
|
L"inv", true);
|
||||||
|
|
||||||
/* init drop button */
|
/* init drop button */
|
||||||
initButton(drop_id,
|
initButton(drop_id,
|
||||||
rect<s32>(0,
|
rect<s32>(m_screensize.X-(0.75*button_size),
|
||||||
m_screensize.Y - (0.5*button_size),
|
m_screensize.Y-(3.5*button_size),
|
||||||
(0.5*button_size),
|
m_screensize.X,
|
||||||
m_screensize.Y),
|
m_screensize.Y-(2.75*button_size)),
|
||||||
L"drop", true);
|
L"drop", true);
|
||||||
|
|
||||||
/* init crunch button */
|
/* init crunch button */
|
||||||
initButton(crunch_id,
|
initButton(crunch_id,
|
||||||
rect<s32>(m_screensize.X-(2.2*button_size),
|
rect<s32>(m_screensize.X-(2.2*button_size),
|
||||||
m_screensize.Y - (0.5*button_size),
|
m_screensize.Y-(0.5*button_size),
|
||||||
m_screensize.X-(1.2*button_size),
|
m_screensize.X-(1.2*button_size),
|
||||||
m_screensize.Y),
|
m_screensize.Y),
|
||||||
L"H",false);
|
L"H",false);
|
||||||
|
|
||||||
#ifdef ENABLE_ANDROID_NOCLIP
|
/*#ifdef ENABLE_ANDROID_NOCLIP
|
||||||
/* init fly button */
|
// init fly button
|
||||||
initButton(fly_id,
|
initButton(fly_id,
|
||||||
rect<s32>(m_screensize.X - (0.75*button_size),
|
rect<s32>(m_screensize.X - (0.75*button_size),
|
||||||
m_screensize.Y - (3.25*button_size),
|
m_screensize.Y - (3.25*button_size),
|
||||||
|
@ -291,21 +314,21 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
|
||||||
m_screensize.Y - (button_size*2.5)),
|
m_screensize.Y - (button_size*2.5)),
|
||||||
L"fly", false, SLOW_BUTTON_REPEAT);
|
L"fly", false, SLOW_BUTTON_REPEAT);
|
||||||
|
|
||||||
/* init noclip button */
|
// init noclip button
|
||||||
initButton(noclip_id,
|
initButton(noclip_id,
|
||||||
rect<s32>(m_screensize.X - (0.75*button_size),
|
rect<s32>(m_screensize.X - (0.75*button_size),
|
||||||
m_screensize.Y - (4.75*button_size),
|
m_screensize.Y - (4.75*button_size),
|
||||||
m_screensize.X,
|
m_screensize.X,
|
||||||
m_screensize.Y - (button_size*4)),
|
m_screensize.Y - (button_size*4)),
|
||||||
L"clip", false, SLOW_BUTTON_REPEAT);
|
L"clip", false, SLOW_BUTTON_REPEAT);
|
||||||
/* init fast button */
|
// init fast button
|
||||||
initButton(fast_id,
|
initButton(fast_id,
|
||||||
rect<s32>(m_screensize.X - (0.75*button_size),
|
rect<s32>(m_screensize.X - (0.75*button_size),
|
||||||
m_screensize.Y - (4*button_size),
|
m_screensize.Y - (4*button_size),
|
||||||
m_screensize.X,
|
m_screensize.X,
|
||||||
m_screensize.Y - (button_size*3.25)),
|
m_screensize.Y - (button_size*3.25)),
|
||||||
L"fast", false, SLOW_BUTTON_REPEAT);
|
L"fast", false, SLOW_BUTTON_REPEAT);
|
||||||
#endif
|
#endif*/
|
||||||
/* init minimap button
|
/* init minimap button
|
||||||
initButton(minimap_id,
|
initButton(minimap_id,
|
||||||
rect<s32>(m_screensize.X - (0.75*button_size),
|
rect<s32>(m_screensize.X - (0.75*button_size),
|
||||||
|
@ -313,13 +336,13 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
|
||||||
m_screensize.X,
|
m_screensize.X,
|
||||||
m_screensize.Y - (button_size*3.25)),
|
m_screensize.Y - (button_size*3.25)),
|
||||||
L"minimap", false, SLOW_BUTTON_REPEAT);*/
|
L"minimap", false, SLOW_BUTTON_REPEAT);*/
|
||||||
#ifndef NDEBUG
|
/*#ifndef NDEBUG
|
||||||
/* init debug button */
|
/* init debug button */
|
||||||
initButton(debug_id,
|
/*initButton(debug_id,
|
||||||
rect<s32>(m_screensize.X - (0.75*button_size), 0.75*button_size,
|
rect<s32>(m_screensize.X - (0.75*button_size), 0.75*button_size,
|
||||||
m_screensize.X, 1.5*button_size),
|
m_screensize.X, 1.5*button_size),
|
||||||
L"dbg", false, SLOW_BUTTON_REPEAT);
|
L"dbg", false, SLOW_BUTTON_REPEAT);
|
||||||
#endif
|
#endif*/
|
||||||
|
|
||||||
/* init chat button */
|
/* init chat button */
|
||||||
initButton(chat_id,
|
initButton(chat_id,
|
||||||
|
|
|
@ -36,8 +36,12 @@ using namespace irr::core;
|
||||||
using namespace irr::gui;
|
using namespace irr::gui;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
forward_id = 0,
|
forward_one = 0,
|
||||||
backward_id,
|
forward_two,
|
||||||
|
forward_three,
|
||||||
|
backward_one,
|
||||||
|
backward_two,
|
||||||
|
backward_three,
|
||||||
left_id,
|
left_id,
|
||||||
right_id,
|
right_id,
|
||||||
inventory_id,
|
inventory_id,
|
||||||
|
@ -50,7 +54,7 @@ typedef enum {
|
||||||
fast_id,
|
fast_id,
|
||||||
#endif
|
#endif
|
||||||
// minimap_id,
|
// minimap_id,
|
||||||
debug_id,
|
// debug_id,
|
||||||
chat_id,
|
chat_id,
|
||||||
// camera_id,
|
// camera_id,
|
||||||
range_id,
|
range_id,
|
||||||
|
|
Loading…
Reference in New Issue