Android work. DONT_BUILD.

git-svn-id: https://svn.eduke32.com/eduke32@5652 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-03-14 00:06:54 +00:00
parent 6f6762edfa
commit 2b357b58f1
11 changed files with 389 additions and 780 deletions

View file

@ -147,7 +147,7 @@ LOCAL_SRC_FILES = $(ANDROID_SRC) $(JAUDIO_SRC) $(JMACT_SRC) $(GAME_SRC) $(BUILD_
LOCAL_LDLIBS := -lGLESv1_CM -lEGL -ldl -llog -lOpenSLES -lz -L$(TOP_DIR)/openssl/libs/
LOCAL_STATIC_LIBRARIES := libpng crypto
LOCAL_SHARED_LIBRARIES := touchcontrols ogg vorbis SDL2 SDL2_mixer libvpx
LOCAL_SHARED_LIBRARIES := ogg vorbis SDL2 SDL2_mixer libvpx drm
# SDL2_image
include $(BUILD_SHARED_LIBRARY)

View file

@ -705,6 +705,10 @@ void uploadtexture(int32_t doalloc, vec2_t siz, int32_t texfmt,
{
gltexmaxsize = 0;
for (; i>1; i>>=1) gltexmaxsize++;
#ifdef EDUKE32_GLES
while ((1<<gltexmaxsize) > xdim)
gltexmaxsize--;
#endif
}
}

View file

@ -1681,7 +1681,7 @@ void enddrawing(void)
#if SDL_MAJOR_VERSION != 1
#ifdef __ANDROID__
extern "C" void frameControls();
extern "C" void AndroidDrawControls();
#endif
void showframe(int32_t w)
@ -1699,7 +1699,7 @@ void showframe(int32_t w)
fullscreen_tint_gl(palfadergb.r, palfadergb.g, palfadergb.b, palfadedelta);
#ifdef __ANDROID__
frameControls();
AndroidDrawControls();
#endif
SDL_GL_SwapWindow(sdl_window);
return;

View file

@ -30,25 +30,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "TouchControlsContainer.h"
#include "JNITouchControlsUtils.h"
using namespace touchcontrols;
extern "C" {
#define DEFAULT_FADE_FRAMES 10
extern void SDL_Android_Init(JNIEnv *env, jclass cls);
extern char const *G_GetStringFromSavegame(const char *filename, int type);
extern int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char *data);
#include "in_android.h"
#include "../function.h"
// #include "../GL/gl.h"
// Copied from build.h, which didnt include here
enum rendmode_t
{
REND_CLASSIC,
REND_POLYMOST = 3,
REND_POLYMER
};
#include "function.h"
enum dukeinv_t
{
@ -66,51 +54,42 @@ enum dukeinv_t
GET_MAX
};
#ifndef LOGI
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "DUKE", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "DUKE", __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "DUKE", __VA_ARGS__))
#endif
#define REND_SOFT 0
#define REND_GL 1
droidsysinfo_t droidinfo;
static int curRenderer;
static bool hideTouchControls = true;
static bool hasTouch = false;
static int weaponWheelVisible = false;
static bool weaponWheelVisible = false;
static bool hwScaling = false;
static bool controlsCreated = false;
static bool backButtonEnabled = true;
TouchControlsContainer controlsContainer;
static int controlsCreated = 0;
touchcontrols::TouchControlsContainer controlsContainer;
TouchControls *tcBlankTap;
TouchControls *tcYesNo;
TouchControls *tcMenuMain;
TouchControls *tcBackButton;
TouchControls *tcGameMain;
TouchControls *tcGameWeapons;
TouchControls *tcAutomap;
touchcontrols::TouchControls *tcBlankTap;
touchcontrols::TouchControls *tcYesNo;
touchcontrols::TouchControls *tcMenuMain;
touchcontrols::TouchControls *tcGameMain;
touchcontrols::TouchControls *tcGameWeapons;
// touchcontrols::TouchControls *tcInventory;
touchcontrols::TouchControls *tcAutomap;
touchcontrols::TouchJoy *touchJoyLeft;
touchcontrols::WheelSelect *weaponWheel;
TouchStick *touchJoyLeft;
WheelSelect *weaponWheel;
extern JNIEnv *env_;
JavaVM *jvm_;
touchcontrols::Button *inv_buttons[GET_MAX];
Button *inv_buttons[GET_MAX];
std::string obbPath, gamePath;
void openGLStart()
{
if (curRenderer == REND_GL)
void AndroidPreDrawButtons()
{
glPushMatrix();
@ -120,7 +99,7 @@ void openGLStart()
// glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
// glClear(GL_COLOR_BUFFER_BIT);
// LOGI("openGLStart");
// LOGI("AndroidPreDrawButtons");
glDisable(GL_ALPHA_TEST);
glDisable(GL_DEPTH_TEST);
glDisable(GL_FOG);
@ -141,26 +120,13 @@ void openGLStart()
glMatrixMode(GL_MODELVIEW);
}
}
void openGLEnd()
void AndroidPostDrawButtons()
{
if (curRenderer == REND_GL)
glPopMatrix();
}
void gameSettingsButton(int state)
{
if (state == 1)
showTouchSettings();
}
// This is a bit of a hack, if the weapon wheel was selected, then an inv chosen instead, we need to cancel the weapon
// selection
// NOT needed actually, weapon wheel disabled before is get finger up anyway
// static bool invWasSelected = false;
void showWeaponsInventory(bool show)
void AndroidShowWheel(bool show)
{
if (!controlsCreated)
return;
@ -168,32 +134,33 @@ void showWeaponsInventory(bool show)
if (show)
{
for (int n = 0; n < 10; n++)
weaponWheel->setSegmentEnabled(n, (PortableRead(READ_WEAPONS) >> n) & 0x1);
weaponWheel->setSegmentEnabled(n, (AndroidRead(R_PLAYER_GOTWEAPON) >> n) & 0x1);
// Show inventory buttons
tcGameWeapons->setAllButtonsEnable(true);
tcGameWeapons->fade(touchcontrols::FADE_IN, 5); // fade in
tcGameWeapons->setAllButtonsEnabled(true);
tcGameWeapons->fade(FADE_IN, 5);
weaponWheelVisible = true;
PortableTimer(0);
AndroidTimer(0);
}
else // hide
{
tcGameWeapons->setAllButtonsEnable(false);
tcGameWeapons->setAllButtonsEnabled(false);
weaponWheel->setTapMode(false);
weaponWheelVisible = false;
PortableTimer(120);
AndroidTimer(120);
}
}
void AndroidShowKeyboard(int onf)
{
showKeyboard(onf);
JNI_ShowKeyboard(onf);
}
void gameButton(int state, int code)
namespace callbacks
{
void in_game(int state, int code)
{
if (!controlsCreated)
return;
@ -201,24 +168,24 @@ void gameButton(int state, int code)
switch (code)
{
case gamefunc_Fire:
if (state && PortableRead(READ_SOMETHINGONPLAYER))
if (state && AndroidRead(R_SOMETHINGONPLAYER))
{
PortableAction(1, gamefunc_Quick_Kick);
PortableAction(0, gamefunc_Quick_Kick);
AndroidAction(1, gamefunc_Quick_Kick);
AndroidAction(0, gamefunc_Quick_Kick);
}
else PortableAction(state, code);
else AndroidAction(state, code);
break;
case KEY_SHOW_KBRD:
if (state)
toggleKeyboard();
JNI_ToggleKeyboard();
PortableKeyEvent(state, SDL_SCANCODE_GRAVE, 0);
AndroidKeyEvent(state, SDL_SCANCODE_GRAVE, 0);
break;
case KEY_QUICK_CMD:
if (state == 1)
showCustomCommands();
JNI_ShowCustomCommands();
break;
case KEY_SHOW_INVEN:
@ -227,152 +194,133 @@ void gameButton(int state, int code)
if (!weaponWheelVisible)
{
weaponWheel->setTapMode(true);
showWeaponsInventory(true);
AndroidShowWheel(true);
}
else
{
showWeaponsInventory(false);
AndroidShowWheel(false);
}
}
break;
case KEY_QUICK_SAVE:
LOGI("QUICK SAVE");
PortableKeyEvent(state, SDL_SCANCODE_F6, 0);
AndroidKeyEvent(state, SDL_SCANCODE_F6, 0);
break;
case KEY_QUICK_LOAD:
LOGI("QUICK LOAD");
PortableKeyEvent(state, SDL_SCANCODE_F9, 0);
AndroidKeyEvent(state, SDL_SCANCODE_F9, 0);
break;
default: PortableAction(state, code); break;
default: AndroidAction(state, code); break;
}
}
void automapButton(int state, int code) { PortableAction(state, code); }
void inventoryButton(int state, int code)
void inv_button(int state, int code)
{
PortableAction(state, code);
AndroidAction(state, code);
if (state == 0)
{
// Inventory chosen, hide them and wheel
showWeaponsInventory(false);
AndroidShowWheel(false);
}
}
void menuButton(int state, int code) { PortableKeyEvent(state, code, code); }
void menuMouse(int action, float x, float y, float dx, float dy)
void menu_button(int state, int code)
{
// PortableMouse(dx,dy);
PortableMouseMenu(x * droidinfo.screen_width, y * droidinfo.screen_height);
AndroidKeyEvent(state, code, code);
if (controlsContainer.editingControls)
controlsContainer.editorButtonPress();
}
void menu_select(int action, float x, float y, float dx, float dy)
{
AndroidMouseMenu(x * droidinfo.screen_width, y * droidinfo.screen_height);
if (action == MULTITOUCHMOUSE_DOWN || action == MULTITOUCHMOUSE_UP)
PortableMouseMenuButton(action == MULTITOUCHMOUSE_DOWN, 0);
AndroidMouseMenuButton(action == MULTITOUCHMOUSE_DOWN, 0);
}
void blankTapButton(int state, int code)
void proceed(int state, int code)
{
if (PortableRead(READ_IS_DEAD)) // if the player is dead we need to send a 'open' button
if (AndroidRead(R_PLAYER_DEAD_FLAG))
{
if (state)
{
PortableAction(1, gamefunc_Open);
PortableAction(0, gamefunc_Open);
AndroidAction(1, gamefunc_Open);
AndroidAction(0, gamefunc_Open);
}
}
else // everything else send a return key
PortableKeyEvent(state, SDL_SCANCODE_RETURN, 0);
else
AndroidKeyEvent(state, SDL_SCANCODE_RETURN, 0);
}
void weaponWheelSelected(int enabled) {
showWeaponsInventory(enabled ? true : false);
}
void weaponWheelChosen(int segment)
void show_wheel(int enabled) { AndroidShowWheel(enabled ? true : false); }
void select_weapon(int segment)
{
// LOGI("weaponWheel %d",segment);
if (segment == -1 && droidinput.quickSelectWeapon)
segment = PortableRead(READ_LASTWEAPON);
segment = AndroidRead(R_PLAYER_LASTWEAPON);
if (segment != -1)
PortableAction(2, gamefunc_Weapon_1 + segment);
AndroidAction(2, gamefunc_Weapon_1 + segment);
}
void left_double_tap(int state)
{
// LOGI("L double %d, droidinput.left_double_action = %d",state,droidinput.left_double_action);
if (droidinput.left_double_action != -1)
PortableAction(state, droidinput.left_double_action);
AndroidAction(state, droidinput.left_double_action);
}
void right_double_tap(int state)
{
// LOGTOUCH("R double %d",state);
if (droidinput.right_double_action != -1)
PortableAction(state, droidinput.right_double_action);
AndroidAction(state, droidinput.right_double_action);
}
void mouseMove(int action, float x, float y, float dx, float dy)
void look(int action, float x, float y, float dx, float dy)
{
// LOGI(" mouse dx = %f, dy = %f",dx,dy);
if (weaponWheelVisible)
return;
float const scale = .1f;
PortableLook(dx * droidinput.yaw_sens * scale, -dy * droidinput.pitch_sens * scale * (droidinput.invertLook ? -1.f : 1.f));
AndroidLook(dx * droidinput.yaw_sens * scale, -dy * droidinput.pitch_sens * scale * (droidinput.invertLook ? -1.f : 1.f));
}
void automap_multitouch_mouse_move(int action, float x, float y, float dx, float dy)
{
if (action == MULTITOUCHMOUSE_MOVE)
PortableAutomapControl(0, dx, dy);
AndroidAutomapControl(0, dx, dy);
else if (action == MULTITOUCHMOUSE_ZOOM)
PortableAutomapControl(x, 0, 0);
AndroidAutomapControl(x, 0, 0);
}
void left_stick(float joy_x, float joy_y, float mouse_x, float mouse_y)
void move(float joy_x, float joy_y, float mouse_x, float mouse_y)
{
// LOGI("left_stick joy_x = %f, joy_y = %f",joy_x,joy_y);
PortableMove(joy_y * droidinput.forward_sens, -joy_x * droidinput.strafe_sens);
AndroidMove(joy_y * droidinput.forward_sens, -joy_x * droidinput.strafe_sens);
}
}
void setHideSticks(bool v)
void AndroidToggleButtonEditor(void)
{
if (touchJoyLeft)
touchJoyLeft->setHideGraphics(v);
controlsContainer.editorButtonPress();
}
void touchSettingsButton(int state)
void AndroidTouchInit(int width, int height, const char *graphics_path)
{
/*
int32_t paused = PortableRead(READ_PAUSED);
GLScaleWidth = (float)width;
GLScaleHeight = (float)-height;
//We wanna pause the game when doing settings
if (state && !paused || !state && paused)
{
PortableKeyEvent(2, SDL_SCANCODE_PAUSE, 0);
}
*/
}
void initControls(int width, int height, const char *graphics_path)
{
touchcontrols::GLScaleWidth = (float)width;
touchcontrols::GLScaleHeight = (float)-height;
touchcontrols::ScaleY = nearbyintf(((float) height/(float) width) * touchcontrols::ScaleX);
/*
if (hwScaling)
{
touchcontrols::GLScaleWidth = (float) (width * 2);
touchcontrols::GLScaleHeight = (float) -(height * 2);
}
*/
ScaleY = nearbyintf(((float) height/(float) width) * ScaleX);
LOGI("initControls %d x %d,x path = %s", width, height, graphics_path);
@ -381,180 +329,139 @@ void initControls(int width, int height, const char *graphics_path)
LOGI("creating controls");
touchcontrols::setGraphicsBasePath(graphics_path);
setGraphicsBasePath(graphics_path);
controlsContainer.openGL_start.connect(sigc::ptr_fun(&openGLStart));
controlsContainer.openGL_end.connect(sigc::ptr_fun(&openGLEnd));
controlsContainer.signal_settings.connect(sigc::ptr_fun(&touchSettingsButton));
controlsContainer.pre_draw.connect(sigc::ptr_fun(&AndroidPreDrawButtons));
controlsContainer.post_draw.connect(sigc::ptr_fun(&AndroidPostDrawButtons));
tcBlankTap = new touchcontrols::TouchControls("blank_tap", false, false);
tcYesNo = new touchcontrols::TouchControls("yes_no", false, false);
tcMenuMain = new touchcontrols::TouchControls("menu", false, false);
tcGameMain = new touchcontrols::TouchControls("game", false, true, 1);
tcGameWeapons = new touchcontrols::TouchControls("weapons", false, false);
tcAutomap = new touchcontrols::TouchControls("automap", false, false);
tcBlankTap = new TouchControls("blank_tap", false, false);
tcYesNo = new TouchControls("yes_no", false, false);
tcMenuMain = new TouchControls("menu", false, false);
tcBackButton = new TouchControls("back", false, false);
tcGameMain = new TouchControls("game", false, true, 1);
tcGameWeapons = new TouchControls("weapons", false, false);
tcAutomap = new TouchControls("automap", false, false);
///////////////////////// BLANK TAP SCREEN //////////////////////
// One button on whole screen with no graphic, send a return key
tcBlankTap->addControl(new touchcontrols::Button("whole_screen", touchcontrols::RectF(0, 0, 26, 16),
"" /*std::string("test")*/, SDL_SCANCODE_RETURN));
tcBlankTap->signal_button.connect(sigc::ptr_fun(&blankTapButton)); // Just reuse the menuButton function
tcBlankTap->addControl(new Button("whole_screen", RectF(0, 0, 26, 16), "", SDL_SCANCODE_RETURN));
tcBlankTap->signal_button.connect(sigc::ptr_fun(&callbacks::proceed));
///////////////////////// YES NO SCREEN /////////////////////
tcYesNo->addControl(
new touchcontrols::Button("enter", touchcontrols::RectF(16, 9, 18, 11), "yes", SDL_SCANCODE_RETURN));
tcYesNo->addControl(
new touchcontrols::Button("esc", touchcontrols::RectF(8, 9, 10, 11), "no", SDL_SCANCODE_ESCAPE));
tcYesNo->signal_button.connect(sigc::ptr_fun(&menuButton)); // Just reuse the menuButton function
tcYesNo->addControl(new Button("enter", RectF(16, 9, 18, 11), "yes", SDL_SCANCODE_RETURN));
tcYesNo->addControl(new Button("esc", RectF(8, 9, 10, 11), "no", SDL_SCANCODE_ESCAPE));
tcYesNo->signal_button.connect(sigc::ptr_fun(&callbacks::menu_button));
///////////////////////// MAIN MENU SCREEN /////////////////////
// menu and shared back button
tcMenuMain->addControl(
new touchcontrols::Button("arrow_left", touchcontrols::RectF(0, 0, 2, 2), "arrow_left", SDL_SCANCODE_ESCAPE));
tcMenuMain->signal_button.connect(sigc::ptr_fun(&menuButton));
touchcontrols::MultitouchMouse *mouseMenu =
new touchcontrols::MultitouchMouse("mouse", touchcontrols::RectF(0, 0, 26, 16), "");
MultitouchMouse *mouseMenu = new MultitouchMouse("mouse", RectF(0, 0, 26, 16), "");
mouseMenu->signal_action.connect(sigc::ptr_fun(&callbacks::menu_select));
mouseMenu->setHideGraphics(true);
tcMenuMain->addControl(mouseMenu);
mouseMenu->signal_action.connect(sigc::ptr_fun(&menuMouse));
touchcontrols::Button *console_button = new touchcontrols::Button(
"keyboard", "Development console", touchcontrols::RectF(8, 0, 10, 2), "keyboard", KEY_SHOW_KBRD, false, true);
Button *console_button = new Button("keyboard", "Development console", RectF(8, 0, 10, 2), "keyboard", KEY_SHOW_KBRD, false, true);
tcMenuMain->addControl(console_button);
//////////////////////////// GAME SCREEN /////////////////////
tcBackButton->addControl(new Button("menu_back", RectF(0, 0, 2, 2), "arrow_left", SDL_SCANCODE_ESCAPE));
tcBackButton->signal_button.connect(sigc::ptr_fun(&callbacks::menu_button));
// main controls
tcGameMain->setAlpha(droidinput.gameControlsAlpha);
controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha;
tcGameMain->addControl(
new touchcontrols::Button("game_menu", touchcontrols::RectF(0, 0, 2, 2), "settings_bars", MENU_BACK));
tcGameMain->addControl(new Button("use", RectF(20, 4, 23, 7), "use", gamefunc_Open));
tcGameMain->addControl(new Button("fire", RectF(20, 7, 23, 10), "fire2", gamefunc_Fire));
tcGameMain->addControl(new Button("jump", RectF(23, 6, 26, 9), "jump", gamefunc_Jump));
tcGameMain->addControl(new Button("crouch", RectF(24, 12, 26, 14), "crouch", gamefunc_Crouch));
tcGameMain->addControl(new Button("kick", "Mighty Foot", RectF(23, 3, 26, 6), "boot", gamefunc_Quick_Kick, false, true));
tcGameMain->addControl(new touchcontrols::Button("use", touchcontrols::RectF(20, 4, 23, 7), "use", gamefunc_Open));
tcGameMain->addControl(
new touchcontrols::Button("fire", touchcontrols::RectF(20, 7, 23, 10), "fire2", gamefunc_Fire));
tcGameMain->addControl(
new touchcontrols::Button("jump", touchcontrols::RectF(23, 6, 26, 9), "jump", gamefunc_Jump));
tcGameMain->addControl(
new touchcontrols::Button("crouch", touchcontrols::RectF(24, 12, 26, 14), "crouch", gamefunc_Crouch));
tcGameMain->addControl(new touchcontrols::Button("kick", "Mighty Foot", touchcontrols::RectF(23, 3, 26, 6), "boot",
gamefunc_Quick_Kick, false, true));
touchcontrols::Button *map_button = new touchcontrols::Button(
"map", "Overhead map", touchcontrols::RectF(6, 0, 8, 2), "map", gamefunc_Map, false, true);
Button *map_button = new Button("map", "Overhead map", RectF(6, 0, 8, 2), "map", gamefunc_Map, false, true);
tcGameMain->addControl(map_button);
tcGameMain->addControl(new touchcontrols::Button("show_inventory", "Inventory", touchcontrols::RectF(24, 0, 26, 2),
"inv", KEY_SHOW_INVEN));
tcGameMain->addControl(new touchcontrols::Button("next_weapon", "Next weapon", touchcontrols::RectF(0, 3, 3, 5),
"next_weap", gamefunc_Next_Weapon, false, true));
tcGameMain->addControl(new touchcontrols::Button("prev_weapon", "Previous weapon", touchcontrols::RectF(0, 5, 3, 7),
"prev_weap", gamefunc_Previous_Weapon, false, true));
tcGameMain->addControl(new touchcontrols::Button("quick_save", "Save game", touchcontrols::RectF(22, 0, 24, 2),
"save", KEY_QUICK_SAVE, false, true));
tcGameMain->addControl(new touchcontrols::Button("quick_load", "Load game", touchcontrols::RectF(20, 0, 22, 2),
"load", KEY_QUICK_LOAD, false, true));
Button *inv_button = new Button("show_inventory", "Inventory", RectF(24, 0, 26, 2), "inv", KEY_SHOW_INVEN);
tcGameMain->addControl(inv_button);
tcGameMain->addControl(new Button("next_weapon", "Next weapon", RectF(0, 3, 3, 5), "next_weap", gamefunc_Next_Weapon, false, true));
tcGameMain->addControl(new Button("prev_weapon", "Previous weapon", RectF(0, 5, 3, 7), "prev_weap", gamefunc_Previous_Weapon, false, true));
tcGameMain->addControl(new Button("quick_save", "Save game", RectF(22, 0, 24, 2), "save", KEY_QUICK_SAVE, false, true));
tcGameMain->addControl(new Button("quick_load", "Load game", RectF(20, 0, 22, 2), "load", KEY_QUICK_LOAD, false, true));
tcGameMain->addControl(console_button);
/*
//quick actions binds
tcGameMain->addControl(new
touchcontrols::Button("quick_key_1",touchcontrols::RectF(4,3,6,5),"quick_key_1",KEY_QUICK_KEY1,false,true));
tcGameMain->addControl(new
touchcontrols::Button("quick_key_2",touchcontrols::RectF(6,3,8,5),"quick_key_2",KEY_QUICK_KEY2,false,true));
tcGameMain->addControl(new
touchcontrols::Button("quick_key_3",touchcontrols::RectF(8,3,10,5),"quick_key_3",KEY_QUICK_KEY3,false,true));
tcGameMain->addControl(new
touchcontrols::Button("quick_key_4",touchcontrols::RectF(10,3,12,5),"quick_key_4",KEY_QUICK_KEY4,false,true));
*/
// Left stick
touchJoyLeft = new touchcontrols::TouchJoy("stick", touchcontrols::RectF(0, 7, 8, 16), "strafe_arrow");
touchJoyLeft = new TouchStick("stick", RectF(0, 7, 8, 16), "strafe_arrow");
tcGameMain->addControl(touchJoyLeft);
touchJoyLeft->signal_move.connect(sigc::ptr_fun(&left_stick));
touchJoyLeft->signal_double_tap.connect(sigc::ptr_fun(&left_double_tap));
touchJoyLeft->signal_move.connect(sigc::ptr_fun(&callbacks::move));
touchJoyLeft->signal_double_tap.connect(sigc::ptr_fun(&callbacks::left_double_tap));
// Mouse look for whole screen
touchcontrols::Mouse *mouse = new touchcontrols::Mouse("mouse", touchcontrols::RectF(3, 0, 26, 16), "");
mouse->signal_action.connect(sigc::ptr_fun(&mouseMove));
mouse->signal_double_tap.connect(sigc::ptr_fun(&right_double_tap));
Mouse *mouse = new Mouse("mouse", RectF(3, 0, 26, 16), "");
mouse->signal_action.connect(sigc::ptr_fun(&callbacks::look));
mouse->signal_double_tap.connect(sigc::ptr_fun(&callbacks::right_double_tap));
mouse->setHideGraphics(true);
tcGameMain->addControl(mouse);
tcGameMain->signal_button.connect(sigc::ptr_fun(&gameButton));
tcGameMain->signal_settingsButton.connect(sigc::ptr_fun(&gameSettingsButton));
///////////////////////// AUTO MAP SCREEN ///////////////////////
tcGameMain->signal_button.connect(sigc::ptr_fun(&callbacks::in_game));
// Automap
touchcontrols::MultitouchMouse *multimouse =
new touchcontrols::MultitouchMouse("gamemouse", touchcontrols::RectF(0, 0, 26, 16), "");
MultitouchMouse *multimouse = new MultitouchMouse("gamemouse", RectF(0, 0, 26, 16), "");
multimouse->setHideGraphics(true);
tcAutomap->addControl(multimouse);
multimouse->signal_action.connect(sigc::ptr_fun(&automap_multitouch_mouse_move));
multimouse->signal_action.connect(sigc::ptr_fun(&callbacks::automap_multitouch_mouse_move));
tcAutomap->addControl(map_button);
tcAutomap->signal_button.connect(sigc::ptr_fun(&gameButton));
tcAutomap->signal_button.connect(sigc::ptr_fun(&callbacks::in_game));
tcAutomap->setAlpha(0.5);
// Now inventory in the weapons control group!
inv_buttons[GET_JETPACK] = new touchcontrols::Button("jetpack", touchcontrols::RectF(0, 3, 2, 5), "jetpack",
gamefunc_Jetpack, false, false, true);
inv_buttons[GET_FIRSTAID] = new touchcontrols::Button("medkit", touchcontrols::RectF(0, 5, 2, 7), "medkit",
gamefunc_MedKit, false, false, true);
inv_buttons[GET_HEATS] = new touchcontrols::Button("nightv", touchcontrols::RectF(0, 7, 2, 9), "nightvision",
gamefunc_NightVision, false, false, true);
inv_buttons[GET_HOLODUKE] = new touchcontrols::Button("holoduke", touchcontrols::RectF(0, 9, 2, 11), "holoduke",
gamefunc_Holo_Duke, false, false, true);
inv_buttons[GET_STEROIDS] = new touchcontrols::Button("steroids", touchcontrols::RectF(0, 11, 2, 13), "steroids",
gamefunc_Steroids, false, false, true);
inv_buttons[GET_JETPACK] = new Button("jetpack", RectF(0, 3, 2, 5), "jetpack", gamefunc_Jetpack, false, false, true);
inv_buttons[GET_FIRSTAID] = new Button("medkit", RectF(0, 5, 2, 7), "medkit", gamefunc_MedKit, false, false, true);
inv_buttons[GET_HEATS] = new Button("nightv", RectF(0, 7, 2, 9), "nightvision", gamefunc_NightVision, false, false, true);
inv_buttons[GET_HOLODUKE] = new Button("holoduke", RectF(0, 9, 2, 11), "holoduke", gamefunc_Holo_Duke, false, false, true);
inv_buttons[GET_STEROIDS] = new Button("steroids", RectF(0, 11, 2, 13), "steroids", gamefunc_Steroids, false, false, true);
tcGameWeapons->addControl(inv_buttons[GET_JETPACK]);
tcGameWeapons->addControl(inv_buttons[GET_FIRSTAID]);
tcGameWeapons->addControl(inv_buttons[GET_HEATS]);
tcGameWeapons->addControl(inv_buttons[GET_HOLODUKE]);
tcGameWeapons->addControl(inv_buttons[GET_STEROIDS]);
// tcGameWeapons->addControl(inv_button);
// Inventory are the only buttons so safe to do this
tcGameWeapons->signal_button.connect(sigc::ptr_fun(&inventoryButton));
tcGameWeapons->signal_button.connect(sigc::ptr_fun(&callbacks::inv_button));
// Weapons
weaponWheel =
new touchcontrols::WheelSelect("weapon_wheel", touchcontrols::RectF(7, 2, 19, 14), "weapon_wheel_orange_blank", 10);
weaponWheel->signal_selected.connect(sigc::ptr_fun(&weaponWheelChosen));
weaponWheel->signal_enabled.connect(sigc::ptr_fun(&weaponWheelSelected));
weaponWheel = new WheelSelect("weapon_wheel", RectF(7, 2, 19, 14), "weapon_wheel_orange_blank", 10);
weaponWheel->signal_selected.connect(sigc::ptr_fun(&callbacks::select_weapon));
weaponWheel->signal_enabled.connect(sigc::ptr_fun(&callbacks::show_wheel));
tcGameWeapons->addControl(weaponWheel);
tcGameWeapons->setAlpha(0.9);
/////////////////////////////////////////////////////////////
controlsContainer.addControlGroup(tcMenuMain);
controlsContainer.addControlGroup(tcBackButton);
controlsContainer.addControlGroup(tcGameMain);
// controlsContainer.addControlGroup(tcInventory);//Need to be above tcGameMain incase buttons over stick
controlsContainer.addControlGroup(tcGameWeapons);
controlsContainer.addControlGroup(tcAutomap);
controlsContainer.addControlGroup(tcYesNo);
controlsContainer.addControlGroup(tcBlankTap);
controlsCreated = 1;
tcGameMain->setAlpha(droidinput.gameControlsAlpha);
controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha;
tcGameWeapons->setAlpha(droidinput.gameControlsAlpha);
tcMenuMain->setAlpha(droidinput.gameControlsAlpha);
tcBackButton->setAlpha(droidinput.gameControlsAlpha);
tcGameMain->setXMLFile(gamePath + "/control_layout_main.xml");
tcGameWeapons->setXMLFile(gamePath + "/control_layout_weapons.xml");
tcAutomap->setXMLFile(gamePath + "/control_layout_automap.xml");
// tcInventory->setXMLFile((std::string)graphics_path + "/inventory.xml");
setControlsContainer(&controlsContainer);
// controlsContainer.initGL();
controlsCreated = true;
}
void updateTouchScreenMode(touchscreemode_t mode)
@ -577,21 +484,23 @@ void updateTouchScreenMode(touchscreemode_t mode)
break;
case TOUCH_SCREEN_YES_NO:
tcYesNo->resetOutput();
tcYesNo->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
tcYesNo->setEnabled(false);
break;
case TOUCH_SCREEN_MENU_NOBACK:
tcBackButton->fade(FADE_IN, DEFAULT_FADE_FRAMES);
case TOUCH_SCREEN_MENU:
tcMenuMain->resetOutput();
tcMenuMain->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
tcMenuMain->fade(FADE_OUT, DEFAULT_FADE_FRAMES);
break;
case TOUCH_SCREEN_GAME:
tcGameMain->resetOutput();
tcGameMain->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
tcGameMain->fade(FADE_OUT, DEFAULT_FADE_FRAMES);
tcGameWeapons->setEnabled(false);
break;
case TOUCH_SCREEN_AUTOMAP:
tcAutomap->resetOutput();
tcAutomap->fade(touchcontrols::FADE_OUT, DEFAULT_FADE_FRAMES);
tcAutomap->fade(FADE_OUT, DEFAULT_FADE_FRAMES);
break;
case TOUCH_SCREEN_CONSOLE: break;
}
@ -603,23 +512,26 @@ void updateTouchScreenMode(touchscreemode_t mode)
case TOUCH_SCREEN_BLANK_TAP: tcBlankTap->setEnabled(true); break;
case TOUCH_SCREEN_YES_NO:
tcYesNo->setEnabled(true);
tcYesNo->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
tcYesNo->fade(FADE_IN, DEFAULT_FADE_FRAMES);
break;
case TOUCH_SCREEN_MENU_NOBACK:
tcBackButton->fade(FADE_OUT, DEFAULT_FADE_FRAMES);
case TOUCH_SCREEN_MENU:
tcMenuMain->setEnabled(true);
tcMenuMain->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
tcMenuMain->fade(FADE_IN, DEFAULT_FADE_FRAMES);
// This is a bit of a hack, we need to enable the inventory buttons so they can be edited, they will not
// be seen anyway
break;
case TOUCH_SCREEN_GAME:
tcGameMain->setEnabled(true);
tcGameMain->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
tcGameMain->fade(FADE_IN, DEFAULT_FADE_FRAMES);
tcGameWeapons->setEnabled(true);
break;
case TOUCH_SCREEN_AUTOMAP:
tcAutomap->setEnabled(true);
tcAutomap->fade(touchcontrols::FADE_IN, DEFAULT_FADE_FRAMES);
tcAutomap->fade(FADE_IN, DEFAULT_FADE_FRAMES);
break;
case TOUCH_SCREEN_CONSOLE: break;
}
@ -627,16 +539,19 @@ void updateTouchScreenMode(touchscreemode_t mode)
lastMode = mode;
}
int inv = PortableRead(READ_INVENTORY);
int inv = AndroidRead(R_PLAYER_INV_AMOUNT);
for (int i = 0; i < GET_MAX; ++i)
if (inv_buttons[i])
inv_buttons[i]->setAlpha(tcGameWeapons->getFadedAlpha() * ((inv & (1 << i)) ? 1.f : 0.3f));
backButtonEnabled = !tcBlankTap->enabled && mode != TOUCH_SCREEN_MENU_NOBACK;
tcBackButton->setEnabled(backButtonEnabled);
}
extern char videomodereset;
void frameControls()
void AndroidDrawControls()
{
static int loadedGLImages = 0;
@ -654,47 +569,34 @@ void frameControls()
loadedGLImages = 1;
}
// LOGI("frameControls");
curRenderer = (PortableRead(READ_RENDERER) != REND_CLASSIC);
// LOGI("AndroidDrawControls");
if (!controlsCreated)
return;
updateTouchScreenMode((touchscreemode_t)PortableRead(READ_SCREEN_MODE));
updateTouchScreenMode((touchscreemode_t)AndroidRead(R_TOUCH_MODE));
setHideSticks(droidinput.hideStick);
if (touchJoyLeft)
touchJoyLeft->setHideGraphics(droidinput.hideStick);
if (tcGameMain)
{
tcGameMain->setAlpha(droidinput.gameControlsAlpha);
controlsContainer.editButtonAlpha = droidinput.gameControlsAlpha;
if (tcGameWeapons)
tcGameWeapons->setAlpha(droidinput.gameControlsAlpha);
if (tcMenuMain)
tcMenuMain->setAlpha(droidinput.gameControlsAlpha);
}
if (tcBackButton)
tcBackButton->setAlpha(droidinput.gameControlsAlpha);
controlsContainer.draw();
if (controlsContainer.editingControls)
tcBackButton->draw();
}
void setTouchSettings(int other)
{
// TODO: defined names for these values
hasTouch = other & 0x4000 ? true : false;
hideTouchControls = other & 0x8000 ? true : false;
hwScaling = other & 0x10000 ? true : false;
// keep in sync with Duke3d/res/values/strings.xml
int doubletap_options[4] = { -1, gamefunc_Quick_Kick, gamefunc_MedKit, gamefunc_Jetpack };
droidinput.left_double_action = doubletap_options[((other >> 4) & 0xF)];
droidinput.right_double_action = doubletap_options[((other >> 8) & 0xF)];
LOGI("setTouchSettings left_double_action = %d", droidinput.left_double_action);
}
#define EXPORT_ME __NDK_FPABI__ __attribute__((visibility("default")))
@ -715,8 +617,6 @@ jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_init(JNIEnv *env, jobj
droidinfo.audio_sample_rate = audio_rate;
droidinfo.audio_buffer_size = audio_buffer_size;
curRenderer = REND_GL;
argv[0] = "eduke32";
int argCount = (env)->GetArrayLength(argsArray);
LOGI("argCount = %d", argCount);
@ -742,9 +642,10 @@ jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_init(JNIEnv *env, jobj
LOGI("obbPath = %s", obbPath.c_str());
if (hasTouch)
initControls(droidinfo.screen_width, droidinfo.screen_height, (obbPath + "/assets/").c_str());
AndroidTouchInit(droidinfo.screen_width, droidinfo.screen_height, (obbPath + "/assets/").c_str());
else LOGI("skipping touch input");
PortableInit(argc, argv);
main(argc, (char **)argv);
return 0;
}
@ -769,15 +670,19 @@ Java_com_voidpoint_duke3d_engine_NativeLib_keyPress(JNIEnv *env, jobject obj, ji
return;
}
PortableKeyEvent(down, keycode, unicode);
AndroidKeyEvent(down, keycode, unicode);
}
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_touchEvent(JNIEnv *env, jobject obj, jint action, jint pid,
jfloat x, jfloat y)
{
if (tcBackButton && backButtonEnabled)
tcBackButton->processPointer(action, pid, x, y);
// LOGI("TOUCHED");
controlsContainer.processPointer(action, pid, x, y);
}
@ -795,23 +700,34 @@ void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_doAction(JNIEnv *env,
tcGameWeapons->setEnabled(false);
}
PortableAction(state, action);
AndroidAction(state, action);
}
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogMove(JNIEnv *env, jobject obj, jfloat fwd, jfloat strafe)
{
PortableMove(fwd, strafe);
AndroidMove(fwd, strafe);
}
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_analogLook(JNIEnv *env, jobject obj, jfloat pitch, jfloat yaw)
{
PortableLookJoystick(yaw, pitch);
AndroidLookJoystick(yaw, pitch);
}
void EXPORT_ME
Java_com_voidpoint_duke3d_engine_NativeLib_setTouchSettings(JNIEnv *env, jobject obj, int other)
{
setTouchSettings(other);
// TODO: defined names for these values
hasTouch = other & 0x4000 ? true : false;
hideTouchControls = other & 0x8000 ? true : false;
hwScaling = other & 0x10000 ? true : false;
// keep in sync with Duke3d/res/values/strings.xml
int doubletap_options[4] ={ -1, gamefunc_Quick_Kick, gamefunc_MedKit, gamefunc_Jetpack };
droidinput.left_double_action = doubletap_options[((other >> 4) & 0xF)];
droidinput.right_double_action = doubletap_options[((other >> 8) & 0xF)];
LOGI("setTouchSettings left_double_action = %d", droidinput.left_double_action);
}
void EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_resetTouchSettings(JNIEnv *env, jobject obj)
@ -826,7 +742,7 @@ jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_quickCommand(JNIEnv *e
const char *p = env->GetStringUTFChars(command, NULL);
quickCommandString = std::string(p) + "\n";
env->ReleaseStringUTFChars(command, p);
PortableCommand(quickCommandString.c_str());
AndroidOSD(quickCommandString.c_str());
}
void EXPORT_ME
@ -836,6 +752,8 @@ Java_com_voidpoint_duke3d_engine_NativeLib_setScreenSize(JNIEnv *env, jobject th
droidinfo.screen_height = height;
}
extern void SDL_Android_Init(JNIEnv *env, jclass cls);
void EXPORT_ME Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv *env, jclass cls)
{
/* This interface could expand with ABI negotiation, calbacks, etc. */
@ -844,29 +762,4 @@ void EXPORT_ME Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv *env, jclass cl
// SDL_EventState(SDL_TEXTINPUT,SDL_ENABLE);
}
jstring EXPORT_ME
Java_com_voidpoint_duke3d_engine_NativeLib_getSaveText(JNIEnv *env, jobject obj, jstring jfile, jint type)
{
const char *p = env->GetStringUTFChars(jfile, NULL);
jstring ret = env->NewStringUTF(G_GetStringFromSavegame(p, type));
env->ReleaseStringUTFChars(jfile, p);
return ret;
}
jint EXPORT_ME Java_com_voidpoint_duke3d_engine_NativeLib_getScreenshot(JNIEnv *env, jobject obj, jstring jfile,
jobject jpal, jobject jdataOut)
{
const char *p = env->GetStringUTFChars(jfile, NULL);
jbyte *bb = (jbyte *)env->GetDirectBufferAddress(jdataOut);
jbyte *pb = (jbyte *)env->GetDirectBufferAddress(jpal);
int ret = G_GetScreenshotFromSavegame(p, (char *)pb, (char *)bb);
env->ReleaseStringUTFChars(jfile, p);
return ret;
}
}

