merge diff branch

This commit is contained in:
Maksim Gamarnik 2019-04-01 21:33:19 +02:00 committed by MoNTE48
parent 06b1df684f
commit cc3045473e
7 changed files with 127 additions and 86 deletions

View File

@ -77,14 +77,14 @@ IRRLICHT_TIMESTAMP = $(IRRLICHT_DIR)/timestamp
IRRLICHT_TIMESTAMP_INT = $(ANDR_ROOT)/deps/irrlicht_timestamp IRRLICHT_TIMESTAMP_INT = $(ANDR_ROOT)/deps/irrlicht_timestamp
IRRLICHT_URL_HTTP = https://github.com/zaki/irrlicht/archive/$(IRRLICHT_COMMIT).zip IRRLICHT_URL_HTTP = https://github.com/zaki/irrlicht/archive/$(IRRLICHT_COMMIT).zip
CURL_VERSION = 7.62.0 CURL_VERSION = 7.64.0
CURL_DIR = $(ANDR_ROOT)/deps/curl CURL_DIR = $(ANDR_ROOT)/deps/curl
CURL_LIB = $(CURL_DIR)/lib/.libs/libcurl.a CURL_LIB = $(CURL_DIR)/lib/.libs/libcurl.a
CURL_TIMESTAMP = $(CURL_DIR)/timestamp CURL_TIMESTAMP = $(CURL_DIR)/timestamp
CURL_TIMESTAMP_INT = $(ANDR_ROOT)/deps/curl_timestamp CURL_TIMESTAMP_INT = $(ANDR_ROOT)/deps/curl_timestamp
CURL_URL_HTTP = http://dl.uxnr.de/mirror/curl/curl-${CURL_VERSION}.tar.bz2 CURL_URL_HTTP = http://dl.uxnr.de/mirror/curl/curl-${CURL_VERSION}.tar.bz2
FREETYPE_VERSION = 2.9.1 FREETYPE_VERSION = 2.10.0
FREETYPE_DIR = $(ANDR_ROOT)/deps/freetype FREETYPE_DIR = $(ANDR_ROOT)/deps/freetype
FREETYPE_LIB = $(FREETYPE_DIR)/objs/.libs/libfreetype.a FREETYPE_LIB = $(FREETYPE_DIR)/objs/.libs/libfreetype.a
FREETYPE_TIMESTAMP = $(FREETYPE_DIR)/timestamp FREETYPE_TIMESTAMP = $(FREETYPE_DIR)/timestamp

View File

@ -411,7 +411,7 @@ void set_default_settings(Settings *settings)
// check screen size // check screen size
float x_inches = ((double) porting::getDisplaySize().X / float x_inches = ((double) porting::getDisplaySize().X /
(160 * porting::getDisplayDensity())); (160 * porting::getDisplayDensity()));
if (x_inches <= 3.7) { if (x_inches <= 3.7) {
// small 4" phones // small 4" phones
settings->setDefault("hud_scaling", "0.5"); settings->setDefault("hud_scaling", "0.5");

View File

@ -68,10 +68,10 @@ void android_main(android_app *app)
/* TODO this doesn't work as expected, no idea why but there's a workaround */ /* TODO this doesn't work as expected, no idea why but there's a workaround */
/* for it right now */ /* for it right now */
extern "C" { extern "C" {
JNIEXPORT void JNICALL Java_mobi_MultiCraft_GameActivity_putMessageBoxResult( JNIEXPORT void JNICALL Java_com_multicraft_game_GameActivity_putMessageBoxResult(
JNIEnv *env, jclass j_this, jstring text) JNIEnv *env, jclass j_this, jstring text)
{ {
errorstream << "Java_mobi_MultiCraft_GameActivity_putMessageBoxResult got: " errorstream << "Java_com_multicraft_game_GameActivity_putMessageBoxResult got: "
<< std::string((const char*)env->GetStringChars(text,0)) << std::string((const char*)env->GetStringChars(text,0))
<< std::endl; << std::endl;
} }
@ -125,7 +125,7 @@ void initAndroid()
exit(-1); exit(-1);
} }
nativeActivity = findClass("mobi/MultiCraft/GameActivity"); nativeActivity = findClass("com/multicraft/game/GameActivity");
if (nativeActivity == 0) { if (nativeActivity == 0) {
errorstream << errorstream <<
"porting::initAndroid unable to find java native activity class" << "porting::initAndroid unable to find java native activity class" <<
@ -206,7 +206,7 @@ void initializePathsAndroid()
cls_File, mt_getAbsPath, "getCacheDir"); cls_File, mt_getAbsPath, "getCacheDir");
path_storage = getAndroidPath(cls_Env, NULL, cls_File, mt_getAbsPath, path_storage = getAndroidPath(cls_Env, NULL, cls_File, mt_getAbsPath,
"getExternalStorageDirectory"); "getExternalStorageDirectory");
path_user = path_storage + DIR_DELIM + "Android/data/mobi.MultiCraft/files"; path_user = path_storage + DIR_DELIM + "Android/data/com.multicraft.game/files";
path_share = path_user; path_share = path_user;
path_locale = path_user + DIR_DELIM + "locale"; path_locale = path_user + DIR_DELIM + "locale";
} }

