Compare commits
30 Commits
ae84705332
...
0.6.1-alph
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b6039d8a4 | |||
| 1e908423d5 | |||
| 4bd3821ff6 | |||
| 28a49debcf | |||
| d2a5f4755c | |||
| 7f3af5c98a | |||
| d82d19be68 | |||
| 33590751c5 | |||
| a80d2ee847 | |||
| 8875342557 | |||
| 933ef9c988 | |||
| 09d28be195 | |||
| ffd9dda611 | |||
| 6ed2d40edc | |||
| ce6a987651 | |||
| 23cdc15285 | |||
| 904bf68cd6 | |||
| e529bd5d64 | |||
| 099b560273 | |||
| 2d70b68b73 | |||
| 01f78eabc7 | |||
|
|
99164a781d | ||
|
|
d25a04f154 | ||
|
|
3c71139a7c | ||
|
|
9991ba312d | ||
|
|
11d5551d02 | ||
|
|
d0939875fc | ||
| da1906f94b | |||
| 04f13ab4a7 | |||
| 2d17f9d152 |
210
CMakeLists.txt
210
CMakeLists.txt
@@ -5,11 +5,11 @@ include(cmake/CPM.cmake)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||||
|
set(CMAKE_POLICY_VERSION_MINIMUM 3.10)
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
||||||
endif()
|
endif()
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
CPMAddPackage("gh:madler/zlib@1.3.2")
|
CPMAddPackage("gh:madler/zlib@1.3.2")
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME "libpng"
|
NAME "libpng"
|
||||||
@@ -44,8 +44,189 @@ CPMAddPackage(
|
|||||||
"GLFW_BUILD_DOCS OFF"
|
"GLFW_BUILD_DOCS OFF"
|
||||||
"BUILD_SHARED_LIBS ON"
|
"BUILD_SHARED_LIBS ON"
|
||||||
)
|
)
|
||||||
|
# TODO: Clear this paths with *
|
||||||
|
file(GLOB SERVER_SOURCES
|
||||||
|
"src/NinecraftApp.cpp"
|
||||||
|
"src/Performance.cpp"
|
||||||
|
"src/SharedConstants.cpp"
|
||||||
|
|
||||||
file(GLOB SOURCES
|
"src/client/IConfigListener.cpp"
|
||||||
|
"src/client/Minecraft.cpp"
|
||||||
|
"src/client/OptionStrings.cpp"
|
||||||
|
"src/client/Options.cpp"
|
||||||
|
"src/client/OptionsFile.cpp"
|
||||||
|
|
||||||
|
"src/client/gamemode/CreativeMode.cpp"
|
||||||
|
"src/client/gamemode/GameMode.cpp"
|
||||||
|
"src/client/gamemode/SurvivalMode.cpp"
|
||||||
|
|
||||||
|
"src/client/player/LocalPlayer.cpp"
|
||||||
|
"src/client/player/RemotePlayer.cpp"
|
||||||
|
"src/client/player/input/KeyboardInput.cpp"
|
||||||
|
|
||||||
|
"src/locale/I18n.cpp"
|
||||||
|
|
||||||
|
"src/main.cpp"
|
||||||
|
"src/main_dedicated.cpp"
|
||||||
|
|
||||||
|
"src/nbt/Tag.cpp"
|
||||||
|
|
||||||
|
"src/network/ClientSideNetworkHandler.cpp"
|
||||||
|
"src/network/NetEventCallback.cpp"
|
||||||
|
"src/network/Packet.cpp"
|
||||||
|
"src/network/RakNetInstance.cpp"
|
||||||
|
"src/network/ServerSideNetworkHandler.cpp"
|
||||||
|
"src/network/command/CommandServer.cpp"
|
||||||
|
|
||||||
|
"src/platform/CThread.cpp"
|
||||||
|
"src/platform/time.cpp"
|
||||||
|
|
||||||
|
"src/platform/input/Controller.cpp"
|
||||||
|
"src/platform/input/Keyboard.cpp"
|
||||||
|
"src/platform/input/Mouse.cpp"
|
||||||
|
"src/platform/input/Multitouch.cpp"
|
||||||
|
|
||||||
|
"src/server/ArgumentsSettings.cpp"
|
||||||
|
"src/server/ServerLevel.cpp"
|
||||||
|
"src/server/ServerPlayer.cpp"
|
||||||
|
|
||||||
|
"src/util/DataIO.cpp"
|
||||||
|
"src/util/Mth.cpp"
|
||||||
|
"src/util/PerfTimer.cpp"
|
||||||
|
"src/util/StringUtils.cpp"
|
||||||
|
|
||||||
|
"src/world/Direction.cpp"
|
||||||
|
|
||||||
|
"src/world/entity/AgableMob.cpp"
|
||||||
|
"src/world/entity/Entity.cpp"
|
||||||
|
"src/world/entity/EntityFactory.cpp"
|
||||||
|
"src/world/entity/FlyingMob.cpp"
|
||||||
|
"src/world/entity/HangingEntity.cpp"
|
||||||
|
"src/world/entity/Mob.cpp"
|
||||||
|
"src/world/entity/MobCategory.cpp"
|
||||||
|
"src/world/entity/Motive.cpp"
|
||||||
|
"src/world/entity/Painting.cpp"
|
||||||
|
"src/world/entity/PathfinderMob.cpp"
|
||||||
|
"src/world/entity/SynchedEntityData.cpp"
|
||||||
|
|
||||||
|
"src/world/entity/ai/control/MoveControl.cpp"
|
||||||
|
|
||||||
|
"src/world/entity/animal/Animal.cpp"
|
||||||
|
"src/world/entity/animal/Chicken.cpp"
|
||||||
|
"src/world/entity/animal/Cow.cpp"
|
||||||
|
"src/world/entity/animal/Pig.cpp"
|
||||||
|
"src/world/entity/animal/Sheep.cpp"
|
||||||
|
"src/world/entity/animal/WaterAnimal.cpp"
|
||||||
|
|
||||||
|
"src/world/entity/item/FallingTile.cpp"
|
||||||
|
"src/world/entity/item/ItemEntity.cpp"
|
||||||
|
"src/world/entity/item/PrimedTnt.cpp"
|
||||||
|
"src/world/entity/item/TripodCamera.cpp"
|
||||||
|
|
||||||
|
"src/world/entity/monster/Creeper.cpp"
|
||||||
|
"src/world/entity/monster/Monster.cpp"
|
||||||
|
"src/world/entity/monster/PigZombie.cpp"
|
||||||
|
"src/world/entity/monster/Skeleton.cpp"
|
||||||
|
"src/world/entity/monster/Spider.cpp"
|
||||||
|
"src/world/entity/monster/Zombie.cpp"
|
||||||
|
|
||||||
|
"src/world/entity/player/Inventory.cpp"
|
||||||
|
"src/world/entity/player/Player.cpp"
|
||||||
|
|
||||||
|
"src/world/entity/projectile/Arrow.cpp"
|
||||||
|
"src/world/entity/projectile/Throwable.cpp"
|
||||||
|
|
||||||
|
"src/world/food/SimpleFoodData.cpp"
|
||||||
|
|
||||||
|
"src/world/inventory/BaseContainerMenu.cpp"
|
||||||
|
"src/world/inventory/ContainerMenu.cpp"
|
||||||
|
"src/world/inventory/FillingContainer.cpp"
|
||||||
|
"src/world/inventory/FurnaceMenu.cpp"
|
||||||
|
|
||||||
|
"src/world/item/ArmorItem.cpp"
|
||||||
|
"src/world/item/BedItem.cpp"
|
||||||
|
"src/world/item/DyePowderItem.cpp"
|
||||||
|
"src/world/item/HangingEntityItem.cpp"
|
||||||
|
"src/world/item/HatchetItem.cpp"
|
||||||
|
"src/world/item/HoeItem.cpp"
|
||||||
|
"src/world/item/Item.cpp"
|
||||||
|
"src/world/item/ItemInstance.cpp"
|
||||||
|
"src/world/item/PickaxeItem.cpp"
|
||||||
|
"src/world/item/ShovelItem.cpp"
|
||||||
|
|
||||||
|
"src/world/item/crafting/ArmorRecipes.cpp"
|
||||||
|
"src/world/item/crafting/FurnaceRecipes.cpp"
|
||||||
|
"src/world/item/crafting/OreRecipes.cpp"
|
||||||
|
"src/world/item/crafting/Recipe.cpp"
|
||||||
|
"src/world/item/crafting/Recipes.cpp"
|
||||||
|
"src/world/item/crafting/StructureRecipes.cpp"
|
||||||
|
"src/world/item/crafting/ToolRecipes.cpp"
|
||||||
|
"src/world/item/crafting/WeaponRecipes.cpp"
|
||||||
|
|
||||||
|
"src/world/level/Explosion.cpp"
|
||||||
|
"src/world/level/Level.cpp"
|
||||||
|
"src/world/level/LightLayer.cpp"
|
||||||
|
"src/world/level/LightUpdate.cpp"
|
||||||
|
"src/world/level/MobSpawner.cpp"
|
||||||
|
"src/world/level/Region.cpp"
|
||||||
|
"src/world/level/TickNextTickData.cpp"
|
||||||
|
|
||||||
|
"src/world/level/biome/Biome.cpp"
|
||||||
|
"src/world/level/biome/BiomeSource.cpp"
|
||||||
|
|
||||||
|
"src/world/level/chunk/LevelChunk.cpp"
|
||||||
|
|
||||||
|
"src/world/level/dimension/Dimension.cpp"
|
||||||
|
|
||||||
|
"src/world/level/levelgen/CanyonFeature.cpp"
|
||||||
|
"src/world/level/levelgen/DungeonFeature.cpp"
|
||||||
|
"src/world/level/levelgen/LargeCaveFeature.cpp"
|
||||||
|
"src/world/level/levelgen/LargeFeature.cpp"
|
||||||
|
"src/world/level/levelgen/RandomLevelSource.cpp"
|
||||||
|
"src/world/level/levelgen/feature/Feature.cpp"
|
||||||
|
"src/world/level/levelgen/synth/ImprovedNoise.cpp"
|
||||||
|
"src/world/level/levelgen/synth/PerlinNoise.cpp"
|
||||||
|
"src/world/level/levelgen/synth/Synth.cpp"
|
||||||
|
|
||||||
|
"src/world/level/material/Material.cpp"
|
||||||
|
|
||||||
|
"src/world/level/pathfinder/Path.cpp"
|
||||||
|
|
||||||
|
"src/world/level/storage/ExternalFileLevelStorage.cpp"
|
||||||
|
"src/world/level/storage/ExternalFileLevelStorageSource.cpp"
|
||||||
|
"src/world/level/storage/FolderMethods.cpp"
|
||||||
|
"src/world/level/storage/LevelData.cpp"
|
||||||
|
"src/world/level/storage/LevelStorageSource.cpp"
|
||||||
|
"src/world/level/storage/RegionFile.cpp"
|
||||||
|
|
||||||
|
"src/world/level/tile/BedTile.cpp"
|
||||||
|
"src/world/level/tile/ChestTile.cpp"
|
||||||
|
"src/world/level/tile/CropTile.cpp"
|
||||||
|
"src/world/level/tile/DoorTile.cpp"
|
||||||
|
"src/world/level/tile/EntityTile.cpp"
|
||||||
|
"src/world/level/tile/FurnaceTile.cpp"
|
||||||
|
"src/world/level/tile/GrassTile.cpp"
|
||||||
|
"src/world/level/tile/HeavyTile.cpp"
|
||||||
|
"src/world/level/tile/LightGemTile.cpp"
|
||||||
|
"src/world/level/tile/MelonTile.cpp"
|
||||||
|
"src/world/level/tile/Mushroom.cpp"
|
||||||
|
"src/world/level/tile/NetherReactor.cpp"
|
||||||
|
"src/world/level/tile/NetherReactorPattern.cpp"
|
||||||
|
"src/world/level/tile/StairTile.cpp"
|
||||||
|
"src/world/level/tile/StemTile.cpp"
|
||||||
|
"src/world/level/tile/StoneSlabTile.cpp"
|
||||||
|
"src/world/level/tile/TallGrass.cpp"
|
||||||
|
"src/world/level/tile/Tile.cpp"
|
||||||
|
"src/world/level/tile/TrapDoorTile.cpp"
|
||||||
|
"src/world/level/tile/entity/ChestTileEntity.cpp"
|
||||||
|
"src/world/level/tile/entity/FurnaceTileEntity.cpp"
|
||||||
|
"src/world/level/tile/entity/NetherReactorTileEntity.cpp"
|
||||||
|
"src/world/level/tile/entity/SignTileEntity.cpp"
|
||||||
|
"src/world/level/tile/entity/TileEntity.cpp"
|
||||||
|
|
||||||
|
"src/world/phys/HitResult.cpp"
|
||||||
|
)
|
||||||
|
file(GLOB CLIENT_SOURCES
|
||||||
"src/client/*.cpp"
|
"src/client/*.cpp"
|
||||||
|
|
||||||
"src/client/gamemode/*.cpp"
|
"src/client/gamemode/*.cpp"
|
||||||
@@ -129,25 +310,29 @@ endif()
|
|||||||
|
|
||||||
|
|
||||||
if(PLATFORM STREQUAL "PLATFORM_WIN32")
|
if(PLATFORM STREQUAL "PLATFORM_WIN32")
|
||||||
list(APPEND SOURCES "src/AppPlatform_win32.cpp")
|
list(APPEND CLIENT_SOURCES "src/AppPlatform_win32.cpp")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PLATFORM STREQUAL "PLATFORM_GLFW")
|
if(PLATFORM STREQUAL "PLATFORM_GLFW")
|
||||||
list(APPEND SOURCES "src/AppPlatform_glfw.cpp")
|
list(APPEND CLIENT_SOURCES "src/AppPlatform_glfw.cpp")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Explicitly list files added after the initial glob so they are always included
|
# Explicitly list files added after the initial glob so they are always included
|
||||||
list(APPEND SOURCES
|
list(APPEND CLIENT_SOURCES
|
||||||
"src/client/gui/screens/ConsoleScreen.cpp"
|
"src/client/gui/screens/ConsoleScreen.cpp"
|
||||||
"src/client/gui/screens/UsernameScreen.cpp"
|
"src/client/gui/screens/UsernameScreen.cpp"
|
||||||
"src/client/gui/screens/CreditsScreen.cpp"
|
"src/client/gui/screens/CreditsScreen.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}
|
add_executable(${PROJECT_NAME}
|
||||||
${SOURCES}
|
${CLIENT_SOURCES}
|
||||||
"glad/src/glad.c"
|
"glad/src/glad.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#add_executable("${PROJECT_NAME}-server"
|
||||||
|
# ${SERVER_SOURCES}
|
||||||
|
#)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(EXTRA_LIBS "ws2_32")
|
set(EXTRA_LIBS "ws2_32")
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "_CRT_SECURE_NO_WARNINGS")
|
target_compile_definitions(${PROJECT_NAME} PUBLIC "_CRT_SECURE_NO_WARNINGS")
|
||||||
@@ -157,6 +342,7 @@ if(PLATFORM STREQUAL "PLATFORM_WIN32" OR PLATFORM STREQUAL "PLATFORM_GLFW")
|
|||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "PLATFORM_DESKTOP")
|
target_compile_definitions(${PROJECT_NAME} PUBLIC "PLATFORM_DESKTOP")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||||
"${CMAKE_SOURCE_DIR}/glad/include/"
|
"${CMAKE_SOURCE_DIR}/glad/include/"
|
||||||
"${CMAKE_SOURCE_DIR}/src"
|
"${CMAKE_SOURCE_DIR}/src"
|
||||||
@@ -165,6 +351,16 @@ target_include_directories(${PROJECT_NAME} PUBLIC
|
|||||||
"lib/include"
|
"lib/include"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Server
|
||||||
|
#target_link_libraries("${PROJECT_NAME}-server" PRIVATE
|
||||||
|
# raknet ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
#target_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER")
|
||||||
|
|
||||||
|
#target_include_directories("${PROJECT_NAME}-server" PUBLIC
|
||||||
|
# "${CMAKE_SOURCE_DIR}/src/"
|
||||||
|
#)
|
||||||
|
|
||||||
|
# Client
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM})
|
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM})
|
||||||
target_link_libraries(${PROJECT_NAME} zlib png_shared alsoft.common OpenAL::OpenAL glfw ${EXTRA_LIBS})
|
target_link_libraries(${PROJECT_NAME} zlib png_shared alsoft.common OpenAL::OpenAL glfw ${EXTRA_LIBS})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# MinecraftPE
|
# MinecraftPE
|
||||||
> [!Important]
|
> [!Important]
|
||||||
> We have a discord server, where you can report bugs or send feedback https://discord.gg/ryZ884DWJf
|
> We have a discord server, where you can report bugs or send feedback https://discord.gg/c58YesBxve
|
||||||
|
|
||||||
Source code for **Minecraft Pocket Edition 0.6.1 alpha** with various fixes and improvements.
|
Source code for **Minecraft Pocket Edition 0.6.1 alpha** with various fixes and improvements.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ============================================================
|
# ============================================================
|
||||||
# MCPE 0.4.0 Android Build Script — from-scratch capable
|
# MCPE 0.6.1 Android Build Script — from-scratch capable
|
||||||
# Works on a clean machine; creates all dirs, keystore and
|
# Works on a clean machine; creates all dirs, keystore and
|
||||||
# stub Java files automatically.
|
# stub Java files automatically.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,46 +1,46 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.mojang.minecraftpe"
|
package="com.mojang.minecraftpe"
|
||||||
android:versionCode="6006"
|
android:versionCode="6010"
|
||||||
android:versionName="0.6.0"
|
android:versionName="0.6.1-alpha-0.0.3"
|
||||||
android:installLocation="preferExternal">
|
android:installLocation="preferExternal">
|
||||||
|
|
||||||
<!-- This is the platform API where NativeActivity was introduced. -->
|
<!-- This is the platform API where NativeActivity was introduced. -->
|
||||||
<uses-sdk android:minSdkVersion="21"
|
<uses-sdk android:minSdkVersion="24"
|
||||||
android:targetSdkVersion="21" />
|
android:targetSdkVersion="24" />
|
||||||
|
|
||||||
<!-- uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="true"/ -->
|
<!-- uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="true"/ -->
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
|
|
||||||
<application android:icon="@drawable/icon"
|
<application android:icon="@drawable/icon"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
>
|
>
|
||||||
|
|
||||||
<activity android:name="com.mojang.minecraftpe.MainActivity"
|
<activity android:name="com.mojang.minecraftpe.MainActivity"
|
||||||
android:label="@string/app_name_short"
|
android:label="@string/app_name_short"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:screenOrientation="landscape"
|
android:screenOrientation="landscape"
|
||||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||||
android:launchMode="singleTop">
|
android:launchMode="singleTop">
|
||||||
|
|
||||||
<meta-data android:name="android.app.lib_name"
|
<meta-data android:name="android.app.lib_name"
|
||||||
android:value="minecraftpe" />
|
android:value="minecraftpe" />
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.mojang.minecraftpe.MainMenuOptionsActivity"></activity>
|
<activity android:name="com.mojang.minecraftpe.MainMenuOptionsActivity"></activity>
|
||||||
|
|
||||||
<meta-data android:name="xperiaplayoptimized_content" android:resource="@string/xperiaplayoptimized_content" />
|
<meta-data android:name="xperiaplayoptimized_content" android:resource="@string/xperiaplayoptimized_content" />
|
||||||
<meta-data android:name="game_display_name" android:resource="@string/app_name" />
|
<meta-data android:name="game_display_name" android:resource="@string/app_name" />
|
||||||
<meta-data android:name="game_icon" android:resource="@drawable/iconx" />
|
<meta-data android:name="game_icon" android:resource="@drawable/iconx" />
|
||||||
|
|
||||||
<uses-library android:name="xperiaplaycertified" android:required="false"/>
|
<uses-library android:name="xperiaplaycertified" android:required="false"/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \
|
|||||||
../../../src/client/gui/screens/SelectWorldScreen.cpp \
|
../../../src/client/gui/screens/SelectWorldScreen.cpp \
|
||||||
../../../src/client/gui/screens/StartMenuScreen.cpp \
|
../../../src/client/gui/screens/StartMenuScreen.cpp \
|
||||||
../../../src/client/gui/screens/TextEditScreen.cpp \
|
../../../src/client/gui/screens/TextEditScreen.cpp \
|
||||||
|
../../../src/client/gui/screens/JoinByIPScreen.cpp \
|
||||||
../../../src/client/gui/screens/touch/TouchIngameBlockSelectionScreen.cpp \
|
../../../src/client/gui/screens/touch/TouchIngameBlockSelectionScreen.cpp \
|
||||||
../../../src/client/gui/screens/touch/TouchJoinGameScreen.cpp \
|
../../../src/client/gui/screens/touch/TouchJoinGameScreen.cpp \
|
||||||
../../../src/client/gui/screens/touch/TouchSelectWorldScreen.cpp \
|
../../../src/client/gui/screens/touch/TouchSelectWorldScreen.cpp \
|
||||||
|
|||||||
@@ -468,17 +468,16 @@ public class MainActivity extends NativeActivity {
|
|||||||
|
|
||||||
_userInputStatus = 1;
|
_userInputStatus = 1;
|
||||||
InputMethodManager inputManager = (InputMethodManager)getSystemService("input_method");
|
InputMethodManager inputManager = (InputMethodManager)getSystemService("input_method");
|
||||||
boolean result = inputManager.showSoftInput(this.getCurrentFocus(), InputMethodManager.SHOW_IMPLICIT);
|
View focused = this.getCurrentFocus();
|
||||||
}
|
if (focused != null) {
|
||||||
|
boolean result = inputManager.showSoftInput(focused, InputMethodManager.SHOW_IMPLICIT);
|
||||||
protected void onStart() {
|
} else {
|
||||||
//System.out.println("onStart");
|
// fallback: try to show using decor view token
|
||||||
super.onStart();
|
View decor = getWindow().getDecorView();
|
||||||
}
|
if (decor != null) {
|
||||||
|
inputManager.showSoftInput(decor, InputMethodManager.SHOW_IMPLICIT);
|
||||||
protected void onResume() {
|
}
|
||||||
//System.out.println("onResume");
|
}
|
||||||
super.onResume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
|
|||||||
@@ -1,74 +1,74 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.mojang.minecraftpe"
|
package="com.mojang.minecraftpe"
|
||||||
android:versionCode="4000"
|
android:versionCode="6010"
|
||||||
android:versionName="0.4.0">
|
android:versionName="0.6.1-alpha-0.0.3">
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="21"
|
android:minSdkVersion="24"
|
||||||
android:targetSdkVersion="28"/>
|
android:targetSdkVersion="28"/>
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.touchscreen.multitouch"
|
android:name="android.hardware.touchscreen.multitouch"
|
||||||
android:required="true"/>
|
android:required="true"/>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:icon="@drawable/icon"
|
android:icon="@drawable/icon"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:hardwareAccelerated="true"
|
android:hardwareAccelerated="true"
|
||||||
android:extractNativeLibs="true"
|
android:extractNativeLibs="true"
|
||||||
android:requestLegacyExternalStorage="true">
|
android:requestLegacyExternalStorage="true">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.mojang.minecraftpe.Minecraft_Market"
|
android:name="com.mojang.minecraftpe.Minecraft_Market"
|
||||||
android:label="@string/app_name_short"
|
android:label="@string/app_name_short"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize|uiMode"
|
android:configChanges="orientation|keyboardHidden|screenSize|uiMode"
|
||||||
android:screenOrientation="landscape"
|
android:screenOrientation="landscape"
|
||||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.app.lib_name"
|
android:name="android.app.lib_name"
|
||||||
android:value="minecraftpe"/>
|
android:value="minecraftpe"/>
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.mojang.minecraftpe.MainActivity"
|
android:name="com.mojang.minecraftpe.MainActivity"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize|uiMode"
|
android:configChanges="orientation|keyboardHidden|screenSize|uiMode"
|
||||||
android:screenOrientation="landscape"
|
android:screenOrientation="landscape"
|
||||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||||
android:exported="false"/>
|
android:exported="false"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.mojang.minecraftpe.MainMenuOptionsActivity"
|
android:name="com.mojang.minecraftpe.MainMenuOptionsActivity"
|
||||||
android:exported="false"/>
|
android:exported="false"/>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="xperiaplayoptimized_content"
|
android:name="xperiaplayoptimized_content"
|
||||||
android:resource="@string/xperiaplayoptimized_content"/>
|
android:resource="@string/xperiaplayoptimized_content"/>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="game_display_name"
|
android:name="game_display_name"
|
||||||
android:resource="@string/app_name"/>
|
android:resource="@string/app_name"/>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="game_icon"
|
android:name="game_icon"
|
||||||
android:resource="@drawable/iconx"/>
|
android:resource="@drawable/iconx"/>
|
||||||
|
|
||||||
<uses-library
|
<uses-library
|
||||||
android:name="xperiaplaycertified"
|
android:name="xperiaplaycertified"
|
||||||
android:required="false"/>
|
android:required="false"/>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -31,6 +31,8 @@ import android.content.Intent;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Build;
|
||||||
import android.graphics.Bitmap.CompressFormat;
|
import android.graphics.Bitmap.CompressFormat;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
@@ -54,7 +56,8 @@ import com.mojang.minecraftpe.sound.SoundPlayer;
|
|||||||
|
|
||||||
public class MainActivity extends Activity {
|
public class MainActivity extends Activity {
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
|
private static final int PERMISSION_REQUEST_CODE = 123;
|
||||||
|
|
||||||
private GLView _glView;
|
private GLView _glView;
|
||||||
public float invScale = 1.0f;// / 1.5f;
|
public float invScale = 1.0f;// / 1.5f;
|
||||||
private int _screenWidth = 0;
|
private int _screenWidth = 0;
|
||||||
@@ -108,10 +111,53 @@ public class MainActivity extends Activity {
|
|||||||
setContentView(_glView);
|
setContentView(_glView);
|
||||||
|
|
||||||
_soundPlayer = new SoundPlayer(this, AudioManager.STREAM_MUSIC);
|
_soundPlayer = new SoundPlayer(this, AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
|
// request dangerous permissions at runtime if necessary
|
||||||
|
checkAndRequestPermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkAndRequestPermissions() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
|
boolean needRequest = false;
|
||||||
|
if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||||
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
needRequest = true;
|
||||||
|
}
|
||||||
|
if (checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||||
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
needRequest = true;
|
||||||
|
}
|
||||||
|
if (needRequest) {
|
||||||
|
requestPermissions(new String[] {
|
||||||
|
android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||||
|
android.Manifest.permission.READ_EXTERNAL_STORAGE
|
||||||
|
}, PERMISSION_REQUEST_CODE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||||
|
if (requestCode == PERMISSION_REQUEST_CODE) {
|
||||||
|
boolean granted = true;
|
||||||
|
for (int r : grantResults) {
|
||||||
|
if (r != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
granted = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!granted) {
|
||||||
|
// user denied; you might want to warn or close the app
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
}
|
||||||
|
|
||||||
|
// method required by native code to detect touchscreen support
|
||||||
|
public boolean supportsTouchscreen() {
|
||||||
|
return true; // all devices using this build are touch-capable
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTouchscreen() { return true; }
|
|
||||||
public boolean supportsTouchscreen() { return true; }
|
|
||||||
static public boolean isXperiaPlay() { return false; }
|
static public boolean isXperiaPlay() { return false; }
|
||||||
|
|
||||||
static private boolean _isPowerVr = false;
|
static private boolean _isPowerVr = false;
|
||||||
@@ -537,6 +583,15 @@ public class MainActivity extends Activity {
|
|||||||
return kcm.get(keyCode, metaState);
|
return kcm.get(keyCode, metaState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void openURL(String url) {
|
||||||
|
try {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW, android.net.Uri.parse(url));
|
||||||
|
startActivity(intent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String getPlatformStringVar(int id) {
|
public String getPlatformStringVar(int id) {
|
||||||
if (id == 0) return android.os.Build.MODEL;
|
if (id == 0) return android.os.Build.MODEL;
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.7)
|
cmake_minimum_required(VERSION 3.5.0)
|
||||||
find_package (Threads)
|
find_package (Threads)
|
||||||
include_directories("${PROJECT_SOURCE_DIR}/../lib_projects/raknet/jni/RaknetSources")
|
include_directories("${PROJECT_SOURCE_DIR}/../lib_projects/raknet/jni/RaknetSources")
|
||||||
add_subdirectory("${PROJECT_SOURCE_DIR}/../lib_projects/raknet/jni" "${CMAKE_CURRENT_BINARY_DIR}/raknet")
|
add_subdirectory("${PROJECT_SOURCE_DIR}/../lib_projects/raknet/jni" "${CMAKE_CURRENT_BINARY_DIR}/raknet")
|
||||||
@@ -151,6 +151,9 @@ set(CompileFiles ../../src/main.cpp
|
|||||||
../../src/world/level/tile/entity/TileEntity.cpp
|
../../src/world/level/tile/entity/TileEntity.cpp
|
||||||
../../src/world/level/tile/entity/FurnaceTileEntity.cpp
|
../../src/world/level/tile/entity/FurnaceTileEntity.cpp
|
||||||
../../src/world/phys/HitResult.cpp)
|
../../src/world/phys/HitResult.cpp)
|
||||||
message(${CMAKE_LIBRARY_ARCHITECTURE})
|
|
||||||
add_executable(mcpe_server ${CompileFiles})
|
add_executable(mcpe_server ${CompileFiles})
|
||||||
target_link_libraries(mcpe_server raknet ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(mcpe_server raknet ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
target_include_directories(mcpe_server PUBLIC
|
||||||
|
"minecraft-pe-0.6.1/src/"
|
||||||
|
)
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ static const unsigned int MAX_OFFLINE_DATA_LENGTH=400; // I set this because I l
|
|||||||
#pragma warning(disable:4309) // 'initializing' : truncation of constant value
|
#pragma warning(disable:4309) // 'initializing' : truncation of constant value
|
||||||
#endif
|
#endif
|
||||||
// Make sure highest bit is 0, so isValid in DatagramHeaderFormat is false
|
// Make sure highest bit is 0, so isValid in DatagramHeaderFormat is false
|
||||||
static const char OFFLINE_MESSAGE_DATA_ID[16]={0x00,0xFF,0xFF,0x00,0xFE,0xFE,0xFE,0xFE,0xFD,0xFD,0xFD,0xFD,0x12,0x34,0x56,0x78};
|
static const unsigned char OFFLINE_MESSAGE_DATA_ID[16]={0x00,0xFF,0xFF,0x00,0xFE,0xFE,0xFE,0xFE,0xFD,0xFD,0xFD,0xFD,0x12,0x34,0x56,0x78};
|
||||||
|
|
||||||
struct PacketFollowedByData
|
struct PacketFollowedByData
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -96,9 +96,6 @@ public:
|
|||||||
virtual std::string getDateString(int s) { return ""; }
|
virtual std::string getDateString(int s) { return ""; }
|
||||||
//virtual void createUserInputScreen(const char* types) {}
|
//virtual void createUserInputScreen(const char* types) {}
|
||||||
|
|
||||||
virtual int checkLicense() { return 0; }
|
|
||||||
virtual bool hasBuyButtonWhenInvalidLicense() { return false; }
|
|
||||||
|
|
||||||
virtual void uploadPlatformDependentData(int id, void* data) {}
|
virtual void uploadPlatformDependentData(int id, void* data) {}
|
||||||
virtual BinaryBlob readAssetFile(const std::string& filename) { return BinaryBlob(); }
|
virtual BinaryBlob readAssetFile(const std::string& filename) { return BinaryBlob(); }
|
||||||
virtual void _tick() {}
|
virtual void _tick() {}
|
||||||
@@ -117,8 +114,6 @@ public:
|
|||||||
virtual bool isSuperFast() = 0;
|
virtual bool isSuperFast() = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual void buyGame() {}
|
|
||||||
|
|
||||||
virtual void openURL(const std::string& url) {}
|
virtual void openURL(const std::string& url) {}
|
||||||
|
|
||||||
virtual void finish() {}
|
virtual void finish() {}
|
||||||
|
|||||||
@@ -68,9 +68,6 @@ public:
|
|||||||
|
|
||||||
_methodGetDateString(0),
|
_methodGetDateString(0),
|
||||||
|
|
||||||
_methodCheckLicense(0),
|
|
||||||
_methodHasBuyButton(0),
|
|
||||||
_methodBuyGame(0),
|
|
||||||
_methodVibrate(0),
|
_methodVibrate(0),
|
||||||
_methodSupportsTouchscreen(0),
|
_methodSupportsTouchscreen(0),
|
||||||
_methodSetIsPowerVR(0),
|
_methodSetIsPowerVR(0),
|
||||||
@@ -147,10 +144,6 @@ public:
|
|||||||
|
|
||||||
_methodGetDateString = env->GetMethodID( _activityClass, "getDateString", "(I)Ljava/lang/String;");
|
_methodGetDateString = env->GetMethodID( _activityClass, "getDateString", "(I)Ljava/lang/String;");
|
||||||
|
|
||||||
_methodCheckLicense = env->GetMethodID( _activityClass, "checkLicense", "()I");
|
|
||||||
_methodHasBuyButton = env->GetMethodID( _activityClass, "hasBuyButtonWhenInvalidLicense", "()Z");
|
|
||||||
_methodBuyGame = env->GetMethodID( _activityClass, "buyGame", "()V");
|
|
||||||
|
|
||||||
_methodVibrate = env->GetMethodID( _activityClass, "vibrate", "(I)V");
|
_methodVibrate = env->GetMethodID( _activityClass, "vibrate", "(I)V");
|
||||||
_methodSupportsTouchscreen = env->GetMethodID( _activityClass, "supportsTouchscreen", "()Z");
|
_methodSupportsTouchscreen = env->GetMethodID( _activityClass, "supportsTouchscreen", "()Z");
|
||||||
_methodSetIsPowerVR = env->GetMethodID( _activityClass, "setIsPowerVR", "(Z)V");
|
_methodSetIsPowerVR = env->GetMethodID( _activityClass, "setIsPowerVR", "(Z)V");
|
||||||
@@ -158,6 +151,8 @@ public:
|
|||||||
|
|
||||||
_methodGetPixelsPerMillimeter = env->GetMethodID( _activityClass, "getPixelsPerMillimeter", "()F");
|
_methodGetPixelsPerMillimeter = env->GetMethodID( _activityClass, "getPixelsPerMillimeter", "()F");
|
||||||
_methodGetPlatformStringVar = env->GetMethodID( _activityClass, "getPlatformStringVar", "(I)Ljava/lang/String;");
|
_methodGetPlatformStringVar = env->GetMethodID( _activityClass, "getPlatformStringVar", "(I)Ljava/lang/String;");
|
||||||
|
// custom helper to launch external URLs
|
||||||
|
_methodOpenURL = env->GetMethodID(_activityClass, "openURL", "(Ljava/lang/String;)V");
|
||||||
|
|
||||||
_classWindow = (jclass)env->NewGlobalRef(env->FindClass("android/view/Window"));
|
_classWindow = (jclass)env->NewGlobalRef(env->FindClass("android/view/Window"));
|
||||||
_classContext = (jclass)env->NewGlobalRef(env->FindClass("android/content/Context"));
|
_classContext = (jclass)env->NewGlobalRef(env->FindClass("android/content/Context"));
|
||||||
@@ -472,37 +467,15 @@ public:
|
|||||||
env->ReleaseStringUTFChars(stringVar, str);
|
env->ReleaseStringUTFChars(stringVar, str);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
// Opens a webpage using an Android intent. Called from native code.
|
||||||
int checkLicense() {
|
virtual void openURL(const std::string& url) {
|
||||||
if (!_isInited) return -2;
|
if (!_isInited || !_methodOpenURL) return;
|
||||||
if (!_methodCheckLicense) return -2;
|
JVMAttacher ta(_vm);
|
||||||
|
JNIEnv* env = ta.getEnv();
|
||||||
JVMAttacher ta(_vm);
|
jstring jurl = env->NewStringUTF(url.c_str());
|
||||||
JNIEnv* env = ta.getEnv();
|
env->CallVoidMethod(instance, _methodOpenURL, jurl);
|
||||||
|
env->DeleteLocalRef(jurl);
|
||||||
return env->CallIntMethod(instance, _methodCheckLicense);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool hasBuyButtonWhenInvalidLicense() {
|
|
||||||
if (!_isInited) return false;
|
|
||||||
if (!_methodHasBuyButton) return false;
|
|
||||||
|
|
||||||
JVMAttacher ta(_vm);
|
|
||||||
JNIEnv* env = ta.getEnv();
|
|
||||||
|
|
||||||
return JNI_TRUE == env->CallBooleanMethod(instance, _methodHasBuyButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
void buyGame() {
|
|
||||||
if (!_isInited) return;
|
|
||||||
if (!_methodBuyGame) return;
|
|
||||||
|
|
||||||
JVMAttacher ta(_vm);
|
|
||||||
JNIEnv* env = ta.getEnv();
|
|
||||||
|
|
||||||
env->CallVoidMethod(instance, _methodBuyGame);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void finish() {
|
virtual void finish() {
|
||||||
if (!_isInited) return;
|
if (!_isInited) return;
|
||||||
if (!_methodFinish) return;
|
if (!_methodFinish) return;
|
||||||
@@ -644,10 +617,6 @@ private:
|
|||||||
|
|
||||||
jmethodID _methodGetDateString;
|
jmethodID _methodGetDateString;
|
||||||
|
|
||||||
jmethodID _methodCheckLicense;
|
|
||||||
jmethodID _methodHasBuyButton;
|
|
||||||
jmethodID _methodBuyGame;
|
|
||||||
|
|
||||||
jmethodID _getScreenWidth;
|
jmethodID _getScreenWidth;
|
||||||
jmethodID _getScreenHeight;
|
jmethodID _getScreenHeight;
|
||||||
jmethodID _methodGetPixelsPerMillimeter;
|
jmethodID _methodGetPixelsPerMillimeter;
|
||||||
@@ -657,6 +626,7 @@ private:
|
|||||||
jmethodID _methodIsNetworkEnabled;
|
jmethodID _methodIsNetworkEnabled;
|
||||||
|
|
||||||
jmethodID _methodGetPlatformStringVar;
|
jmethodID _methodGetPlatformStringVar;
|
||||||
|
jmethodID _methodOpenURL; // new JNI method for launching browser
|
||||||
|
|
||||||
jclass _classWindow;
|
jclass _classWindow;
|
||||||
jclass _classContext;
|
jclass _classContext;
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
@@ -106,17 +108,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string getDateString(int s) {
|
std::string getDateString(int s) {
|
||||||
std::stringstream ss;
|
time_t tm = s;
|
||||||
ss << s << " s (UTC)";
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int checkLicense() {
|
char mbstr[100];
|
||||||
static int _z = 0;//20;
|
std::strftime(mbstr, sizeof(mbstr), "%F %T", std::localtime(&tm));
|
||||||
_z--;
|
|
||||||
if (_z < 0) return 0;
|
return std::string(mbstr);
|
||||||
//if (_z < 0) return 107;
|
|
||||||
return -2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int getScreenWidth() { return 854; };
|
virtual int getScreenWidth() { return 854; };
|
||||||
@@ -125,11 +122,13 @@ public:
|
|||||||
virtual float getPixelsPerMillimeter();
|
virtual float getPixelsPerMillimeter();
|
||||||
|
|
||||||
virtual bool supportsTouchscreen() { return true; }
|
virtual bool supportsTouchscreen() { return true; }
|
||||||
virtual bool hasBuyButtonWhenInvalidLicense() { return false; }
|
|
||||||
|
|
||||||
virtual void openURL(const std::string& url) {
|
virtual void openURL(const std::string& url) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
|
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
#elif __linux__
|
||||||
|
std::string command = "xdg-open " + url;
|
||||||
|
system(command.c_str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,17 +41,6 @@ public:
|
|||||||
|
|
||||||
std::string getDateString(int s);
|
std::string getDateString(int s);
|
||||||
|
|
||||||
virtual int checkLicense() {
|
|
||||||
return 0;
|
|
||||||
static int _z = 20;
|
|
||||||
_z--;
|
|
||||||
if (_z < 0) return 0;
|
|
||||||
//if (_z < 0) return 107;
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void buyGame();
|
|
||||||
|
|
||||||
virtual int getScreenWidth();
|
virtual int getScreenWidth();
|
||||||
virtual int getScreenHeight();
|
virtual int getScreenHeight();
|
||||||
virtual float getPixelsPerMillimeter();
|
virtual float getPixelsPerMillimeter();
|
||||||
|
|||||||
@@ -175,10 +175,6 @@ BinaryBlob AppPlatform_iOS::readAssetFile(const std::string& filename_) {
|
|||||||
return BinaryBlob(bytes, numBytes);
|
return BinaryBlob(bytes, numBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppPlatform_iOS::buyGame() {
|
|
||||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=479516143&mt=8"]];
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string AppPlatform_iOS::getDateString(int s) {
|
std::string AppPlatform_iOS::getDateString(int s) {
|
||||||
|
|
||||||
NSDate* date = [NSDate dateWithTimeIntervalSince1970:s];
|
NSDate* date = [NSDate dateWithTimeIntervalSince1970:s];
|
||||||
|
|||||||
@@ -14,4 +14,3 @@ float AppPlatform_win32::getPixelsPerMillimeter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AppPlatform_win32::supportsTouchscreen() { return true; }
|
bool AppPlatform_win32::supportsTouchscreen() { return true; }
|
||||||
bool AppPlatform_win32::hasBuyButtonWhenInvalidLicense() { return true; }
|
|
||||||
|
|||||||
@@ -103,17 +103,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string getDateString(int s) {
|
std::string getDateString(int s) {
|
||||||
std::stringstream ss;
|
time_t tm = s;
|
||||||
ss << s << " s (UTC)";
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int checkLicense() {
|
char mbstr[100];
|
||||||
static int _z = 0;//20;
|
std::strftime(mbstr, sizeof(mbstr), "%F %T", std::localtime(&tm));
|
||||||
_z--;
|
|
||||||
if (_z < 0) return 0;
|
return std::string(mbstr);
|
||||||
//if (_z < 0) return 107;
|
|
||||||
return -2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int getScreenWidth();
|
virtual int getScreenWidth();
|
||||||
@@ -122,7 +117,6 @@ public:
|
|||||||
virtual float getPixelsPerMillimeter();
|
virtual float getPixelsPerMillimeter();
|
||||||
|
|
||||||
virtual bool supportsTouchscreen();
|
virtual bool supportsTouchscreen();
|
||||||
virtual bool hasBuyButtonWhenInvalidLicense();
|
|
||||||
|
|
||||||
virtual void openURL(const std::string& url) {
|
virtual void openURL(const std::string& url) {
|
||||||
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
|
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "Minecraft.h"
|
#include "Minecraft.h"
|
||||||
#include "client/player/input/IBuildInput.h"
|
#include "client/player/input/IBuildInput.h"
|
||||||
|
#include <string>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
#if defined(APPLE_DEMO_PROMOTION)
|
#if defined(APPLE_DEMO_PROMOTION)
|
||||||
#define NO_NETWORK
|
#define NO_NETWORK
|
||||||
@@ -55,7 +57,6 @@
|
|||||||
#include "player/input/XperiaPlayInput.h"
|
#include "player/input/XperiaPlayInput.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "player/input/MouseTurnInput.h"
|
#include "player/input/MouseTurnInput.h"
|
||||||
#include "../world/entity/MobFactory.h"
|
#include "../world/entity/MobFactory.h"
|
||||||
#include "../world/level/MobSpawner.h"
|
#include "../world/level/MobSpawner.h"
|
||||||
@@ -864,6 +865,10 @@ void Minecraft::tickInput() {
|
|||||||
|
|
||||||
static bool prevMouseDownLeft = false;
|
static bool prevMouseDownLeft = false;
|
||||||
|
|
||||||
|
if (Mouse::getButtonState(MouseAction::ACTION_LEFT) == 0) {
|
||||||
|
gameMode->stopDestroyBlock();
|
||||||
|
}
|
||||||
|
|
||||||
if (useTouchscreen()) {
|
if (useTouchscreen()) {
|
||||||
// Touch: gesture recognizer classifies the action type (turn/destroy/build)
|
// Touch: gesture recognizer classifies the action type (turn/destroy/build)
|
||||||
BuildActionIntention bai;
|
BuildActionIntention bai;
|
||||||
@@ -1284,6 +1289,31 @@ bool Minecraft::joinMultiplayer( const PingedCompatibleServer& server )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Minecraft::joinMultiplayerFromString( const std::string& server )
|
||||||
|
{
|
||||||
|
std::string ip = "";
|
||||||
|
std::string port = "19132";
|
||||||
|
|
||||||
|
size_t pos = server.find(":");
|
||||||
|
|
||||||
|
if (pos != std::string::npos) {
|
||||||
|
ip = server.substr(0, pos);
|
||||||
|
port = server.substr(pos + 1);
|
||||||
|
} else {
|
||||||
|
ip = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s \n", port.c_str());
|
||||||
|
|
||||||
|
if (isLookingForMultiplayer && netCallback) {
|
||||||
|
isLookingForMultiplayer = false;
|
||||||
|
printf("test");
|
||||||
|
int portNum = atoi(port.c_str());
|
||||||
|
return raknetInstance->connect(ip.c_str(), portNum);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void Minecraft::hostMultiplayer(int port) {
|
void Minecraft::hostMultiplayer(int port) {
|
||||||
// Tear down last instance
|
// Tear down last instance
|
||||||
raknetInstance->disconnect();
|
raknetInstance->disconnect();
|
||||||
@@ -1451,11 +1481,11 @@ LevelStorageSource* Minecraft::getLevelSource()
|
|||||||
return storageSource;
|
return storageSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Minecraft::getLicenseId() {
|
// int Minecraft::getLicenseId() {
|
||||||
if (!LicenseCodes::isReady(_licenseId))
|
// if (!LicenseCodes::isReady(_licenseId))
|
||||||
_licenseId = platform()->checkLicense();
|
// _licenseId = platform()->checkLicense();
|
||||||
return _licenseId;
|
// return _licenseId;
|
||||||
}
|
// }
|
||||||
|
|
||||||
void Minecraft::audioEngineOn() {
|
void Minecraft::audioEngineOn() {
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public:
|
|||||||
void locateMultiplayer();
|
void locateMultiplayer();
|
||||||
void cancelLocateMultiplayer();
|
void cancelLocateMultiplayer();
|
||||||
bool joinMultiplayer(const PingedCompatibleServer& server);
|
bool joinMultiplayer(const PingedCompatibleServer& server);
|
||||||
|
bool joinMultiplayerFromString(const std::string& server);
|
||||||
void hostMultiplayer(int port=19132);
|
void hostMultiplayer(int port=19132);
|
||||||
Player* respawnPlayer(int playerId);
|
Player* respawnPlayer(int playerId);
|
||||||
void respawnPlayer();
|
void respawnPlayer();
|
||||||
@@ -109,7 +110,6 @@ public:
|
|||||||
void onGraphicsReset();
|
void onGraphicsReset();
|
||||||
|
|
||||||
bool isLevelGenerated();
|
bool isLevelGenerated();
|
||||||
int getLicenseId();
|
|
||||||
|
|
||||||
void audioEngineOn();
|
void audioEngineOn();
|
||||||
void audioEngineOff();
|
void audioEngineOff();
|
||||||
|
|||||||
@@ -86,13 +86,15 @@ void TextBox::render(Minecraft* minecraft, int xm, int ym) {
|
|||||||
Gui::GuiScale * (height - 2)
|
Gui::GuiScale * (height - 2)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
int _y = y + (height - Font::DefaultLineHeight) / 2;
|
||||||
|
|
||||||
if (text.empty() && !focused) {
|
if (text.empty() && !focused) {
|
||||||
drawString(minecraft->font, hint, x + 2, y + 2, 0xff5e5e5e);
|
drawString(minecraft->font, hint, x + 2, _y, 0xff5e5e5e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (focused && blink) text.push_back('_');
|
if (focused && blink) text.push_back('_');
|
||||||
|
|
||||||
drawString(minecraft->font, text, x + 2, y + 2, 0xffffffff);
|
drawString(minecraft->font, text, x + 2, _y, 0xffffffff);
|
||||||
|
|
||||||
if (focused && blink) text.pop_back();
|
if (focused && blink) text.pop_back();
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__BuyGameScreen_H__
|
|
||||||
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__BuyGameScreen_H__
|
|
||||||
|
|
||||||
#include "../Screen.h"
|
|
||||||
#include "../components/Button.h"
|
|
||||||
|
|
||||||
class BuyGameScreen: public Screen
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
BuyGameScreen() {}
|
|
||||||
virtual ~BuyGameScreen() {}
|
|
||||||
|
|
||||||
void init();
|
|
||||||
|
|
||||||
void render(int xm, int ym, float a);
|
|
||||||
|
|
||||||
void buttonClicked(Button* button) {
|
|
||||||
//if (button->id == bQuit.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
//Button bQuit;
|
|
||||||
//Button bBuyGame;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__BuyGameScreen_H__*/
|
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "../../Minecraft.h"
|
#include "../../Minecraft.h"
|
||||||
#include "../components/Button.h"
|
#include "../components/Button.h"
|
||||||
#include "../components/ImageButton.h"
|
#include "../components/ImageButton.h"
|
||||||
|
#include "platform/input/Mouse.h"
|
||||||
|
|
||||||
CreditsScreen::CreditsScreen()
|
CreditsScreen::CreditsScreen()
|
||||||
: bHeader(NULL), btnBack(NULL)
|
: bHeader(NULL), btnBack(NULL)
|
||||||
@@ -37,7 +38,8 @@ void CreditsScreen::init() {
|
|||||||
_lines.push_back("InviseDivine");
|
_lines.push_back("InviseDivine");
|
||||||
_lines.push_back("Kolyah35");
|
_lines.push_back("Kolyah35");
|
||||||
_lines.push_back("");
|
_lines.push_back("");
|
||||||
_lines.push_back("[Gold]Join our Discord server:[/Gold] [Green]url.....[/Green]");
|
// avoid color tags around the URL so it isn't mangled by the parser please
|
||||||
|
_lines.push_back("Join our Discord server: https://discord.gg/c58YesBxve");
|
||||||
_scrollSpeed = 0.5f;
|
_scrollSpeed = 0.5f;
|
||||||
_scrollY = height; // start below screen
|
_scrollY = height; // start below screen
|
||||||
}
|
}
|
||||||
@@ -65,11 +67,16 @@ void CreditsScreen::tick() {
|
|||||||
if (_scrollY + totalHeight < 0) {
|
if (_scrollY + totalHeight < 0) {
|
||||||
_scrollY = height;
|
_scrollY = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Mouse::isButtonDown(MouseAction::ACTION_LEFT)) {
|
||||||
|
_scrollSpeed = 1.5f;
|
||||||
|
} else {
|
||||||
|
_scrollSpeed = 0.5f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreditsScreen::render(int xm, int ym, float a) {
|
void CreditsScreen::render(int xm, int ym, float a) {
|
||||||
renderBackground();
|
renderBackground();
|
||||||
super::render(xm, ym, a);
|
|
||||||
int w = width;
|
int w = width;
|
||||||
Font* font = minecraft->font;
|
Font* font = minecraft->font;
|
||||||
float y = _scrollY;
|
float y = _scrollY;
|
||||||
@@ -87,6 +94,8 @@ void CreditsScreen::render(int xm, int ym, float a) {
|
|||||||
}
|
}
|
||||||
y += lineHeight;
|
y += lineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super::render(xm, ym, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreditsScreen::buttonClicked(Button* button) {
|
void CreditsScreen::buttonClicked(Button* button) {
|
||||||
|
|||||||
@@ -1,107 +0,0 @@
|
|||||||
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__InvalidLicenseScreen_H__
|
|
||||||
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__InvalidLicenseScreen_H__
|
|
||||||
|
|
||||||
#include "../Screen.h"
|
|
||||||
#include "../components/Button.h"
|
|
||||||
#include "../../Minecraft.h"
|
|
||||||
#include "../../../LicenseCodes.h"
|
|
||||||
|
|
||||||
class InvalidLicenseScreen: public Screen
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
InvalidLicenseScreen(int id, bool hasBuyButton)
|
|
||||||
: _id(id),
|
|
||||||
_hasBuyButton(hasBuyButton),
|
|
||||||
_baseY(0),
|
|
||||||
bOk(0),
|
|
||||||
bBuy(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~InvalidLicenseScreen() {
|
|
||||||
delete bOk;
|
|
||||||
delete bBuy;
|
|
||||||
}
|
|
||||||
|
|
||||||
void init() {
|
|
||||||
if (minecraft->useTouchscreen()) {
|
|
||||||
bOk = new Touch::TButton(1, "Ok");
|
|
||||||
bBuy = new Touch::TButton(2, "Buy");
|
|
||||||
} else {
|
|
||||||
bOk = new Button(1, "Ok");
|
|
||||||
bBuy = new Button(2, "Buy");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_hasBuyButton)
|
|
||||||
bOk->msg = "Quit";
|
|
||||||
|
|
||||||
if (!LicenseCodes::isOk(_id)) {
|
|
||||||
char buf[20] = {0};
|
|
||||||
sprintf(buf, "%d", _id);
|
|
||||||
|
|
||||||
desc1 = "License verification failed (error ";
|
|
||||||
desc1 += buf;
|
|
||||||
desc1 += ")";
|
|
||||||
desc2 = "Try again later.";
|
|
||||||
hint = "You need to be connected to the internet\n";
|
|
||||||
hint += "once while you start the game.";
|
|
||||||
}
|
|
||||||
|
|
||||||
buttons.push_back(bOk);
|
|
||||||
tabButtons.push_back(bOk);
|
|
||||||
|
|
||||||
if (_hasBuyButton) {
|
|
||||||
buttons.push_back(bBuy);
|
|
||||||
tabButtons.push_back(bBuy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setupPositions() {
|
|
||||||
_baseY = height/5 + 6;
|
|
||||||
//if (_hasBuyButton)
|
|
||||||
_baseY -= 24;
|
|
||||||
|
|
||||||
bOk->width = bBuy->width = 200;
|
|
||||||
bOk->x = bBuy->x = (width - bOk->width) / 2;
|
|
||||||
bBuy->y = _baseY + 84;
|
|
||||||
bOk->y = bBuy->y + bBuy->height + 4;
|
|
||||||
|
|
||||||
if (!_hasBuyButton)
|
|
||||||
bOk->y -= 24;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tick() {}
|
|
||||||
|
|
||||||
//void keyPressed(int eventKey) {}
|
|
||||||
|
|
||||||
void render(int xm, int ym, float a) {
|
|
||||||
renderDirtBackground(0);
|
|
||||||
drawCenteredString(minecraft->font, desc1, width/2, _baseY, 0xffffff);
|
|
||||||
drawCenteredString(minecraft->font, desc2, width/2, _baseY + 24, 0xffffff);
|
|
||||||
|
|
||||||
drawCenteredString(minecraft->font, hint, width/2, _baseY + 60, 0xffffff);
|
|
||||||
|
|
||||||
Screen::render(xm, ym, a);
|
|
||||||
}
|
|
||||||
|
|
||||||
void buttonClicked(Button* button) {
|
|
||||||
if (button->id == bOk->id) {
|
|
||||||
minecraft->quit();
|
|
||||||
}
|
|
||||||
if (button->id == bBuy->id) {
|
|
||||||
minecraft->platform()->buyGame();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private:
|
|
||||||
int _id;
|
|
||||||
std::string desc1;
|
|
||||||
std::string desc2;
|
|
||||||
std::string hint;
|
|
||||||
|
|
||||||
Button* bOk;
|
|
||||||
Button* bBuy;
|
|
||||||
bool _hasBuyButton;
|
|
||||||
int _baseY;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__InvalidLicenseScreen_H__*/
|
|
||||||
140
src/client/gui/screens/JoinByIPScreen.cpp
Normal file
140
src/client/gui/screens/JoinByIPScreen.cpp
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
#include "JoinByIPScreen.h"
|
||||||
|
|
||||||
|
#include "JoinGameScreen.h"
|
||||||
|
#include "StartMenuScreen.h"
|
||||||
|
#include "ProgressScreen.h"
|
||||||
|
#include "../Font.h"
|
||||||
|
#include "../../../network/RakNetInstance.h"
|
||||||
|
#include "client/gui/components/TextBox.h"
|
||||||
|
#include "network/ClientSideNetworkHandler.h"
|
||||||
|
|
||||||
|
JoinByIPScreen::JoinByIPScreen() :
|
||||||
|
tIP(0, "Server IP"),
|
||||||
|
bHeader(1, "Join on server"),
|
||||||
|
bJoin( 2, "Join Game"),
|
||||||
|
bBack( 3, "")
|
||||||
|
{
|
||||||
|
bJoin.active = false;
|
||||||
|
//gamesList->yInertia = 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
JoinByIPScreen::~JoinByIPScreen()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void JoinByIPScreen::buttonClicked(Button* button)
|
||||||
|
{
|
||||||
|
if (button->id == bJoin.id)
|
||||||
|
{
|
||||||
|
minecraft->isLookingForMultiplayer = true;
|
||||||
|
minecraft->netCallback = new ClientSideNetworkHandler(minecraft, minecraft->raknetInstance);
|
||||||
|
|
||||||
|
minecraft->joinMultiplayerFromString(tIP.text);
|
||||||
|
{
|
||||||
|
|
||||||
|
bJoin.active = false;
|
||||||
|
bBack.active = false;
|
||||||
|
minecraft->setScreen(new ProgressScreen());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (button->id == bBack.id)
|
||||||
|
{
|
||||||
|
minecraft->cancelLocateMultiplayer();
|
||||||
|
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JoinByIPScreen::handleBackEvent(bool isDown)
|
||||||
|
{
|
||||||
|
if (!isDown)
|
||||||
|
{
|
||||||
|
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JoinByIPScreen::tick()
|
||||||
|
{
|
||||||
|
bJoin.active = !tIP.text.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void JoinByIPScreen::init()
|
||||||
|
{
|
||||||
|
ImageDef def;
|
||||||
|
def.name = "gui/touchgui.png";
|
||||||
|
def.width = 34;
|
||||||
|
def.height = 26;
|
||||||
|
|
||||||
|
def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height));
|
||||||
|
bBack.setImageDef(def, true);
|
||||||
|
|
||||||
|
buttons.push_back(&bJoin);
|
||||||
|
buttons.push_back(&bBack);
|
||||||
|
buttons.push_back(&bHeader);
|
||||||
|
|
||||||
|
textBoxes.push_back(&tIP);
|
||||||
|
#ifdef ANDROID
|
||||||
|
tabButtons.push_back(&bJoin);
|
||||||
|
tabButtons.push_back(&bBack);
|
||||||
|
tabButtons.push_back(&bHeader);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void JoinByIPScreen::setupPositions() {
|
||||||
|
int tIpDiff = 40;
|
||||||
|
|
||||||
|
bJoin.y = height * 2 / 3;
|
||||||
|
bBack.y = 0;
|
||||||
|
bHeader.y = 0;
|
||||||
|
|
||||||
|
// Center buttons
|
||||||
|
//bJoin.x = width / 2 - 4 - bJoin.w;
|
||||||
|
bBack.x = width - bBack.width;//width / 2 + 4;
|
||||||
|
|
||||||
|
bJoin.x = (width - bJoin.width) / 2;
|
||||||
|
|
||||||
|
bHeader.x = 0;
|
||||||
|
bHeader.width = width - bBack.width;
|
||||||
|
|
||||||
|
tIP.width = bJoin.width + tIpDiff;
|
||||||
|
tIP.height = 16;
|
||||||
|
tIP.x = bJoin.x - tIpDiff / 2;
|
||||||
|
tIP.y = ((height - bJoin.height) / 2) - tIP.height - 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JoinByIPScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||||
|
int lvlTop = tIP.y - (Font::DefaultLineHeight + 4);
|
||||||
|
int lvlBottom = tIP.y + tIP.height;
|
||||||
|
int lvlLeft = tIP.x;
|
||||||
|
int lvlRight = tIP.x + tIP.width;
|
||||||
|
bool clickedIP = x >= lvlLeft && x < lvlRight && y >= lvlTop && y < lvlBottom;
|
||||||
|
|
||||||
|
if (clickedIP) {
|
||||||
|
tIP.setFocus(minecraft);
|
||||||
|
} else {
|
||||||
|
tIP.loseFocus(minecraft);
|
||||||
|
}
|
||||||
|
|
||||||
|
Screen::mouseClicked(x, y, buttonNum);
|
||||||
|
}
|
||||||
|
void JoinByIPScreen::render( int xm, int ym, float a )
|
||||||
|
{
|
||||||
|
renderBackground();
|
||||||
|
Screen::render(xm, ym, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JoinByIPScreen::keyPressed(int eventKey)
|
||||||
|
{
|
||||||
|
if (eventKey == Keyboard::KEY_ESCAPE) {
|
||||||
|
minecraft->screenChooser.setScreen(SCREEN_STARTMENU);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// let base class handle navigation and text box keys
|
||||||
|
Screen::keyPressed(eventKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JoinByIPScreen::keyboardNewChar(char inputChar)
|
||||||
|
{
|
||||||
|
// forward character input to focused textbox(s)
|
||||||
|
for (auto* tb : textBoxes) tb->handleChar(inputChar);
|
||||||
|
}
|
||||||
30
src/client/gui/screens/JoinByIPScreen.h
Normal file
30
src/client/gui/screens/JoinByIPScreen.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
#include "../Screen.h"
|
||||||
|
#include "../components/Button.h"
|
||||||
|
#include "../../Minecraft.h"
|
||||||
|
#include "client/gui/components/ImageButton.h"
|
||||||
|
#include "client/gui/components/TextBox.h"
|
||||||
|
|
||||||
|
class JoinByIPScreen: public Screen
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
JoinByIPScreen();
|
||||||
|
virtual ~JoinByIPScreen();
|
||||||
|
|
||||||
|
void init();
|
||||||
|
void setupPositions();
|
||||||
|
|
||||||
|
virtual void tick();
|
||||||
|
void render(int xm, int ym, float a);
|
||||||
|
|
||||||
|
virtual void keyPressed(int eventKey);
|
||||||
|
virtual void keyboardNewChar(char inputChar);
|
||||||
|
void buttonClicked(Button* button);
|
||||||
|
virtual void mouseClicked(int x, int y, int buttonNum);
|
||||||
|
virtual bool handleBackEvent(bool isDown);
|
||||||
|
private:
|
||||||
|
TextBox tIP;
|
||||||
|
Touch::THeader bHeader;
|
||||||
|
Touch::TButton bJoin;
|
||||||
|
ImageButton bBack;
|
||||||
|
};
|
||||||
@@ -77,8 +77,8 @@ void OptionsScreen::init() {
|
|||||||
categoryButtons.push_back(new Touch::TButton(4, "Controls"));
|
categoryButtons.push_back(new Touch::TButton(4, "Controls"));
|
||||||
categoryButtons.push_back(new Touch::TButton(5, "Graphics"));
|
categoryButtons.push_back(new Touch::TButton(5, "Graphics"));
|
||||||
|
|
||||||
btnChangeUsername = new Button(10, "Username");
|
btnChangeUsername = new Touch::TButton(10, "Username");
|
||||||
btnCredits = new Button(11, "Credits");
|
btnCredits = new Touch::TButton(11, "Credits");
|
||||||
|
|
||||||
buttons.push_back(bHeader);
|
buttons.push_back(bHeader);
|
||||||
buttons.push_back(btnClose);
|
buttons.push_back(btnClose);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "PauseScreen.h"
|
#include "PauseScreen.h"
|
||||||
#include "RenameMPLevelScreen.h"
|
#include "RenameMPLevelScreen.h"
|
||||||
#include "IngameBlockSelectionScreen.h"
|
#include "IngameBlockSelectionScreen.h"
|
||||||
|
#include "JoinByIPScreen.h"
|
||||||
#include "touch/TouchStartMenuScreen.h"
|
#include "touch/TouchStartMenuScreen.h"
|
||||||
#include "touch/TouchSelectWorldScreen.h"
|
#include "touch/TouchSelectWorldScreen.h"
|
||||||
#include "touch/TouchJoinGameScreen.h"
|
#include "touch/TouchJoinGameScreen.h"
|
||||||
@@ -18,13 +19,13 @@ Screen* ScreenChooser::createScreen( ScreenId id )
|
|||||||
|
|
||||||
if (_mc->useTouchscreen()) {
|
if (_mc->useTouchscreen()) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case SCREEN_STARTMENU: screen = new Touch::StartMenuScreen(); break;
|
case SCREEN_STARTMENU: screen = new Touch::StartMenuScreen(); break;
|
||||||
case SCREEN_SELECTWORLD:screen = new Touch::SelectWorldScreen();break;
|
case SCREEN_SELECTWORLD: screen = new Touch::SelectWorldScreen();break;
|
||||||
case SCREEN_JOINGAME: screen = new Touch::JoinGameScreen(); break;
|
case SCREEN_JOINGAME: screen = new Touch::JoinGameScreen(); break;
|
||||||
case SCREEN_PAUSE: screen = new PauseScreen(false); break;
|
case SCREEN_PAUSE: screen = new PauseScreen(false); break;
|
||||||
case SCREEN_PAUSEPREV: screen = new PauseScreen(true); break;
|
case SCREEN_PAUSEPREV: screen = new PauseScreen(true); break;
|
||||||
case SCREEN_BLOCKSELECTION: screen = new Touch::IngameBlockSelectionScreen(); break;
|
case SCREEN_BLOCKSELECTION: screen = new Touch::IngameBlockSelectionScreen(); break;
|
||||||
|
case SCREEN_JOINBYIP: screen = new JoinByIPScreen(); break;
|
||||||
case SCREEN_NONE:
|
case SCREEN_NONE:
|
||||||
default:
|
default:
|
||||||
// Do nothing
|
// Do nothing
|
||||||
@@ -32,12 +33,13 @@ Screen* ScreenChooser::createScreen( ScreenId id )
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case SCREEN_STARTMENU: screen = new StartMenuScreen(); break;
|
case SCREEN_STARTMENU: screen = new StartMenuScreen(); break;
|
||||||
case SCREEN_SELECTWORLD:screen = new SelectWorldScreen();break;
|
case SCREEN_SELECTWORLD: screen = new SelectWorldScreen();break;
|
||||||
case SCREEN_JOINGAME: screen = new JoinGameScreen(); break;
|
case SCREEN_JOINGAME: screen = new JoinGameScreen(); break;
|
||||||
case SCREEN_PAUSE: screen = new PauseScreen(false); break;
|
case SCREEN_PAUSE: screen = new PauseScreen(false); break;
|
||||||
case SCREEN_PAUSEPREV: screen = new PauseScreen(true); break;
|
case SCREEN_PAUSEPREV: screen = new PauseScreen(true); break;
|
||||||
case SCREEN_BLOCKSELECTION: screen = new IngameBlockSelectionScreen(); break;
|
case SCREEN_BLOCKSELECTION: screen = new IngameBlockSelectionScreen(); break;
|
||||||
|
case SCREEN_JOINBYIP: screen = new JoinByIPScreen(); break;
|
||||||
|
|
||||||
case SCREEN_NONE:
|
case SCREEN_NONE:
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ enum ScreenId {
|
|||||||
SCREEN_PAUSE,
|
SCREEN_PAUSE,
|
||||||
SCREEN_PAUSEPREV,
|
SCREEN_PAUSEPREV,
|
||||||
SCREEN_SELECTWORLD,
|
SCREEN_SELECTWORLD,
|
||||||
SCREEN_BLOCKSELECTION
|
SCREEN_BLOCKSELECTION,
|
||||||
|
SCREEN_JOINBYIP
|
||||||
};
|
};
|
||||||
|
|
||||||
class Screen;
|
class Screen;
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ SimpleChooseLevelScreen::~SimpleChooseLevelScreen()
|
|||||||
|
|
||||||
void SimpleChooseLevelScreen::init()
|
void SimpleChooseLevelScreen::init()
|
||||||
{
|
{
|
||||||
|
tLevelName.text = "New world";
|
||||||
|
|
||||||
// header + close button
|
// header + close button
|
||||||
bHeader = new Touch::THeader(0, "Create World");
|
bHeader = new Touch::THeader(0, "Create World");
|
||||||
// create the back/X button as ImageButton like CreditsScreen
|
// create the back/X button as ImageButton like CreditsScreen
|
||||||
@@ -186,7 +188,7 @@ void SimpleChooseLevelScreen::buttonClicked( Button* button )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button == bCreate) {
|
if (button == bCreate && !tLevelName.text.empty()) {
|
||||||
int seed = getEpochTimeS();
|
int seed = getEpochTimeS();
|
||||||
if (!tSeed.text.empty()) {
|
if (!tSeed.text.empty()) {
|
||||||
std::string seedString = Util::stringTrim(tSeed.text);
|
std::string seedString = Util::stringTrim(tSeed.text);
|
||||||
|
|||||||
@@ -5,9 +5,7 @@
|
|||||||
#include "JoinGameScreen.h"
|
#include "JoinGameScreen.h"
|
||||||
#include "OptionsScreen.h"
|
#include "OptionsScreen.h"
|
||||||
#include "PauseScreen.h"
|
#include "PauseScreen.h"
|
||||||
#include "InvalidLicenseScreen.h"
|
|
||||||
#include "PrerenderTilesScreen.h" // test button
|
#include "PrerenderTilesScreen.h" // test button
|
||||||
//#include "BuyGameScreen.h"
|
|
||||||
|
|
||||||
#include "../../../util/Mth.h"
|
#include "../../../util/Mth.h"
|
||||||
|
|
||||||
@@ -27,9 +25,7 @@
|
|||||||
StartMenuScreen::StartMenuScreen()
|
StartMenuScreen::StartMenuScreen()
|
||||||
: bHost( 2, 0, 0, 160, 24, "Start Game"),
|
: bHost( 2, 0, 0, 160, 24, "Start Game"),
|
||||||
bJoin( 3, 0, 0, 160, 24, "Join Game"),
|
bJoin( 3, 0, 0, 160, 24, "Join Game"),
|
||||||
bOptions( 4, 0, 0, 78, 22, "Options"),
|
bOptions( 4, 0, 0, 78, 22, "Options")
|
||||||
bBuy( 5, 0, 0, 78, 22, "Buy"),
|
|
||||||
bTest( 999, 0, 0, 78, 22, "Create")
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,6 +35,9 @@ StartMenuScreen::~StartMenuScreen()
|
|||||||
|
|
||||||
void StartMenuScreen::init()
|
void StartMenuScreen::init()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
bJoin.active = bHost.active = bOptions.active = true;
|
||||||
|
|
||||||
if (minecraft->options.username.empty()) {
|
if (minecraft->options.username.empty()) {
|
||||||
return; // tick() will redirect to UsernameScreen
|
return; // tick() will redirect to UsernameScreen
|
||||||
}
|
}
|
||||||
@@ -94,14 +93,12 @@ void StartMenuScreen::setupPositions() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bOptions.y = yBase + 28 + 2;
|
bOptions.y = yBase + 28 + 2;
|
||||||
bTest.y = bBuy.y = bOptions.y;
|
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
// Center buttons
|
// Center buttons
|
||||||
bHost.x = (width - bHost.width) / 2;
|
bHost.x = (width - bHost.width) / 2;
|
||||||
bJoin.x = (width - bJoin.width) / 2;
|
bJoin.x = (width - bJoin.width) / 2;
|
||||||
bOptions.x = (width - bJoin.width) / 2;
|
bOptions.x = (width - bJoin.width) / 2;
|
||||||
bTest.x = bBuy.x = bOptions.x + bOptions.width + 4;
|
|
||||||
|
|
||||||
copyrightPosX = width - minecraft->font->width(copyright) - 1;
|
copyrightPosX = width - minecraft->font->width(copyright) - 1;
|
||||||
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
|
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
|
||||||
@@ -112,7 +109,6 @@ void StartMenuScreen::tick() {
|
|||||||
minecraft->setScreen(new UsernameScreen());
|
minecraft->setScreen(new UsernameScreen());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_updateLicense();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenuScreen::buttonClicked(Button* button) {
|
void StartMenuScreen::buttonClicked(Button* button) {
|
||||||
@@ -134,16 +130,6 @@ void StartMenuScreen::buttonClicked(Button* button) {
|
|||||||
{
|
{
|
||||||
minecraft->setScreen(new OptionsScreen());
|
minecraft->setScreen(new OptionsScreen());
|
||||||
}
|
}
|
||||||
if (button->id == bTest.id)
|
|
||||||
{
|
|
||||||
//minecraft->setScreen(new PauseScreen());
|
|
||||||
//minecraft->setScreen(new PrerenderTilesScreen());
|
|
||||||
}
|
|
||||||
if (button->id == bBuy.id)
|
|
||||||
{
|
|
||||||
minecraft->platform()->buyGame();
|
|
||||||
//minecraft->setScreen(new BuyGameScreen());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartMenuScreen::isInGameScreen() { return false; }
|
bool StartMenuScreen::isInGameScreen() { return false; }
|
||||||
@@ -202,23 +188,6 @@ void StartMenuScreen::render( int xm, int ym, float a )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenuScreen::_updateLicense()
|
|
||||||
{
|
|
||||||
int id = minecraft->getLicenseId();
|
|
||||||
if (LicenseCodes::isReady(id))
|
|
||||||
{
|
|
||||||
if (LicenseCodes::isOk(id))
|
|
||||||
bJoin.active = bHost.active = bOptions.active = true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool hasBuyButton = minecraft->platform()->hasBuyButtonWhenInvalidLicense();
|
|
||||||
minecraft->setScreen(new InvalidLicenseScreen(id, hasBuyButton));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
bJoin.active = bHost.active = bOptions.active = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) {
|
void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||||
const int logoX = 2;
|
const int logoX = 2;
|
||||||
const int logoW = 8 + 2 + font->width("Kolyah35/minecraft-pe-0.6.1");
|
const int logoW = 8 + 2 + font->width("Kolyah35/minecraft-pe-0.6.1");
|
||||||
|
|||||||
@@ -21,13 +21,10 @@ public:
|
|||||||
bool handleBackEvent(bool isDown);
|
bool handleBackEvent(bool isDown);
|
||||||
bool isInGameScreen();
|
bool isInGameScreen();
|
||||||
private:
|
private:
|
||||||
void _updateLicense();
|
|
||||||
|
|
||||||
Button bHost;
|
Button bHost;
|
||||||
Button bJoin;
|
Button bJoin;
|
||||||
Button bOptions;
|
Button bOptions;
|
||||||
Button bTest;
|
|
||||||
Button bBuy;
|
|
||||||
|
|
||||||
std::string copyright;
|
std::string copyright;
|
||||||
int copyrightPosX;
|
int copyrightPosX;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
UsernameScreen::UsernameScreen()
|
UsernameScreen::UsernameScreen()
|
||||||
: _btnDone(0, "Done"),
|
: _btnDone(0, "Done"),
|
||||||
_input(""),
|
tUsername(0, "Username"),
|
||||||
_cursorBlink(0)
|
_cursorBlink(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -23,55 +23,68 @@ void UsernameScreen::init()
|
|||||||
_input = "";
|
_input = "";
|
||||||
_btnDone.active = false; // disabled until name typed
|
_btnDone.active = false; // disabled until name typed
|
||||||
buttons.push_back(&_btnDone);
|
buttons.push_back(&_btnDone);
|
||||||
|
tabButtons.push_back(&_btnDone);
|
||||||
|
textBoxes.push_back(&tUsername);
|
||||||
setupPositions();
|
setupPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsernameScreen::setupPositions()
|
void UsernameScreen::setupPositions()
|
||||||
{
|
{
|
||||||
|
int cx = width / 2;
|
||||||
|
int cy = height / 2;
|
||||||
|
|
||||||
_btnDone.width = 120;
|
_btnDone.width = 120;
|
||||||
_btnDone.height = 20;
|
_btnDone.height = 20;
|
||||||
_btnDone.x = (width - _btnDone.width) / 2;
|
_btnDone.x = (width - _btnDone.width) / 2;
|
||||||
_btnDone.y = height / 2 + 52;
|
_btnDone.y = height / 2 + 52;
|
||||||
|
|
||||||
|
tUsername.x = _btnDone.x;
|
||||||
|
tUsername.y = _btnDone.y - 60;
|
||||||
|
tUsername.width = 120;
|
||||||
|
tUsername.height = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsernameScreen::tick()
|
void UsernameScreen::tick()
|
||||||
{
|
{
|
||||||
_cursorBlink++;
|
for (auto* tb : textBoxes)
|
||||||
|
tb->tick(minecraft);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsernameScreen::keyPressed(int eventKey)
|
void UsernameScreen::keyPressed(int eventKey)
|
||||||
{
|
{
|
||||||
if (eventKey == Keyboard::KEY_BACKSPACE) {
|
if (eventKey == Keyboard::KEY_RETURN) {
|
||||||
if (!_input.empty())
|
if (!tUsername.text.empty())
|
||||||
_input.erase(_input.size() - 1, 1);
|
|
||||||
} else if (eventKey == Keyboard::KEY_RETURN) {
|
|
||||||
if (!_input.empty())
|
|
||||||
buttonClicked(&_btnDone);
|
buttonClicked(&_btnDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
// deliberately do NOT call super::keyPressed — that would close the screen on Escape
|
// deliberately do NOT call super::keyPressed — that would close the screen on Escape
|
||||||
_btnDone.active = !_input.empty();
|
_btnDone.active = !tUsername.text.empty();
|
||||||
|
|
||||||
|
Screen::keyPressed(eventKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsernameScreen::keyboardNewChar(char inputChar)
|
void UsernameScreen::keyboardNewChar(char inputChar)
|
||||||
{
|
{
|
||||||
if (_input.size() < 16 && inputChar >= 32 && inputChar < 127)
|
for (auto* tb : textBoxes) tb->handleChar(inputChar);
|
||||||
_input += inputChar;
|
|
||||||
_btnDone.active = !_input.empty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsernameScreen::mouseClicked(int x, int y, int button)
|
void UsernameScreen::mouseClicked(int x, int y, int button)
|
||||||
{
|
{
|
||||||
int cx = width / 2;
|
int lvlTop = tUsername.y - (Font::DefaultLineHeight + 4);
|
||||||
int cy = height / 2;
|
int lvlBottom = tUsername.y + tUsername.height;
|
||||||
int boxW = 160;
|
int lvlLeft = tUsername.x;
|
||||||
int boxH = 18;
|
int lvlRight = tUsername.x + tUsername.width;
|
||||||
int boxX = cx - boxW / 2;
|
bool clickedLevel = x >= lvlLeft && x < lvlRight && y >= lvlTop && y < lvlBottom;
|
||||||
int boxY = cy - 5;
|
|
||||||
if (x >= boxX && x <= boxX + boxW && y >= boxY && y <= boxY + boxH) {
|
if (clickedLevel) {
|
||||||
minecraft->platform()->showKeyboard();
|
tUsername.setFocus(minecraft);
|
||||||
} else {
|
} else {
|
||||||
super::mouseClicked(x, y, button);
|
// click outside both fields -> blur both
|
||||||
|
tUsername.loseFocus(minecraft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// also let the parent class handle button presses/etc.
|
||||||
|
Screen::mouseClicked(x, y, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsernameScreen::removed()
|
void UsernameScreen::removed()
|
||||||
@@ -81,10 +94,10 @@ void UsernameScreen::removed()
|
|||||||
|
|
||||||
void UsernameScreen::buttonClicked(Button* button)
|
void UsernameScreen::buttonClicked(Button* button)
|
||||||
{
|
{
|
||||||
if (button == &_btnDone && !_input.empty()) {
|
if (button == &_btnDone && !tUsername.text.empty()) {
|
||||||
minecraft->options.username = _input;
|
minecraft->options.username = tUsername.text;
|
||||||
minecraft->options.save();
|
minecraft->options.save();
|
||||||
minecraft->user->name = _input;
|
minecraft->user->name = tUsername.text;
|
||||||
minecraft->setScreen(NULL); // goes to StartMenuScreen
|
minecraft->setScreen(NULL); // goes to StartMenuScreen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,23 +118,8 @@ void UsernameScreen::render(int xm, int ym, float a)
|
|||||||
drawCenteredString(font, "identify you in chat. Don't worry, you can", cx, cy - 40, 0xffaaaaaa);
|
drawCenteredString(font, "identify you in chat. Don't worry, you can", cx, cy - 40, 0xffaaaaaa);
|
||||||
drawCenteredString(font, "change it anytime.", cx, cy - 28, 0xffaaaaaa);
|
drawCenteredString(font, "change it anytime.", cx, cy - 28, 0xffaaaaaa);
|
||||||
|
|
||||||
// Input box background
|
// // Hint below box
|
||||||
int boxW = 160;
|
// drawCenteredString(font, "Max 16 characters", cx, cy + 20, 0xff808080);
|
||||||
int boxH = 18;
|
|
||||||
int boxX = cx - boxW / 2;
|
|
||||||
int boxY = cy - 5;
|
|
||||||
fill(boxX - 1, boxY - 1, boxX + boxW + 1, boxY + boxH + 1, 0xff000000);
|
|
||||||
fill(boxX, boxY, boxX + boxW, boxY + boxH, 0xff202020);
|
|
||||||
|
|
||||||
// Build display string with cursor
|
|
||||||
std::string display = _input;
|
|
||||||
if ((_cursorBlink / 10) % 2 == 0)
|
|
||||||
display += '|';
|
|
||||||
|
|
||||||
font->draw(display, (float)(boxX + 4), (float)(boxY + (boxH - 8) / 2 + 1), 0xffffffff, false);
|
|
||||||
|
|
||||||
// Hint below box
|
|
||||||
drawCenteredString(font, "Max 16 characters", cx, cy + 20, 0xff808080);
|
|
||||||
|
|
||||||
// Buttons (Done)
|
// Buttons (Done)
|
||||||
super::render(xm, ym, a);
|
super::render(xm, ym, a);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "../Screen.h"
|
#include "../Screen.h"
|
||||||
#include "../components/Button.h"
|
#include "../components/Button.h"
|
||||||
|
#include "client/gui/components/TextBox.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class UsernameScreen : public Screen
|
class UsernameScreen : public Screen
|
||||||
@@ -30,6 +31,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Button _btnDone;
|
Button _btnDone;
|
||||||
|
TextBox tUsername;
|
||||||
std::string _input;
|
std::string _input;
|
||||||
int _cursorBlink;
|
int _cursorBlink;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ void AvailableGamesList::renderItem( int i, int x, int y, int h, Tesselator& t )
|
|||||||
JoinGameScreen::JoinGameScreen()
|
JoinGameScreen::JoinGameScreen()
|
||||||
: bJoin( 2, "Join Game"),
|
: bJoin( 2, "Join Game"),
|
||||||
bBack( 3, "Back"),
|
bBack( 3, "Back"),
|
||||||
|
bJoinByIp(4, "Join By IP"),
|
||||||
bHeader(0, ""),
|
bHeader(0, ""),
|
||||||
gamesList(NULL)
|
gamesList(NULL)
|
||||||
{
|
{
|
||||||
@@ -80,6 +81,7 @@ void JoinGameScreen::init()
|
|||||||
{
|
{
|
||||||
//buttons.push_back(&bJoin);
|
//buttons.push_back(&bJoin);
|
||||||
buttons.push_back(&bBack);
|
buttons.push_back(&bBack);
|
||||||
|
buttons.push_back(&bJoinByIp);
|
||||||
buttons.push_back(&bHeader);
|
buttons.push_back(&bHeader);
|
||||||
|
|
||||||
minecraft->raknetInstance->clearServerList();
|
minecraft->raknetInstance->clearServerList();
|
||||||
@@ -88,6 +90,7 @@ void JoinGameScreen::init()
|
|||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
//tabButtons.push_back(&bJoin);
|
//tabButtons.push_back(&bJoin);
|
||||||
tabButtons.push_back(&bBack);
|
tabButtons.push_back(&bBack);
|
||||||
|
tabButtons.push_back(&bJoinByIp);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,16 +98,18 @@ void JoinGameScreen::setupPositions() {
|
|||||||
//int yBase = height - 26;
|
//int yBase = height - 26;
|
||||||
|
|
||||||
//#ifdef ANDROID
|
//#ifdef ANDROID
|
||||||
bJoin.y = 0;
|
bJoin.y = 0;
|
||||||
bBack.y = 0;
|
bBack.y = 0;
|
||||||
bHeader.y = 0;
|
bJoinByIp.y = 0;
|
||||||
|
bHeader.y = 0;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
// Center buttons
|
// Center buttons
|
||||||
//bJoin.x = width / 2 - 4 - bJoin.w;
|
//bJoin.x = width / 2 - 4 - bJoin.w;
|
||||||
bBack.x = 0;//width / 2 + 4;
|
bBack.x = 0;//width / 2 + 4;
|
||||||
bHeader.x = bBack.width;
|
bJoinByIp.x = width - bJoinByIp.width;;
|
||||||
bHeader.width = width - bHeader.x;
|
bHeader.x = bJoinByIp.width;
|
||||||
|
bHeader.width = width - (bBack.width + bJoinByIp.width);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JoinGameScreen::buttonClicked(Button* button)
|
void JoinGameScreen::buttonClicked(Button* button)
|
||||||
@@ -124,6 +129,11 @@ void JoinGameScreen::buttonClicked(Button* button)
|
|||||||
//minecraft->locateMultiplayer();
|
//minecraft->locateMultiplayer();
|
||||||
//minecraft->setScreen(new JoinGameScreen());
|
//minecraft->setScreen(new JoinGameScreen());
|
||||||
}
|
}
|
||||||
|
if(button->id == bJoinByIp.id) {
|
||||||
|
minecraft->cancelLocateMultiplayer();
|
||||||
|
minecraft->screenChooser.setScreen(SCREEN_JOINBYIP);
|
||||||
|
}
|
||||||
|
|
||||||
if (button->id == bBack.id)
|
if (button->id == bBack.id)
|
||||||
{
|
{
|
||||||
minecraft->cancelLocateMultiplayer();
|
minecraft->cancelLocateMultiplayer();
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
Button bJoin;
|
Button bJoin;
|
||||||
TButton bBack;
|
TButton bBack;
|
||||||
|
TButton bJoinByIp;
|
||||||
THeader bHeader;
|
THeader bHeader;
|
||||||
AvailableGamesList* gamesList;
|
AvailableGamesList* gamesList;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
#include "../ProgressScreen.h"
|
#include "../ProgressScreen.h"
|
||||||
#include "../OptionsScreen.h"
|
#include "../OptionsScreen.h"
|
||||||
#include "../PauseScreen.h"
|
#include "../PauseScreen.h"
|
||||||
#include "../InvalidLicenseScreen.h"
|
|
||||||
//#include "BuyGameScreen.h"
|
|
||||||
|
|
||||||
#include "../../Font.h"
|
#include "../../Font.h"
|
||||||
#include "../../components/SmallButton.h"
|
#include "../../components/SmallButton.h"
|
||||||
@@ -22,62 +20,6 @@
|
|||||||
#include "../DialogDefinitions.h"
|
#include "../DialogDefinitions.h"
|
||||||
#include "../SimpleChooseLevelScreen.h"
|
#include "../SimpleChooseLevelScreen.h"
|
||||||
|
|
||||||
//
|
|
||||||
// Buy Button implementation
|
|
||||||
//
|
|
||||||
BuyButton::BuyButton(int id)
|
|
||||||
: super(id, "")
|
|
||||||
{
|
|
||||||
ImageDef def;
|
|
||||||
// Setup the source rectangle
|
|
||||||
def.setSrc(IntRectangle(64, 182, 190, 55));
|
|
||||||
def.width = 75;//rc.w / 3;
|
|
||||||
def.height = 75 * (55.0f / 190.0f);//rc.h / 3;
|
|
||||||
def.name = "gui/gui.png";
|
|
||||||
|
|
||||||
setImageDef(def, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuyButton::render(Minecraft* minecraft, int xm, int ym) {
|
|
||||||
glColor4f2(1, 1, 1, 1);
|
|
||||||
bool hovered = active && (minecraft->useTouchscreen()? (xm >= x && ym >= y && xm < x + width && ym < y + height) : false);
|
|
||||||
renderBg(minecraft, xm, ym);
|
|
||||||
TextureId texId = (_imageDef.name.length() > 0)? minecraft->textures->loadAndBindTexture(_imageDef.name) : Textures::InvalidId;
|
|
||||||
if ( Textures::isTextureIdValid(texId) ) {
|
|
||||||
const ImageDef& d = _imageDef;
|
|
||||||
Tesselator& t = Tesselator::instance;
|
|
||||||
|
|
||||||
t.begin();
|
|
||||||
if (!active) t.color(0xff808080);
|
|
||||||
else if (hovered||selected) t.color(0xffcccccc);
|
|
||||||
//else t.color(0xffe0e0e0);
|
|
||||||
else t.color(0xffffffff);
|
|
||||||
|
|
||||||
float hx = ((float) d.width) * 0.5f;
|
|
||||||
float hy = ((float) d.height) * 0.5f;
|
|
||||||
const float cx = ((float)x+d.x) + hx;
|
|
||||||
const float cy = ((float)y+d.y) + hy;
|
|
||||||
if (hovered) {
|
|
||||||
hx *= 0.95f;
|
|
||||||
hy *= 0.95f;
|
|
||||||
}
|
|
||||||
|
|
||||||
const TextureData* td = minecraft->textures->getTemporaryTextureData(texId);
|
|
||||||
const IntRectangle* src = _imageDef.getSrc();
|
|
||||||
if (td != NULL && src != NULL) {
|
|
||||||
float u0 = (src->x) / (float)td->w;
|
|
||||||
float u1 = (src->x+src->w) / (float)td->w;
|
|
||||||
float v0 = (src->y) / (float)td->h;
|
|
||||||
float v1 = (src->y+src->h) / (float)td->h;
|
|
||||||
t.vertexUV(cx-hx, cy-hy, blitOffset, u0, v0);
|
|
||||||
t.vertexUV(cx-hx, cy+hy, blitOffset, u0, v1);
|
|
||||||
t.vertexUV(cx+hx, cy+hy, blitOffset, u1, v1);
|
|
||||||
t.vertexUV(cx+hx, cy-hy, blitOffset, u1, v0);
|
|
||||||
}
|
|
||||||
t.draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Touch {
|
namespace Touch {
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -88,8 +30,7 @@ namespace Touch {
|
|||||||
StartMenuScreen::StartMenuScreen()
|
StartMenuScreen::StartMenuScreen()
|
||||||
: bHost( 2, "Start Game"),
|
: bHost( 2, "Start Game"),
|
||||||
bJoin( 3, "Join Game"),
|
bJoin( 3, "Join Game"),
|
||||||
bOptions( 4, "Options"),
|
bOptions( 4, "Options")
|
||||||
bBuy( 5)
|
|
||||||
{
|
{
|
||||||
ImageDef def;
|
ImageDef def;
|
||||||
bJoin.width = 75;
|
bJoin.width = 75;
|
||||||
@@ -148,7 +89,7 @@ void StartMenuScreen::init()
|
|||||||
version = versionString + " (Demo)";
|
version = versionString + " (Demo)";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bJoin.active = bHost.active = bOptions.active = false;
|
bJoin.active = bHost.active = bOptions.active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenuScreen::setupPositions() {
|
void StartMenuScreen::setupPositions() {
|
||||||
@@ -166,20 +107,11 @@ void StartMenuScreen::setupPositions() {
|
|||||||
bJoin.x = 0*buttonWidth + (int)(1*spacing);
|
bJoin.x = 0*buttonWidth + (int)(1*spacing);
|
||||||
bHost.x = 1*buttonWidth + (int)(2*spacing);
|
bHost.x = 1*buttonWidth + (int)(2*spacing);
|
||||||
bOptions.x = 2*buttonWidth + (int)(3*spacing);
|
bOptions.x = 2*buttonWidth + (int)(3*spacing);
|
||||||
//bBuy.y = bOptions.y - bBuy.h - 6;
|
|
||||||
//bBuy.x = bOptions.x + bOptions.w - bBuy.w;
|
|
||||||
|
|
||||||
bBuy.y = height - bBuy.height - 3;
|
|
||||||
bBuy.x = (width - bBuy.width) / 2;
|
|
||||||
|
|
||||||
copyrightPosX = width - minecraft->font->width(copyright) - 1;
|
copyrightPosX = width - minecraft->font->width(copyright) - 1;
|
||||||
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
|
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenuScreen::tick() {
|
|
||||||
_updateLicense();
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartMenuScreen::buttonClicked(::Button* button) {
|
void StartMenuScreen::buttonClicked(::Button* button) {
|
||||||
|
|
||||||
if (button->id == bHost.id)
|
if (button->id == bHost.id)
|
||||||
@@ -203,11 +135,6 @@ void StartMenuScreen::buttonClicked(::Button* button) {
|
|||||||
{
|
{
|
||||||
minecraft->setScreen(new OptionsScreen());
|
minecraft->setScreen(new OptionsScreen());
|
||||||
}
|
}
|
||||||
if (button->id == bBuy.id)
|
|
||||||
{
|
|
||||||
minecraft->platform()->buyGame();
|
|
||||||
//minecraft->setScreen(new BuyGameScreen());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StartMenuScreen::isInGameScreen() { return false; }
|
bool StartMenuScreen::isInGameScreen() { return false; }
|
||||||
@@ -256,22 +183,6 @@ void StartMenuScreen::render( int xm, int ym, float a )
|
|||||||
glDisable2(GL_BLEND);
|
glDisable2(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMenuScreen::_updateLicense()
|
|
||||||
{
|
|
||||||
int id = minecraft->getLicenseId();
|
|
||||||
if (LicenseCodes::isReady(id))
|
|
||||||
{
|
|
||||||
if (LicenseCodes::isOk(id))
|
|
||||||
bJoin.active = bHost.active = bOptions.active = true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool hasBuyButton = minecraft->platform()->hasBuyButtonWhenInvalidLicense();
|
|
||||||
minecraft->setScreen(new InvalidLicenseScreen(id, hasBuyButton));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
bJoin.active = bHost.active = bOptions.active = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) {
|
void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||||
const int logoX = 2;
|
const int logoX = 2;
|
||||||
|
|||||||
@@ -5,14 +5,6 @@
|
|||||||
#include "../../components/LargeImageButton.h"
|
#include "../../components/LargeImageButton.h"
|
||||||
#include "../../components/TextBox.h"
|
#include "../../components/TextBox.h"
|
||||||
|
|
||||||
class BuyButton: public ImageButton {
|
|
||||||
typedef ImageButton super;
|
|
||||||
public:
|
|
||||||
BuyButton(int id);
|
|
||||||
void render(Minecraft* minecraft, int xm, int ym);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
namespace Touch {
|
namespace Touch {
|
||||||
|
|
||||||
class StartMenuScreen: public Screen
|
class StartMenuScreen: public Screen
|
||||||
@@ -23,8 +15,7 @@ public:
|
|||||||
|
|
||||||
void init();
|
void init();
|
||||||
void setupPositions();
|
void setupPositions();
|
||||||
|
|
||||||
void tick();
|
|
||||||
void render(int xm, int ym, float a);
|
void render(int xm, int ym, float a);
|
||||||
|
|
||||||
void buttonClicked(Button* button);
|
void buttonClicked(Button* button);
|
||||||
@@ -32,12 +23,10 @@ public:
|
|||||||
bool handleBackEvent(bool isDown);
|
bool handleBackEvent(bool isDown);
|
||||||
bool isInGameScreen();
|
bool isInGameScreen();
|
||||||
private:
|
private:
|
||||||
void _updateLicense();
|
|
||||||
|
|
||||||
LargeImageButton bHost;
|
LargeImageButton bHost;
|
||||||
LargeImageButton bJoin;
|
LargeImageButton bJoin;
|
||||||
LargeImageButton bOptions;
|
LargeImageButton bOptions;
|
||||||
BuyButton bBuy;
|
|
||||||
|
|
||||||
std::string copyright;
|
std::string copyright;
|
||||||
int copyrightPosX;
|
int copyrightPosX;
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#include "App.h"
|
#include "App.h"
|
||||||
#include "AppPlatform_android.h"
|
#include "AppPlatform_android.h"
|
||||||
|
|
||||||
|
// JNI keycode constants
|
||||||
|
#include <android/keycodes.h>
|
||||||
|
|
||||||
//#include "main_android_java.h"
|
//#include "main_android_java.h"
|
||||||
#include "platform/input/Multitouch.h"
|
#include "platform/input/Multitouch.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -181,20 +184,40 @@ Java_com_mojang_minecraftpe_GLRenderer_nativeUpdate(JNIEnv* env) {
|
|||||||
//
|
//
|
||||||
// Keyboard events
|
// Keyboard events
|
||||||
//
|
//
|
||||||
|
// helper to convert Android keycodes to our internal Keyboard constants
|
||||||
|
static int androidKeyToInternal(int androidKey) {
|
||||||
|
switch(androidKey) {
|
||||||
|
case AKEYCODE_DEL: return Keyboard::KEY_BACKSPACE;
|
||||||
|
case AKEYCODE_ENTER:
|
||||||
|
case AKEYCODE_NUMPAD_ENTER:
|
||||||
|
return Keyboard::KEY_RETURN;
|
||||||
|
// letters are delivered via nativeTextChar so no need to map here
|
||||||
|
default:
|
||||||
|
return androidKey; // fall back to raw code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_mojang_minecraftpe_MainActivity_nativeOnKeyDown(JNIEnv* env, jclass cls, jint keyCode) {
|
Java_com_mojang_minecraftpe_MainActivity_nativeOnKeyDown(JNIEnv* env, jclass cls, jint keyCode) {
|
||||||
LOGI("@nativeOnKeyDown: %d\n", keyCode);
|
LOGI("@nativeOnKeyDown: %d\n", keyCode);
|
||||||
Keyboard::feed(keyCode, true);
|
int mapped = androidKeyToInternal(keyCode);
|
||||||
|
Keyboard::feed(mapped, true);
|
||||||
}
|
}
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_mojang_minecraftpe_MainActivity_nativeTextChar(JNIEnv* env, jclass cls, jint unicodeChar) {
|
Java_com_mojang_minecraftpe_MainActivity_nativeTextChar(JNIEnv* env, jclass cls, jint unicodeChar) {
|
||||||
if (unicodeChar > 0 && unicodeChar < 128)
|
// soft-keyboards may send a backspace as a character code
|
||||||
|
if (unicodeChar == 8) {
|
||||||
|
Keyboard::feed(Keyboard::KEY_BACKSPACE, true);
|
||||||
|
Keyboard::feed(Keyboard::KEY_BACKSPACE, false);
|
||||||
|
} else if (unicodeChar > 0 && unicodeChar < 128) {
|
||||||
Keyboard::feedText((char)unicodeChar);
|
Keyboard::feedText((char)unicodeChar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_mojang_minecraftpe_MainActivity_nativeOnKeyUp(JNIEnv* env, jclass cls, jint keyCode) {
|
Java_com_mojang_minecraftpe_MainActivity_nativeOnKeyUp(JNIEnv* env, jclass cls, jint keyCode) {
|
||||||
LOGI("@nativeOnKeyUp: %d\n", (int)keyCode);
|
LOGI("@nativeOnKeyUp: %d\n", (int)keyCode);
|
||||||
Keyboard::feed(keyCode, false);
|
int mapped = androidKeyToInternal(keyCode);
|
||||||
|
Keyboard::feed(mapped, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
JNIEXPORT jboolean JNICALL
|
||||||
|
|||||||
Reference in New Issue
Block a user