View file

@ -57,17 +57,15 @@ extern int SDL_SendMouseButton(SDL_Window * window, Uint32 mouseID, Uint8 state,
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO,"DUKE", __VA_ARGS__))
extern int32_t main(int32_t argc, char *argv []);
static char sdl_text[2];
droidinput_t droidinput;
int PortableTimer(int tics) { G_InitTimer(tics); }
int AndroidTimer(int tics) { G_InitTimer(tics); }
int PortableKeyEvent(int state, int code,int unicode)
int AndroidKeyEvent(int state, int code,int unicode)
{
LOGI("PortableKeyEvent %d %d %d",state,(SDL_Scancode)code,unicode);
LOGI("AndroidKeyEvent %d %d %d",state,(SDL_Scancode)code,unicode);
SDL_SendKeyboardKey(state ? SDL_PRESSED : SDL_RELEASED, (SDL_Scancode)code);
SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
@ -86,18 +84,18 @@ int PortableKeyEvent(int state, int code,int unicode)
}
if (state == 2)
PortableKeyEvent(0, code, unicode);
AndroidKeyEvent(0, code, unicode);
}
return 0;
}
void PortableMouseMenu(float x,float y)
void AndroidMouseMenu(float x,float y)
{
SDL_SendMouseMotion(NULL,0,0,x,y);
}
void PortableMouseMenuButton(int state,int button)
void AndroidMouseMenuButton(int state,int button)
{
SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, state?SDL_PRESSED:SDL_RELEASED, SDL_BUTTON_LEFT);
}
@ -116,23 +114,20 @@ void changeActionState(int state, int action)
droidinput.functionHeld &= ~((uint64_t) 1<<((uint64_t) (action)));
}
void PortableAction(int state, int action)
void AndroidAction(int state, int action)
{
LOGI("PortableAction action = %d, state = %d", action, state);
LOGI("AndroidAction action = %d, state = %d", action, state);
if (action >= MENU_UP && action <= MENU_BACK)
{
// if (PortableRead(READ_SCREEN_MODE) == TOUCH_SCREEN_MENU)
{
int const sdl_code [] = { SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT,
SDL_SCANCODE_RIGHT, SDL_SCANCODE_RETURN, SDL_SCANCODE_ESCAPE };
PortableKeyEvent(state, sdl_code[action-MENU_UP], 0);
AndroidKeyEvent(state, sdl_code[action-MENU_UP], 0);
return;
}
}
else
{
//if (PortableRead(READ_SCREEN_MODE) != TOUCH_SCREEN_GAME) //If not in game don't do any of this
//if (AndroidRead(READ_SCREEN_MODE) != TOUCH_SCREEN_GAME) //If not in game don't do any of this
/// return;
//Special toggle for crouch, NOT when using jetpack or in water
@ -145,7 +140,7 @@ void PortableAction(int state, int action)
droidinput.crouchToggleState = 0;
if (action == gamefunc_Crouch)
state = 0;
else PortableAction(0, gamefunc_Crouch);
else AndroidAction(0, gamefunc_Crouch);
}
if (action == gamefunc_Crouch)
@ -177,9 +172,9 @@ void PortableAction(int state, int action)
changeActionState(state, action);
if (state == 2)
PortableAction(0, action);
AndroidAction(0, action);
// LOGI("PortableAction state = 0x%016llX", CONTROL_ButtonState);
// LOGI("AndroidAction state = 0x%016llX", CONTROL_ButtonState);
}
}
@ -196,7 +191,7 @@ float analogCalibrate(float v)
}
//Need these NAN check as not cumulative.
void PortableMove(float fwd, float strafe)
void AndroidMove(float fwd, float strafe)
{
if (!ud.auto_run)
{
@ -211,13 +206,13 @@ void PortableMove(float fwd, float strafe)
droidinput.sidemove = fclamp2(analogCalibrate(strafe), -1.f, 1.f);
}
void PortableLook(float yaw, float pitch)
void AndroidLook(float yaw, float pitch)
{
droidinput.pitch += pitch;
droidinput.yaw += yaw;
}
void PortableLookJoystick(float yaw, float pitch)
void AndroidLookJoystick(float yaw, float pitch)
{
if (!isnan(pitch))
droidinput.pitch_joystick = analogCalibrate(pitch);
@ -226,16 +221,11 @@ void PortableLookJoystick(float yaw, float pitch)
droidinput.yaw_joystick = analogCalibrate(yaw);
}
void PortableCommand(const char * cmd)
void AndroidOSD(const char * cmd)
{
OSD_Dispatch(cmd);
}
void PortableInit(int argc, const char ** argv)
{
main(argc, ( char **)argv);
}
int consoleShown = 0;
void AndroidSetConsoleShown(int onf)
{
@ -243,49 +233,49 @@ void AndroidSetConsoleShown(int onf)
}
extern int inExtraScreens; //In game.c
int32_t PortableRead(portableread_t r)
int32_t AndroidRead(portableread_t r)
{
int32_t rv;
switch (r)
{
case READ_SCREEN_MODE:
case R_TOUCH_MODE:
if (g_animPtr || inExtraScreens)
rv = TOUCH_SCREEN_BLANK_TAP;
else if (consoleShown)
rv = TOUCH_SCREEN_CONSOLE;
else if ((g_player[myconnectindex].ps->gm & MODE_MENU) == MODE_MENU)
else if ((g_player[myconnectindex].ps->gm & MODE_MENU) == MODE_MENU && g_currentMenu != MENU_MAIN)
rv = (m_currentMenu->type == Verify) ? TOUCH_SCREEN_YES_NO : TOUCH_SCREEN_MENU;
else if ((g_player[myconnectindex].ps->gm & MODE_MENU) == MODE_MENU && g_currentMenu == MENU_MAIN)
rv = TOUCH_SCREEN_MENU_NOBACK;
/*
else if (ud.overhead_on == 2)
rv = TOUCH_SCREEN_AUTOMAP;
*/
else if ((g_player[myconnectindex].ps->gm & MODE_GAME))
if (PortableRead(READ_IS_DEAD))
if (AndroidRead(R_PLAYER_DEAD_FLAG))
rv = TOUCH_SCREEN_BLANK_TAP;
else
rv = TOUCH_SCREEN_GAME;
else
rv = TOUCH_SCREEN_BLANK_TAP;
break;
case READ_WEAPONS:
case R_PLAYER_GOTWEAPON:
rv = g_player[myconnectindex].ps->gotweapon; break;
case READ_AUTOMAP:
case R_UD_OVERHEAD_ON:
rv = 0; break;//ud.overhead_on != 0; break;// ud.overhead_on ranges from 0-2
case READ_MAPFOLLOWMODE:
case R_UD_SCROLLMODE:
rv = ud.scrollmode; break;
case READ_RENDERER:
rv = getrendermode(); break;
case READ_LASTWEAPON:
case R_PLAYER_LASTWEAPON:
rv = droidinput.lastWeapon;
if ((unsigned)rv < MAX_WEAPONS && !g_player[myconnectindex].ps->ammo_amount[rv])
rv = -1;
break;
case READ_PAUSED:
case R_GAME_PAUSED:
rv = ud.pause_on != 0; break;
case READ_IS_DEAD:
case R_PLAYER_DEAD_FLAG:
rv = g_player[myconnectindex].ps->dead_flag; break;
case READ_INVENTORY:
case R_PLAYER_INV_AMOUNT:
rv = 0;
for (int i = 0; i < GET_MAX; i++)
{
@ -293,7 +283,7 @@ int32_t PortableRead(portableread_t r)
rv += (1 << i);
}
break;
case READ_SOMETHINGONPLAYER:
case R_SOMETHINGONPLAYER:
rv = g_player[myconnectindex].ps->somethingonplayer != -1;
break;
default:
@ -305,7 +295,7 @@ int32_t PortableRead(portableread_t r)
static float map_zoom,map_dx,map_dy = 0;
void PortableAutomapControl(float zoom,float dx,float dy)
void AndroidAutomapControl(float zoom,float dx,float dy)
{
map_zoom += zoom;
map_dx += dx;

View file

@ -40,16 +40,15 @@ extern "C"
#define MINCONTROLALPHA 0.25f
typedef enum {
READ_SCREEN_MODE,
READ_WEAPONS,
READ_AUTOMAP,
READ_MAPFOLLOWMODE,
READ_RENDERER,
READ_LASTWEAPON,
READ_PAUSED,
READ_IS_DEAD,
READ_INVENTORY,
READ_SOMETHINGONPLAYER
R_TOUCH_MODE,
R_PLAYER_GOTWEAPON,
R_UD_OVERHEAD_ON,
R_UD_SCROLLMODE,
R_PLAYER_LASTWEAPON,
R_GAME_PAUSED,
R_PLAYER_DEAD_FLAG,
R_PLAYER_INV_AMOUNT,
R_SOMETHINGONPLAYER
} portableread_t;
@ -57,7 +56,8 @@ typedef enum {
TOUCH_SCREEN_BLANK, //Nothing on screen (not used)
TOUCH_SCREEN_BLANK_TAP, //One button filling screen with no graphic, tap to send Enter key
TOUCH_SCREEN_YES_NO, //Yes/No buttons on screen, sends Enter or Esc
TOUCH_SCREEN_MENU, //Normal Menu arrows and Enter Esc keys
TOUCH_SCREEN_MENU, //Normal menu
TOUCH_SCREEN_MENU_NOBACK, // menu without back button
TOUCH_SCREEN_GAME, //Normal game screen
TOUCH_SCREEN_AUTOMAP, //When auto map is up (not used yet)
TOUCH_SCREEN_CONSOLE //When Console is up
@ -100,27 +100,25 @@ typedef struct
extern droidinput_t droidinput;
extern droidsysinfo_t droidinfo;
int PortableTimer(int tics);
int PortableKeyEvent(int state, int code, int unicode);
int PortableRead(portableread_t r);
int AndroidTimer(int tics);
int AndroidKeyEvent(int state, int code, int unicode);
int AndroidRead(portableread_t r);
void PortableAction(int state, int action);
void AndroidAction(int state, int action);
void PortableMouseMenu(float x,float y);
void PortableMouseMenuButton(int state,int button);
void AndroidMouseMenu(float x,float y);
void AndroidMouseMenuButton(int state,int button);
void PortableMove(float fwd, float strafe);
void PortableLook(float yaw, float pitch);
void PortableLookJoystick(float yaw, float pitch);
void PortableCommand(const char * cmd);
void AndroidMove(float fwd, float strafe);
void AndroidLook(float yaw, float pitch);
void AndroidLookJoystick(float yaw, float pitch);
void AndroidOSD(const char * cmd);
void PortableAutomapControl(float zoom,float dx,float dy);
void PortableInit(int argc, const char ** argv);
void AndroidAutomapControl(float zoom,float dx,float dy);
void AndroidShowKeyboard(int onf);
void AndroidToggleButtonEditor(void);
#ifdef __cplusplus
}
#endif

View file

@ -416,6 +416,8 @@ MAKE_MENU_TOP_ENTRYLINK( "Mouse Setup", MEF_CenterMenu, OPTIONS_MOUSESETUP, MENU
MAKE_MENU_TOP_ENTRYLINK( "Joystick Setup", MEF_CenterMenu, OPTIONS_JOYSTICKSETUP, MENU_JOYSTICKSETUP );
#ifdef DROIDMENU
MAKE_MENU_TOP_ENTRYLINK( "Touch Setup", MEF_CenterMenu, OPTIONS_TOUCHSETUP, MENU_TOUCHSETUP );
MAKE_MENU_TOP_ENTRYLINK( "Touch Sensitivity", MEF_CenterMenu, OPTIONS_TOUCHSENS, MENU_TOUCHSENS);
MAKE_MENU_TOP_ENTRYLINK( "Touch Buttons", MEF_CenterMenu, OPTIONS_TOUCHBUTTONS, MENU_TOUCHBUTTONS);
#endif
static int32_t newresolution, newrendermode, newfullscreen, newvsync;
@ -480,7 +482,9 @@ static MenuOption_t MEO_DISPLAYSETUP_ASPECTRATIO = MAKE_MENUOPTION(&MF_Redfont,
#else
static MenuOption_t MEO_DISPLAYSETUP_ASPECTRATIO = MAKE_MENUOPTION(&MF_Redfont, &MEOS_OffOn, &r_usenewaspect);
#endif
#ifndef DROIDMENU
static MenuEntry_t ME_DISPLAYSETUP_ASPECTRATIO = MAKE_MENUENTRY( "Widescreen:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_DISPLAYSETUP_ASPECTRATIO, Option );
#endif
#ifdef POLYMER
static char const *MEOSN_DISPLAYSETUP_ASPECTRATIO_POLYMER[] = { "Auto", "4:3", "16:10", "5:3", "16:9", "1.85:1", "2.39:1", };
static double MEOSV_DISPLAYSETUP_ASPECTRATIO_POLYMER[] = { 0., 1.33, 1.6, 1.66, 1.78, 1.85, 2.39, };
@ -645,8 +649,8 @@ static MenuEntry_t *MEL_DISPLAYSETUP[] = {
&ME_DISPLAYSETUP_COLORCORR,
#ifndef DROIDMENU
&ME_DISPLAYSETUP_VIDEOSETUP,
#endif
&ME_DISPLAYSETUP_ASPECTRATIO,
#endif
&ME_DISPLAYSETUP_PIXELDOUBLING,
};
@ -656,8 +660,8 @@ static MenuEntry_t *MEL_DISPLAYSETUP_GL[] = {
&ME_DISPLAYSETUP_COLORCORR,
#ifndef DROIDMENU
&ME_DISPLAYSETUP_VIDEOSETUP,
#endif
&ME_DISPLAYSETUP_ASPECTRATIO,
#endif
&ME_DISPLAYSETUP_TEXFILTER,
#ifdef DROIDMENU
&ME_DISPLAYSETUP_HIDEDPAD,
@ -675,8 +679,8 @@ static MenuEntry_t *MEL_DISPLAYSETUP_GL_POLYMER[] = {
&ME_DISPLAYSETUP_COLORCORR,
#ifndef DROIDMENU
&ME_DISPLAYSETUP_VIDEOSETUP,
#endif
&ME_DISPLAYSETUP_ASPECTRATIO_POLYMER,
#endif
&ME_DISPLAYSETUP_TEXFILTER,
#ifndef DROIDMENU
&ME_DISPLAYSETUP_ANISOTROPY,
@ -779,21 +783,29 @@ static MenuEntry_t *MEL_MOUSESETUP[] = {
#ifdef DROIDMENU
static MenuRangeFloat_t MEO_TOUCHSETUP_SENSITIVITY_MOVE = MAKE_MENURANGE(&droidinput.forward_sens, &MF_Redfont, 1.f, 9.f, 0.f, 17, 1 + EnforceIntervals);
static MenuEntry_t ME_TOUCHSETUP_SENSITIVITY_MOVE = MAKE_MENUENTRY("Run sens:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_TOUCHSETUP_SENSITIVITY_MOVE, RangeFloat);
static MenuEntry_t ME_TOUCHSETUP_SENSITIVITY_MOVE = MAKE_MENUENTRY("Running:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_TOUCHSETUP_SENSITIVITY_MOVE, RangeFloat);
static MenuRangeFloat_t MEO_TOUCHSETUP_SENSITIVITY_STRAFE = MAKE_MENURANGE(&droidinput.strafe_sens, &MF_Redfont, 1.f, 9.f, 0.f, 17, 1 + EnforceIntervals);
static MenuEntry_t ME_TOUCHSETUP_SENSITIVITY_STRAFE = MAKE_MENUENTRY("Strafe sens:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_TOUCHSETUP_SENSITIVITY_STRAFE, RangeFloat);
static MenuEntry_t ME_TOUCHSETUP_SENSITIVITY_STRAFE = MAKE_MENUENTRY("Strafing:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_TOUCHSETUP_SENSITIVITY_STRAFE, RangeFloat);
static MenuRangeFloat_t MEO_TOUCHSETUP_SENSITIVITY_LOOK = MAKE_MENURANGE(&droidinput.pitch_sens, &MF_Redfont, 1.f, 9.f, 0.f, 17, 1 + EnforceIntervals);
static MenuEntry_t ME_TOUCHSETUP_SENSITIVITY_LOOK = MAKE_MENUENTRY("Look sens:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_TOUCHSETUP_SENSITIVITY_LOOK, RangeFloat);
static MenuEntry_t ME_TOUCHSETUP_SENSITIVITY_LOOK = MAKE_MENUENTRY("Looking:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_TOUCHSETUP_SENSITIVITY_LOOK, RangeFloat);
static MenuRangeFloat_t MEO_TOUCHSETUP_SENSITIVITY_TURN = MAKE_MENURANGE(&droidinput.yaw_sens, &MF_Redfont, 1.f, 9.f, 0.f, 17, 1 + EnforceIntervals);
static MenuEntry_t ME_TOUCHSETUP_SENSITIVITY_TURN = MAKE_MENUENTRY("Turn sens:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_TOUCHSETUP_SENSITIVITY_TURN, RangeFloat);
static MenuEntry_t ME_TOUCHSETUP_SENSITIVITY_TURN = MAKE_MENUENTRY("Turning:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_TOUCHSETUP_SENSITIVITY_TURN, RangeFloat);
static MenuOption_t MEO_TOUCHSETUP_INVERT = MAKE_MENUOPTION(&MF_Redfont, &MEOS_NoYes, &droidinput.invertLook);
static MenuEntry_t ME_TOUCHSETUP_INVERT = MAKE_MENUENTRY("Invert look:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_TOUCHSETUP_INVERT, Option);
MAKE_MENU_TOP_ENTRYLINK("Sensitivity", MEF_CenterMenu, TOUCHSENS, MENU_TOUCHSENS);
MAKE_MENU_TOP_ENTRYLINK("Button Setup", MEF_CenterMenu, TOUCHBUTTONS, MENU_TOUCHBUTTONS);
static MenuEntry_t *MEL_TOUCHSETUP [] ={
&ME_TOUCHSENS,
&ME_TOUCHBUTTONS,
};
static MenuEntry_t *MEL_TOUCHSENS [] ={
&ME_TOUCHSETUP_SENSITIVITY_MOVE,
&ME_TOUCHSETUP_SENSITIVITY_STRAFE,
&ME_TOUCHSETUP_SENSITIVITY_LOOK,
@ -801,6 +813,9 @@ static MenuEntry_t *MEL_TOUCHSETUP [] ={
&ME_Space2,
&ME_TOUCHSETUP_INVERT,
};
static MenuEntry_t *MEL_TOUCHBUTTONS [] ={
};
#endif
MAKE_MENU_TOP_ENTRYLINK( "Edit Buttons", MEF_CenterMenu, JOYSTICK_EDITBUTTONS, MENU_JOYSTICKBTNS );
@ -1219,7 +1234,9 @@ static MenuMenu_t M_CONTROLS = MAKE_MENUMENU( "Control Setup", &MMF_Top_Options,
static MenuMenu_t M_CHEATS = MAKE_MENUMENU( "Cheats", &MMF_SmallOptions, MEL_CHEATS );
static MenuMenu_t M_MOUSESETUP = MAKE_MENUMENU( "Mouse Setup", &MMF_BigOptions, MEL_MOUSESETUP );
#ifdef DROIDMENU
static MenuMenu_t M_TOUCHSETUP = MAKE_MENUMENU( "Touch Setup", &MMF_BigOptions, MEL_TOUCHSETUP );
static MenuMenu_t M_TOUCHSETUP = MAKE_MENUMENU( "Touch Setup", &MMF_Top_Options, MEL_TOUCHSETUP );
static MenuMenu_t M_TOUCHSENS = MAKE_MENUMENU( "Sensitivity", &MMF_BigOptions, MEL_TOUCHSENS);
static MenuMenu_t M_TOUCHBUTTONS = MAKE_MENUMENU("Button Setup", &MMF_BigOptions, MEL_TOUCHBUTTONS);
#endif
static MenuMenu_t M_JOYSTICKSETUP = MAKE_MENUMENU( "Joystick Setup", &MMF_Top_Joystick_Network, MEL_JOYSTICKSETUP );
static MenuMenu_t M_JOYSTICKBTNS = MAKE_MENUMENU( "Joystick Buttons", &MMF_MouseJoySetupBtns, MEL_JOYSTICKBTNS );
@ -1311,6 +1328,8 @@ static Menu_t Menus[] = {
{ &M_JOYSTICKAXIS, MENU_JOYSTICKAXIS, MENU_JOYSTICKAXES, MA_Return, Menu },
#ifdef DROIDMENU
{ &M_TOUCHSETUP, MENU_TOUCHSETUP, MENU_OPTIONS, MA_Return, Menu },
{ &M_TOUCHSENS, MENU_TOUCHSENS, MENU_TOUCHSETUP, MA_Return, Menu },
{ &M_TOUCHBUTTONS, MENU_TOUCHBUTTONS, MENU_TOUCHSETUP, MA_Return, Menu },
#endif
{ &M_CONTROLS, MENU_CONTROLS, MENU_OPTIONS, MA_Return, Menu },
#ifdef USE_OPENGL
@ -2790,10 +2809,12 @@ static int32_t M_MenuEntryOptionModify(MenuEntry_t *entry, int32_t newOption)
gltexfiltermode = newOption ? TEXFILTER_ON : TEXFILTER_OFF;
gltexapplyprops();
}
#ifndef DROIDMENU
else if (entry == &ME_DISPLAYSETUP_ASPECTRATIO)
{
r_usenewaspect = newOption & 1;
}
#endif
#ifdef POLYMER
else if (entry == &ME_DISPLAYSETUP_ASPECTRATIO_POLYMER)
{
@ -3101,8 +3122,10 @@ static int32_t M_MenuEntryOptionSource(MenuEntry_t *entry, int32_t currentValue)
else if (entry == &ME_DISPLAYSETUP_TEXFILTER)
return gltexfiltermode;
*/
#ifndef DROIDMENU
else if (entry == &ME_DISPLAYSETUP_ASPECTRATIO)
return r_usenewaspect;
#endif
#ifdef POLYMER
else if (entry == &ME_DISPLAYSETUP_ASPECTRATIO_POLYMER)
return clamp(currentValue, 0, ARRAY_SIZE(MEOSV_DISPLAYSETUP_ASPECTRATIO_POLYMER)-1);
@ -3583,6 +3606,12 @@ int M_ChangeMenu(MenuID_t cm)
soundvoices = ud.config.NumVoices;
break;
#ifdef DROIDMENU
case MENU_TOUCHBUTTONS:
AndroidToggleButtonEditor();
break;
#endif
default:
break;
}

View file

@ -57,6 +57,8 @@ enum MenuIndex_t {
MENU_MOUSEADVANCED = 212,
MENU_JOYSTICKAXIS = 213,
MENU_TOUCHSETUP = 214,
MENU_TOUCHSENS = 215,
MENU_TOUCHBUTTONS = 216,
MENU_CONTROLS = 220,
MENU_POLYMOST = 230,
MENU_COLCORR = 231,

View file

@ -1,195 +0,0 @@
// All things old go here to keep the sources clean. To have a reference to the place
// in the code, place a marker like __SomeMarker__ in the source file, and refer to it
// by placing it as the first context line of the corresponding hunk.
Index: astub.c
==============================
+++ astub.c
--- astub.c
@@ -2118,1 +2118,37 @@
///__ShowHelpText__
+#if 0
+static void ShowHelpText(char *name)
+{
+ BFILE *fp;
+ char x=0,y=4;
+ UNREFERENCED_PARAMETER(name);
+ if ((fp=fopenfrompath("helpdoc.txt","rb")) == NULL)
+ {
+ begindrawing();
+ printext256(1*4,4*8,whitecol,-1,"ERROR: file not found.",0);
+ enddrawing();
+ return;
+ }
+ /*
+ Bfgets(tempbuf,80,fp);
+ while(!Bfeof(fp) && Bstrcmp(tempbuf,"SectorEffector"))
+ {
+ Bfgets(tempbuf,80,fp);
+ }
+ */
+ y=2;
+ Bfgets(tempbuf,80,fp);
+ Bstrcat(tempbuf,"\n");
+ begindrawing();
+ while (!Bfeof(fp) && !(Bstrcmp(tempbuf,"SectorEffector")==0))
+ {
+ Bfgets(tempbuf,80,fp);
+ Bstrcat(tempbuf,"\n");
+ printext256(x*4,(y*6)+2,whitecol,-1,tempbuf,1);
+ y++;
+ }
+ enddrawing();
+
+ Bfclose(fp);
+}// end ShowHelpText
+#endif
@@ -6777,1 +6777,34 @@
///__bigcomment__
+ /*
+ if ((totalclock > getmessagetimeoff) && (totalclock > (lastpm16time + 120*3)))
+ {
+ if (pointhighlight >= 16384)
+ {
+ char tmpbuf[2048];
+ i = pointhighlight-16384;
+ if (strlen(names[sprite[i].picnum]) > 0)
+ {
+ if (sprite[i].picnum==SECTOREFFECTOR)
+ Bsprintf(tmpbuf,"Sprite %d %s, hi:%d ex:%d",i,SectorEffectorText(i),sprite[i].hitag,sprite[i].extra);
+ else Bsprintf(tmpbuf,"Sprite %d %s: lo:%d hi:%d ex:%d",i,names[sprite[i].picnum],sprite[i].lotag,sprite[i].hitag,sprite[i].extra);
+ }
+ else Bsprintf(tmpbuf,"Sprite %d picnum %d: lo:%d hi:%d ex:%d",i,sprite[i].picnum,sprite[i].lotag,sprite[i].hitag,sprite[i].extra);
+ _printmessage16(tmpbuf);
+ }
+ else if ((linehighlight >= 0) && (sectorofwall(linehighlight) == cursectornum))
+ {
+ int32_t dax, day, dist;
+ dax = wall[linehighlight].x-wall[wall[linehighlight].point2].x;
+ day = wall[linehighlight].y-wall[wall[linehighlight].point2].y;
+ dist = ksqrt(dax*dax+day*day);
+ Bsprintf(tempbuf,"Wall %d: length:%d lo:%d hi:%d ex:%d",linehighlight,dist,wall[linehighlight].lotag,wall[linehighlight].hitag,wall[linehighlight].extra);
+ _printmessage16(tempbuf);
+ }
+ else if (cursectornum >= 0)
+ {
+ Bsprintf(tempbuf,"Sector %d: lo:%d hi:%d ex:%d",cursectornum,sector[cursectornum].lotag,sector[cursectornum].hitag,sector[cursectornum].extra);
+ _printmessage16(tempbuf);
+ }
+ else _printmessage16("");
+ }
+ */
@@ -6723,1 +6723,29 @@
///__old_sprite_search_1__
+#if 0
+ {
+ if (cursearchspritenum>0) cursearchspritenum--;
+ for (i=cursearchspritenum; i>=0; i--)
+ {
+
+ if (
+ (sprite[i].picnum==sprite[cursearchsprite].picnum &&
+ sprite[i].statnum==0)
+ &&((search_lotag==0)||
+ (search_lotag!=0 && search_lotag==sprite[i].lotag))
+ &&((search_hitag==0)||
+ (search_hitag!=0 && search_hitag==sprite[i].hitag))
+ )
+ {
+ pos.x=sprite[i].x;
+ pos.y=sprite[i].y;
+ ang= sprite[i].ang;
+ printmessage16("< Sprite search: found");
+ // curspritenum--;
+ keystatus[KEYSC_LBRACK]=0;
+ return;
+ }
+ cursearchspritenum--;
+ }
+ printmessage16("< Sprite search: none found");
+ }
+#endif
@@ -6757,1 +6757,27 @@
///__old_sprite_search_2__
+#if 0
+ {
+ if (cursearchspritenum<MAXSPRITES) cursearchspritenum++;
+ for (i=cursearchspritenum; i<=MAXSPRITES; i++)
+ {
+ if ((sprite[i].picnum==sprite[cursearchsprite].picnum &&
+ sprite[i].statnum==0)
+ &&((search_lotag==0)||
+ (search_lotag!=0 && search_lotag==sprite[i].lotag))
+ &&((search_hitag==0)||
+ (search_hitag!=0 && search_hitag==sprite[i].hitag))
+ )
+ {
+ pos.x=sprite[i].x;
+ pos.y=sprite[i].y;
+ ang= sprite[i].ang;
+ printmessage16("> Sprite search: found");
+ // curspritenum++;
+ keystatus[KEYSC_RBRACK]=0;
+ return;
+ }
+ cursearchspritenum++;
+ }
+ printmessage16("> Sprite search: none found");
+ }
+#endif
@@ -6840,1 +6840,37 @@
///__motorcycle__
+ /*
+ if (keystatus[KEYSC_QUOTE] && PRESSED_KEYSC(5)) // ' 5
+ {
+ sprintf(tempbuf,"Power-Up Ammo now equals Normal");
+ printmessage16(tempbuf);
+ for(i=0;i<MAXSPRITES;i++)
+ {
+ if(sprite[i].picnum>=20 && sprite[i].picnum<=59)
+ {
+ sprite[i].xrepeat = 32;
+ sprite[i].yrepeat = 32;
+ }
+ }
+
+ }
+ */
+
+ // What the fuck is this supposed to do?
+
+ /* Motorcycle ha ha ha
+ if (keystatus[KEYSC_QUOTE] && PRESSED_KEYSC(5)) // ' 5
+ {
+ sidemode++; if (sidemode > 2) sidemode = 0;
+ if (sidemode == 1)
+ {
+ editstatus = 0;
+ zmode = 2;
+ pos.z = ((sector[cursectnum].ceilingz+sector[cursectnum].floorz)>>1);
+ }
+ else
+ {
+ editstatus = 1;
+ zmode = 1;
+ }
+ }
+ */
@@ -5532,1 +5532,17 @@
///__unused_keys__
+ /* if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_G]) // ' g <Unused>
+ {
+ keystatus[KEYSC_G] = 0;
+ tabgraphic++;
+ if (tabgraphic > 2) tabgraphic = 0;
+ if (tabgraphic) message("Graphics ON");
+ else message("Graphics OFF");
+ }*/
+
+ /* if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_R]) // ' r <Handled already>
+ {
+ keystatus[KEYSC_R] = 0;
+ framerateon=!framerateon;
+ if (framerateon) message("Framerate ON");
+ else message("Framerate OFF");
+ }*/

View file

@ -2249,110 +2249,3 @@ static void postloadplayer(int32_t savegamep)
////////// END GENERIC SAVING/LOADING SYSTEM //////////
#ifdef __ANDROID__
#include <jni.h>
#include <android/log.h>
#ifndef LOGI
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO,"DUKE", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "DUKE", __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR,"DUKE", __VA_ARGS__))
#endif
char const * G_GetStringFromSavegame(const char *filename, int type)
{
LOGI("getSavegameText %s", filename);
int32_t fil = kopen4load(filename, 0);
if (fil == -1)
{
LOGE("couldn't load %s", filename);
return "";
}
savehead_t saveh;
int32_t i = sv_loadheader(fil, 0, &saveh);
if (i && (i != 2 && i != 3))
goto corrupt;
kclose(fil);
static char tempbuf[64];
switch (type)
{
case 0: Bstrncpyz(tempbuf, saveh.savename, sizeof(saveh.savename) - 1); break;
case 1: Bstrncpyz(tempbuf, saveh.volname, sizeof(saveh.volname) - 1); break;
case 2: Bstrncpyz(tempbuf, saveh.skillname, sizeof(saveh.skillname) - 1); break;
}
return tempbuf;
corrupt:
kclose(fil);
LOGE("couldn't load %s", filename);
return "";
}
int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char *data)
{
LOGI("getSavegameScreenshot %s", filename);
int32_t fil = kopen4load(filename, 0);
if (fil == -1)
return -1;
savehead_t saveh;
int32_t i = sv_loadheader(fil, 0, &saveh);
if (i && (i != 2 && i != 3))
goto corrupt;
int32_t screenshotofs;
if (kread(fil, &screenshotofs, 4) != 4)
goto corrupt;
if (screenshotofs)
{
if (kdfread(data, 320, 200, fil) != 200)
{
// OSD_Printf("G_LoadSaveHeaderNew(%d): failed reading screenshot\n", spot);
goto corrupt;
}
}
else
{
kclose(fil);
return -1;
}
kclose(fil);
char pstr[BMAX_PATH];
Bstrcpy(pstr, filename);
Bcorrectfilename(pstr, 1);
Bstrcat(pstr, "palette.dat");
int32_t pfil;
if ((pfil = kopen4load(pstr, 0)) == -1)
{
LOGE("couldn't load %s", pstr);
return -1;
}
kread(pfil, pal, 768);
kclose(pfil);
return 0;
corrupt:
kclose(fil);
return 1;
}
#endif

View file

@ -111,11 +111,6 @@ extern const char *(*El_SerializeGamevars)(int32_t *slenptr, int32_t levelnum);
void El_FreeSaveCode(void);
#endif
#ifdef __ANDROID__
char const * G_GetStringFromSavegame(const char *filename, int type);
int32_t G_GetScreenshotFromSavegame(const char *filename, char *pal, char *data);
#endif
#ifdef __cplusplus
}
#endif