View File

@ -1,3 +1,24 @@
/*
MultiCraft
Copyright (C) 2014-2019 Maksim Gamarnik [MoNTE48] MoNTE48@mail.ua
Copyright (C) 2016-2019 sfan5
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 3.0 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.
*/
#include <string> #include <string>
#include "porting.h" #include "porting.h"
@ -7,40 +28,40 @@
static void *uiviewcontroller; static void *uiviewcontroller;
namespace porting { namespace porting {
void initializePathsiOS() { void initializePathsiOS() {
char buf[128]; char buf[128];
ioswrap_paths(PATH_DOCUMENTS, buf, sizeof(buf)); ioswrap_paths(PATH_DOCUMENTS, buf, sizeof(buf));
path_user = std::string(buf); path_user = std::string(buf);
ioswrap_paths(PATH_LIBRARY_SUPPORT, buf, sizeof(buf)); ioswrap_paths(PATH_LIBRARY_SUPPORT, buf, sizeof(buf));
path_share = std::string(buf); path_share = std::string(buf);
path_locale = std::string(buf) + "/locale"; path_locale = std::string(buf) + "/locale";
ioswrap_paths(PATH_LIBRARY_CACHE, buf, sizeof(buf)); ioswrap_paths(PATH_LIBRARY_CACHE, buf, sizeof(buf));
path_cache = std::string(buf); path_cache = std::string(buf);
} }
void copyAssets() { void copyAssets() {
ioswrap_assets(); ioswrap_assets();
} }
float getDisplayDensity() { float getDisplayDensity() {
return 1.0; return 1.0;
} }
v2u32 getDisplaySize() { v2u32 getDisplaySize() {
static bool firstrun = true; static bool firstrun = true;
static v2u32 retval; static v2u32 retval;
if(firstrun) { if(firstrun) {
unsigned int values[2]; unsigned int values[2];
ioswrap_size(values); ioswrap_size(values);
retval.X = values[0]; retval.X = values[0];
retval.Y = values[1]; retval.Y = values[1];
firstrun = false; firstrun = false;
} }
return retval; return retval;
} }
void setViewController(void *v) { void setViewController(void *v) {
uiviewcontroller = v; uiviewcontroller = v;
@ -61,13 +82,13 @@ namespace porting {
ioswrap_get_dialog(&str); ioswrap_get_dialog(&str);
return std::string(str); return std::string(str);
} }
void notifyServerConnect(bool is_multiplayer) { void notifyServerConnect(bool is_multiplayer) {
#ifdef ADS #ifdef ADS
ads_allow(!is_multiplayer); ads_allow(!is_multiplayer);
#endif #endif
} }
void notifyExitGame() { void notifyExitGame() {
#ifdef ADS #ifdef ADS
ads_allow(true); ads_allow(true);

View File

@ -1,3 +1,24 @@
/*
MultiCraft
Copyright (C) 2014-2019 Maksim Gamarnik [MoNTE48] MoNTE48@mail.ua
Copyright (C) 2016-2019 sfan5
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 3.0 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.
*/
#ifndef __PORTING__IOS_H__ #ifndef __PORTING__IOS_H__
#define __PORTING__IOS_H__ #define __PORTING__IOS_H__
@ -11,16 +32,16 @@
#endif #endif
namespace porting { namespace porting {
void initializePathsiOS(); void initializePathsiOS();
void copyAssets(); void copyAssets();
void setViewController(void *v); void setViewController(void *v);
void showInputDialog(const std::string &acceptButton, const std::string &hint, void showInputDialog(const std::string &acceptButton, const std::string &hint,
const std::string &current, int editType); const std::string &current, int editType);
int getInputDialogState(); int getInputDialogState();
std::string getInputDialogValue(); std::string getInputDialogValue();
inline void notifyAbortLoading() {} inline void notifyAbortLoading() {}
void notifyServerConnect(bool is_multiplayer); void notifyServerConnect(bool is_multiplayer);
void notifyExitGame(); void notifyExitGame();
} }

View File

@ -1,5 +1,6 @@
/* /*
Copyright (C) 2014 sapier Copyright (C) 2014 sapier
Copyright (C) 2014-2019 Maksim Gamarnik [MoNTE48] MoNTE48@mail.ua
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU Lesser General Public License as published by
@ -57,9 +58,9 @@ const char* touchgui_button_imagenames[] = {
"noclip_btn.png", "noclip_btn.png",
#endif*/ #endif*/
"minimap_btn.png", "minimap_btn.png",
// "debug_btn.png", //"debug_btn.png",
"chat.png", "chat.png",
// "camera.png", //"camera.png",
"rangeview.png", "rangeview.png",
"rangeview_ios.png", "rangeview_ios.png",
"empty.png", "empty.png",
@ -150,7 +151,7 @@ TouchScreenGUI *g_touchscreengui;
TouchScreenGUI::TouchScreenGUI(IrrlichtDevice *device, IEventReceiver* receiver): TouchScreenGUI::TouchScreenGUI(IrrlichtDevice *device, IEventReceiver* receiver):
m_device(device), m_device(device),
m_guienv(device->getGUIEnvironment()), m_guienv(device->getGUIEnvironment()),
// m_camera_yaw(0.0), //m_camera_yaw(0.0),
m_camera_pitch(0.0), m_camera_pitch(0.0),
m_visible(false), m_visible(false),
m_move_id(-1), m_move_id(-1),
@ -222,7 +223,7 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
u32 control_pad_size = u32 control_pad_size =
MYMIN((2 * m_screensize.Y) / 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;
@ -292,17 +293,17 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
/* init inventory button */ /* init inventory button */
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, m_screensize.X,
m_screensize.Y), m_screensize.Y),
L"inv", false, SLOW_BUTTON_REPEAT); L"inv", false, SLOW_BUTTON_REPEAT);
/* init drop button */ /* init drop button */
initButton(drop_id, initButton(drop_id,
rect<s32>(m_screensize.X-(0.75*button_size), rect<s32>(m_screensize.X-(0.75*button_size),
m_screensize.Y/2-(1.5*button_size), m_screensize.Y/2-(1.5*button_size),
m_screensize.X, m_screensize.X,
m_screensize.Y/2-(0.75*button_size)), m_screensize.Y/2-(0.75*button_size)),
L"drop", false, SLOW_BUTTON_REPEAT); L"drop", false, SLOW_BUTTON_REPEAT);
/* init crunch button */ /* init crunch button */
@ -315,77 +316,74 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc)
/* init jump button */ /* init jump button */
initButton(jump_id, initButton(jump_id,
rect<s32>(m_screensize.X-(button_size*2), rect<s32>(m_screensize.X-(button_size*2),
m_screensize.Y-(button_size*2), m_screensize.Y-(button_size*2),
m_screensize.X-(button_size), m_screensize.X-(button_size),
m_screensize.Y-(button_size)), m_screensize.Y-(button_size)),
L"x", false, SLOW_BUTTON_REPEAT); L"x", false, SLOW_BUTTON_REPEAT);
/*#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),
m_screensize.X, m_screensize.X,
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*/
#ifdef __IOS__ #ifdef __IOS__
// iOS bar // iOS bar
/* init pause button */ /* init pause button */
initButton(escape_id, initButton(escape_id,
rect<s32>(m_screensize.X / 2 - (button_size * 0.75), 0, rect<s32>(m_screensize.X / 2 - (button_size * 0.75), 0,
m_screensize.X / 2, m_screensize.X / 2, (button_size * 0.75)),
(button_size * 0.75)),
L"Exit", false, SLOW_BUTTON_REPEAT); L"Exit", false, SLOW_BUTTON_REPEAT);
/* init rangeselect button */ /* init rangeselect button */
initButton(range_ios_id, initButton(range_ios_id,
rect<s32>(m_screensize.X / 2, 0, rect<s32>(m_screensize.X / 2, 0,
m_screensize.X / 2 + (button_size * 0.75), m_screensize.X / 2 + (button_size * 0.75),
(button_size * 0.75)), (button_size * 0.75)),
L"far", false, SLOW_BUTTON_REPEAT); L"far", false, SLOW_BUTTON_REPEAT);
/* init chat button */ /* init chat button */
initButton(chat_id, initButton(chat_id,
rect<s32>(m_screensize.X / 2 + (button_size * 0.75), 0, rect<s32>(m_screensize.X / 2 + (button_size * 0.75), 0,
m_screensize.X / 2 + (button_size * 1.5), m_screensize.X / 2 + (button_size * 1.5),
(button_size * 0.75)), (button_size * 0.75)),
L"Chat", false, SLOW_BUTTON_REPEAT); L"Chat", false, SLOW_BUTTON_REPEAT);
#else #else
// Android and Windows bar // Android and Windows bar
/* init rangeselect button */ /* init rangeselect button */
initButton(range_id, initButton(range_id,
rect<s32>(m_screensize.X / 2 - (button_size * 1.125), 0, rect<s32>(m_screensize.X / 2 - (button_size * 1.125), 0,
m_screensize.X / 2 - (button_size * 0.375), m_screensize.X / 2 - (button_size * 0.375),
(button_size * 0.75)), (button_size * 0.75)),
L"far", false, SLOW_BUTTON_REPEAT); L"far", false, SLOW_BUTTON_REPEAT);
/* init minimap button */ /* init minimap button */
initButton(minimap_id, initButton(minimap_id,
rect<s32>(m_screensize.X / 2 - (button_size * 0.375), 0, rect<s32>(m_screensize.X / 2 - (button_size * 0.375), 0,
m_screensize.X / 2 + (button_size * 0.375), m_screensize.X / 2 + (button_size * 0.375),
(button_size * 0.75)), (button_size * 0.75)),
L"minimap", false, SLOW_BUTTON_REPEAT); L"minimap", false, SLOW_BUTTON_REPEAT);
/* init chat button */ /* init chat button */
initButton(chat_id, initButton(chat_id,
@ -557,7 +555,7 @@ void TouchScreenGUI::handleReleaseEvent(size_t evt_id)
m_receiver->OnEvent(*translated); m_receiver->OnEvent(*translated);
delete translated; delete translated;
} else if (m_control_pad_rect.isPointInside(v2s32(m_move_downlocation.X, m_move_downlocation.Y))) { } else if (m_control_pad_rect.isPointInside(v2s32(m_move_downlocation.X, m_move_downlocation.Y))) {
// ignore events inside the control pad not already handled // ignore events inside the control pad not already handled
} else if (!m_move_has_really_moved) { } else if (!m_move_has_really_moved) {
SEvent* translated = new SEvent; SEvent* translated = new SEvent;
memset(translated, 0, sizeof(SEvent)); memset(translated, 0, sizeof(SEvent));

View File

@ -1,5 +1,6 @@
/* /*
Copyright (C) 2014 sapier Copyright (C) 2014 sapier
Copyright (C) 2014-2019 Maksim Gamarnik [MoNTE48] MoNTE48@mail.ua
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU Lesser General Public License as published by
@ -54,9 +55,9 @@ 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,
range_ios_id, range_ios_id,
empty_id, empty_id,