34 Commits

Author SHA1 Message Date
fe73853a64 defined() would be better ig 2026-04-06 22:49:54 +03:00
845d721b1e fixed compile issues from main rebase and lowered ios minimum deployment back to 12 2026-04-06 14:48:46 -04:00
d7a02bfc90 Added iOS comppiling instructions to README 2026-04-06 14:28:07 -04:00
13fd830361 fixed the possible broken header search and added all jobs including ios to publish 2026-04-06 14:28:07 -04:00
a96b942c17 FIX: web and android compilation 2026-04-06 14:28:07 -04:00
c476153231 FIX: other platforms compilation 2026-04-06 14:28:07 -04:00
412a34562f Lowered minimum deployment to iOS 12, rather than iOS 14 2026-04-06 14:28:06 -04:00
98dd53e2f5 Update .github/workflows/build.yml
I keep messing this up. For now I am removing all the needs for publish except iOS
2026-04-06 14:28:06 -04:00
6f0c485a9f removed if line from publish to always run it. can we not skip publish thanks 2026-04-06 14:28:06 -04:00
7cc33b011d Fixed bugs in starting the game. ALso added build job for iOS ipa unsigned 2026-04-06 14:28:06 -04:00
aeb8e45879 fixed button not pressable on ios 2026-04-06 14:28:06 -04:00
d554767309 IT COMPILESgit add .! also added full screen support. see issues. 2026-04-06 14:28:06 -04:00
aec534d948 restore include paths for cross-platform builds because i messed absolutely every #include up. 2026-04-06 14:28:06 -04:00
8867878ccf more refactoring for iOS 2026-04-06 14:28:06 -04:00
44ece561e8 fixed slider for hopefully the final fucking time. Nether Reactor fix: Need to make the array for building it all unsigned integers as now Xcode is strict about the new C++ Standards as they have changed since 2011 2026-04-06 14:28:06 -04:00
22b59bd2cc Synced options UI files from main branch 2026-04-06 14:28:06 -04:00
705c4154ee gonna try changing all Options::Option* in the whole project to just Option* not sure if this works but it gets the compiler to shut up. if this breaks everything change all 'Option*' to 'Options::Option*' as it once was. 2026-04-06 14:28:06 -04:00
59898ca504 more header fixes 2026-04-06 14:28:06 -04:00
b658132dac fix missing file, commiting now because what im about to do might break Option class 2026-04-06 14:28:06 -04:00
ab5f177208 added needed missing files 2026-04-06 14:28:06 -04:00
72b68389b2 Started to port to iOS; fixing compiler errors here and there 2026-04-06 14:28:06 -04:00
Shredder
59ba8bfb7c my bad should be fixed now 2026-04-06 10:00:12 +05:00
Shredder
ef32fcfe08 attempt again 2026-04-06 02:26:46 +05:00
Shredder
2237515793 fileshredder - linux compile fix 2026-04-06 02:15:35 +05:00
Shredder
e272991159 fileshredder - minor goof up 2026-04-06 02:05:23 +05:00
Shredder
055f00be49 A bit big of a commit but
Added 3 Fog Choices (Pocket) (Java) (Unknown that was unused)

Restored Java Beta Sky Color code that was unused that depends on biome temperature (choosable using Java fog)

Tile Shadows and Entity Shadows that appear beneath them have been restored and fixed from the unused code, toggleable by turning fancy graphics on or off

Entities will now render flames on themselves when on fire, including the player

Added option to use Java Style Item Count text and position in tweaks

- fileshredder
2026-04-06 01:52:27 +05:00
Shredder
378dfe8e22 award for brain of a goldfish goes to me 2026-04-03 15:54:48 +05:00
Shredder
61f0124beb oops forgot to define some things 2026-04-03 15:37:15 +05:00
Shredder
ff5c57f6ba Added Foliage and Grass Color tinting, Started Basic Work on restoring ravines, New Option to Toggle Tinting. 2026-04-03 14:55:33 +05:00
Shredder
eac71a93d1 ok this should finally work now 2026-04-02 01:35:06 +05:00
Shredder
fa249728e5 hopefully fixes broken build 2026-04-02 01:19:47 +05:00
Shredder
84e8744387 oops forgot to include the other files. 2026-04-01 23:37:37 +05:00
Shredder
27f0287986 Ported over Spooner Trees (Fancy Trees), Flint and Steel can be used to ignite fire now and modified Forest and Rainforest to generate spooner trees. 2026-04-01 23:31:15 +05:00
Shredder
109bbcfdb1 Added Rendering and Dynamic texture for Fire and it's behaviour 2026-04-01 14:03:38 +05:00
973 changed files with 99775 additions and 91347 deletions

View File

@@ -72,6 +72,30 @@ jobs:
${{github.workspace}}/build/OpenAL32.dll ${{github.workspace}}/build/OpenAL32.dll
${{github.workspace}}/build/libz.dll ${{github.workspace}}/build/libz.dll
build-ios:
# credit to pengubow from deepfriedwaffles repo
name: Build iOS
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Build
run: |
cd project/iosproj
xcodebuild -scheme minecraftpe -derivedDataPath build -destination 'generic/platform=iOS' CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
mkdir -p Payload
cp -R build/Build/Products/Debug-iphoneos/minecraftpe.app Payload/
zip -r minecraftpe.ipa Payload
rm -rf Payload
- name: Upload artifact
uses: actions/upload-artifact@main
with:
name: minecraftpe-ios
path: project/iosproj/minecraftpe.ipa
build-linux: build-linux:
name: Build Linux name: Build Linux
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -266,8 +290,7 @@ jobs:
publish: publish:
name: Publish name: Publish
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [ build-windows, build-linux, build-android, build-web ] needs: [ build-windows, build-ios, build-linux, build-android, build-web ]
if: github.ref == 'refs/heads/main'
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -340,4 +363,4 @@ jobs:
./minecraftpe-server-${{ steps.ref.outputs.hash }}.zip ./minecraftpe-server-${{ steps.ref.outputs.hash }}.zip
./minecraftpe-${{ steps.ref.outputs.hash }}-android-arm64-v8a.zip ./minecraftpe-${{ steps.ref.outputs.hash }}-android-arm64-v8a.zip
./minecraftpe-${{ steps.ref.outputs.hash }}-android-armeabi-v7a.zip ./minecraftpe-${{ steps.ref.outputs.hash }}-android-armeabi-v7a.zip
./minecraftpe-${{ steps.ref.outputs.hash }}-web.zip ./minecraftpe-${{ steps.ref.outputs.hash }}-web.zip

View File

@@ -39,8 +39,6 @@ if (${PLATFORM} STREQUAL "Desktop")
set(EXTRA_LIBS pthread m) set(EXTRA_LIBS pthread m)
endif() endif()
include_directories("glad/include")
elseif (${PLATFORM} STREQUAL "Web") elseif (${PLATFORM} STREQUAL "Web")
set(PLATFORM_CPP "PLATFORM_WEB") set(PLATFORM_CPP "PLATFORM_WEB")
set(EXTRA_LIBS "idbfs.js") set(EXTRA_LIBS "idbfs.js")
@@ -116,38 +114,34 @@ CPMAddPackage(
# TODO: Clear this paths with * # TODO: Clear this paths with *
file(GLOB SERVER_SOURCES file(GLOB SERVER_SOURCES
"project/lib_projects/raknet/jni/RaknetSources/*.cpp" "project/lib_projects/raknet/jni/RaknetSources/*.cpp"
"src/NinecraftApp.cpp"
"src/Performance.cpp" "src/Performance.cpp"
"src/SharedConstants.cpp" "src/SharedConstants.cpp"
"src/Minecraft.cpp"
"src/MinecraftServer.cpp"
"src/App.cpp"
"src/IPlatform.cpp"
"src/client/IConfigListener.cpp"
"src/client/Minecraft.cpp"
"src/client/OptionStrings.cpp"
"src/client/Option.cpp"
"src/client/Options.cpp"
"src/client/OptionsFile.cpp"
"src/client/ServerProfiler.cpp"
# "src/client/IConfigListener.cpp" "src/client/gamemode/CreativeMode.cpp"
# "src/client/Minecraft.cpp" "src/client/gamemode/GameMode.cpp"
# "src/client/OptionStrings.cpp" "src/client/gamemode/SurvivalMode.cpp"
# "src/client/Option.cpp"
# "src/client/Options.cpp"
# "src/client/OptionsFile.cpp"
# "src/client/ServerProfiler.cpp"
# "src/client/gamemode/CreativeMode.cpp" "src/client/player/LocalPlayer.cpp"
# "src/client/gamemode/GameMode.cpp" "src/client/player/RemotePlayer.cpp"
# "src/client/gamemode/SurvivalMode.cpp" "src/client/player/input/KeyboardInput.cpp"
# "src/client/player/LocalPlayer.cpp"
# "src/client/player/RemotePlayer.cpp"
# "src/client/player/input/KeyboardInput.cpp"
"src/gamemode/*.cpp"
"src/locale/I18n.cpp" "src/locale/I18n.cpp"
"src/main.cpp"
"src/main_dedicated.cpp" "src/main_dedicated.cpp"
"src/nbt/Tag.cpp" "src/nbt/Tag.cpp"
"src/network/ClientSideNetworkHandler.cpp"
"src/network/NetEventCallback.cpp" "src/network/NetEventCallback.cpp"
"src/network/Packet.cpp" "src/network/Packet.cpp"
"src/network/RakNetInstance.cpp" "src/network/RakNetInstance.cpp"
@@ -158,7 +152,11 @@ file(GLOB SERVER_SOURCES
"src/platform/HttpClient.cpp" "src/platform/HttpClient.cpp"
"src/platform/PngLoader.cpp" "src/platform/PngLoader.cpp"
"src/platform/time.cpp" "src/platform/time.cpp"
"src/platform/server/PlatformServer.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/ArgumentsSettings.cpp"
"src/server/ServerLevel.cpp" "src/server/ServerLevel.cpp"
@@ -168,6 +166,7 @@ file(GLOB SERVER_SOURCES
"src/util/Mth.cpp" "src/util/Mth.cpp"
"src/util/PerfTimer.cpp" "src/util/PerfTimer.cpp"
"src/util/StringUtils.cpp" "src/util/StringUtils.cpp"
"src/util/Color.cpp"
"src/world/Direction.cpp" "src/world/Direction.cpp"
@@ -201,6 +200,9 @@ file(GLOB SERVER_SOURCES
"src/world/level/dimension/Dimension.cpp" "src/world/level/dimension/Dimension.cpp"
"src/world/level/dimension/FoliageColor.cpp"
"src/world/level/GrassColor.cpp"
"src/world/level/levelgen/*.cpp" "src/world/level/levelgen/*.cpp"
"src/world/level/levelgen/feature/Feature.cpp" "src/world/level/levelgen/feature/Feature.cpp"
"src/world/level/levelgen/synth/*.cpp" "src/world/level/levelgen/synth/*.cpp"
@@ -260,6 +262,8 @@ file(GLOB CLIENT_SOURCES
"src/util/**.cpp" "src/util/**.cpp"
"src/util/Color.cpp"
"src/world/*.cpp" "src/world/*.cpp"
"src/world/phys/*.cpp" "src/world/phys/*.cpp"
"src/world/entity/*.cpp" "src/world/entity/*.cpp"
@@ -371,7 +375,7 @@ if(${PLATFORM} MATCHES "Web")
endif() endif()
# Client # Client
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" "${PLATFORM_CPP}") target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM})
target_link_libraries(${PROJECT_NAME} zlib ${PNG_LIB} OpenAL::OpenAL glfw ${EXTRA_LIBS}) target_link_libraries(${PROJECT_NAME} zlib ${PNG_LIB} OpenAL::OpenAL glfw ${EXTRA_LIBS})
if (OpenSSL_FOUND) if (OpenSSL_FOUND)

View File

@@ -197,4 +197,39 @@ cmake --build .
3. Run game: 3. Run game:
``` ```
emrun --port 8080 . emrun --port 8080 .
``` ```
## iOS
### Xcode
> [Note!]
> There's a precompiled IPA artifact in the GitHub mirror under Actions for those who either don't have Macs or don't want to build themself. But if you want to build youself, you'll need a Mac with Xcode. Download Xcode from the Mac App Store.
### 1. Clone
Open your terminal and clone the repository
```bash
git clone https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
cd minecraft-pe-0.6.1
```
You can also build from the ios-support branch by checking out to it
```
git checkout ios-support
```
### 2. Open in Xcode
The project file is in `minecraft-pe-0.6.1/project/iosproj/minecraftpe.xcodeproj`. Open it.
### 3. Configure Code Signing
Before you can deploy to an iPhone, you must sign the app with your own Apple Developer account:
1. Select the **minecraftpe** project in the left sidebar.
2. Go to **Signing & Capabilities**.
3. Change the **Bundle Identifier** to something unique (e.g., `com.yourname.mcpe`).
4. Select your **Team** from the dropdown menu.
### 4. Build and Run
1. Connect your iPhone via USB or LAN.
2. Select your device from the run destination menu at the top of Xcode.
3. Press **Cmd + R** (or the Play button).
4. **Note:** If you encounter a "Developer Mode" or "Untrusted Developer" error on your phone, go to **Settings > General > VPN & Device Management** to trust your certificate.

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
data/images/misc/shadow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -153,6 +153,7 @@ options.group.tweaks=Tweaks
options.allowSprint=Allow sprint options.allowSprint=Allow sprint
options.barOnTop=HUD above inventory options.barOnTop=HUD above inventory
options.rpiCursor=Show Raspberry PI cursor options.rpiCursor=Show Raspberry PI cursor
options.foliageTint=Tint Grass and Leaves
options.autoJump=Auto Jump options.autoJump=Auto Jump
options.thirdperson=Third Person options.thirdperson=Third Person
options.servervisible=Server Visible options.servervisible=Server Visible

View File

@@ -146,6 +146,7 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \
../../../src/util/StringUtils.cpp \ ../../../src/util/StringUtils.cpp \
../../../src/util/PerfTimer.cpp \ ../../../src/util/PerfTimer.cpp \
../../../src/util/PerfRenderer.cpp \ ../../../src/util/PerfRenderer.cpp \
../../../src/util/Color.cpp \
../../../src/world/Direction.cpp \ ../../../src/world/Direction.cpp \
../../../src/world/entity/AgableMob.cpp \ ../../../src/world/entity/AgableMob.cpp \
../../../src/world/entity/Entity.cpp \ ../../../src/world/entity/Entity.cpp \
@@ -209,6 +210,8 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \
../../../src/world/level/MobSpawner.cpp \ ../../../src/world/level/MobSpawner.cpp \
../../../src/world/level/Region.cpp \ ../../../src/world/level/Region.cpp \
../../../src/world/level/TickNextTickData.cpp \ ../../../src/world/level/TickNextTickData.cpp \
../../../src/world/level/FoliageColor.cpp \
../../../src/world/level/GrassColor.cpp \
../../../src/world/level/biome/Biome.cpp \ ../../../src/world/level/biome/Biome.cpp \
../../../src/world/level/biome/BiomeSource.cpp \ ../../../src/world/level/biome/BiomeSource.cpp \
../../../src/world/level/chunk/LevelChunk.cpp \ ../../../src/world/level/chunk/LevelChunk.cpp \

View File

@@ -122,6 +122,7 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \
../../../src/util/StringUtils.cpp \ ../../../src/util/StringUtils.cpp \
../../../src/util/PerfTimer.cpp \ ../../../src/util/PerfTimer.cpp \
../../../src/util/PerfRenderer.cpp \ ../../../src/util/PerfRenderer.cpp \
../../../src/util/Color.cpp \
../../../src/world/Direction.cpp \ ../../../src/world/Direction.cpp \
../../../src/world/entity/AgableMob.cpp \ ../../../src/world/entity/AgableMob.cpp \
../../../src/world/entity/Entity.cpp \ ../../../src/world/entity/Entity.cpp \
@@ -183,6 +184,8 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \
../../../src/world/level/MobSpawner.cpp \ ../../../src/world/level/MobSpawner.cpp \
../../../src/world/level/Region.cpp \ ../../../src/world/level/Region.cpp \
../../../src/world/level/TickNextTickData.cpp \ ../../../src/world/level/TickNextTickData.cpp \
../../../src/world/level/FoliageColor.cpp \
../../../src/world/level/GrassColor.cpp \
../../../src/world/level/biome/Biome.cpp \ ../../../src/world/level/biome/Biome.cpp \
../../../src/world/level/biome/BiomeSource.cpp \ ../../../src/world/level/biome/BiomeSource.cpp \
../../../src/world/level/chunk/LevelChunk.cpp \ ../../../src/world/level/chunk/LevelChunk.cpp \

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13142" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12042"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
<rect key="frame" x="0.0" y="626.5" width="375" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="minecraftpe" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
<rect key="frame" x="0.0" y="202" width="375" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
<constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" constant="20" symbolic="YES" id="SfN-ll-jLj"/>
<constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" constant="20" symbolic="YES" id="x7j-FC-K8j"/>
</constraints>
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

View File

@@ -41,7 +41,6 @@
042A91AE16B17517007ABBC6 /* GuiElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91A316B17517007ABBC6 /* GuiElement.cpp */; }; 042A91AE16B17517007ABBC6 /* GuiElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91A316B17517007ABBC6 /* GuiElement.cpp */; };
042A91AF16B17517007ABBC6 /* NinePatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91A516B17517007ABBC6 /* NinePatch.cpp */; }; 042A91AF16B17517007ABBC6 /* NinePatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91A516B17517007ABBC6 /* NinePatch.cpp */; };
042A91B016B17517007ABBC6 /* OptionsGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91A716B17517007ABBC6 /* OptionsGroup.cpp */; }; 042A91B016B17517007ABBC6 /* OptionsGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91A716B17517007ABBC6 /* OptionsGroup.cpp */; };
042A91B116B17517007ABBC6 /* OptionsPane.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91A916B17517007ABBC6 /* OptionsPane.cpp */; };
042A91B216B17517007ABBC6 /* TextBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91AB16B17517007ABBC6 /* TextBox.cpp */; }; 042A91B216B17517007ABBC6 /* TextBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91AB16B17517007ABBC6 /* TextBox.cpp */; };
044129071682FF9600B70EE6 /* MouseHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 044129061682FF9600B70EE6 /* MouseHandler.cpp */; }; 044129071682FF9600B70EE6 /* MouseHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 044129061682FF9600B70EE6 /* MouseHandler.cpp */; };
9D293CE716071C08000305C8 /* CreateNewWorld_iphone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9D293CE616071C08000305C8 /* CreateNewWorld_iphone.xib */; }; 9D293CE716071C08000305C8 /* CreateNewWorld_iphone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9D293CE616071C08000305C8 /* CreateNewWorld_iphone.xib */; };
@@ -1147,6 +1146,39 @@
D5F3B7DD14548E7900D25470 /* IASKPSToggleSwitchSpecifierViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D5F3B7C814548E7900D25470 /* IASKPSToggleSwitchSpecifierViewCell.xib */; }; D5F3B7DD14548E7900D25470 /* IASKPSToggleSwitchSpecifierViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D5F3B7C814548E7900D25470 /* IASKPSToggleSwitchSpecifierViewCell.xib */; };
D5F3B7DE14548E7900D25470 /* IASKSpecifierValuesView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D5F3B7C914548E7900D25470 /* IASKSpecifierValuesView.xib */; }; D5F3B7DE14548E7900D25470 /* IASKSpecifierValuesView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D5F3B7C914548E7900D25470 /* IASKSpecifierValuesView.xib */; };
D5F3B7E51454930400D25470 /* InAppSettings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = D5F3B7E41454930400D25470 /* InAppSettings.bundle */; }; D5F3B7E51454930400D25470 /* InAppSettings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = D5F3B7E41454930400D25470 /* InAppSettings.bundle */; };
F912B8CF2F6C3D5200BC60DF /* TextBox.h in Sources */ = {isa = PBXBuildFile; fileRef = 042A91AC16B17517007ABBC6 /* TextBox.h */; };
F99D341F2F736AA100DC153E /* HttpClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D341E2F736AA100DC153E /* HttpClient.cpp */; };
F99D34202F736AA100DC153E /* HttpClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D341E2F736AA100DC153E /* HttpClient.cpp */; };
F99D34232F736AD400DC153E /* TextOption.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D34222F736AD400DC153E /* TextOption.cpp */; };
F99D34242F736AD400DC153E /* TextOption.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D34222F736AD400DC153E /* TextOption.cpp */; };
F99D34272F736AFB00DC153E /* OptionsFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D34262F736AFB00DC153E /* OptionsFile.cpp */; };
F99D34282F736AFB00DC153E /* OptionsFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D34262F736AFB00DC153E /* OptionsFile.cpp */; };
F99D342B2F736B6F00DC153E /* OptionsItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D342A2F736B6F00DC153E /* OptionsItem.cpp */; };
F99D342C2F736B6F00DC153E /* OptionsItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D342A2F736B6F00DC153E /* OptionsItem.cpp */; };
F99D342F2F736BAD00DC153E /* ConsoleScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D342E2F736BAD00DC153E /* ConsoleScreen.cpp */; };
F99D34302F736BAD00DC153E /* ConsoleScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D342E2F736BAD00DC153E /* ConsoleScreen.cpp */; };
F99D34332F736BDA00DC153E /* CreditsScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D34322F736BDA00DC153E /* CreditsScreen.cpp */; };
F99D34342F736BDA00DC153E /* CreditsScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D34322F736BDA00DC153E /* CreditsScreen.cpp */; };
F99D34372F736C1000DC153E /* JoinByIPScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D34362F736C1000DC153E /* JoinByIPScreen.cpp */; };
F99D34382F736C1000DC153E /* JoinByIPScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D34362F736C1000DC153E /* JoinByIPScreen.cpp */; };
F99D343B2F736C3B00DC153E /* UsernameScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D343A2F736C3B00DC153E /* UsernameScreen.cpp */; };
F99D343C2F736C3B00DC153E /* UsernameScreen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D343A2F736C3B00DC153E /* UsernameScreen.cpp */; };
F99D343F2F736C8400DC153E /* GuiElementContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D343E2F736C8400DC153E /* GuiElementContainer.cpp */; };
F99D34402F736C8400DC153E /* GuiElementContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D343E2F736C8400DC153E /* GuiElementContainer.cpp */; };
F99D34432F736F9400DC153E /* Option.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D34422F736F9400DC153E /* Option.cpp */; };
F99D34442F736F9400DC153E /* Option.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D34422F736F9400DC153E /* Option.cpp */; };
F99D34472F736FE800DC153E /* KeyOption.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D34462F736FE800DC153E /* KeyOption.cpp */; };
F99D34482F736FE800DC153E /* KeyOption.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D34462F736FE800DC153E /* KeyOption.cpp */; };
F99D344B2F7370CF00DC153E /* Slider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D344A2F7370CF00DC153E /* Slider.cpp */; };
F99D344C2F7370CF00DC153E /* Slider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99D344A2F7370CF00DC153E /* Slider.cpp */; };
F99D344E2F7372A100DC153E /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F99D344D2F7372A100DC153E /* Launch Screen.storyboard */; };
F99D344F2F7372A100DC153E /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F99D344D2F7372A100DC153E /* Launch Screen.storyboard */; };
F99F0FA92F84369F00F2B29A /* GrassColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FA82F84369F00F2B29A /* GrassColor.cpp */; };
F99F0FAA2F84369F00F2B29A /* GrassColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FA82F84369F00F2B29A /* GrassColor.cpp */; };
F99F0FAC2F8436CE00F2B29A /* FoliageColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAB2F8436CE00F2B29A /* FoliageColor.cpp */; };
F99F0FAD2F8436CE00F2B29A /* FoliageColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAB2F8436CE00F2B29A /* FoliageColor.cpp */; };
F99F0FAF2F8436EB00F2B29A /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAE2F8436EB00F2B29A /* Color.cpp */; };
F99F0FB02F8436EB00F2B29A /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAE2F8436EB00F2B29A /* Color.cpp */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@@ -1208,10 +1240,8 @@
042A91A616B17517007ABBC6 /* NinePatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NinePatch.h; sourceTree = "<group>"; }; 042A91A616B17517007ABBC6 /* NinePatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NinePatch.h; sourceTree = "<group>"; };
042A91A716B17517007ABBC6 /* OptionsGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionsGroup.cpp; sourceTree = "<group>"; }; 042A91A716B17517007ABBC6 /* OptionsGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionsGroup.cpp; sourceTree = "<group>"; };
042A91A816B17517007ABBC6 /* OptionsGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionsGroup.h; sourceTree = "<group>"; }; 042A91A816B17517007ABBC6 /* OptionsGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionsGroup.h; sourceTree = "<group>"; };
042A91A916B17517007ABBC6 /* OptionsPane.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionsPane.cpp; sourceTree = "<group>"; };
042A91AA16B17517007ABBC6 /* OptionsPane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionsPane.h; sourceTree = "<group>"; };
042A91AB16B17517007ABBC6 /* TextBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextBox.cpp; sourceTree = "<group>"; }; 042A91AB16B17517007ABBC6 /* TextBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextBox.cpp; sourceTree = "<group>"; };
042A91AC16B17517007ABBC6 /* TextBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextBox.h; sourceTree = "<group>"; }; 042A91AC16B17517007ABBC6 /* TextBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextBox.h; path = ../../src/client/gui/components/TextBox.h; sourceTree = SOURCE_ROOT; };
044129061682FF9600B70EE6 /* MouseHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseHandler.cpp; sourceTree = "<group>"; }; 044129061682FF9600B70EE6 /* MouseHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseHandler.cpp; sourceTree = "<group>"; };
9D293CE616071C08000305C8 /* CreateNewWorld_iphone.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = CreateNewWorld_iphone.xib; path = minecraftpe/dialogs/CreateNewWorld_iphone.xib; sourceTree = "<group>"; }; 9D293CE616071C08000305C8 /* CreateNewWorld_iphone.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = CreateNewWorld_iphone.xib; path = minecraftpe/dialogs/CreateNewWorld_iphone.xib; sourceTree = "<group>"; };
9D293CEA160720D6000305C8 /* worldname_iphone5_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_iphone5_3.png; sourceTree = "<group>"; }; 9D293CEA160720D6000305C8 /* worldname_iphone5_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_iphone5_3.png; sourceTree = "<group>"; };
@@ -2017,7 +2047,7 @@
D5B50D6914CFF66F005F7284 /* Multitouch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Multitouch.h; sourceTree = "<group>"; }; D5B50D6914CFF66F005F7284 /* Multitouch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Multitouch.h; sourceTree = "<group>"; };
D5B50D6A14CFF66F005F7284 /* log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = log.h; sourceTree = "<group>"; }; D5B50D6A14CFF66F005F7284 /* log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = log.h; sourceTree = "<group>"; };
D5B50D6B14CFF66F005F7284 /* time.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = time.cpp; sourceTree = "<group>"; }; D5B50D6B14CFF66F005F7284 /* time.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = time.cpp; sourceTree = "<group>"; };
D5B50D6C14CFF66F005F7284 /* time.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = time.h; sourceTree = "<group>"; }; D5B50D6C14CFF66F005F7284 /* time.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; fileEncoding = 4; path = time.h; sourceTree = "<group>"; };
D5B50E5614CFF66F005F7284 /* SharedConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedConstants.h; sourceTree = "<group>"; }; D5B50E5614CFF66F005F7284 /* SharedConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedConstants.h; sourceTree = "<group>"; };
D5B50E5714CFF66F005F7284 /* terrain_4444.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = terrain_4444.h; sourceTree = "<group>"; }; D5B50E5714CFF66F005F7284 /* terrain_4444.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = terrain_4444.h; sourceTree = "<group>"; };
D5B50E5814CFF66F005F7284 /* terrain_5551.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = terrain_5551.h; sourceTree = "<group>"; }; D5B50E5814CFF66F005F7284 /* terrain_5551.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = terrain_5551.h; sourceTree = "<group>"; };
@@ -2408,6 +2438,34 @@
D5F3B7C814548E7900D25470 /* IASKPSToggleSwitchSpecifierViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = IASKPSToggleSwitchSpecifierViewCell.xib; sourceTree = "<group>"; }; D5F3B7C814548E7900D25470 /* IASKPSToggleSwitchSpecifierViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = IASKPSToggleSwitchSpecifierViewCell.xib; sourceTree = "<group>"; };
D5F3B7C914548E7900D25470 /* IASKSpecifierValuesView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = IASKSpecifierValuesView.xib; sourceTree = "<group>"; }; D5F3B7C914548E7900D25470 /* IASKSpecifierValuesView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = IASKSpecifierValuesView.xib; sourceTree = "<group>"; };
D5F3B7E41454930400D25470 /* InAppSettings.bundle */ = {isa = PBXFileReference; explicitFileType = "wrapper.installer-pkg"; path = InAppSettings.bundle; sourceTree = "<group>"; }; D5F3B7E41454930400D25470 /* InAppSettings.bundle */ = {isa = PBXFileReference; explicitFileType = "wrapper.installer-pkg"; path = InAppSettings.bundle; sourceTree = "<group>"; };
F99D341D2F736AA100DC153E /* HttpClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = HttpClient.h; path = ../../src/platform/HttpClient.h; sourceTree = "<group>"; };
F99D341E2F736AA100DC153E /* HttpClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = HttpClient.cpp; path = ../../src/platform/HttpClient.cpp; sourceTree = "<group>"; };
F99D34212F736AD400DC153E /* TextOption.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TextOption.h; path = ../../src/client/gui/components/TextOption.h; sourceTree = "<group>"; };
F99D34222F736AD400DC153E /* TextOption.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = TextOption.cpp; path = ../../src/client/gui/components/TextOption.cpp; sourceTree = "<unknown>"; };
F99D34252F736AFB00DC153E /* OptionsFile.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionsFile.h; path = ../../src/client/OptionsFile.h; sourceTree = "<group>"; };
F99D34262F736AFB00DC153E /* OptionsFile.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = OptionsFile.cpp; path = ../../src/client/OptionsFile.cpp; sourceTree = "<group>"; };
F99D34292F736B6F00DC153E /* OptionsItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = OptionsItem.h; path = ../../src/client/gui/components/OptionsItem.h; sourceTree = "<group>"; };
F99D342A2F736B6F00DC153E /* OptionsItem.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = OptionsItem.cpp; path = ../../src/client/gui/components/OptionsItem.cpp; sourceTree = "<group>"; };
F99D342D2F736BAD00DC153E /* ConsoleScreen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ConsoleScreen.h; path = ../../src/client/gui/screens/ConsoleScreen.h; sourceTree = "<group>"; };
F99D342E2F736BAD00DC153E /* ConsoleScreen.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = ConsoleScreen.cpp; path = ../../src/client/gui/screens/ConsoleScreen.cpp; sourceTree = "<group>"; };
F99D34312F736BDA00DC153E /* CreditsScreen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CreditsScreen.h; path = ../../src/client/gui/screens/CreditsScreen.h; sourceTree = "<group>"; };
F99D34322F736BDA00DC153E /* CreditsScreen.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = CreditsScreen.cpp; path = ../../src/client/gui/screens/CreditsScreen.cpp; sourceTree = "<group>"; };
F99D34352F736C1000DC153E /* JoinByIPScreen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = JoinByIPScreen.h; path = ../../src/client/gui/screens/JoinByIPScreen.h; sourceTree = "<group>"; };
F99D34362F736C1000DC153E /* JoinByIPScreen.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = JoinByIPScreen.cpp; path = ../../src/client/gui/screens/JoinByIPScreen.cpp; sourceTree = "<group>"; };
F99D34392F736C3B00DC153E /* UsernameScreen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = UsernameScreen.h; path = ../../src/client/gui/screens/UsernameScreen.h; sourceTree = "<group>"; };
F99D343A2F736C3B00DC153E /* UsernameScreen.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = UsernameScreen.cpp; path = ../../src/client/gui/screens/UsernameScreen.cpp; sourceTree = "<group>"; };
F99D343D2F736C8400DC153E /* GuiElementContainer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = GuiElementContainer.h; path = ../../src/client/gui/components/GuiElementContainer.h; sourceTree = "<group>"; };
F99D343E2F736C8400DC153E /* GuiElementContainer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = GuiElementContainer.cpp; path = ../../src/client/gui/components/GuiElementContainer.cpp; sourceTree = "<group>"; };
F99D34412F736F9400DC153E /* Option.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Option.h; path = ../../src/client/Option.h; sourceTree = "<group>"; };
F99D34422F736F9400DC153E /* Option.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Option.cpp; path = ../../src/client/Option.cpp; sourceTree = "<group>"; };
F99D34452F736FE800DC153E /* KeyOption.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = KeyOption.h; path = ../../src/client/gui/components/KeyOption.h; sourceTree = "<group>"; };
F99D34462F736FE800DC153E /* KeyOption.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = KeyOption.cpp; path = ../../src/client/gui/components/KeyOption.cpp; sourceTree = "<group>"; };
F99D34492F7370CF00DC153E /* Slider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Slider.h; path = ../../src/client/gui/components/Slider.h; sourceTree = "<group>"; };
F99D344A2F7370CF00DC153E /* Slider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Slider.cpp; path = ../../src/client/gui/components/Slider.cpp; sourceTree = "<group>"; };
F99D344D2F7372A100DC153E /* Launch Screen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = "<group>"; };
F99F0FA82F84369F00F2B29A /* GrassColor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GrassColor.cpp; sourceTree = "<group>"; };
F99F0FAB2F8436CE00F2B29A /* FoliageColor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FoliageColor.cpp; sourceTree = "<group>"; };
F99F0FAE2F8436EB00F2B29A /* Color.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Color.cpp; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@@ -3226,8 +3284,6 @@
042A91A616B17517007ABBC6 /* NinePatch.h */, 042A91A616B17517007ABBC6 /* NinePatch.h */,
042A91A716B17517007ABBC6 /* OptionsGroup.cpp */, 042A91A716B17517007ABBC6 /* OptionsGroup.cpp */,
042A91A816B17517007ABBC6 /* OptionsGroup.h */, 042A91A816B17517007ABBC6 /* OptionsGroup.h */,
042A91A916B17517007ABBC6 /* OptionsPane.cpp */,
042A91AA16B17517007ABBC6 /* OptionsPane.h */,
042A91AB16B17517007ABBC6 /* TextBox.cpp */, 042A91AB16B17517007ABBC6 /* TextBox.cpp */,
042A91AC16B17517007ABBC6 /* TextBox.h */, 042A91AC16B17517007ABBC6 /* TextBox.h */,
D5B50C2814CFF66F005F7284 /* Button.cpp */, D5B50C2814CFF66F005F7284 /* Button.cpp */,
@@ -3714,6 +3770,7 @@
D5B50E6914CFF66F005F7284 /* StringUtils.cpp */, D5B50E6914CFF66F005F7284 /* StringUtils.cpp */,
D5B50E6A14CFF66F005F7284 /* StringUtils.h */, D5B50E6A14CFF66F005F7284 /* StringUtils.h */,
D5B50E6B14CFF66F005F7284 /* WeighedRandom.h */, D5B50E6B14CFF66F005F7284 /* WeighedRandom.h */,
F99F0FAE2F8436EB00F2B29A /* Color.cpp */,
); );
path = util; path = util;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -3978,6 +4035,8 @@
D5B50F3714CFF66F005F7284 /* TickNextTickData.h */, D5B50F3714CFF66F005F7284 /* TickNextTickData.h */,
D5B50F3814CFF66F005F7284 /* tile */, D5B50F3814CFF66F005F7284 /* tile */,
D5B50F6814CFF66F005F7284 /* TilePos.h */, D5B50F6814CFF66F005F7284 /* TilePos.h */,
F99F0FA82F84369F00F2B29A /* GrassColor.cpp */,
F99F0FAB2F8436CE00F2B29A /* FoliageColor.cpp */,
); );
path = level; path = level;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -4256,6 +4315,7 @@
D5CF9C37144C225000E4244F = { D5CF9C37144C225000E4244F = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
F99D344D2F7372A100DC153E /* Launch Screen.storyboard */,
D5E1BA9A1451C8A0007DCC4F /* Default@2x.png */, D5E1BA9A1451C8A0007DCC4F /* Default@2x.png */,
9D959AFF16036BEE00E23A6F /* Default-568h@2x.png */, 9D959AFF16036BEE00E23A6F /* Default-568h@2x.png */,
D5F07744145EF79B00EC30FB /* Default-Landscape~ipad.png */, D5F07744145EF79B00EC30FB /* Default-Landscape~ipad.png */,
@@ -4267,6 +4327,30 @@
D5CF9C45144C225000E4244F /* Frameworks */, D5CF9C45144C225000E4244F /* Frameworks */,
D5CF9C43144C225000E4244F /* Products */, D5CF9C43144C225000E4244F /* Products */,
D5B50C1614CFF66F005F7284 /* src */, D5B50C1614CFF66F005F7284 /* src */,
F99D341D2F736AA100DC153E /* HttpClient.h */,
F99D341E2F736AA100DC153E /* HttpClient.cpp */,
F99D34212F736AD400DC153E /* TextOption.h */,
F99D34222F736AD400DC153E /* TextOption.cpp */,
F99D34252F736AFB00DC153E /* OptionsFile.h */,
F99D34262F736AFB00DC153E /* OptionsFile.cpp */,
F99D34292F736B6F00DC153E /* OptionsItem.h */,
F99D342A2F736B6F00DC153E /* OptionsItem.cpp */,
F99D342D2F736BAD00DC153E /* ConsoleScreen.h */,
F99D342E2F736BAD00DC153E /* ConsoleScreen.cpp */,
F99D34312F736BDA00DC153E /* CreditsScreen.h */,
F99D34322F736BDA00DC153E /* CreditsScreen.cpp */,
F99D34352F736C1000DC153E /* JoinByIPScreen.h */,
F99D34362F736C1000DC153E /* JoinByIPScreen.cpp */,
F99D34392F736C3B00DC153E /* UsernameScreen.h */,
F99D343A2F736C3B00DC153E /* UsernameScreen.cpp */,
F99D343D2F736C8400DC153E /* GuiElementContainer.h */,
F99D343E2F736C8400DC153E /* GuiElementContainer.cpp */,
F99D34412F736F9400DC153E /* Option.h */,
F99D34422F736F9400DC153E /* Option.cpp */,
F99D34452F736FE800DC153E /* KeyOption.h */,
F99D34462F736FE800DC153E /* KeyOption.cpp */,
F99D34492F7370CF00DC153E /* Slider.h */,
F99D344A2F7370CF00DC153E /* Slider.cpp */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
}; };
@@ -4527,10 +4611,16 @@
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0420; LastUpgradeCheck = 0420;
TargetAttributes = {
D5CF9C41144C225000E4244F = {
DevelopmentTeam = PZUVNW8F2U;
ProvisioningStyle = Automatic;
};
};
}; };
buildConfigurationList = D5CF9C3C144C225000E4244F /* Build configuration list for PBXProject "minecraftpe" */; buildConfigurationList = D5CF9C3C144C225000E4244F /* Build configuration list for PBXProject "minecraftpe" */;
compatibilityVersion = "Xcode 3.2"; compatibilityVersion = "Xcode 3.2";
developmentRegion = English; developmentRegion = en;
hasScannedForEncodings = 0; hasScannedForEncodings = 0;
knownRegions = ( knownRegions = (
en, en,
@@ -4599,6 +4689,7 @@
D5B50A5614CFF492005F7284 /* pig.png in Resources */, D5B50A5614CFF492005F7284 /* pig.png in Resources */,
D5B50A5814CFF492005F7284 /* sheep_fur.png in Resources */, D5B50A5814CFF492005F7284 /* sheep_fur.png in Resources */,
D5B50A5A14CFF492005F7284 /* sheep.png in Resources */, D5B50A5A14CFF492005F7284 /* sheep.png in Resources */,
F99D344F2F7372A100DC153E /* Launch Screen.storyboard in Resources */,
D5B50A5C14CFF492005F7284 /* skeleton.png in Resources */, D5B50A5C14CFF492005F7284 /* skeleton.png in Resources */,
D5B50A5E14CFF492005F7284 /* spider.png in Resources */, D5B50A5E14CFF492005F7284 /* spider.png in Resources */,
D5B50A6014CFF492005F7284 /* zombie.png in Resources */, D5B50A6014CFF492005F7284 /* zombie.png in Resources */,
@@ -4935,6 +5026,7 @@
D5ACF26F15C03DBF00E21C22 /* sand2.m4a in Resources */, D5ACF26F15C03DBF00E21C22 /* sand2.m4a in Resources */,
D5ACF27115C03DBF00E21C22 /* sand3.m4a in Resources */, D5ACF27115C03DBF00E21C22 /* sand3.m4a in Resources */,
D5ACF27315C03DBF00E21C22 /* sand4.m4a in Resources */, D5ACF27315C03DBF00E21C22 /* sand4.m4a in Resources */,
F99D344E2F7372A100DC153E /* Launch Screen.storyboard in Resources */,
D5ACF27515C03DBF00E21C22 /* snow1.m4a in Resources */, D5ACF27515C03DBF00E21C22 /* snow1.m4a in Resources */,
D5ACF27715C03DBF00E21C22 /* snow2.m4a in Resources */, D5ACF27715C03DBF00E21C22 /* snow2.m4a in Resources */,
D5ACF27915C03DBF00E21C22 /* snow3.m4a in Resources */, D5ACF27915C03DBF00E21C22 /* snow3.m4a in Resources */,
@@ -5011,18 +5103,22 @@
D58BB544146A0B910002C9F5 /* IASKSettingsStore.m in Sources */, D58BB544146A0B910002C9F5 /* IASKSettingsStore.m in Sources */,
D58BB545146A0B910002C9F5 /* IASKSettingsStoreFile.m in Sources */, D58BB545146A0B910002C9F5 /* IASKSettingsStoreFile.m in Sources */,
D58BB546146A0B910002C9F5 /* IASKSettingsStoreUserDefaults.m in Sources */, D58BB546146A0B910002C9F5 /* IASKSettingsStoreUserDefaults.m in Sources */,
F99D34232F736AD400DC153E /* TextOption.cpp in Sources */,
D58BB547146A0B910002C9F5 /* IASKSpecifier.m in Sources */, D58BB547146A0B910002C9F5 /* IASKSpecifier.m in Sources */,
D58BB548146A0B910002C9F5 /* IASKPSSliderSpecifierViewCell.m in Sources */, D58BB548146A0B910002C9F5 /* IASKPSSliderSpecifierViewCell.m in Sources */,
D58BB549146A0B910002C9F5 /* IASKPSTextFieldSpecifierViewCell.m in Sources */, D58BB549146A0B910002C9F5 /* IASKPSTextFieldSpecifierViewCell.m in Sources */,
D58BB54A146A0B910002C9F5 /* IASKPSTitleValueSpecifierViewCell.m in Sources */, D58BB54A146A0B910002C9F5 /* IASKPSTitleValueSpecifierViewCell.m in Sources */,
D58BB54B146A0B910002C9F5 /* IASKPSToggleSwitchSpecifierViewCell.m in Sources */, D58BB54B146A0B910002C9F5 /* IASKPSToggleSwitchSpecifierViewCell.m in Sources */,
F99D343B2F736C3B00DC153E /* UsernameScreen.cpp in Sources */,
D58BB54C146A0B910002C9F5 /* IASKSlider.m in Sources */, D58BB54C146A0B910002C9F5 /* IASKSlider.m in Sources */,
D58BB54D146A0B910002C9F5 /* IASKSwitch.m in Sources */, D58BB54D146A0B910002C9F5 /* IASKSwitch.m in Sources */,
F99D34302F736BAD00DC153E /* ConsoleScreen.cpp in Sources */,
D58BB54E146A0B910002C9F5 /* IASKTextField.m in Sources */, D58BB54E146A0B910002C9F5 /* IASKTextField.m in Sources */,
D58BB550146A0B910002C9F5 /* PVRTexture.m in Sources */, D58BB550146A0B910002C9F5 /* PVRTexture.m in Sources */,
D5D43CC9146AF4B4002ED842 /* RenameMPWorldViewController.mm in Sources */, D5D43CC9146AF4B4002ED842 /* RenameMPWorldViewController.mm in Sources */,
D5B50F7014CFF670005F7284 /* AppPlatform_iOS.mm in Sources */, D5B50F7014CFF670005F7284 /* AppPlatform_iOS.mm in Sources */,
D5B50F7414CFF670005F7284 /* CreativeMode.cpp in Sources */, D5B50F7414CFF670005F7284 /* CreativeMode.cpp in Sources */,
F99D34432F736F9400DC153E /* Option.cpp in Sources */,
D5B50F7614CFF670005F7284 /* GameMode.cpp in Sources */, D5B50F7614CFF670005F7284 /* GameMode.cpp in Sources */,
D5B50F7814CFF670005F7284 /* Button.cpp in Sources */, D5B50F7814CFF670005F7284 /* Button.cpp in Sources */,
D5B50F7A14CFF670005F7284 /* ImageButton.cpp in Sources */, D5B50F7A14CFF670005F7284 /* ImageButton.cpp in Sources */,
@@ -5067,6 +5163,7 @@
D5B50FC814CFF670005F7284 /* KeyboardInput.cpp in Sources */, D5B50FC814CFF670005F7284 /* KeyboardInput.cpp in Sources */,
D5B50FCA14CFF670005F7284 /* TouchscreenInput.cpp in Sources */, D5B50FCA14CFF670005F7284 /* TouchscreenInput.cpp in Sources */,
D5B50FCC14CFF670005F7284 /* LocalPlayer.cpp in Sources */, D5B50FCC14CFF670005F7284 /* LocalPlayer.cpp in Sources */,
F99D34482F736FE800DC153E /* KeyOption.cpp in Sources */,
D5B50FCE14CFF670005F7284 /* Chunk.cpp in Sources */, D5B50FCE14CFF670005F7284 /* Chunk.cpp in Sources */,
D5B50FD014CFF670005F7284 /* Frustum.cpp in Sources */, D5B50FD014CFF670005F7284 /* Frustum.cpp in Sources */,
D5B50FD214CFF670005F7284 /* ChickenRenderer.cpp in Sources */, D5B50FD214CFF670005F7284 /* ChickenRenderer.cpp in Sources */,
@@ -5109,6 +5206,7 @@
D5B5111014CFF670005F7284 /* Mth.cpp in Sources */, D5B5111014CFF670005F7284 /* Mth.cpp in Sources */,
D5B5111214CFF670005F7284 /* PerfRenderer.cpp in Sources */, D5B5111214CFF670005F7284 /* PerfRenderer.cpp in Sources */,
D5B5111414CFF670005F7284 /* PerfTimer.cpp in Sources */, D5B5111414CFF670005F7284 /* PerfTimer.cpp in Sources */,
F99F0FA92F84369F00F2B29A /* GrassColor.cpp in Sources */,
D5B5111614CFF670005F7284 /* StringUtils.cpp in Sources */, D5B5111614CFF670005F7284 /* StringUtils.cpp in Sources */,
D5B5111814CFF670005F7284 /* Direction.cpp in Sources */, D5B5111814CFF670005F7284 /* Direction.cpp in Sources */,
D5B5111A14CFF670005F7284 /* Animal.cpp in Sources */, D5B5111A14CFF670005F7284 /* Animal.cpp in Sources */,
@@ -5125,17 +5223,21 @@
D5B5113014CFF670005F7284 /* TripodCamera.cpp in Sources */, D5B5113014CFF670005F7284 /* TripodCamera.cpp in Sources */,
D5B5113214CFF670005F7284 /* Mob.cpp in Sources */, D5B5113214CFF670005F7284 /* Mob.cpp in Sources */,
D5B5113414CFF670005F7284 /* MobCategory.cpp in Sources */, D5B5113414CFF670005F7284 /* MobCategory.cpp in Sources */,
F99D34282F736AFB00DC153E /* OptionsFile.cpp in Sources */,
D5B5113814CFF670005F7284 /* PathFinderMob.cpp in Sources */, D5B5113814CFF670005F7284 /* PathFinderMob.cpp in Sources */,
D5B5113A14CFF670005F7284 /* Inventory.cpp in Sources */, D5B5113A14CFF670005F7284 /* Inventory.cpp in Sources */,
D5B5113C14CFF670005F7284 /* Player.cpp in Sources */, D5B5113C14CFF670005F7284 /* Player.cpp in Sources */,
F99F0FB02F8436EB00F2B29A /* Color.cpp in Sources */,
D5B5113E14CFF670005F7284 /* Arrow.cpp in Sources */, D5B5113E14CFF670005F7284 /* Arrow.cpp in Sources */,
D5B5114014CFF670005F7284 /* Recipes.cpp in Sources */, D5B5114014CFF670005F7284 /* Recipes.cpp in Sources */,
D5B5114214CFF670005F7284 /* ToolRecipes.cpp in Sources */, D5B5114214CFF670005F7284 /* ToolRecipes.cpp in Sources */,
D5B5114414CFF670005F7284 /* WeaponRecipes.cpp in Sources */, D5B5114414CFF670005F7284 /* WeaponRecipes.cpp in Sources */,
D5B5114614CFF670005F7284 /* HatchetItem.cpp in Sources */, D5B5114614CFF670005F7284 /* HatchetItem.cpp in Sources */,
D5B5114814CFF670005F7284 /* Item.cpp in Sources */, D5B5114814CFF670005F7284 /* Item.cpp in Sources */,
F99F0FAC2F8436CE00F2B29A /* FoliageColor.cpp in Sources */,
D5B5114A14CFF670005F7284 /* ItemInstance.cpp in Sources */, D5B5114A14CFF670005F7284 /* ItemInstance.cpp in Sources */,
D5B5114C14CFF670005F7284 /* PickaxeItem.cpp in Sources */, D5B5114C14CFF670005F7284 /* PickaxeItem.cpp in Sources */,
F99D344B2F7370CF00DC153E /* Slider.cpp in Sources */,
D5B5114E14CFF670005F7284 /* ShovelItem.cpp in Sources */, D5B5114E14CFF670005F7284 /* ShovelItem.cpp in Sources */,
D5B5115014CFF670005F7284 /* Biome.cpp in Sources */, D5B5115014CFF670005F7284 /* Biome.cpp in Sources */,
D5B5115214CFF670005F7284 /* BiomeSource.cpp in Sources */, D5B5115214CFF670005F7284 /* BiomeSource.cpp in Sources */,
@@ -5186,6 +5288,7 @@
D5251DBA1538192700FC82C8 /* CloudServer.cpp in Sources */, D5251DBA1538192700FC82C8 /* CloudServer.cpp in Sources */,
D5251DBE1538192700FC82C8 /* CommandParserInterface.cpp in Sources */, D5251DBE1538192700FC82C8 /* CommandParserInterface.cpp in Sources */,
D5251DC01538192700FC82C8 /* ConnectionGraph2.cpp in Sources */, D5251DC01538192700FC82C8 /* ConnectionGraph2.cpp in Sources */,
F99D34402F736C8400DC153E /* GuiElementContainer.cpp in Sources */,
D5251DC21538192700FC82C8 /* ConsoleServer.cpp in Sources */, D5251DC21538192700FC82C8 /* ConsoleServer.cpp in Sources */,
D5251DC41538192700FC82C8 /* DataCompressor.cpp in Sources */, D5251DC41538192700FC82C8 /* DataCompressor.cpp in Sources */,
D5251DC61538192700FC82C8 /* DirectoryDeltaTransfer.cpp in Sources */, D5251DC61538192700FC82C8 /* DirectoryDeltaTransfer.cpp in Sources */,
@@ -5210,6 +5313,8 @@
D5251DEC1538192700FC82C8 /* HTTPConnection.cpp in Sources */, D5251DEC1538192700FC82C8 /* HTTPConnection.cpp in Sources */,
D5251DEE1538192700FC82C8 /* IncrementalReadInterface.cpp in Sources */, D5251DEE1538192700FC82C8 /* IncrementalReadInterface.cpp in Sources */,
D5251DF01538192700FC82C8 /* Itoa.cpp in Sources */, D5251DF01538192700FC82C8 /* Itoa.cpp in Sources */,
F99D34202F736AA100DC153E /* HttpClient.cpp in Sources */,
F99D34382F736C1000DC153E /* JoinByIPScreen.cpp in Sources */,
D5251DF21538192700FC82C8 /* LinuxStrings.cpp in Sources */, D5251DF21538192700FC82C8 /* LinuxStrings.cpp in Sources */,
D5251DF41538192700FC82C8 /* LocklessTypes.cpp in Sources */, D5251DF41538192700FC82C8 /* LocklessTypes.cpp in Sources */,
D5251DF61538192700FC82C8 /* LogCommandParser.cpp in Sources */, D5251DF61538192700FC82C8 /* LogCommandParser.cpp in Sources */,
@@ -5238,6 +5343,7 @@
D5251E2A1538192700FC82C8 /* RakSleep.cpp in Sources */, D5251E2A1538192700FC82C8 /* RakSleep.cpp in Sources */,
D5251E2C1538192700FC82C8 /* RakString.cpp in Sources */, D5251E2C1538192700FC82C8 /* RakString.cpp in Sources */,
D5251E2E1538192700FC82C8 /* RakThread.cpp in Sources */, D5251E2E1538192700FC82C8 /* RakThread.cpp in Sources */,
F99D34332F736BDA00DC153E /* CreditsScreen.cpp in Sources */,
D5251E301538192700FC82C8 /* RakWString.cpp in Sources */, D5251E301538192700FC82C8 /* RakWString.cpp in Sources */,
D5251E321538192700FC82C8 /* Rand.cpp in Sources */, D5251E321538192700FC82C8 /* Rand.cpp in Sources */,
D5251E341538192700FC82C8 /* rdlmalloc.cpp in Sources */, D5251E341538192700FC82C8 /* rdlmalloc.cpp in Sources */,
@@ -5280,6 +5386,7 @@
D5951EEB159349100043A12A /* TileEntity.cpp in Sources */, D5951EEB159349100043A12A /* TileEntity.cpp in Sources */,
D5951EEF159349680043A12A /* FurnaceScreen.cpp in Sources */, D5951EEF159349680043A12A /* FurnaceScreen.cpp in Sources */,
D5951EF215934A2D0043A12A /* Feature.cpp in Sources */, D5951EF215934A2D0043A12A /* Feature.cpp in Sources */,
F99D342C2F736B6F00DC153E /* OptionsItem.cpp in Sources */,
D5951EF815934AC50043A12A /* BaseContainerMenu.cpp in Sources */, D5951EF815934AC50043A12A /* BaseContainerMenu.cpp in Sources */,
D5951EFA15934AC50043A12A /* FurnaceMenu.cpp in Sources */, D5951EFA15934AC50043A12A /* FurnaceMenu.cpp in Sources */,
D5D381F315A1A1CF00B6C50E /* FillingContainer.cpp in Sources */, D5D381F315A1A1CF00B6C50E /* FillingContainer.cpp in Sources */,
@@ -5339,8 +5446,10 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
F912B8CF2F6C3D5200BC60DF /* TextBox.h in Sources */,
D5CF9C57144C225000E4244F /* main.mm in Sources */, D5CF9C57144C225000E4244F /* main.mm in Sources */,
D5CF9C5B144C225000E4244F /* minecraftpeAppDelegate.mm in Sources */, D5CF9C5B144C225000E4244F /* minecraftpeAppDelegate.mm in Sources */,
F99D343C2F736C3B00DC153E /* UsernameScreen.cpp in Sources */,
D5CF9C65144C225000E4244F /* EAGLView.m in Sources */, D5CF9C65144C225000E4244F /* EAGLView.m in Sources */,
D5CFA01D144C453900E4244F /* minecraftpeViewController.mm in Sources */, D5CFA01D144C453900E4244F /* minecraftpeViewController.mm in Sources */,
D5A55E4914500EDE00A7571B /* CreateNewWorldViewController.mm in Sources */, D5A55E4914500EDE00A7571B /* CreateNewWorldViewController.mm in Sources */,
@@ -5354,6 +5463,7 @@
D5F3B7D014548E7900D25470 /* IASKSettingsStoreUserDefaults.m in Sources */, D5F3B7D014548E7900D25470 /* IASKSettingsStoreUserDefaults.m in Sources */,
D5F3B7D114548E7900D25470 /* IASKSpecifier.m in Sources */, D5F3B7D114548E7900D25470 /* IASKSpecifier.m in Sources */,
D5F3B7D214548E7900D25470 /* IASKPSSliderSpecifierViewCell.m in Sources */, D5F3B7D214548E7900D25470 /* IASKPSSliderSpecifierViewCell.m in Sources */,
F99D34472F736FE800DC153E /* KeyOption.cpp in Sources */,
D5F3B7D314548E7900D25470 /* IASKPSTextFieldSpecifierViewCell.m in Sources */, D5F3B7D314548E7900D25470 /* IASKPSTextFieldSpecifierViewCell.m in Sources */,
D5F3B7D414548E7900D25470 /* IASKPSTitleValueSpecifierViewCell.m in Sources */, D5F3B7D414548E7900D25470 /* IASKPSTitleValueSpecifierViewCell.m in Sources */,
D5F3B7D514548E7900D25470 /* IASKPSToggleSwitchSpecifierViewCell.m in Sources */, D5F3B7D514548E7900D25470 /* IASKPSToggleSwitchSpecifierViewCell.m in Sources */,
@@ -5433,6 +5543,7 @@
D5B5102F14CFF670005F7284 /* main.cpp in Sources */, D5B5102F14CFF670005F7284 /* main.cpp in Sources */,
D5B5103514CFF670005F7284 /* Tag.cpp in Sources */, D5B5103514CFF670005F7284 /* Tag.cpp in Sources */,
D5B5103714CFF670005F7284 /* ClientSideNetworkHandler.cpp in Sources */, D5B5103714CFF670005F7284 /* ClientSideNetworkHandler.cpp in Sources */,
F99F0FAF2F8436EB00F2B29A /* Color.cpp in Sources */,
D5B5103914CFF670005F7284 /* NetEventCallback.cpp in Sources */, D5B5103914CFF670005F7284 /* NetEventCallback.cpp in Sources */,
D5B5103B14CFF670005F7284 /* Packet.cpp in Sources */, D5B5103B14CFF670005F7284 /* Packet.cpp in Sources */,
D5B5103D14CFF670005F7284 /* RakNetInstance.cpp in Sources */, D5B5103D14CFF670005F7284 /* RakNetInstance.cpp in Sources */,
@@ -5453,6 +5564,7 @@
D5B5111514CFF670005F7284 /* StringUtils.cpp in Sources */, D5B5111514CFF670005F7284 /* StringUtils.cpp in Sources */,
D5B5111714CFF670005F7284 /* Direction.cpp in Sources */, D5B5111714CFF670005F7284 /* Direction.cpp in Sources */,
D5B5111914CFF670005F7284 /* Animal.cpp in Sources */, D5B5111914CFF670005F7284 /* Animal.cpp in Sources */,
F99F0FAD2F8436CE00F2B29A /* FoliageColor.cpp in Sources */,
D5B5111B14CFF670005F7284 /* Chicken.cpp in Sources */, D5B5111B14CFF670005F7284 /* Chicken.cpp in Sources */,
D5B5111D14CFF670005F7284 /* Cow.cpp in Sources */, D5B5111D14CFF670005F7284 /* Cow.cpp in Sources */,
D5B5111F14CFF670005F7284 /* Pig.cpp in Sources */, D5B5111F14CFF670005F7284 /* Pig.cpp in Sources */,
@@ -5465,11 +5577,13 @@
D5B5112D14CFF670005F7284 /* PrimedTnt.cpp in Sources */, D5B5112D14CFF670005F7284 /* PrimedTnt.cpp in Sources */,
D5B5112F14CFF670005F7284 /* TripodCamera.cpp in Sources */, D5B5112F14CFF670005F7284 /* TripodCamera.cpp in Sources */,
D5B5113114CFF670005F7284 /* Mob.cpp in Sources */, D5B5113114CFF670005F7284 /* Mob.cpp in Sources */,
F99D34442F736F9400DC153E /* Option.cpp in Sources */,
D5B5113314CFF670005F7284 /* MobCategory.cpp in Sources */, D5B5113314CFF670005F7284 /* MobCategory.cpp in Sources */,
D5B5113714CFF670005F7284 /* PathFinderMob.cpp in Sources */, D5B5113714CFF670005F7284 /* PathFinderMob.cpp in Sources */,
D5B5113914CFF670005F7284 /* Inventory.cpp in Sources */, D5B5113914CFF670005F7284 /* Inventory.cpp in Sources */,
D5B5113B14CFF670005F7284 /* Player.cpp in Sources */, D5B5113B14CFF670005F7284 /* Player.cpp in Sources */,
D5B5113D14CFF670005F7284 /* Arrow.cpp in Sources */, D5B5113D14CFF670005F7284 /* Arrow.cpp in Sources */,
F99D343F2F736C8400DC153E /* GuiElementContainer.cpp in Sources */,
D5B5113F14CFF670005F7284 /* Recipes.cpp in Sources */, D5B5113F14CFF670005F7284 /* Recipes.cpp in Sources */,
D5B5114114CFF670005F7284 /* ToolRecipes.cpp in Sources */, D5B5114114CFF670005F7284 /* ToolRecipes.cpp in Sources */,
D5B5114314CFF670005F7284 /* WeaponRecipes.cpp in Sources */, D5B5114314CFF670005F7284 /* WeaponRecipes.cpp in Sources */,
@@ -5501,16 +5615,19 @@
D5B5117714CFF670005F7284 /* ExternalFileLevelStorageSource.cpp in Sources */, D5B5117714CFF670005F7284 /* ExternalFileLevelStorageSource.cpp in Sources */,
D5B5117914CFF670005F7284 /* RegionFile.cpp in Sources */, D5B5117914CFF670005F7284 /* RegionFile.cpp in Sources */,
D5B5117B14CFF670005F7284 /* TickNextTickData.cpp in Sources */, D5B5117B14CFF670005F7284 /* TickNextTickData.cpp in Sources */,
F99F0FAA2F84369F00F2B29A /* GrassColor.cpp in Sources */,
D5B5117D14CFF670005F7284 /* DoorTile.cpp in Sources */, D5B5117D14CFF670005F7284 /* DoorTile.cpp in Sources */,
D5B5118114CFF670005F7284 /* StoneSlabTile.cpp in Sources */, D5B5118114CFF670005F7284 /* StoneSlabTile.cpp in Sources */,
D5B5118314CFF670005F7284 /* Tile.cpp in Sources */, D5B5118314CFF670005F7284 /* Tile.cpp in Sources */,
D5B5118514CFF670005F7284 /* HitResult.cpp in Sources */, D5B5118514CFF670005F7284 /* HitResult.cpp in Sources */,
D5B5118B14D03342005F7284 /* SynchedEntityData.cpp in Sources */, D5B5118B14D03342005F7284 /* SynchedEntityData.cpp in Sources */,
D5B5118E14DEA27F005F7284 /* DeathScreen.cpp in Sources */, D5B5118E14DEA27F005F7284 /* DeathScreen.cpp in Sources */,
F99D34242F736AD400DC153E /* TextOption.cpp in Sources */,
D5B5119114DEA2B7005F7284 /* LevelData.cpp in Sources */, D5B5119114DEA2B7005F7284 /* LevelData.cpp in Sources */,
D5B5119414DEA2EF005F7284 /* DyePowderItem.cpp in Sources */, D5B5119414DEA2EF005F7284 /* DyePowderItem.cpp in Sources */,
D584926D14FD234400741128 /* SharedConstants.cpp in Sources */, D584926D14FD234400741128 /* SharedConstants.cpp in Sources */,
D584927314FD236700741128 /* MoveControl.cpp in Sources */, D584927314FD236700741128 /* MoveControl.cpp in Sources */,
F99D344C2F7370CF00DC153E /* Slider.cpp in Sources */,
D584928614FD240D00741128 /* IConfigListener.cpp in Sources */, D584928614FD240D00741128 /* IConfigListener.cpp in Sources */,
D584928914FD2FAF00741128 /* Path.cpp in Sources */, D584928914FD2FAF00741128 /* Path.cpp in Sources */,
D5B86281153810BD00F3238A /* I18n.cpp in Sources */, D5B86281153810BD00F3238A /* I18n.cpp in Sources */,
@@ -5562,6 +5679,7 @@
D5251E011538192700FC82C8 /* NatTypeDetectionServer.cpp in Sources */, D5251E011538192700FC82C8 /* NatTypeDetectionServer.cpp in Sources */,
D5251E031538192700FC82C8 /* NetworkIDManager.cpp in Sources */, D5251E031538192700FC82C8 /* NetworkIDManager.cpp in Sources */,
D5251E051538192700FC82C8 /* NetworkIDObject.cpp in Sources */, D5251E051538192700FC82C8 /* NetworkIDObject.cpp in Sources */,
F99D34372F736C1000DC153E /* JoinByIPScreen.cpp in Sources */,
D5251E071538192700FC82C8 /* PacketConsoleLogger.cpp in Sources */, D5251E071538192700FC82C8 /* PacketConsoleLogger.cpp in Sources */,
D5251E091538192700FC82C8 /* PacketFileLogger.cpp in Sources */, D5251E091538192700FC82C8 /* PacketFileLogger.cpp in Sources */,
D5251E0B1538192700FC82C8 /* PacketizedTCP.cpp in Sources */, D5251E0B1538192700FC82C8 /* PacketizedTCP.cpp in Sources */,
@@ -5591,11 +5709,13 @@
D5251E411538192700FC82C8 /* SendToThread.cpp in Sources */, D5251E411538192700FC82C8 /* SendToThread.cpp in Sources */,
D5251E431538192700FC82C8 /* SHA1.cpp in Sources */, D5251E431538192700FC82C8 /* SHA1.cpp in Sources */,
D5251E451538192700FC82C8 /* SignaledEvent.cpp in Sources */, D5251E451538192700FC82C8 /* SignaledEvent.cpp in Sources */,
F99D34342F736BDA00DC153E /* CreditsScreen.cpp in Sources */,
D5251E471538192700FC82C8 /* SimpleMutex.cpp in Sources */, D5251E471538192700FC82C8 /* SimpleMutex.cpp in Sources */,
D5251E491538192700FC82C8 /* SocketLayer.cpp in Sources */, D5251E491538192700FC82C8 /* SocketLayer.cpp in Sources */,
D5251E4B1538192700FC82C8 /* StringCompressor.cpp in Sources */, D5251E4B1538192700FC82C8 /* StringCompressor.cpp in Sources */,
D5251E4D1538192700FC82C8 /* StringTable.cpp in Sources */, D5251E4D1538192700FC82C8 /* StringTable.cpp in Sources */,
D5251E4F1538192700FC82C8 /* SuperFastHash.cpp in Sources */, D5251E4F1538192700FC82C8 /* SuperFastHash.cpp in Sources */,
F99D342B2F736B6F00DC153E /* OptionsItem.cpp in Sources */,
D5251E511538192700FC82C8 /* TableSerializer.cpp in Sources */, D5251E511538192700FC82C8 /* TableSerializer.cpp in Sources */,
D5251E531538192700FC82C8 /* TCPInterface.cpp in Sources */, D5251E531538192700FC82C8 /* TCPInterface.cpp in Sources */,
D5251E551538192700FC82C8 /* TeamBalancer.cpp in Sources */, D5251E551538192700FC82C8 /* TeamBalancer.cpp in Sources */,
@@ -5618,6 +5738,7 @@
D5951EDD159348C50043A12A /* ItemPane.cpp in Sources */, D5951EDD159348C50043A12A /* ItemPane.cpp in Sources */,
D5951EE3159349000043A12A /* FurnaceTile.cpp in Sources */, D5951EE3159349000043A12A /* FurnaceTile.cpp in Sources */,
D5951EE8159349100043A12A /* FurnaceTileEntity.cpp in Sources */, D5951EE8159349100043A12A /* FurnaceTileEntity.cpp in Sources */,
F99D342F2F736BAD00DC153E /* ConsoleScreen.cpp in Sources */,
D5951EEA159349100043A12A /* TileEntity.cpp in Sources */, D5951EEA159349100043A12A /* TileEntity.cpp in Sources */,
D5951EEE159349680043A12A /* FurnaceScreen.cpp in Sources */, D5951EEE159349680043A12A /* FurnaceScreen.cpp in Sources */,
D5951EF115934A2D0043A12A /* Feature.cpp in Sources */, D5951EF115934A2D0043A12A /* Feature.cpp in Sources */,
@@ -5654,6 +5775,7 @@
D544941E15D13F45005FA9B0 /* PlayerRenderer.cpp in Sources */, D544941E15D13F45005FA9B0 /* PlayerRenderer.cpp in Sources */,
D544942215D13F5E005FA9B0 /* RemotePlayer.cpp in Sources */, D544942215D13F5E005FA9B0 /* RemotePlayer.cpp in Sources */,
D5B17ED515E226F50056E751 /* Throwable.cpp in Sources */, D5B17ED515E226F50056E751 /* Throwable.cpp in Sources */,
F99D341F2F736AA100DC153E /* HttpClient.cpp in Sources */,
D5B17ED915E2273F0056E751 /* SurvivalMode.cpp in Sources */, D5B17ED915E2273F0056E751 /* SurvivalMode.cpp in Sources */,
D5B17EDD15E227670056E751 /* TrapDoorTile.cpp in Sources */, D5B17EDD15E227670056E751 /* TrapDoorTile.cpp in Sources */,
D5B17EE115E260910056E751 /* MoveFolder.mm in Sources */, D5B17EE115E260910056E751 /* MoveFolder.mm in Sources */,
@@ -5689,6 +5811,7 @@
0400453A16A4125C003EB6FA /* FallingTileRenderer.cpp in Sources */, 0400453A16A4125C003EB6FA /* FallingTileRenderer.cpp in Sources */,
0413970716A82E1E008A9F1A /* ArmorItem.cpp in Sources */, 0413970716A82E1E008A9F1A /* ArmorItem.cpp in Sources */,
0413970D16A82E6B008A9F1A /* CraftingFilters.cpp in Sources */, 0413970D16A82E6B008A9F1A /* CraftingFilters.cpp in Sources */,
F99D34272F736AFB00DC153E /* OptionsFile.cpp in Sources */,
0413970E16A82E6B008A9F1A /* StonecutterScreen.cpp in Sources */, 0413970E16A82E6B008A9F1A /* StonecutterScreen.cpp in Sources */,
0413971116A82E7B008A9F1A /* ArmorScreen.cpp in Sources */, 0413971116A82E7B008A9F1A /* ArmorScreen.cpp in Sources */,
0413971516A82EB9008A9F1A /* ArmorRecipes.cpp in Sources */, 0413971516A82EB9008A9F1A /* ArmorRecipes.cpp in Sources */,
@@ -5697,7 +5820,6 @@
042A91AE16B17517007ABBC6 /* GuiElement.cpp in Sources */, 042A91AE16B17517007ABBC6 /* GuiElement.cpp in Sources */,
042A91AF16B17517007ABBC6 /* NinePatch.cpp in Sources */, 042A91AF16B17517007ABBC6 /* NinePatch.cpp in Sources */,
042A91B016B17517007ABBC6 /* OptionsGroup.cpp in Sources */, 042A91B016B17517007ABBC6 /* OptionsGroup.cpp in Sources */,
042A91B116B17517007ABBC6 /* OptionsPane.cpp in Sources */,
042A91B216B17517007ABBC6 /* TextBox.cpp in Sources */, 042A91B216B17517007ABBC6 /* TextBox.cpp in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
@@ -5735,25 +5857,29 @@
D50BE20815EE05B8008AA75E /* Ad-Hoc */ = { D50BE20815EE05B8008AA75E /* Ad-Hoc */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)"; ARCHS = "$(ARCHS_STANDARD)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Mojang AB"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Mojang AB";
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PREPROCESSOR_DEFINITIONS = PUBLISH; GCC_PREPROCESSOR_DEFINITIONS = PUBLISH;
GCC_VERSION = com.apple.compilers.llvmgcc42; GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src";
IPHONEOS_DEPLOYMENT_TARGET = 12;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "C93D3524-5C6F-466E-B12B-833663B7EAE0"; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "C93D3524-5C6F-466E-B12B-833663B7EAE0";
RUN_CLANG_STATIC_ANALYZER = NO; RUN_CLANG_STATIC_ANALYZER = NO;
SDKROOT = iphoneos6.0; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src";
USE_HEADERMAP = NO;
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
}; };
name = "Ad-Hoc"; name = "Ad-Hoc";
@@ -5765,15 +5891,26 @@
GCC_PREFIX_HEADER = "minecraftpe/minecraftpe-Prefix.pch"; GCC_PREFIX_HEADER = "minecraftpe/minecraftpe-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_PREPROCESSOR_DEFINITIONS = "";
"GCC_THUMB_SUPPORT[arch=armv7]" = NO; "GCC_THUMB_SUPPORT[arch=armv7]" = NO;
GCC_VERSION = com.apple.compilers.llvmgcc42; GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
HEADER_SEARCH_PATHS = ""; HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../../src",
"$(SRCROOT)/../../src/client/gui/components",
"$(SRCROOT)/../../src/world",
"$(SRCROOT)/../../src/platform/input",
"$(SRCROOT)/../../project/lib_projects/InAppSettingsKit/Views",
);
INFOPLIST_FILE = "minecraftpe/minecraftpe-Info.plist"; INFOPLIST_FILE = "minecraftpe/minecraftpe-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.games";
IPHONEOS_DEPLOYMENT_TARGET = 12;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.mojang.mcpe-arm64";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
RUN_CLANG_STATIC_ANALYZER = NO; RUN_CLANG_STATIC_ANALYZER = NO;
SDKROOT = iphoneos6.0; SDKROOT = iphoneos;
VALID_ARCHS = "i386 armv6 armv7"; SYSTEM_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src $(SRCROOT)/../../src/client/gui/components $(SRCROOT)/../../src/world $(SRCROOT)/../../src/platform/input $(SRCROOT)/../../project/lib_projects/InAppSettingsKit/Views";
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src $(SRCROOT)/../lib_projects/InAppSettingsKit/Models $(SRCROOT)/../../src/client/gui/components $(SRCROOT)/../../src/world $(SRCROOT)/../../src/platform/input $(SRCROOT)/../../project/lib_projects/InAppSettingsKit/Views";
USE_HEADERMAP = NO;
WRAPPER_EXTENSION = app; WRAPPER_EXTENSION = app;
}; };
name = "Ad-Hoc"; name = "Ad-Hoc";
@@ -5846,24 +5983,28 @@
D5A20ADB146AAD9C00A52FEC /* AppStore */ = { D5A20ADB146AAD9C00A52FEC /* AppStore */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)"; ARCHS = "$(ARCHS_STANDARD)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Mojang AB"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Mojang AB";
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_VERSION = com.apple.compilers.llvmgcc42; GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src";
IPHONEOS_DEPLOYMENT_TARGET = 12;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "64BA8967-1A9A-4980-972C-42E75AD5E023"; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "64BA8967-1A9A-4980-972C-42E75AD5E023";
RUN_CLANG_STATIC_ANALYZER = NO; RUN_CLANG_STATIC_ANALYZER = NO;
SDKROOT = iphoneos6.0; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src";
USE_HEADERMAP = NO;
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
}; };
name = AppStore; name = AppStore;
@@ -5876,11 +6017,19 @@
GCC_PREFIX_HEADER = "minecraftpe/minecraftpe-Prefix.pch"; GCC_PREFIX_HEADER = "minecraftpe/minecraftpe-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = PUBLISH; GCC_PREPROCESSOR_DEFINITIONS = PUBLISH;
"GCC_THUMB_SUPPORT[arch=armv7]" = NO; "GCC_THUMB_SUPPORT[arch=armv7]" = NO;
GCC_VERSION = com.apple.compilers.llvmgcc42; GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
HEADER_SEARCH_PATHS = ""; HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../../src",
"$(SRCROOT)/../../src/client/gui/components",
"$(SRCROOT)/../../src/world",
"$(SRCROOT)/../../src/platform/input",
"$(SRCROOT)/../../project/lib_projects/InAppSettingsKit/Views",
);
INFOPLIST_FILE = "minecraftpe/minecraftpe-Info.plist"; INFOPLIST_FILE = "minecraftpe/minecraftpe-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.games";
IPHONEOS_DEPLOYMENT_TARGET = 12;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = ( OTHER_CFLAGS = (
"-DNS_BLOCK_ASSERTIONS=1", "-DNS_BLOCK_ASSERTIONS=1",
"-DANDROID_PUBLISH", "-DANDROID_PUBLISH",
@@ -5888,8 +6037,10 @@
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "1B194957-98CF-49B7-A0E7-76692B4B722D"; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "1B194957-98CF-49B7-A0E7-76692B4B722D";
RUN_CLANG_STATIC_ANALYZER = NO; RUN_CLANG_STATIC_ANALYZER = NO;
SDKROOT = iphoneos6.0; SDKROOT = iphoneos;
VALID_ARCHS = "i386 armv6 armv7"; SYSTEM_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src $(SRCROOT)/../../src/client/gui/components $(SRCROOT)/../../src/world $(SRCROOT)/../../src/platform/input $(SRCROOT)/../../project/lib_projects/InAppSettingsKit/Views";
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src $(SRCROOT)/../lib_projects/InAppSettingsKit/Models $(SRCROOT)/../../src/client/gui/components $(SRCROOT)/../../src/world $(SRCROOT)/../../src/platform/input $(SRCROOT)/../../project/lib_projects/InAppSettingsKit/Views";
USE_HEADERMAP = NO;
WRAPPER_EXTENSION = app; WRAPPER_EXTENSION = app;
}; };
name = AppStore; name = AppStore;
@@ -5922,8 +6073,8 @@
D5CF9C6C144C225000E4244F /* Debug */ = { D5CF9C6C144C225000E4244F /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)"; ARCHS = "$(ARCHS_STANDARD)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
@@ -5935,41 +6086,50 @@
"$(inherited)", "$(inherited)",
); );
GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvmgcc42; GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src";
IPHONEOS_DEPLOYMENT_TARGET = 12;
ONLY_ACTIVE_ARCH = YES;
RUN_CLANG_STATIC_ANALYZER = NO; RUN_CLANG_STATIC_ANALYZER = NO;
SDKROOT = iphoneos6.0; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src";
USE_HEADERMAP = NO;
VALIDATE_PRODUCT = YES;
}; };
name = Debug; name = Debug;
}; };
D5CF9C6D144C225000E4244F /* Release */ = { D5CF9C6D144C225000E4244F /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = YES;
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)"; ARCHS = "$(ARCHS_STANDARD)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PREPROCESSOR_DEFINITIONS = PUBLISH; GCC_PREPROCESSOR_DEFINITIONS = PUBLISH;
GCC_VERSION = com.apple.compilers.llvmgcc42; GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3; HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src";
IPHONEOS_DEPLOYMENT_TARGET = 12;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
RUN_CLANG_STATIC_ANALYZER = NO; RUN_CLANG_STATIC_ANALYZER = NO;
SDKROOT = iphoneos6.0; SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src";
USE_HEADERMAP = NO;
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
}; };
name = Release; name = Release;
@@ -5977,19 +6137,34 @@
D5CF9C6F144C225000E4244F /* Debug */ = { D5CF9C6F144C225000E4244F /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = PZUVNW8F2U;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "minecraftpe/minecraftpe-Prefix.pch"; GCC_PREFIX_HEADER = "minecraftpe/minecraftpe-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1"; GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
"GCC_THUMB_SUPPORT[arch=armv7]" = NO; "GCC_THUMB_SUPPORT[arch=armv7]" = NO;
GCC_VERSION = com.apple.compilers.llvmgcc42; GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
HEADER_SEARCH_PATHS = ""; HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../../src",
"$(SRCROOT)/../../src/client/gui/components",
"$(SRCROOT)/../../src/world",
"$(SRCROOT)/../../src/platform/input",
"$(SRCROOT)/../../project/lib_projects/InAppSettingsKit/Views",
);
INFOPLIST_FILE = "minecraftpe/minecraftpe-Info.plist"; INFOPLIST_FILE = "minecraftpe/minecraftpe-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.games";
IPHONEOS_DEPLOYMENT_TARGET = 12;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.mojang.mcpe-arm64";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
RUN_CLANG_STATIC_ANALYZER = NO; RUN_CLANG_STATIC_ANALYZER = NO;
SDKROOT = iphoneos6.0; SDKROOT = iphoneos;
VALID_ARCHS = "i386 armv6 armv7"; SYSTEM_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src $(SRCROOT)/../../src/client/gui/components $(SRCROOT)/../../src/world $(SRCROOT)/../../src/platform/input $(SRCROOT)/../../project/lib_projects/InAppSettingsKit/Views";
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src $(SRCROOT)/../lib_projects/InAppSettingsKit/Models $(SRCROOT)/../../src/client/gui/components $(SRCROOT)/../../src/world $(SRCROOT)/../../src/platform/input $(SRCROOT)/../../project/lib_projects/InAppSettingsKit/Views";
USE_HEADERMAP = NO;
WRAPPER_EXTENSION = app; WRAPPER_EXTENSION = app;
}; };
name = Debug; name = Debug;
@@ -5997,19 +6172,34 @@
D5CF9C70144C225000E4244F /* Release */ = { D5CF9C70144C225000E4244F /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = PZUVNW8F2U;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "minecraftpe/minecraftpe-Prefix.pch"; GCC_PREFIX_HEADER = "minecraftpe/minecraftpe-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_PREPROCESSOR_DEFINITIONS = "";
"GCC_THUMB_SUPPORT[arch=armv7]" = NO; "GCC_THUMB_SUPPORT[arch=armv7]" = NO;
GCC_VERSION = com.apple.compilers.llvmgcc42; GCC_VERSION = "";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO; GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
HEADER_SEARCH_PATHS = ""; HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../../src",
"$(SRCROOT)/../../src/client/gui/components",
"$(SRCROOT)/../../src/world",
"$(SRCROOT)/../../src/platform/input",
"$(SRCROOT)/../../project/lib_projects/InAppSettingsKit/Views",
);
INFOPLIST_FILE = "minecraftpe/minecraftpe-Info.plist"; INFOPLIST_FILE = "minecraftpe/minecraftpe-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 4.3; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.games";
IPHONEOS_DEPLOYMENT_TARGET = 12;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.mojang.mcpe-arm64";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
RUN_CLANG_STATIC_ANALYZER = NO; RUN_CLANG_STATIC_ANALYZER = NO;
SDKROOT = iphoneos6.0; SDKROOT = iphoneos;
VALID_ARCHS = "i386 armv6 armv7"; SYSTEM_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src $(SRCROOT)/../../src/client/gui/components $(SRCROOT)/../../src/world $(SRCROOT)/../../src/platform/input $(SRCROOT)/../../project/lib_projects/InAppSettingsKit/Views";
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../src $(SRCROOT)/../lib_projects/InAppSettingsKit/Models $(SRCROOT)/../../src/client/gui/components $(SRCROOT)/../../src/world $(SRCROOT)/../../src/platform/input $(SRCROOT)/../../project/lib_projects/InAppSettingsKit/Views";
USE_HEADERMAP = NO;
WRAPPER_EXTENSION = app; WRAPPER_EXTENSION = app;
}; };
name = Release; name = Release;

View File

@@ -37,7 +37,7 @@
</dict> </dict>
</dict> </dict>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.mojang.${PRODUCT_NAME:rfc1034identifier}</string> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
@@ -58,6 +58,8 @@
<array> <array>
<string>minecraft.ttf</string> <string>minecraft.ttf</string>
</array> </array>
<key>UILaunchStoryboardName</key>
<string>Launch Screen</string>
<key>UIPrerenderedIcon</key> <key>UIPrerenderedIcon</key>
<true/> <true/>
<key>UIRequiresPersistentWiFi</key> <key>UIRequiresPersistentWiFi</key>

View File

@@ -142,8 +142,8 @@ void seedMT( unsigned int seed, unsigned int *state, unsigned int *&next, int &l
// so-- that's why the only change I made is to restrict to odd seeds. // so-- that's why the only change I made is to restrict to odd seeds.
// //
unsigned int x = ( seed | 1U ) & 0xFFFFFFFFU, *s = state; register unsigned int x = ( seed | 1U ) & 0xFFFFFFFFU, *s = state;
int j; register int j;
for ( left = 0, *s++ = x, j = N; --j; for ( left = 0, *s++ = x, j = N; --j;
*s++ = ( x *= 69069U ) & 0xFFFFFFFFU ) *s++ = ( x *= 69069U ) & 0xFFFFFFFFU )
@@ -154,8 +154,8 @@ void seedMT( unsigned int seed, unsigned int *state, unsigned int *&next, int &l
unsigned int reloadMT( unsigned int *state, unsigned int *&next, int &left ) unsigned int reloadMT( unsigned int *state, unsigned int *&next, int &left )
{ {
unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1; register unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
int j; register int j;
if ( left < -1 ) if ( left < -1 )
seedMT( 4357U ); seedMT( 4357U );

View File

@@ -1,26 +0,0 @@
#include "App.hpp"
#include "IPlatform.hpp"
#include "platform/server/PlatformServer.hpp"
#include "platform/glfw/PlatformGlfw.hpp"
std::unique_ptr<IPlatform> App::CreatePlatform() {
#if defined(STANDALONE_SERVER)
return std::make_unique<PlatformServer>();
#elif defined(PLATFORM_DESKTOP)
return std::make_unique<PlatformGlfw>();
#else
static_assert(false, "Unsupported platform!");
#endif
}
void App::run() {
init();
m_platform->runMainLoop(*this);
}
void App::swapBuffers() {
m_platform->swapBuffers();
}

87
src/App.h Executable file
View File

@@ -0,0 +1,87 @@
#ifndef APP_H__
#define APP_H__
#ifdef __APPLE__
#define NO_EGL
#endif
#ifdef STANDALONE_SERVER
#define NO_EGL
#endif
#include "AppPlatform.h"
#ifndef NO_EGL
#include <EGL/egl.h>
#endif
#include "platform/log.h"
typedef struct AppContext {
#ifndef NO_EGL
EGLDisplay display;
EGLContext context;
EGLSurface surface;
#endif
AppPlatform* platform;
bool doRender;
} AppContext;
class App
{
public:
App()
: _finished(false),
_inited(false)
{
_context.platform = 0;
}
virtual ~App() {}
void init(AppContext& c) {
_context = c;
init();
_inited = true;
}
bool isInited() { return _inited; }
virtual AppPlatform* platform() { return _context.platform; }
void onGraphicsReset(AppContext& c) {
_context = c;
onGraphicsReset();
}
virtual void audioEngineOn () {}
virtual void audioEngineOff() {}
virtual void destroy() {}
virtual void loadState(void* state, int stateSize) {}
virtual bool saveState(void** state, int* stateSize) { return false; }
void swapBuffers() {
#ifndef NO_EGL
if (_context.doRender)
eglSwapBuffers(_context.display, _context.surface);
#endif
}
virtual void draw() {}
virtual void update() {};// = 0;
virtual void setSize(int width, int height) {}
virtual void quit() { _finished = true; }
virtual bool wantToQuit() { return _finished; }
virtual bool handleBack(bool isDown) { return false; }
protected:
virtual void init() {}
//virtual void onGraphicsLost() = 0;
virtual void onGraphicsReset() = 0;
private:
bool _inited;
bool _finished;
AppContext _context;
};
#endif//APP_H__

View File

@@ -1,71 +0,0 @@
#pragma once
#include <memory>
#ifdef __APPLE__
#define NO_EGL
#endif
#ifdef STANDALONE_SERVER
#define NO_EGL
#endif
#include <IPlatform.hpp>
#ifndef NO_EGL
#include <EGL/egl.h>
#endif
// typedef struct AppContext {
// #ifndef NO_EGL
// EGLDisplay display;
// EGLContext context;
// EGLSurface surface;
// #endif
// AppPlatform* platform;
// bool doRender;
// } AppContext;
class App {
protected:
std::unique_ptr<IPlatform> m_platform;
public:
static std::unique_ptr<IPlatform> CreatePlatform();
App(std::unique_ptr<IPlatform> platform) : m_platform(std::move(platform)), m_finished(false), m_inited(false) {}
App() = delete;
virtual ~App() {}
void run();
bool isInited() { return m_inited; }
virtual void audioEngineOn () {}
virtual void audioEngineOff() {}
virtual void destroy() {}
virtual void loadState(void* state, int stateSize) {}
virtual bool saveState(void** state, int* stateSize) { return false; }
void swapBuffers();
// {
// #ifndef NO_EGL
// if (_context.doRender)
// eglSwapBuffers(_context.display, _context.surface);
// #endif
// m_platform->swapBuffers();
// }
virtual void update() = 0;
virtual void quit() { m_finished = true; }
virtual bool wantToQuit() { return m_finished; }
virtual bool handleBack(bool isDown) { return false; }
protected:
virtual void init() { m_inited = true;}
private:
bool m_inited = false;
bool m_finished = false;
};

10
src/AppConstants.h Executable file
View File

@@ -0,0 +1,10 @@
#ifndef _MINECRAFT_APPCONSTANTS_H_
#define _MINECRAFT_APPCONSTANTS_H_
#define APP_VERSION_STRING "Demo"
#define APP_NAME "Minecraft - Pocket Edition " APP_VERSION_STRING
#endif

143
src/AppPlatform.h Executable file
View File

@@ -0,0 +1,143 @@
#ifndef APPPLATFORM_H__
#define APPPLATFORM_H__
#include <vector>
#include <string>
#include <cstring>
#include "client/renderer/TextureData.h"
typedef std::vector<std::string> StringVector;
/*
typedef struct UserInput
{
static const int STATUS_INVALID = -1;
static const int STATUS_NOTINITED = -2;
static const int STATUS_OK = 1;
static const int STATUS_CANCEL = 0;
UserInput(int id)
: _id(id),
status(STATUS_NOTINITED)
{}
UserInput(int id, int status)
: _id(id),
status(status)
{}
int getId() { return _id; }
int status;
private:
int _id;
} UserInput;
class UserInputStatus {
int _status;
public:
UserInputStatus(int status)
: _status(status)
{}
bool isAnswered() { return _status >= 0; }
bool isOk() { return _status == UserInput::STATUS_OK; }
bool isCancel() { return _status == UserInput::STATUS_CANCEL; }
};
*/
class BinaryBlob {
public:
BinaryBlob()
: data(NULL),
size(-1) {}
BinaryBlob(unsigned char* data, unsigned int size)
: data(data),
size(size) {}
unsigned char* data;
int size;
};
class PlatformStringVars {
public:
static const int DEVICE_BUILD_MODEL = 0;
};
class AppPlatform
{
public:
AppPlatform() : keyboardVisible(false) {}
virtual ~AppPlatform() {}
virtual void saveScreenshot(const std::string& filename, int glWidth, int glHeight) {}
virtual TextureData loadTexture(const std::string& filename_, bool textureFolder) { return TextureData(); }
virtual TextureData loadTextureFromMemory(const unsigned char* data, size_t size) { return TextureData(); }
virtual void playSound(const std::string& fn, float volume, float pitch) {}
virtual void hideCursor(bool hide) {}
virtual void showDialog(int dialogId) {}
virtual void createUserInput() {}
bool is_big_endian(void) {
union {
unsigned int i;
char c[4];
} bint = {0x01020304};
return bint.c[0] == 1;
}
void createUserInput(int dialogId)
{
showDialog(dialogId);
createUserInput();
}
virtual int getUserInputStatus() { return 0; }
virtual StringVector getUserInput() { return StringVector(); }
virtual std::string getDateString(int s) { return ""; }
//virtual void createUserInputScreen(const char* types) {}
virtual void uploadPlatformDependentData(int id, void* data) {}
virtual BinaryBlob readAssetFile(const std::string& filename) { return BinaryBlob(); }
virtual void _tick() {}
virtual int getScreenWidth() { return 854; }
virtual int getScreenHeight() { return 480; }
virtual float getPixelsPerMillimeter() { return 10; }
virtual bool isNetworkEnabled(bool onlyWifiAllowed) { return true; }
virtual bool isPowerVR() {
return false;
}
virtual int getKeyFromKeyCode(int keyCode, int metaState, int deviceId) {return 0;}
#ifdef __APPLE__
virtual bool isSuperFast() = 0;
#endif
virtual void openURL(const std::string& url) {}
virtual void finish() {}
virtual bool supportsTouchscreen() { return false; }
virtual void vibrate(int milliSeconds) {}
virtual std::string getPlatformStringVar(int stringId) {
return "<getPlatformStringVar NotImplemented>";
}
virtual void showKeyboard() {
keyboardVisible = true;
}
virtual void hideKeyboard() {
keyboardVisible = false;
}
virtual bool isKeyboardVisible() {return keyboardVisible;}
protected:
bool keyboardVisible;
};
#endif /*APPPLATFORM_H__*/

View File

@@ -1,49 +1,49 @@
#include "AppPlatform_android.hpp" #include "AppPlatform_android.h"
#include <android/asset_manager.h> #include <android/asset_manager.h>
#include <android/native_activity.h> #include <android/native_activity.h>
class AppPlatform_android23 : public AppPlatform_android class AppPlatform_android23 : public AppPlatform_android
{ {
typedef AppPlatform_android super; typedef AppPlatform_android super;
public: public:
AppPlatform_android23() AppPlatform_android23()
: _assetManager(NULL) : _assetManager(NULL)
{ {
} }
// If we're using Android 2.3+, try reading assets from NDK at first. // If we're using Android 2.3+, try reading assets from NDK at first.
// If that doesn't work, read through java/JNI as usual. // If that doesn't work, read through java/JNI as usual.
BinaryBlob readAssetFile(const std::string& filename) { BinaryBlob readAssetFile(const std::string& filename) {
if (!_isInited) if (!_isInited)
return BinaryBlob(); return BinaryBlob();
if (_assetManager != NULL) { if (_assetManager != NULL) {
AAsset* asset = AAssetManager_open(_assetManager, filename.c_str(), AASSET_MODE_BUFFER); AAsset* asset = AAssetManager_open(_assetManager, filename.c_str(), AASSET_MODE_BUFFER);
if (asset != NULL) { if (asset != NULL) {
const int len = AAsset_getLength(asset); const int len = AAsset_getLength(asset);
const void* buf = len > 0? AAsset_getBuffer(asset) : NULL; const void* buf = len > 0? AAsset_getBuffer(asset) : NULL;
BinaryBlob blob; BinaryBlob blob;
if (buf != NULL) { if (buf != NULL) {
blob = BinaryBlob(new unsigned char[len], len); blob = BinaryBlob(new unsigned char[len], len);
memcpy(blob.data, buf, len); memcpy(blob.data, buf, len);
} }
AAsset_close(asset); AAsset_close(asset);
if (blob.data) if (blob.data)
return blob; return blob;
} }
} }
return super::readAssetFile(filename); return super::readAssetFile(filename);
} }
// Another init method... added to read data from the activity, and setup constants // Another init method... added to read data from the activity, and setup constants
// @note: This is called after instance is set from the outside, BUT this // @note: This is called after instance is set from the outside, BUT this
// will be rewritten later on anyway // will be rewritten later on anyway
void initWithActivity(struct ANativeActivity* activity) { void initWithActivity(struct ANativeActivity* activity) {
_assetManager = activity->assetManager; _assetManager = activity->assetManager;
} }
private: private:
AAssetManager* _assetManager; AAssetManager* _assetManager;
}; };

12
src/AppPlatform_glfw.cpp Normal file
View File

@@ -0,0 +1,12 @@
#include "AppPlatform_glfw.h"
float AppPlatform_glfw::getPixelsPerMillimeter() {
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
int width_mm, height_mm;
glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm);
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
return (float)mode->width / (float)width_mm;
}

155
src/AppPlatform_glfw.h Executable file
View File

@@ -0,0 +1,155 @@
#ifndef APPPLATFORM_GLFW_H__
#define APPPLATFORM_GLFW_H__
#include "AppPlatform.h"
#include "platform/log.h"
#include "platform/HttpClient.h"
#include "platform/PngLoader.h"
#include "client/renderer/gles.h"
#include "world/level/storage/FolderMethods.h"
#include <png.h>
#include <cmath>
#include <fstream>
#include <sstream>
#include <GLFW/glfw3.h>
#include <ctime>
#include "util/StringUtils.h"
#ifdef _WIN32
#include <windows.h>
#include <shellapi.h>
#endif
#ifdef __EMSCRIPTEN__
#include <emscripten/html5.h>
#endif
static void png_funcReadFile(png_structp pngPtr, png_bytep data, png_size_t length) {
((std::istream*)png_get_io_ptr(pngPtr))->read((char*)data, length);
}
class AppPlatform_glfw: public AppPlatform
{
public:
AppPlatform_glfw()
{
}
BinaryBlob readAssetFile(const std::string& filename) override {
FILE* fp = fopen(("data/" + filename).c_str(), "r");
if (!fp)
return BinaryBlob();
int size = getRemainingFileSize(fp);
BinaryBlob blob;
blob.size = size;
blob.data = new unsigned char[size];
fread(blob.data, 1, size, fp);
fclose(fp);
return blob;
}
void saveScreenshot(const std::string& filename, int glWidth, int glHeight) override {
//@todo
}
__inline unsigned int rgbToBgr(unsigned int p) {
return (p & 0xff00ff00) | ((p >> 16) & 0xff) | ((p << 16) & 0xff0000);
}
TextureData loadTexture(const std::string& filename_, bool textureFolder) override
{
// Support fetching PNG textures via HTTP/HTTPS (for skins, etc)
if (Util::startsWith(filename_, "http://") || Util::startsWith(filename_, "https://")) {
std::vector<unsigned char> body;
if (HttpClient::download(filename_, body) && !body.empty()) {
return loadTextureFromMemory(body.data(), body.size());
}
return TextureData();
}
TextureData out;
std::string filename = textureFolder? "data/images/" + filename_
: filename_;
std::ifstream source(filename.c_str(), std::ios::binary);
if (!source) {
LOGI("Couldn't find file: %s\n", filename.c_str());
return out;
}
std::vector<unsigned char> fileData((std::istreambuf_iterator<char>(source)), std::istreambuf_iterator<char>());
source.close();
if (fileData.empty()) {
LOGI("Couldn't read file: %s\n", filename.c_str());
return out;
}
return loadTextureFromMemory(fileData.data(), fileData.size());
}
TextureData loadTextureFromMemory(const unsigned char* data, size_t size) override {
return loadPngFromMemory(data, size);
}
virtual std::string getDateString(int s) override {
time_t tm = s;
char mbstr[100];
std::strftime(mbstr, sizeof(mbstr), "%F %T", std::localtime(&tm));
return std::string(mbstr);
}
virtual int getScreenWidth() override {
#ifdef __EMSCRIPTEN__
int w, h;
emscripten_get_canvas_element_size("canvas", &w, &h);
return w;
#endif
return 854;
};
virtual int getScreenHeight() override {
#ifdef __EMSCRIPTEN__
int w, h;
emscripten_get_canvas_element_size("canvas", &w, &h);
return h;
#endif
return 480;
};
virtual float getPixelsPerMillimeter() override;
virtual bool supportsTouchscreen() override { return false; /* glfw supports only mouse and keyboard */ }
virtual void hideCursor(bool hide) override {
int isHide = hide ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_HIDDEN;
glfwSetInputMode(window, GLFW_CURSOR, isHide);
}
virtual void openURL(const std::string& url) override {
#ifdef _WIN32
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
#elif __linux__
std::string command = "xdg-open " + url;
system(command.c_str());
#elif __EMSCRIPTEN__
emscripten_run_script(std::string("window.open('" + url + "', '_blank')").c_str());
#endif
}
GLFWwindow* window;
private:
};
#endif /*APPPLATFORM_GLFW_H__*/

View File

@@ -1,64 +1,65 @@
#pragma once #ifndef APPPLATFORM_IOS_H__
#define APPPLATFORM_IOS_H__
#include <IPlatform.h>
#include "client/renderer/gles.hpp" #include "AppPlatform.h"
#include "platform/log.hpp" #include "client/renderer/gles.h"
#include <cmath> #include "platform/log.h"
#include <fstream> #include <cmath>
#include <sstream> #include <fstream>
#include <sstream>
@class minecraftpeViewController;
@class minecraftpeViewController;
class AppPlatform_iOS: public AppPlatform
{ class AppPlatform_iOS: public AppPlatform
typedef AppPlatform super; {
public: typedef AppPlatform super;
AppPlatform_iOS(minecraftpeViewController* vc) { public:
_viewController = vc; AppPlatform_iOS(minecraftpeViewController* vc) {
srand(time(0)); _viewController = vc;
srand(time(0));
LOGI("ViewController in AppPlatform: %p\n", _viewController);
} LOGI("ViewController in AppPlatform: %p\n", _viewController);
}
void setBasePath(const std::string& bp) { _basePath = bp; }
void setBasePath(const std::string& bp) { _basePath = bp; }
void saveScreenshot(const std::string& filename, int glWidth, int glHeight) {
//@todo void saveScreenshot(const std::string& filename, int glWidth, int glHeight) {
} //@todo
}
inline unsigned int rgbToBgr(unsigned int p) {
return (p & 0xff00ff00) | ((p >> 16) & 0xff) | ((p << 16) & 0xff0000); __inline unsigned int rgbToBgr(unsigned int p) {
} return (p & 0xff00ff00) | ((p >> 16) & 0xff) | ((p << 16) & 0xff0000);
}
virtual void showDialog(int dialogId);
virtual int getUserInputStatus(); virtual void showDialog(int dialogId);
virtual StringVector getUserInput(); virtual int getUserInputStatus();
virtual StringVector getUserInput();
TextureData loadTexture(const std::string& filename_, bool textureFolder);
TextureData loadTexture(const std::string& filename_, bool textureFolder);
virtual BinaryBlob readAssetFile(const std::string& filename);
virtual BinaryBlob readAssetFile(const std::string& filename);
std::string getDateString(int s);
std::string getDateString(int s);
virtual int getScreenWidth();
virtual int getScreenHeight(); virtual int getScreenWidth();
virtual float getPixelsPerMillimeter(); virtual int getScreenHeight();
virtual float getPixelsPerMillimeter();
virtual bool isTouchscreen();
virtual void vibrate(int milliSeconds); virtual bool isTouchscreen();
virtual void vibrate(int milliSeconds);
virtual bool isNetworkEnabled(bool onlyWifiAllowed);
virtual bool isNetworkEnabled(bool onlyWifiAllowed);
virtual StringVector getOptionStrings();
virtual StringVector getOptionStrings();
virtual bool isPowerVR() { return false; }
virtual bool isSuperFast(); virtual bool isPowerVR();
virtual void showKeyboard(); virtual bool isSuperFast();
virtual void hideKeyboard(); virtual void showKeyboard();
virtual void isPowerVR(); virtual void hideKeyboard();
private: private:
std::string _basePath; std::string _basePath;
minecraftpeViewController* _viewController; minecraftpeViewController* _viewController;
}; };
#endif /*APPPLATFORM_IOS_H__*/

View File

@@ -275,8 +275,10 @@ void AppPlatform_iOS::hideKeyboard() {
[_viewController hideKeyboard]; [_viewController hideKeyboard];
super::hideKeyboard(); super::hideKeyboard();
} }
void AppPlatform_iOS::isPowerVR() {
// this was originally void but i changed it to bool because void cant return values
bool AppPlatform_iOS::isPowerVR() {
const char* s = (const char*)glGetString(GL_RENDERER); const char* s = (const char*)glGetString(GL_RENDERER);
if (!s) return false; if (!s) return false;
return strstr(s, "SGX") != NULL; return strstr(s, "SGX") != NULL;
} }

View File

@@ -1,16 +1,16 @@
#include "AppPlatform_win32.hpp" #include "AppPlatform_win32.h"
#include "util/Mth.hpp" #include "util/Mth.h"
int AppPlatform_win32::getScreenWidth() { return 854; } int AppPlatform_win32::getScreenWidth() { return 854; }
int AppPlatform_win32::getScreenHeight() { return 480; } int AppPlatform_win32::getScreenHeight() { return 480; }
float AppPlatform_win32::getPixelsPerMillimeter() { float AppPlatform_win32::getPixelsPerMillimeter() {
// assuming 24" @ 1920x1200 // assuming 24" @ 1920x1200
const int w = 1920; const int w = 1920;
const int h = 1200; const int h = 1200;
const float pixels = Mth::sqrt(w*w + h*h); const float pixels = Mth::sqrt(w*w + h*h);
const float mm = 24 * 25.4f; const float mm = 24 * 25.4f;
return pixels / mm; return pixels / mm;
} }
bool AppPlatform_win32::supportsTouchscreen() { return true; } bool AppPlatform_win32::supportsTouchscreen() { return true; }

View File

@@ -1,140 +1,142 @@
#pragma once #ifndef APPPLATFORM_WIN32_H__
#define APPPLATFORM_WIN32_H__
#include <IPlatform.hpp>
#include "platform/log.hpp" #include "AppPlatform.h"
#include "platform/HttpClient.hpp" #include "platform/log.h"
#include "platform/PngLoader.hpp" #include "platform/HttpClient.h"
#include "client/renderer/gles.hpp" #include "platform/PngLoader.h"
#include "world/level/storage/FolderMethods.hpp" #include "client/renderer/gles.h"
#include "util/StringUtils.hpp" #include "world/level/storage/FolderMethods.h"
#include <png.h> #include "util/StringUtils.h"
#include <cmath> #include <png.h>
#include <fstream> #include <cmath>
#include <sstream> #include <fstream>
#include <windows.h> #include <sstream>
#include <shellapi.h> #include <windows.h>
#include <shellapi.h>
static void png_funcReadFile(png_structp pngPtr, png_bytep data, png_size_t length) {
((std::istream*)png_get_io_ptr(pngPtr))->read((char*)data, length); static void png_funcReadFile(png_structp pngPtr, png_bytep data, png_size_t length) {
} ((std::istream*)png_get_io_ptr(pngPtr))->read((char*)data, length);
}
class AppPlatform_win32: public AppPlatform
{ class AppPlatform_win32: public AppPlatform
public: {
AppPlatform_win32() public:
{ AppPlatform_win32()
} {
}
BinaryBlob readAssetFile(const std::string& filename) {
FILE* fp = fopen(("data/" + filename).c_str(), "r"); BinaryBlob readAssetFile(const std::string& filename) {
if (!fp) FILE* fp = fopen(("data/" + filename).c_str(), "r");
return BinaryBlob(); if (!fp)
return BinaryBlob();
int size = getRemainingFileSize(fp);
int size = getRemainingFileSize(fp);
BinaryBlob blob;
blob.size = size; BinaryBlob blob;
blob.data = new unsigned char[size]; blob.size = size;
blob.data = new unsigned char[size];
fread(blob.data, 1, size, fp);
fclose(fp); fread(blob.data, 1, size, fp);
fclose(fp);
return blob;
} return blob;
}
void saveScreenshot(const std::string& filename, int glWidth, int glHeight) {
//@todo void saveScreenshot(const std::string& filename, int glWidth, int glHeight) {
} //@todo
}
inline unsigned int rgbToBgr(unsigned int p) {
return (p & 0xff00ff00) | ((p >> 16) & 0xff) | ((p << 16) & 0xff0000); __inline unsigned int rgbToBgr(unsigned int p) {
} return (p & 0xff00ff00) | ((p >> 16) & 0xff) | ((p << 16) & 0xff0000);
}
TextureData loadTexture(const std::string& filename_, bool textureFolder)
{ TextureData loadTexture(const std::string& filename_, bool textureFolder)
// Support fetching PNG textures via HTTP/HTTPS (for skins, etc). {
if (Util::startsWith(filename_, "http://") || Util::startsWith(filename_, "https://")) { // Support fetching PNG textures via HTTP/HTTPS (for skins, etc).
std::vector<unsigned char> body; if (Util::startsWith(filename_, "http://") || Util::startsWith(filename_, "https://")) {
if (HttpClient::download(filename_, body) && !body.empty()) { std::vector<unsigned char> body;
return loadTextureFromMemory(body.data(), body.size()); if (HttpClient::download(filename_, body) && !body.empty()) {
} return loadTextureFromMemory(body.data(), body.size());
return TextureData(); }
} return TextureData();
}
TextureData out;
TextureData out;
std::string filename = textureFolder? "data/images/" + filename_
: filename_; std::string filename = textureFolder? "data/images/" + filename_
std::ifstream source(filename.c_str(), std::ios::binary); : filename_;
std::ifstream source(filename.c_str(), std::ios::binary);
if (source) {
png_structp pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (source) {
png_structp pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!pngPtr)
return out; if (!pngPtr)
return out;
png_infop infoPtr = png_create_info_struct(pngPtr);
png_infop infoPtr = png_create_info_struct(pngPtr);
if (!infoPtr) {
png_destroy_read_struct(&pngPtr, NULL, NULL); if (!infoPtr) {
return out; png_destroy_read_struct(&pngPtr, NULL, NULL);
} return out;
}
// Hack to get around the broken libpng for windows
png_set_read_fn(pngPtr,(void*)&source, png_funcReadFile); // Hack to get around the broken libpng for windows
png_set_read_fn(pngPtr,(void*)&source, png_funcReadFile);
png_read_info(pngPtr, infoPtr);
png_read_info(pngPtr, infoPtr);
// Set up the texdata properties
out.w = png_get_image_width(pngPtr, infoPtr); // Set up the texdata properties
out.h = png_get_image_height(pngPtr, infoPtr); out.w = png_get_image_width(pngPtr, infoPtr);
out.h = png_get_image_height(pngPtr, infoPtr);
png_bytep* rowPtrs = new png_bytep[out.h];
out.data = new unsigned char[4 * out.w * out.h]; png_bytep* rowPtrs = new png_bytep[out.h];
out.memoryHandledExternally = false; out.data = new unsigned char[4 * out.w * out.h];
out.memoryHandledExternally = false;
int rowStrideBytes = 4 * out.w;
for (int i = 0; i < out.h; i++) { int rowStrideBytes = 4 * out.w;
rowPtrs[i] = (png_bytep)&out.data[i*rowStrideBytes]; for (int i = 0; i < out.h; i++) {
} rowPtrs[i] = (png_bytep)&out.data[i*rowStrideBytes];
png_read_image(pngPtr, rowPtrs); }
png_read_image(pngPtr, rowPtrs);
// Teardown and return
png_destroy_read_struct(&pngPtr, &infoPtr,(png_infopp)0); // Teardown and return
delete[] (png_bytep)rowPtrs; png_destroy_read_struct(&pngPtr, &infoPtr,(png_infopp)0);
source.close(); delete[] (png_bytep)rowPtrs;
source.close();
return out;
} return out;
else }
{ else
LOGI("Couldn't find file: %s\n", filename.c_str()); {
return out; LOGI("Couldn't find file: %s\n", filename.c_str());
} return out;
} }
}
TextureData loadTextureFromMemory(const unsigned char* data, size_t size) override {
return loadPngFromMemory(data, size); TextureData loadTextureFromMemory(const unsigned char* data, size_t size) override {
} return loadPngFromMemory(data, size);
time_t tm = s; }
time_t tm = s;
char mbstr[100];
std::strftime(mbstr, sizeof(mbstr), "%F %T", std::localtime(&tm)); char mbstr[100];
std::strftime(mbstr, sizeof(mbstr), "%F %T", std::localtime(&tm));
return std::string(mbstr);
} return std::string(mbstr);
}
virtual int getScreenWidth();
virtual int getScreenHeight(); virtual int getScreenWidth();
virtual int getScreenHeight();
virtual float getPixelsPerMillimeter();
virtual float getPixelsPerMillimeter();
virtual bool supportsTouchscreen();
virtual bool supportsTouchscreen();
virtual void openURL(const std::string& url) {
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL); virtual void openURL(const std::string& url) {
} ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
}
private:
}; private:
};
#endif /*APPPLATFORM_WIN32_H__*/

View File

@@ -1,4 +1,5 @@
#pragma once #ifndef EGLCONFIGPRINTER_H__
#define EGLCONFIGPRINTER_H__
#include <cstdio> #include <cstdio>
#include <string> #include <string>
@@ -121,3 +122,4 @@ public:
} }
}; };
#endif /*EGLCONFIGPRINTER_H__*/

13
src/ErrorCodes.h Executable file
View File

@@ -0,0 +1,13 @@
#ifndef ERRORCODES_H__
#define ERRORCODES_H__
namespace ErrorCodes {
enum Enum {
Unknown,
ContainerRefStillExistsAfterDestruction
};
}
#endif /*ERRORCODES_H__*/

View File

@@ -1,14 +0,0 @@
#include <IPlatform.hpp>
#include <App.hpp>
#include <fstream>
void IPlatform::runMainLoop(App& app) {
while(!app.wantToQuit()) app.update();
}
ByteVector IPlatform::readAssetFile(const std::string& path) {
std::ifstream instream(path, std::ios::in | std::ios::binary);
std::vector<uint8_t> data((std::istreambuf_iterator<char>(instream)), std::istreambuf_iterator<char>());
return data;
}

View File

@@ -1,81 +0,0 @@
#pragma once
#include <vector>
#include <string>
#include "client/renderer/TextureData.hpp"
#include <cstdint>
typedef std::vector<std::string> StringVector;
typedef std::vector<uint8_t> ByteVector;
class App;
class IPlatform {
public:
IPlatform() : keyboardVisible(false), windowSizeChanged(false), m_targetFrametime(0.f) {}
virtual ~IPlatform() {}
virtual bool init() { return true; }
virtual void swapBuffers() {}
virtual void runMainLoop(App& app);
virtual ByteVector readAssetFile(const std::string& path);
// Mojang functions here
virtual TextureData loadTexture(const std::string& filename_, bool textureFolder) { return TextureData(); }
virtual TextureData loadTextureFromMemory(const unsigned char* data, size_t size) { return TextureData(); }
virtual void playSound(const std::string& fn, float volume, float pitch) {}
virtual void hideCursor(bool hide) {}
virtual std::string getDateString(int s) = 0;
virtual void uploadPlatformDependentData(int id, void* data) {}
// virtual BinaryBlob readAssetFile(const std::string& filename) { return BinaryBlob(); }
virtual void _tick() {}
virtual int getScreenWidth() { return 854; }
virtual int getScreenHeight() { return 480; }
virtual float getPixelsPerMillimeter() { return 10; }
virtual bool isNetworkEnabled(bool onlyWifiAllowed) { return true; }
virtual bool isPowerVR() {
return false;
}
virtual int getKeyFromKeyCode(int keyCode, int metaState, int deviceId) {return 0;}
#ifdef __APPLE__
virtual bool isSuperFast() = 0;
#endif
virtual void openURL(const std::string& url) {}
virtual void finish() {}
virtual bool supportsTouchscreen() { return false; }
virtual void vibrate(int milliSeconds) {}
virtual std::string getPlatformStringVar(int stringId) = 0;
virtual void showKeyboard() { keyboardVisible = true; }
virtual void hideKeyboard() { keyboardVisible = false; }
virtual bool isKeyboardVisible() { return keyboardVisible; }
virtual void setTargetFPS(int fps) { m_targetFrametime = 1.0 / fps; }
bool isWindowSizeChanged() { return windowSizeChanged; }
virtual void setVSync(bool on) { vsync = on; }
protected:
bool keyboardVisible;
bool windowSizeChanged;
bool vsync;
double m_targetFrametime;
};

View File

@@ -1,39 +1,40 @@
#pragma once #ifndef LICENSECODES_H__
#define LICENSECODES_H__
class LicenseCodes
{ class LicenseCodes
public: {
// Something's not ready, call again later public:
static const int WAIT_PLATFORM_NOT_READY = -2; // Something's not ready, call again later
static const int WAIT_SERVER_NOT_READY = -1; static const int WAIT_PLATFORM_NOT_READY = -2;
static const int WAIT_SERVER_NOT_READY = -1;
// License is ok
static const int LICENSE_OK = 0; // License is ok
static const int LICENSE_TRIAL_OK = 1; static const int LICENSE_OK = 0;
static const int LICENSE_TRIAL_OK = 1;
// License is not working in one way or another
static const int LICENSE_VALIDATION_FAILED = 50; // License is not working in one way or another
static const int ITEM_NOT_FOUND = 51; static const int LICENSE_VALIDATION_FAILED = 50;
static const int LICENSE_NOT_FOUND = 52; static const int ITEM_NOT_FOUND = 51;
static const int ERROR_CONTENT_HANDLER = 100; static const int LICENSE_NOT_FOUND = 52;
static const int ERROR_ILLEGAL_ARGUMENT = 101; static const int ERROR_CONTENT_HANDLER = 100;
static const int ERROR_SECURITY = 102; static const int ERROR_ILLEGAL_ARGUMENT = 101;
static const int ERROR_INPUT_OUTPUT = 103; static const int ERROR_SECURITY = 102;
static const int ERROR_ILLEGAL_STATE = 104; static const int ERROR_INPUT_OUTPUT = 103;
static const int ERROR_NULL_POINTER = 105; static const int ERROR_ILLEGAL_STATE = 104;
static const int ERROR_GENERAL = 106; static const int ERROR_NULL_POINTER = 105;
static const int ERROR_UNABLE_TO_CONNECT_TO_CDS = 107; static const int ERROR_GENERAL = 106;
static const int ERROR_UNABLE_TO_CONNECT_TO_CDS = 107;
// The call went wrong so we didn't get a license value at all
static const int ERROR_EXCEPTION = 200; // The call went wrong so we didn't get a license value at all
static const int ERROR_EXCEPTION = 200;
static bool isOk(int i) {
return (i == 0) || (i == 1); static bool isOk(int i) {
} return (i == 0) || (i == 1);
static bool isReady(int i) { }
return (i >= 0); static bool isReady(int i) {
} return (i >= 0);
}; }
};
#endif /*LICENSECODES_H__ */
#endif /*LICENSECODES_H__ */

View File

@@ -1,502 +0,0 @@
#include <Minecraft.hpp>
#include "gamemode/CreativeMode.hpp"
#include "gamemode/SurvivalMode.hpp"
#include "gamemode/CreatorMode.hpp"
#include "world/entity/player/Player.hpp"
#include "world/item/Item.hpp"
#include "world/item/ItemInstance.hpp"
#include "world/item/crafting/Recipes.hpp"
#include "world/level/Level.hpp"
#include "world/level/tile/entity/TileEntity.hpp"
#include <string>
#include <cstdlib>
#include "client/gui/Screen.hpp"
#include "world/level/storage/ExternalFileLevelStorageSource.hpp"
#if defined(APPLE_DEMO_PROMOTION)
#define NO_NETWORK
#endif
#if defined(RPI)
#define CREATORMODE
#endif
#include "network/RakNetInstance.hpp"
#include "network/ClientSideNetworkHandler.hpp"
#include "network/ServerSideNetworkHandler.hpp"
//#include "network/Packet.hpp"
#include "world/entity/player/Inventory.hpp"
#include "world/level/tile/Tile.hpp"
#include "world/level/storage/LevelStorageSource.hpp"
#include "world/level/storage/LevelStorage.hpp"
#include "world/level/chunk/ChunkSource.hpp"
#include "platform/CThread.hpp"
#include <IPlatform.hpp>
#include "util/PerfTimer.hpp"
#include "util/PerfRenderer.hpp"
#include "world/entity/MobFactory.hpp"
#include "world/level/MobSpawner.hpp"
#include "util/Mth.hpp"
#include "world/entity/MobCategory.hpp"
#include "server/ServerLevel.hpp"
#ifdef CREATORMODE
#include "server/CreatorLevel.hpp"
#endif
#include "network/command/CommandServer.hpp"
/*static*/
const char* Minecraft::progressMessages[] = {
"Locating server",
"Building terrain",
"Preparing",
"Saving chunks"
};
// int Minecraft::customDebugId = Minecraft::CDI_NONE;
bool Minecraft::_hasInitedStatics = false;
#if defined(_MSC_VER)
#pragma warning( disable : 4355 ) // 'this' pointer in initialization list which is perfectly legal
#endif
// Minecraft::Minecraft() :
// #ifdef __APPLE__
// _isSuperFast(false),
// #endif
// #if defined(NO_NETWORK)
// raknetInstance = new IRakNetInstance();
// #else
// raknetInstance = new RakNetInstance();
// #endif
// #ifndef STANDALONE_SERVER
// soundEngine = new SoundEngine(20.0f);
// soundEngine->init(this, &options);
// #endif
// //setupPieces();
// #if defined(ANDROID) || defined(__APPLE__) || defined(RPI)
// signal(SIGPIPE, SIG_IGN);
// #endif
// externalCacheStoragePath = '.';
// externalCacheStoragePath = '.';
// }
Minecraft::~Minecraft() {
delete netCallback;
delete raknetInstance;
delete gameMode;
if (level != NULL) {
level->saveGame();
if (level->getChunkSource())
level->getChunkSource()->saveAll(true);
delete level->getLevelStorage();
delete level;
level = NULL;
}
//delete player;
delete storageSource;
delete _commandServer;
MobFactory::clearStaticTestMobs();
// Note: Don't tear down statics if we run on Android
// (we might change this in the future)
#ifndef ANDROID
Biome::teardownBiomes();
Item ::teardownItems();
Tile ::teardownTiles();
Material::teardownMaterials();
Recipes ::teardownRecipes();
TileEntity::teardownTileEntities();
#endif
}
// Only called by server
void Minecraft::selectLevel( const std::string& levelId, const std::string& levelName, const LevelSettings& settings ) {
level = (Level*)new ServerLevel(
storageSource->selectLevel(levelId, false),
levelName,
settings,
SharedConstants::GeneratorVersion
);
// note: settings is useless beyond this point, since it's
// either copied to LevelData (or LevelData read from file)
setLevel(level, "Generating level");
setIsCreativeMode(level->getLevelData()->getGameType() == GameType::Creative);
_running = true;
}
void Minecraft::setLevel(Level* level, const std::string& message, Player* forceInsertPlayer) {
LOGI("Seed is %ld\n", level->getSeed());
if (level != NULL) {
level->raknetInstance = raknetInstance;
gameMode->initLevel(level);
this->level = level;
_hasSignaledGeneratingLevelFinished = false;
#ifdef STANDALONE_SERVER
const bool threadedLevelCreation = false;
#else
const bool threadedLevelCreation = true;
#endif
if (threadedLevelCreation) {
// Threaded
// "Lock"
isGeneratingLevel = true;
generateLevelThread = new CThread(Minecraft::prepareLevel_tspawn, this);
} else {
// Non-threaded
generateLevel("Currently not used", level);
}
}
this->lastTickTime = 0;
this->_running = true;
}
void Minecraft::prepareLevel(const std::string& title) {
LOGI("status: 1\n");
progressStageStatusId = 1;
Stopwatch A, B, C, D;
A.start();
Stopwatch L;
// Dont update lights if we load the level (ok, actually just with leveldata version=1.+(?))
if (!level->isNew())
level->setUpdateLights(false);
int Max = CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH;
int pp = 0;
for (int x = 8; x < (CHUNK_CACHE_WIDTH * CHUNK_WIDTH); x += CHUNK_WIDTH) {
for (int z = 8; z < (CHUNK_CACHE_WIDTH * CHUNK_WIDTH); z += CHUNK_WIDTH) {
progressStagePercentage = 100 * pp++ / Max;
//printf("level generation progress %d\n", progressStagePercentage);
B.start();
level->getTile(x, 64, z);
B.stop();
L.start();
if (level->isNew())
while (level->updateLights())
;
L.stop();
}
}
A.stop();
level->setUpdateLights(true);
C.start();
for (int x = 0; x < CHUNK_CACHE_WIDTH; x++)
{
for (int z = 0; z < CHUNK_CACHE_WIDTH; z++)
{
LevelChunk* chunk = level->getChunk(x, z);
if (chunk && !chunk->createdFromSave)
{
chunk->unsaved = false;
chunk->clearUpdateMap();
}
}
}
C.stop();
LOGI("status: 3\n");
progressStageStatusId = 3;
if (level->isNew()) {
level->setInitialSpawn(); // @note: should obviously be called from Level itself
level->saveLevelData();
level->getChunkSource()->saveAll(false);
level->saveGame();
} else {
level->saveLevelData();
level->loadEntities();
}
progressStagePercentage = -1;
progressStageStatusId = 2;
LOGI("status: 2\n");
D.start();
level->prepare();
D.stop();
A.print("Generate level: ");
L.print(" - light: ");
B.print(" - getTl: ");
C.print(" - clear: ");
D.print(" - prepr: ");
progressStageStatusId = 0;
}
void Minecraft::update() {
timer.advanceTime();
raknetInstance->runEvents(netCallback);
TIMER_PUSH("tick");
int toTick = timer.ticks;
timer.ticks = 0;
for (int i = 0; i < toTick; ++i, ++ticks) tick(i, toTick-1);
TIMER_POP_PUSH("updatelights");
{
if (level && !isGeneratingLevel) {
level->updateLights();
}
}
TIMER_POP();
// Restart the server if (our modded) RakNet reports an error
if (level && raknetInstance->isProbablyBroken() && raknetInstance->isServer()) {
restartServer();
}
}
void Minecraft::restartServer() {
if (!level) return;
raknetInstance->resetIsBroken();
hostMultiplayer();
if (netCallback) netCallback->levelGenerated(level);
}
void Minecraft::tick(int nTick, int maxTick) {
if (missTime > 0) missTime--;
TIMER_PUSH("gameMode");
if (level) {
gameMode->tick();
}
TIMER_POP_PUSH("commandServer");
if (level && _commandServer) {
_commandServer->tick();
}
//
// Ongoing level generation in a (perhaps) different thread. When it's
// ready, _levelGenerated() is called once and any threads are deleted.
//
if (isGeneratingLevel) {
return;
} else if (!_hasSignaledGeneratingLevelFinished) {
if (generateLevelThread) {
delete generateLevelThread;
generateLevelThread = NULL;
}
_levelGenerated();
}
//
// Normal game loop, run before or efter level generation
//
if (level != NULL) {
TIMER_POP_PUSH("level");
level->tickEntities();
level->tick();
}
TIMER_POP();
}
bool Minecraft::isOnlineClient() {
return false;
}
bool Minecraft::isOnline() {
return netCallback != NULL;
}
void Minecraft::init()
{
// WHY DO WE NEED THIS ON MODERN PLATFORMS :sob:
// Global initialization goes here
Mth::initMth();
if (raknetInstance != nullptr) {
delete raknetInstance;
}
raknetInstance = new RakNetInstance();
// If we're running Android, only initialize
// the first time class is instanced
#ifdef ANDROID
if (!_hasInitedStatics) {
_hasInitedStatics = true;
#endif
Material::initMaterials();
MobCategory::initMobCategories();
Tile::initTiles();
Item::initItems();
Biome::initBiomes();
TileEntity::initTileEntities();
#ifdef ANDROID
}
#endif
setIsCreativeMode(false); // false means it's Survival Mode
#if !defined(NO_STORAGE)
storageSource = new ExternalFileLevelStorageSource(externalStoragePath, externalCacheStoragePath);
#else
storageSource = new MemoryLevelStorageSource();
#endif
// Server-only featire @todo server class app
hostMultiplayer();
}
//
// Multiplayer
//
void Minecraft::hostMultiplayer(int port) {
// Tear down last instance
raknetInstance->disconnect();
delete netCallback;
netCallback = nullptr;
#if !defined(NO_NETWORK)
netCallback = new ServerSideNetworkHandler(this, raknetInstance);
#endif
}
//
// Level generation
//
/*static*/
void* Minecraft::prepareLevel_tspawn(void *p_param) {
Minecraft* mc = (Minecraft*) p_param;
mc.generateLevel("Currently not used", mc.level);
return 0;
}
void Minecraft::generateLevel( const std::string& message, Level* level ) {
Stopwatch s;
s.start();
prepareLevel(message);
s.stop();
s.print("Level generated: ");
// "Unlock"
isGeneratingLevel = false;
}
void Minecraft::_levelGenerated() {
level->validateSpawn();
if (raknetInstance->isServer())
raknetInstance->announceServer(getServerName());
if (netCallback) {
netCallback->levelGenerated(level);
}
_hasSignaledGeneratingLevelFinished = true;
}
Player* Minecraft::respawnPlayer(int playerId) {
for (unsigned int i = 0; i < level->players.size(); ++i) {
if (level->players[i]->entityId == playerId) {
resetPlayer(level->players[i]);
return level->players[i];
}
}
return NULL;
}
void Minecraft::resetPlayer(Player* player) {
level->validateSpawn();
player->reset();
Pos p;
if(player->hasRespawnPosition()) {
p = player->getRespawnPosition();
}
else {
p = level->getSharedSpawnPos();
}
player->setPos((float)p.x + 0.5f, (float)p.y + 1.0f, (float)p.z + 0.5f);
player->resetPos(true);
if (isCreativeMode())
player->inventory->clearInventoryWithDefault();
}
int Minecraft::getProgressStatusId() {
return progressStageStatusId;
}
const char* Minecraft::getProgressMessage()
{
return progressMessages[progressStageStatusId];
}
bool Minecraft::isLevelGenerated()
{
return level != NULL && !isGeneratingLevel;
}
LevelStorageSource* Minecraft::getLevelSource()
{
return storageSource;
}
void Minecraft::setIsCreativeMode(bool isCreative)
{
#ifdef CREATORMODE
delete gameMode;
gameMode = new CreatorMode(this);
_isCreativeMode = true;
#else
if (!gameMode || isCreative != _isCreativeMode)
{
delete gameMode;
if (isCreative) gameMode = new CreativeMode(*this);
else gameMode = new SurvivalMode(*this);
_isCreativeMode = isCreative;
}
#endif
}
bool Minecraft::isCreativeMode() {
return _isCreativeMode;
}
ICreator* Minecraft::getCreator()
{
#ifdef CREATORMODE
return ((CreatorMode*)gameMode)->getCreator();
#else
return NULL;
#endif
}
void Minecraft::optionUpdated(OptionId option, bool value ) {
if(netCallback != NULL && option == OPTIONS_SERVER_VISIBLE) {
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) netCallback;
ss->allowIncomingConnections(value);
}
}
void Minecraft::optionUpdated(OptionId option, float value ) {}
void Minecraft::optionUpdated(OptionId option, int value ) {}

View File

@@ -1,138 +0,0 @@
#pragma once
#include "client/Options.hpp"
#include "client/Timer.hpp"
//#include "../network/RakNetInstance.hpp"
#include "world/phys/HitResult.hpp"
#include "App.hpp"
#include <cstddef>
class Level;
class LocalPlayer;
class IInputHolder;
class Mob;
class Player;
class Entity;
class ICreator;
class GameMode;
class CThread;
class LevelStorageSource;
class BuildActionIntention;
class PerfRenderer;
class LevelSettings;
class IRakNetInstance;
class NetEventCallback;
class CommandServer;
struct PingedCompatibleServer;
class Minecraft: public App {
public:
using App::App;
virtual ~Minecraft();
virtual void init();
virtual void update();
virtual void restartServer();
virtual void tick(int nTick, int maxTick);
virtual bool isOnlineClient();
virtual bool isOnline();
virtual void setIsCreativeMode(bool isCreative);
virtual void optionUpdated(OptionId option, bool value);
virtual void optionUpdated(OptionId option, float value);
virtual void optionUpdated(OptionId option, int value);
/**
* @brief Get public name that will be listed in JoinGame menu
*/
virtual std::string getServerName() { return "Unknown"; }
void toggleDimension() {}
bool isCreativeMode();
virtual void selectLevel(const std::string& levelId, const std::string& levelName, const LevelSettings& settings);
virtual void setLevel(Level* level, const std::string& message = "", Player* forceInsertPlayer = NULL);
virtual void onBlockDestroyed(Player* player, int x, int y, int z, int face) {}
void generateLevel( const std::string& message, Level* level );
LevelStorageSource* getLevelSource();
virtual void hostMultiplayer(int port=19132);
Player* respawnPlayer(int playerId);
void respawnPlayer();
void resetPlayer(Player* player);
void doActuallyRespawnPlayer();
void prepareLevel(const std::string& message);
int getProgressStatusId();
const char* getProgressMessage();
ICreator* getCreator();
bool isLevelGenerated();
#ifdef __APPLE__
bool _isSuperFast = false;
bool isSuperFast() { return _isSuperFast; }
#endif
protected:
virtual void _levelGenerated();
private:
static void* prepareLevel_tspawn(void *p_param);
public:
Level* level = nullptr;
CommandServer* _commandServer = nullptr;
GameMode* gameMode = nullptr;
IRakNetInstance* raknetInstance = nullptr;
NetEventCallback* netCallback = nullptr;
int commandPort = 4711;
int lastTime = 0;
int lastTickTime = -1;
int missTime = 0;
int ticks = 0;
CThread* generateLevelThread = nullptr;
// static int customDebugId;
HitResult hitResult;
volatile int progressStagePercentage = 0;
// This field is initialized in main()
// It sets the base path to where worlds can be written (sdcard on android)
std::string externalStoragePath;
std::string externalCacheStoragePath;
protected:
Timer timer{20};
// @note @attn @warn: this is dangerous as fuck!
volatile bool isGeneratingLevel = false;
bool _hasSignaledGeneratingLevelFinished = true;
LevelStorageSource* storageSource;
bool _running;
protected:
volatile int progressStageStatusId = 0;
static const char* progressMessages[];
int _licenseId;
bool _isCreativeMode;
Player* _pendingRemovePlayer; // @attn @todo @fix: remove this shait and fix the respawn behaviour
// from NinecraftApp
bool _verbose = true;
int _lastTickMs = 0;
static bool _hasInitedStatics;
};

View File

@@ -1,149 +0,0 @@
#pragma once
#include "client/gui/Font.hpp"
#include "client/gui/Screen.hpp"
#include "client/particle/ParticleEngine.hpp"
#include "client/player/LocalPlayer.hpp"
#include "client/renderer/GameRenderer.hpp"
#include "client/renderer/Textures.hpp"
#include "client/sound/SoundEngine.hpp"
#include <Minecraft.hpp>
#include <client/MouseHandler.hpp>
#include <client/gui/Gui.hpp>
#include <client/gui/screens/ScreenChooser.hpp>
#include <client/PixelCalc.hpp>
#include <client/renderer/LevelRenderer.hpp>
class MinecraftClient : public Minecraft {
public:
using Minecraft::Minecraft;
~MinecraftClient();
void init() override;
void update() override;
void setSize(int width, int height);
void reloadOptions();
bool supportNonTouchScreen();
bool useTouchscreen();
void grabMouse();
void releaseMouse();
void setScreen(Screen*);
void leaveGame(bool renameLevel = false);
void setLevel(Level* level, const std::string& message = "", Player* forceInsertPlayer = NULL) override;
void updateStats();
void restartServer() override;
bool handleBack(bool isDown) override;
void onGraphicsReset();
void initGLStates();
void tick(int nTick, int maxTick) override;
void tickInput();
void handleBuildAction(BuildActionIntention* action);
bool isOnlineClient() override;
void pauseGame(bool isBackPaused);
void gameLostFocus();
void respawnPlayer();
void audioEngineOn() override;
void audioEngineOff() override;
void setIsCreativeMode(bool isCreative) override;
void optionUpdated(OptionId option, bool value) override;
void optionUpdated(OptionId option, float value) override;
void optionUpdated(OptionId option, int value) override;
LocalPlayer* player() { return m_player; }
Font* font() { return m_font; }
Textures& textures() { return m_textures; }
Options& options() { return m_options;}
Screen* getScreen() { return m_screen; }
Gui& gui() { return m_gui; }
ParticleEngine* getParticleEngine() {return particleEngine; }
int getScreenWidth() { return m_width; }
int getScreenHeight() { return m_height; }
virtual void hostMultiplayer(int port) override;
bool isPowerVR() { return _powerVr; }
bool isKindleFire(int kindleVersion);
bool transformResolution(int* w, int* h);
virtual std::string getServerName() override;
void locateMultiplayer();
void cancelLocateMultiplayer();
bool joinMultiplayer(const PingedCompatibleServer& server);
bool joinMultiplayerFromString(const std::string& server);
void onBlockDestroyed(Player* player, int x, int y, int z, int face) override;
ScreenChooser& screenChooser() { return m_screenChooser; }
PixelCalc& pixelCalc() { return m_pixelCalc; }
PixelCalc& pixelCalcUi() { return m_pixelCalcUi; }
IInputHolder* inputHolder() { return m_inputHolder; }
SoundEngine* soundEngine() { return m_soundEngine; }
protected:
void _reloadInput();
void _levelGenerated() override;
int m_width = 1, m_height = 1;
Font* m_font = nullptr;
// @warn This is unsafe cuz Gui may call some MinecraftClient method while MinecraftClient is not ready
MouseHandler mouseHandler;
LevelRenderer* levelRenderer = nullptr;
GameRenderer* gameRenderer = nullptr;
ParticleEngine* particleEngine = nullptr;
SoundEngine* m_soundEngine = nullptr;
PerfRenderer* _perfRenderer = nullptr;
bool mouseGrabbed = false;
PixelCalc m_pixelCalc;
PixelCalc m_pixelCalcUi;
Screen* m_screen = nullptr;
bool screenMutex = false;
bool hasScheduledScreen = false;
Screen* scheduledScreen = nullptr;
int m_frames = 0;
volatile bool pause = false;
LocalPlayer* m_player = nullptr;
IInputHolder* m_inputHolder = nullptr;
Mob* cameraTargetPlayer = nullptr;
bool _supportsNonTouchscreen = false;
bool isLookingForMultiplayer = false;
bool _powerVr = false;
Options m_options{*this};
Textures m_textures{m_options, *m_platform};
ScreenChooser m_screenChooser{*this};
Gui m_gui{*this};
};

View File

@@ -1,15 +0,0 @@
#include "MinecraftServer.hpp"
#include <Minecraft.hpp>
#include <network/RakNetInstance.hpp>
void MinecraftServer::hostMultiplayer(int port) {
Minecraft::hostMultiplayer(port);
raknetInstance->host("Server", port, 16);
}
std::string MinecraftServer::getServerName() {
// @todo read server name from config
return "Dedicated server 0.6.1";
}

View File

@@ -1,10 +0,0 @@
#pragma once
#include <Minecraft.hpp>
class MinecraftServer : public Minecraft {
public:
using Minecraft::Minecraft;
void hostMultiplayer(int port) override;
std::string getServerName() override;
};

428
src/NinecraftApp.cpp Executable file
View File

@@ -0,0 +1,428 @@
#include "NinecraftApp.h"
//#include <EGL/egl.h>
#ifdef RPI
//#define NO_STORAGE
#endif
#include <errno.h>
#include "platform/input/Mouse.h"
#include "platform/input/Multitouch.h"
#include "world/item/Item.h"
#include "world/level/Level.h"
#include "world/level/biome/Biome.h"
#include "world/level/material/Material.h"
#include "world/entity/MobCategory.h"
//#include "world/level/storage/FolderMethods.h"
#ifndef STANDALONE_SERVER
#include "client/gui/screens/StartMenuScreen.h"
#include "client/gui/screens/UsernameScreen.h"
#endif
#include "client/player/LocalPlayer.h"
#ifndef STANDALONE_SERVER
#include "client/renderer/gles.h"
#include "client/renderer/Chunk.h"
#include "client/renderer/LevelRenderer.h"
#include "client/renderer/Tesselator.h"
#endif
// sorry for raknet dependency, but I'm too lazy to find another getTime method
#include "raknet/GetTime.h"
#include "network/RakNetInstance.h"
#include "network/ClientSideNetworkHandler.h"
#include "client/gui/screens/ProgressScreen.h"
//#include "world/entity/player/Inventory2.h"
#if !defined(DEMO_MODE) && !defined(APPLE_DEMO_PROMOTION) && !defined(NO_STORAGE)
#include "world/level/storage/ExternalFileLevelStorageSource.h"
#else
#include "world/level/storage/MemoryLevelStorageSource.h"
#endif
#ifndef STANDALONE_SERVER
#include "client/renderer/Textures.h"
#include "client/renderer/entity/ItemRenderer.h"
#endif
#include "world/item/crafting/Recipes.h"
#include "world/level/tile/entity/TileEntity.h"
#ifndef STANDALONE_SERVER
#include "client/renderer/EntityTileRenderer.h"
#endif
bool NinecraftApp::_hasInitedStatics = false;
NinecraftApp::NinecraftApp()
: _verbose(true),
_lastTickMs(0),
_frames(0)
{
#if defined(ANDROID) || defined(__APPLE__) || defined(RPI)
signal(SIGPIPE, SIG_IGN);
#endif
}
NinecraftApp::~NinecraftApp()
{
teardown();
}
void NinecraftApp::init()
{
// Global initialization goes here
Mth::initMth();
//#ifdef DEMO_MODE
//writeDemoFile();
//#endif
// If we're running Android, only initialize
// the first time class is instanced
#ifdef ANDROID
if (!_hasInitedStatics) {
_hasInitedStatics = true;
#endif
Material::initMaterials();
MobCategory::initMobCategories();
Tile::initTiles();
Item::initItems();
Biome::initBiomes();
TileEntity::initTileEntities();
#ifdef ANDROID
}
#endif
#ifndef STANDALONE_SERVER
initGLStates();
Tesselator::instance.init();
I18n::loadLanguage(platform(), "en_US");
#endif
if (!externalStoragePath.empty()) {
options.setOptionsFilePath(externalStoragePath);
}
Minecraft::init();
#if !defined(DEMO_MODE) && !defined(APPLE_DEMO_PROMOTION) && !defined(NO_STORAGE)
storageSource = new ExternalFileLevelStorageSource(externalStoragePath, externalCacheStoragePath);
#else
storageSource = new MemoryLevelStorageSource();
#endif
_running = false;
#ifndef STANDALONE_SERVER
LOGI("This: %p\n", this);
screenChooser.setScreen(SCREEN_STARTMENU);
if (options.getBooleanValue(OPTIONS_FIRST_LAUNCH)) {
options.toggle(OPTIONS_FIRST_LAUNCH);
setScreen(new UsernameScreen());
}
#else
hostMultiplayer();
#endif
}
void NinecraftApp::teardown()
{
// Note: Don't tear down statics if we run on Android
// (we might change this in the future)
#ifndef ANDROID
Biome::teardownBiomes();
Item ::teardownItems();
Tile ::teardownTiles();
Material::teardownMaterials();
Recipes ::teardownRecipes();
TileEntity::teardownTileEntities();
#endif
#ifdef WIN32
ItemRenderer::teardown_static();
if (EntityTileRenderer::instance != NULL) {
delete EntityTileRenderer::instance;
EntityTileRenderer::instance = NULL;
}
TileEntityRenderDispatcher::destroy();
#endif
}
void NinecraftApp::update()
{
++_frames;
// Generate Multitouch active pointer list
Multitouch::commit();
#ifndef ANDROID_PUBLISH
//testCreationAndDestruction();
//testJoiningAndDestruction();
#endif /*ANDROID_PUBLISH*/
Minecraft::update();
swapBuffers();
Mouse::reset2();
// Restart the server if (our modded) RakNet reports an error
if (level && raknetInstance->isProbablyBroken() && raknetInstance->isServer()) {
restartServer();
}
#ifndef WIN32
updateStats();
#endif
}
void NinecraftApp::updateStats()
{
#ifndef STANDALONE_SERVER
if (Options::debugGl)
LOGI("--------------------------------------------\n");
//*
int now = getTimeMs();
//int since = now - _lastTickMs;
if (now >= lastTime + 1000)
{
if (player) {
LOGI("%d fps \t%3d chunk updates. (%.2f, %.2f, %.2f)\n",
_frames, Chunk::updates, player->x, player->y, player->z);
Chunk::resetUpdates();
//static int _n = 0;
//if (++_n % 5 == -1) { // @note: -1
// static char filename[256];
// sprintf(filename, "%s/games/com.mojang/img_%.4d.jpg", externalStoragePath.c_str(), _n/5);
// _context.platform->saveScreenshot(filename, width, height);
//}
LOGI("%s", levelRenderer->gatherStats1().c_str());
//printf("Texture swaps (this frame): %d\n", Textures::textureChanges);
} else {
LOGI("%d fps\n", _frames);
}
//const int* pointerIds;
//int pointerCount = Multitouch::getActivePointerIds(&pointerIds);
//if (pointerCount) {
// std::string s = "Pointers (";
// s += (char)(48 + pointerCount);
// s += ": ";
// for (int i = 0; i < pointerCount; ++i) {
// s += (char)(48 + pointerIds[i]);
// s += ", ";
// }
// LOGI("%s\n", s.c_str());
//}
lastTime = now;
_frames = 0;
#ifdef GLDEBUG
while (1) {
int error = glGetError();
if (error == GL_NO_ERROR) break;
LOGI("#################### GL-ERROR: %d\t#####################\n", error);
LOGI("#################### GL-ERROR: %d\t#####################\n", error);
LOGI("#################### GL-ERROR: %d\t#####################\n", error);
}
#endif
}
Textures::textureChanges = 0;
/**/
#endif /* STANDALONE_SERVER */
}
void NinecraftApp::initGLStates()
{
#ifndef STANDALONE_SERVER
//glShadeModel2(GL_SMOOTH);
//glClearDepthf(1.0f);
glEnable2(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glDepthRangef(0, 1);
glEnable2(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.1f);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glEnable2(GL_TEXTURE_2D);
#ifndef _EMSCRIPTEN_
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
#endif
// Both updates isPowerVR flag in java and returns if the graphics chip is PowerVR SGX or not
_powerVr = platform()->isPowerVR();
#ifdef __APPLE__
_isSuperFast = platform()->isSuperFast();
#endif
//glLineWidth(4);
#endif /* STANDALONE_SERVER */
}
void NinecraftApp::restartServer() {
if (!level) return;
for (int i = level->players.size()-1; i >= 0; --i) {
Player* p = level->players[i];
if (p != player)
level->removeEntity(p);
}
raknetInstance->resetIsBroken();
#ifndef STANDALONE_SERVER
gui.addMessage("This server has restarted!");
#endif
hostMultiplayer();
if (netCallback) netCallback->levelGenerated(level);
}
bool NinecraftApp::handleBack(bool isDown)
{
if (isGeneratingLevel)
{
return true;
}
if (level)
{
if (!isDown)
{
if (screen)
{
if (!screen->handleBackEvent(isDown))
{
if (player->containerMenu) player->closeContainer();
setScreen(NULL);
}
return true;
} else {
pauseGame(true);
}
//leaveGame();
return false;
}
return true;
}
else if (screen)
{
return screen->handleBackEvent(isDown);
}
return false;
}
void NinecraftApp::onGraphicsReset()
{
#ifndef STANDALONE_SERVER
initGLStates();
Tesselator::instance.init();
Minecraft::onGraphicsReset();
#endif
}
#ifndef ANDROID_PUBLISH
static int _state = -1;
static int _stateTicksLeft = 0;
void NinecraftApp::testCreationAndDestruction()
{
if (_state == -1) {
_stateTicksLeft = 100;
_state = 0;
}
if (_state == 0) {
if (--_stateTicksLeft <= 0)
_state = 1;
}
else if (_state == 1) {
getLevelSource()->deleteLevel("perf");
int seed = getEpochTimeS();
LOGI(">seed %d\n", seed);
selectLevel("perf", "perf", LevelSettings(seed, GameType::Creative));
hostMultiplayer();
#ifndef STANDALONE_SERVER
setScreen(new ProgressScreen());
#endif
_state = 2;
_stateTicksLeft = 1000;//25000;//00;
}
else if (_state == 2) {
if (isLevelGenerated()) {
if (--_stateTicksLeft <= 0) {
_state = 3;
}
}
} else if (_state == 3) {
leaveGame();
_state = 1;
}
}
void NinecraftApp::testJoiningAndDestruction()
{
if (_state == -1) {
//LightUpdate sz[2] = { LightUpdate(LightLayer::Block, 0, 0, 0, 1, 1, 1),
// LightUpdate(LightLayer::Sky, 0, 0, 0, 1, 1, 1) };
//LOGI("size of lightupdate: %lu == %d\n", sizeof(LightUpdate), (const char*)&sz[1] - (const char*)&sz[0]);
_stateTicksLeft = 100;
_state = 0;
}
if (_state == 0) {
if (--_stateTicksLeft <= 0) {
raknetInstance->clearServerList();
locateMultiplayer();
_state = 1;
}
}
else if (_state == 1) {
if (!raknetInstance->getServerList().empty()) {
PingedCompatibleServer s = raknetInstance->getServerList().at(0);
if (s.name.GetLength() > 0) {
joinMultiplayer(s);
#ifndef STANDALONE_SERVER
setScreen(new ProgressScreen());
#endif
_state = 2;
_stateTicksLeft = 80;//1000;
}
}
}
else if (_state == 2) {
if (isLevelGenerated()) {
if (--_stateTicksLeft <= 0) {
_state = 3;
}
}
} else if (_state == 3) {
leaveGame();
_stateTicksLeft = 50;
_state = 0;
}
}
#endif /*ANDROID_PUBLISH*/
/*
void NinecraftApp::writeDemoFile() {
std::string path = externalStoragePath + "/games";
if (createFolderIfNotExists(path.c_str())) {
path += "/com.mojang";
if (createFolderIfNotExists(path.c_str())) {
path += "/minecraftpe";
if (createFolderIfNotExists(path.c_str())) {
path += "/played_demo";
FILE* fp = fopen(path.c_str(), "w");
if (fp) fclose(fp);
}}}
}
bool NinecraftApp::hasPlayedDemo() {
std::string filename = externalStoragePath + "/games/com.mojang/minecraftpe/played_demo";
FILE* fp = fopen(filename.c_str(), "r");
if (!fp) return false;
fclose(fp);
return true;
}
*/

52
src/NinecraftApp.h Executable file
View File

@@ -0,0 +1,52 @@
#ifndef NINECRAFTAPP_H__
#define NINECRAFTAPP_H__
#include "world/Pos.h"
#include "App.h"
#include "client/Minecraft.h"
#include "world/level/storage/MemoryLevelStorage.h"
#include <string>
class Level;
class LocalPlayer;
class ExternalFileLevelStorageSource;
class NinecraftApp: public Minecraft
{
public:
NinecraftApp();
~NinecraftApp();
void init();
void teardown();
void update();
virtual bool handleBack(bool isDown);
protected:
void onGraphicsReset();
private:
void initGLStates();
void restartServer();
void updateStats();
//void writeDemoFile();
//bool hasPlayedDemo();
#ifndef ANDROID_PUBLISH
void testCreationAndDestruction();
void testJoiningAndDestruction();
#endif /*ANDROID_PUBLISH*/
bool _verbose;
int _frames;
int _lastTickMs;
static bool _hasInitedStatics;
};
#endif//NINECRAFTAPP_H__

View File

@@ -1,4 +1,4 @@
#include "Performance.hpp" #include "Performance.h"
/*static*/ /*static*/
StopwatchHandler Performance::watches; StopwatchHandler Performance::watches;

12
src/Performance.h Executable file
View File

@@ -0,0 +1,12 @@
#ifndef PERFORMANCE_H__
#define PERFORMANCE_H__
#include "platform/time.h"
class Performance
{
public:
static StopwatchHandler watches;
};
#endif /*PERFORMANCE_H__*/

View File

@@ -1,10 +0,0 @@
#pragma once
#include "platform/time.hpp"
class Performance
{
public:
static StopwatchHandler watches;
};

View File

@@ -1,16 +1,16 @@
#include "SharedConstants.hpp" #include "SharedConstants.h"
namespace Common { namespace Common {
std::string getGameVersionString(const std::string& versionSuffix /* = "" */) std::string getGameVersionString(const std::string& versionSuffix /* = "" */)
{ {
std::string result = std::string("v0.6.1") + versionSuffix; std::string result = std::string("v0.6.1") + versionSuffix;
// append 64-bit port marker only on Android 64bit targets // append 64-bit port marker only on Android 64bit targets
#if defined(ANDROID) && (defined(__aarch64__) || defined(__x86_64__)) #if defined(ANDROID) && (defined(__aarch64__) || defined(__x86_64__))
result += " (64-bit port)"; result += " (64-bit port)";
#endif #endif
result += " alpha"; result += " alpha";
return result; return result;
} }
}; };

View File

@@ -1,32 +1,34 @@
#pragma once #ifndef NET_MINECRAFT_SharedConstants_H__
#define NET_MINECRAFT_SharedConstants_H__
#include <string>
#include <string>
enum LevelGeneratorVersion
{ enum LevelGeneratorVersion
LGV_ORIGINAL = 0, {
}; LGV_ORIGINAL = 0,
};
namespace Common {
std::string getGameVersionString(const std::string& versionSuffix = ""); namespace Common {
} std::string getGameVersionString(const std::string& versionSuffix = "");
}
namespace SharedConstants
{ namespace SharedConstants
// 0.5.0 uses NPv8 {
// 0.6.0 uses NPv9 // 0.5.0 uses NPv8
const int NetworkProtocolVersion = 9; // 0.6.0 uses NPv9
const int NetworkProtocolLowestSupportedVersion = 9; const int NetworkProtocolVersion = 9;
const int GameProtocolVersion = 1; const int NetworkProtocolLowestSupportedVersion = 9;
const int GameProtocolLowestSupportedVersion = 1; const int GameProtocolVersion = 1;
const int GameProtocolLowestSupportedVersion = 1;
const int StorageVersion = 3;
const int StorageVersion = 3;
const int MaxChatLength = 100;
const int MaxChatLength = 100;
const int TicksPerSecond = 20;
const int TicksPerSecond = 20;
const int GeneratorVersion = (int)LGV_ORIGINAL;
//int FULLBRIGHT_LIGHTVALUE = 15 << 20 | 15 << 4; const int GeneratorVersion = (int)LGV_ORIGINAL;
} //int FULLBRIGHT_LIGHTVALUE = 15 << 20 | 15 << 4;
}
#endif /*NET_MINECRAFT_SharedConstants_H__*/

View File

@@ -1,12 +1,16 @@
#include "IConfigListener.hpp" #include "IConfigListener.h"
#include <MinecraftClient.hpp> #include "Minecraft.h"
#ifndef STANDALONE_SERVER
#include "gui/Gui.hpp" #include "gui/Gui.h"
#endif /* STANDALONE_SERVER */
Config::Config(MinecraftClient& mc) : minecraft(mc), options(mc.options()), pixelCalc(mc.pixelCalc()), pixelCalcUi(mc.pixelCalcUi()) {} Config createConfig(Minecraft* mc) {
Config c;
Config createConfig(MinecraftClient& mc) { #ifndef STANDALONE_SERVER
Config c(mc); c.setScreenSize(mc->width, mc->height, Gui::GuiScale);
c.setScreenSize(mc.getScreenWidth(), mc.getScreenHeight(), Gui::GuiScale); #endif
return c; c.pixelCalc = mc->pixelCalc;
} c.pixelCalcUi = mc->pixelCalcUi;
c.minecraft = mc;
c.options = &mc->options;
return c;
}

View File

@@ -1,49 +1,48 @@
#pragma once #ifndef CONFIGLISTENER_H__
#define CONFIGLISTENER_H__
#include "PixelCalc.hpp"
#include "PixelCalc.h"
class MinecraftClient; class Minecraft;
class Options; class Options;
class Config { class Config {
public: public:
Config(MinecraftClient& mc); // Screen dimensions and world-to-screen conversion
void setScreenSize(int width, int height, float scale) {
// Screen dimensions and world-to-screen conversion this->width = width;
void setScreenSize(int width, int height, float scale) { this->height = height;
this->width = width; this->guiScale = scale;
this->height = height; this->invGuiScale = 1.0f / scale;
this->guiScale = scale; this->guiWidth = (int)(width * invGuiScale);
this->invGuiScale = 1.0f / scale; this->guiHeight = (int)(height * invGuiScale);
this->guiWidth = (int)(width * invGuiScale); }
this->guiHeight = (int)(height * invGuiScale);
} int width;
int height;
int width;
int height; float guiScale;
float invGuiScale;
float guiScale; int guiWidth;
float invGuiScale; int guiHeight;
int guiWidth;
int guiHeight; PixelCalc pixelCalc;
PixelCalc pixelCalcUi;
PixelCalc& pixelCalc;
PixelCalc& pixelCalcUi; Minecraft* minecraft;
Options* options;
MinecraftClient& minecraft; };
Options& options;
}; Config createConfig(Minecraft* mc);
Config createConfig(MinecraftClient& mc); // Interface for Configuration-Changed listener
// This can mean (for instance);
// Interface for Configuration-Changed listener // - Screen has changed dimensions, or rotation if rotations are enabled
// This can mean (for instance); // - New input device or control mechanism
// - Screen has changed dimensions, or rotation if rotations are enabled class IConfigListener
// - New input device or control mechanism {
class IConfigListener public:
{ virtual ~IConfigListener() {}
public: virtual void onConfigChanged(const Config& config) = 0;
virtual ~IConfigListener() {} };
virtual void onConfigChanged(const Config& config) = 0;
}; #endif /*CONFIGLISTENER_H__*/

21
src/client/KeyMapping.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef NET_MINECRAFT_CLIENT__KeyMapping_H__
#define NET_MINECRAFT_CLIENT__KeyMapping_H__
//package net.minecraft.client;
#include <string>
class KeyMapping
{
public:
std::string name;
int key;
KeyMapping() {}
KeyMapping(const std::string& name_, int key_)
: name(name_),
key(key_)
{}
};
#endif /*NET_MINECRAFT_CLIENT__KeyMapping_H__*/

2870
src/MinecraftClient.cpp → src/client/Minecraft.cpp Normal file → Executable file

File diff suppressed because it is too large Load Diff

230
src/client/Minecraft.h Executable file
View File

@@ -0,0 +1,230 @@
#ifndef NET_MINECRAFT_CLIENT__Minecraft_H__
#define NET_MINECRAFT_CLIENT__Minecraft_H__
#include "Options.h"
#ifndef STANDALONE_SERVER
#include "MouseHandler.h"
#include "gui/Gui.h"
#include "gui/screens/ScreenChooser.h"
#endif
#include "Timer.h"
//#include "../network/RakNetInstance.h"
#include "../world/phys/HitResult.h"
class Level;
class LocalPlayer;
class IInputHolder;
class Mob;
class Player;
class LevelRenderer;
class GameRenderer;
class ParticleEngine;
class Entity;
class ICreator;
class GameMode;
class Textures;
class CThread;
class SoundEngine;
class Screen;
class Font;
class LevelStorageSource;
class BuildActionIntention;
class PerfRenderer;
class LevelSettings;
class IRakNetInstance;
class NetEventCallback;
class CommandServer;
struct PingedCompatibleServer;
//class ExternalFileLevelStorageSource;
#include "../App.h"
#include "PixelCalc.h"
class AppPlatform;
class AppPlatform_android;
class Minecraft: public App
{
protected:
Minecraft();
public:
virtual ~Minecraft();
void init();
void setSize(int width, int height);
void reloadOptions();
bool supportNonTouchScreen();
bool useTouchscreen();
void grabMouse();
void releaseMouse();
void handleBuildAction(BuildActionIntention*);
void toggleDimension(){}
bool isCreativeMode();
void setIsCreativeMode(bool isCreative);
void setScreen(Screen*);
virtual void selectLevel(const std::string& levelId, const std::string& levelName, const LevelSettings& settings);
virtual void setLevel(Level* level, const std::string& message = "", LocalPlayer* forceInsertPlayer = NULL);
void generateLevel( const std::string& message, Level* level );
LevelStorageSource* getLevelSource();
bool isLookingForMultiplayer;
void locateMultiplayer();
void cancelLocateMultiplayer();
bool joinMultiplayer(const PingedCompatibleServer& server);
bool joinMultiplayerFromString(const std::string& server);
void hostMultiplayer(int port=19132);
Player* respawnPlayer(int playerId);
void respawnPlayer();
void resetPlayer(Player* player);
void doActuallyRespawnPlayer();
void update();
void tick(int nTick, int maxTick);
void tickInput();
bool isOnlineClient();
bool isOnline();
void pauseGame(bool isBackPaused);
void gameLostFocus();
void prepareLevel(const std::string& message);
void leaveGame(bool renameLevel = false);
int getProgressStatusId();
const char* getProgressMessage();
ICreator* getCreator();
// void onGraphicsLost() {}
void onGraphicsReset();
bool isLevelGenerated();
void handleMouseDown(int button, bool down);
void audioEngineOn();
void audioEngineOff();
bool isPowerVR() { return _powerVr; }
bool isKindleFire(int kindleVersion);
bool transformResolution(int* w, int* h);
void optionUpdated(OptionId option, bool value);
void optionUpdated(OptionId option, float value);
void optionUpdated(OptionId option, int value);
#ifdef __APPLE__
bool _isSuperFast;
bool isSuperFast() { return _isSuperFast; }
#endif
protected:
void _levelGenerated();
private:
static void* prepareLevel_tspawn(void *p_param);
void _reloadInput();
public:
int width;
int height;
// Vars that the platform is allowed to use in the future
int commandPort;
int reserved_d1, reserved_d2;
float reserved_f1, reserved_f2;
Options options;
static bool useAmbientOcclusion;
//static bool threadInterrupt;
volatile bool pause;
LevelRenderer* levelRenderer;
GameRenderer* gameRenderer;
ParticleEngine* particleEngine;
SoundEngine* soundEngine;
GameMode* gameMode;
#ifndef STANDALONE_SERVER
Textures* textures;
ScreenChooser screenChooser;
Font* font;
#endif
IRakNetInstance* raknetInstance;
NetEventCallback* netCallback;
int lastTime;
int lastTickTime;
float ticksSinceLastUpdate;
Level* level;
LocalPlayer* player;
IInputHolder* inputHolder;
Mob* cameraTargetPlayer;
#ifndef STANDALONE_SERVER
Gui gui;
#endif
CThread* generateLevelThread;
Screen* screen;
static int customDebugId;
static const int CDI_NONE = 0;
static const int CDI_GRAPHICS = 1;
#ifndef STANDALONE_SERVER
MouseHandler mouseHandler;
#endif
bool mouseGrabbed;
PixelCalc pixelCalc;
PixelCalc pixelCalcUi;
HitResult hitResult;
volatile int progressStagePercentage;
// This field is initialized in main()
// It sets the base path to where worlds can be written (sdcard on android)
std::string externalStoragePath;
std::string externalCacheStoragePath;
protected:
Timer timer;
// @note @attn @warn: this is dangerous as fuck!
volatile bool isGeneratingLevel;
bool _hasSignaledGeneratingLevelFinished;
LevelStorageSource* storageSource;
bool _running;
bool _powerVr;
private:
volatile int progressStageStatusId;
static const char* progressMessages[];
int missTime;
int ticks;
bool screenMutex;
bool hasScheduledScreen;
Screen* scheduledScreen;
int _licenseId;
bool _supportsNonTouchscreen;
bool _isCreativeMode;
//int _respawnPlayerTicks;
Player* _pendingRemovePlayer; // @attn @todo @fix: remove this shait and fix the respawn behaviour
// shit* lmao
PerfRenderer* _perfRenderer;
CommandServer* _commandServer;
};
#endif /*NET_MINECRAFT_CLIENT__Minecraft_H__*/

View File

@@ -1,60 +1,60 @@
#include "MouseHandler.hpp" #include "MouseHandler.h"
#include "player/input/ITurnInput.hpp" #include "player/input/ITurnInput.h"
#ifdef RPI #ifdef RPI
#include <SDL/SDL.h> #include <SDL/SDL.h>
#endif #endif
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#endif #endif
MouseHandler::MouseHandler( ITurnInput* turnInput ) MouseHandler::MouseHandler( ITurnInput* turnInput )
: _turnInput(turnInput) : _turnInput(turnInput)
{} {}
MouseHandler::MouseHandler() MouseHandler::MouseHandler()
: _turnInput(0) : _turnInput(0)
{} {}
MouseHandler::~MouseHandler() { MouseHandler::~MouseHandler() {
} }
void MouseHandler::setTurnInput( ITurnInput* turnInput ) { void MouseHandler::setTurnInput( ITurnInput* turnInput ) {
_turnInput = turnInput; _turnInput = turnInput;
} }
void MouseHandler::grab() { void MouseHandler::grab() {
xd = 0; xd = 0;
yd = 0; yd = 0;
#if defined(RPI) #if defined(RPI)
//LOGI("Grabbing input!\n"); //LOGI("Grabbing input!\n");
SDL_WM_GrabInput(SDL_GRAB_ON); SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_ShowCursor(0); SDL_ShowCursor(0);
#endif #endif
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_DISABLED); glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
#endif #endif
} }
void MouseHandler::release() { void MouseHandler::release() {
#if defined(RPI) #if defined(RPI)
//LOGI("Releasing input!\n"); //LOGI("Releasing input!\n");
SDL_WM_GrabInput(SDL_GRAB_OFF); SDL_WM_GrabInput(SDL_GRAB_OFF);
SDL_ShowCursor(1); SDL_ShowCursor(1);
#endif #endif
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_NORMAL); glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
#endif #endif
} }
void MouseHandler::poll() { void MouseHandler::poll() {
if (_turnInput != 0) { if (_turnInput != 0) {
TurnDelta td = _turnInput->getTurnDelta(); TurnDelta td = _turnInput->getTurnDelta();
xd = td.x; xd = td.x;
yd = td.y; yd = td.y;
} }
} }

View File

@@ -1,26 +1,28 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT__MouseHandler_H__
#define NET_MINECRAFT_CLIENT__MouseHandler_H__
//package net.minecraft.client;
//package net.minecraft.client;
class ITurnInput;
class ITurnInput;
class MouseHandler
{ class MouseHandler
public: {
MouseHandler(ITurnInput* turnInput); public:
MouseHandler(); MouseHandler(ITurnInput* turnInput);
~MouseHandler(); MouseHandler();
~MouseHandler();
void setTurnInput(ITurnInput* turnInput);
void setTurnInput(ITurnInput* turnInput);
void grab();
void release(); void grab();
void release();
void poll();
void poll();
float xd, yd;
private: float xd, yd;
int toSkip; private:
ITurnInput* _turnInput; int toSkip;
}; ITurnInput* _turnInput;
};
#endif /*NET_MINECRAFT_CLIENT__MouseHandler_H__*/

View File

@@ -1,4 +1,4 @@
#include "Option.hpp" #include "Option.h"
#include <sstream> #include <sstream>
#include <cstdio> #include <cstdio>

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <sstream> #include <sstream>
#include <type_traits> #include <type_traits>
#include <util/Mth.hpp> #include <util/Mth.h>
/* /*
template<typename T> template<typename T>
struct is_option_type : std::false_type {}; struct is_option_type : std::false_type {};
@@ -104,4 +104,4 @@ public:
private: private:
std::string m_value; std::string m_value;
}; };

View File

@@ -1,4 +1,4 @@
#include "OptionStrings.hpp" #include "OptionStrings.h"
const char* OptionStrings::Multiplayer_Username = "mp_username"; const char* OptionStrings::Multiplayer_Username = "mp_username";
const char* OptionStrings::Multiplayer_ServerVisible = "mp_server_visible_default"; const char* OptionStrings::Multiplayer_ServerVisible = "mp_server_visible_default";

View File

@@ -1,4 +1,5 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT__OptionStrings_H__
#define NET_MINECRAFT_CLIENT__OptionStrings_H__
class OptionStrings { class OptionStrings {
public: public:
@@ -32,3 +33,4 @@ public:
}; };
#endif /*NET_MINECRAFT_CLIENT__OptionsStrings_H__*/

View File

@@ -1,297 +1,316 @@
#include "Options.hpp" #include "Options.h"
#include "world/Difficulty.hpp" #include "OptionStrings.h"
#include <MinecraftClient.hpp> #include "Minecraft.h"
#include "../platform/log.h"
bool Options::debugGl = false; #include "../world/Difficulty.h"
#include <cmath>
// OPTIONS TABLE
#include <memory>
OptionInt difficulty("difficulty", Difficulty::NORMAL, 0, Difficulty::COUNT);
OptionBool hidegui("hidegui", false); bool Options::debugGl = false;
OptionBool thirdPersonView("thirdperson", false);
OptionBool renderDebug("renderDebug", false); // OPTIONS TABLE
OptionBool smoothCamera("smoothCamera", false);
OptionBool fixedCamera("fixedCamera", false); OptionInt difficulty("difficulty", Difficulty::NORMAL, 0, Difficulty::COUNT);
OptionBool isFlying("isflying", false); OptionBool hidegui("hidegui", false);
OptionBool barOnTop("barOnTop", false); OptionBool thirdPersonView("thirdperson", false);
OptionBool allowSprint("allowSprint", true); OptionBool renderDebug("renderDebug", false);
OptionBool rpiCursor("rpiCursor", false); OptionBool smoothCamera("smoothCamera", false);
OptionBool autoJump("autoJump", true); OptionBool fixedCamera("fixedCamera", false);
OptionBool isFlying("isflying", false);
OptionBool barOnTop("barOnTop", false);
OptionFloat flySpeed("flySpeed", 1.f); OptionBool allowSprint("allowSprint", true);
OptionFloat cameraSpeed("cameraSpeed", 1.f); OptionBool rpiCursor("rpiCursor", false);
OptionBool autoJump("autoJump", true);
OptionInt guiScale("guiScale", 0, 0, 5);
OptionString skin("skin", "Default"); OptionFloat flySpeed("flySpeed", 1.f);
OptionFloat cameraSpeed("cameraSpeed", 1.f);
#ifdef RPI
OptionString username("username", "StevePi"); OptionInt guiScale("guiScale", 0, 0, 5);
#else
OptionString username("username", "Steve"); OptionString skin("skin", "Default");
#endif
#ifdef RPI
OptionBool destroyVibration("destroyVibration", true); OptionString username("username", "StevePi");
OptionBool isLeftHanded("isLeftHanded", false); #else
OptionBool isJoyTouchArea("isJoyTouchArea", false); OptionString username("username", "Steve");
#endif
OptionFloat musicVolume("music", 1.f, MUSIC_MIN_VALUE, MUSIC_MAX_VALUE);
OptionFloat soundVolume("sound", 1.f, SOUND_MIN_VALUE, SOUND_MAX_VALUE); OptionBool destroyVibration("destroyVibration", true);
OptionBool isLeftHanded("isLeftHanded", false);
OptionFloat sensitivityOpt("sensitivity", 0.5f, SENSITIVITY_MIN_VALUE, SENSITIVITY_MAX_VALUE); OptionBool isJoyTouchArea("isJoyTouchArea", false);
OptionBool invertYMouse("invertMouse", false); OptionFloat musicVolume("music", 1.f, MUSIC_MIN_VALUE, MUSIC_MAX_VALUE);
OptionInt viewDistance("renderDistance", 2, 0, 4); OptionFloat soundVolume("sound", 1.f, SOUND_MIN_VALUE, SOUND_MAX_VALUE);
OptionBool anaglyph3d("anaglyph3d", false); OptionFloat sensitivityOpt("sensitivity", 0.5f, SENSITIVITY_MIN_VALUE, SENSITIVITY_MAX_VALUE);
OptionBool limitFramerate("limitFramerate", false);
OptionBool vsync("vsync", true); OptionBool invertYMouse("invertMouse", false);
OptionBool fancyGraphics("fancyGraphics", true); OptionInt viewDistance("renderDistance", 2, 0, 4);
OptionBool viewBobbing("viewBobbing", true);
OptionBool ambientOcclusion("ao", false); OptionBool anaglyph3d("anaglyph3d", false);
OptionBool limitFramerate("limitFramerate", false);
OptionBool useTouchscreen("useTouchscreen", true); OptionBool vsync("vsync", true);
OptionBool fancyGraphics("fancyGraphics", true);
OptionBool serverVisible("servervisible", true); OptionBool viewBobbing("viewBobbing", true);
OptionBool ambientOcclusion("ao", false);
OptionInt keyForward("key.forward", Keyboard::KEY_W);
OptionInt keyLeft("key.left", Keyboard::KEY_A); OptionBool useTouchscreen("useTouchscreen", true);
OptionInt keyBack("key.back", Keyboard::KEY_S);
OptionInt keyRight("key.right", Keyboard::KEY_D); OptionBool serverVisible("servervisible", true);
OptionInt keyJump("key.jump", Keyboard::KEY_SPACE);
OptionInt keyInventory("key.inventory", Keyboard::KEY_E); OptionBool foliageTint("foliagetint", false);
OptionInt keySneak("key.sneak", Keyboard::KEY_LSHIFT);
OptionInt keyDrop("key.drop", Keyboard::KEY_Q); OptionInt fogType("fogType", 0, 0, 2);
OptionInt keyChat("key.chat", Keyboard::KEY_T);
OptionInt keyFog("key.fog", Keyboard::KEY_F); OptionBool javaHud("javaHud", false);
OptionInt keyUse("key.use", Keyboard::KEY_U);
OptionInt keyForward("key.forward", Keyboard::KEY_W);
// TODO: make human readable keycodes here OptionInt keyLeft("key.left", Keyboard::KEY_A);
OptionInt keyMenuNext("key.menu.next", 40); OptionInt keyBack("key.back", Keyboard::KEY_S);
OptionInt keyMenuPrev("key.menu.previous", 38); OptionInt keyRight("key.right", Keyboard::KEY_D);
OptionInt keyMenuOk("key.menu.ok", 13); OptionInt keyJump("key.jump", Keyboard::KEY_SPACE);
OptionInt keyMenuCancel("key.menu.cancel", 8); OptionInt keyInventory("key.inventory", Keyboard::KEY_E);
OptionInt keySneak("key.sneak", Keyboard::KEY_LSHIFT);
OptionBool firstLaunch("firstLaunch", true); OptionInt keyDrop("key.drop", Keyboard::KEY_Q);
OptionInt keyChat("key.chat", Keyboard::KEY_T);
OptionString lastIp("lastip"); OptionInt keyFog("key.fog", Keyboard::KEY_F);
OptionInt keyUse("key.use", Keyboard::KEY_U);
void Options::initTable() {
m_options[OPTIONS_DIFFICULTY] = &difficulty; // TODO: make human readable keycodes here
m_options[OPTIONS_HIDEGUI] = &hidegui; OptionInt keyMenuNext("key.menu.next", 40);
m_options[OPTIONS_THIRD_PERSON_VIEW] = &thirdPersonView; OptionInt keyMenuPrev("key.menu.previous", 38);
m_options[OPTIONS_RENDER_DEBUG] = &renderDebug; OptionInt keyMenuOk("key.menu.ok", 13);
m_options[OPTIONS_SMOOTH_CAMERA] = &smoothCamera; OptionInt keyMenuCancel("key.menu.cancel", 8);
m_options[OPTIONS_FIXED_CAMERA] = &fixedCamera;
m_options[OPTIONS_IS_FLYING] = &isFlying; OptionBool firstLaunch("firstLaunch", true);
m_options[OPTIONS_FLY_SPEED] = &flySpeed; OptionString lastIp("lastip");
m_options[OPTIONS_CAMERA_SPEED] = &cameraSpeed;
void Options::initTable() {
m_options[OPTIONS_GUI_SCALE] = &guiScale; m_options[OPTIONS_DIFFICULTY] = &difficulty;
m_options[OPTIONS_HIDEGUI] = &hidegui;
m_options[OPTIONS_DESTROY_VIBRATION] = &destroyVibration; m_options[OPTIONS_THIRD_PERSON_VIEW] = &thirdPersonView;
m_options[OPTIONS_RENDER_DEBUG] = &renderDebug;
m_options[OPTIONS_IS_LEFT_HANDED] = &isLeftHanded; m_options[OPTIONS_SMOOTH_CAMERA] = &smoothCamera;
m_options[OPTIONS_IS_JOY_TOUCH_AREA] = &isJoyTouchArea; m_options[OPTIONS_FIXED_CAMERA] = &fixedCamera;
m_options[OPTIONS_IS_FLYING] = &isFlying;
m_options[OPTIONS_MUSIC_VOLUME] = &musicVolume;
m_options[OPTIONS_SOUND_VOLUME] = &soundVolume; m_options[OPTIONS_FLY_SPEED] = &flySpeed;
m_options[OPTIONS_CAMERA_SPEED] = &cameraSpeed;
#if defined(PLATFORM_DESKTOP) || defined(RPI)
float sensitivity = sensitivityOpt.get(); m_options[OPTIONS_GUI_SCALE] = &guiScale;
sensitivity *= 0.4f;
sensitivityOpt.set(sensitivity); m_options[OPTIONS_DESTROY_VIBRATION] = &destroyVibration;
#endif
m_options[OPTIONS_IS_LEFT_HANDED] = &isLeftHanded;
m_options[OPTIONS_IS_JOY_TOUCH_AREA] = &isJoyTouchArea;
m_options[OPTIONS_GUI_SCALE] = &guiScale;
m_options[OPTIONS_MUSIC_VOLUME] = &musicVolume;
m_options[OPTIONS_SKIN] = &skin; m_options[OPTIONS_SOUND_VOLUME] = &soundVolume;
m_options[OPTIONS_USERNAME] = &username;
#if defined(PLATFORM_DESKTOP) || defined(RPI)
m_options[OPTIONS_DESTROY_VIBRATION] = &destroyVibration; float sensitivity = sensitivityOpt.get();
m_options[OPTIONS_IS_LEFT_HANDED] = &isLeftHanded; sensitivity *= 0.4f;
sensitivityOpt.set(sensitivity);
m_options[OPTIONS_MUSIC_VOLUME] = &musicVolume; #endif
m_options[OPTIONS_SOUND_VOLUME] = &soundVolume;
m_options[OPTIONS_SENSITIVITY] = &sensitivityOpt; m_options[OPTIONS_GUI_SCALE] = &guiScale;
m_options[OPTIONS_INVERT_Y_MOUSE] = &invertYMouse; m_options[OPTIONS_SKIN] = &skin;
m_options[OPTIONS_VIEW_DISTANCE] = &viewDistance; m_options[OPTIONS_USERNAME] = &username;
m_options[OPTIONS_ANAGLYPH_3D] = &anaglyph3d; m_options[OPTIONS_DESTROY_VIBRATION] = &destroyVibration;
m_options[OPTIONS_LIMIT_FRAMERATE] = &limitFramerate; m_options[OPTIONS_IS_LEFT_HANDED] = &isLeftHanded;
m_options[OPTIONS_VSYNC] = &vsync;
m_options[OPTIONS_FANCY_GRAPHICS] = &fancyGraphics; m_options[OPTIONS_MUSIC_VOLUME] = &musicVolume;
m_options[OPTIONS_VIEW_BOBBING] = &viewBobbing; m_options[OPTIONS_SOUND_VOLUME] = &soundVolume;
m_options[OPTIONS_AMBIENT_OCCLUSION] = &ambientOcclusion;
m_options[OPTIONS_SENSITIVITY] = &sensitivityOpt;
m_options[OPTIONS_USE_TOUCHSCREEN] = &useTouchscreen;
m_options[OPTIONS_INVERT_Y_MOUSE] = &invertYMouse;
m_options[OPTIONS_SERVER_VISIBLE] = &serverVisible; m_options[OPTIONS_VIEW_DISTANCE] = &viewDistance;
m_options[OPTIONS_KEY_FORWARD] = &keyForward; m_options[OPTIONS_ANAGLYPH_3D] = &anaglyph3d;
m_options[OPTIONS_KEY_LEFT] = &keyLeft; m_options[OPTIONS_LIMIT_FRAMERATE] = &limitFramerate;
m_options[OPTIONS_KEY_BACK] = &keyBack; m_options[OPTIONS_VSYNC] = &vsync;
m_options[OPTIONS_KEY_RIGHT] = &keyRight; m_options[OPTIONS_FANCY_GRAPHICS] = &fancyGraphics;
m_options[OPTIONS_KEY_JUMP] = &keyJump; m_options[OPTIONS_VIEW_BOBBING] = &viewBobbing;
m_options[OPTIONS_KEY_INVENTORY] = &keyInventory; m_options[OPTIONS_AMBIENT_OCCLUSION] = &ambientOcclusion;
m_options[OPTIONS_KEY_SNEAK] = &keySneak;
m_options[OPTIONS_KEY_DROP] = &keyDrop; m_options[OPTIONS_USE_TOUCHSCREEN] = &useTouchscreen;
m_options[OPTIONS_KEY_CHAT] = &keyChat;
m_options[OPTIONS_KEY_FOG] = &keyFog;
m_options[OPTIONS_KEY_USE] = &keyUse;
m_options[OPTIONS_SERVER_VISIBLE] = &serverVisible;
m_options[OPTIONS_KEY_MENU_NEXT] = &keyMenuNext;
m_options[OPTIONS_KEY_MENU_PREV] = &keyMenuPrev; m_options[OPTIONS_KEY_FORWARD] = &keyForward;
m_options[OPTIONS_KEY_MENU_OK] = &keyMenuOk; m_options[OPTIONS_KEY_LEFT] = &keyLeft;
m_options[OPTIONS_KEY_MENU_CANCEL] = &keyMenuCancel; m_options[OPTIONS_KEY_BACK] = &keyBack;
m_options[OPTIONS_KEY_RIGHT] = &keyRight;
m_options[OPTIONS_FIRST_LAUNCH] = &firstLaunch; m_options[OPTIONS_KEY_JUMP] = &keyJump;
m_options[OPTIONS_KEY_INVENTORY] = &keyInventory;
m_options[OPTIONS_BAR_ON_TOP] = &barOnTop; m_options[OPTIONS_KEY_SNEAK] = &keySneak;
m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint; m_options[OPTIONS_KEY_DROP] = &keyDrop;
m_options[OPTIONS_RPI_CURSOR] = &rpiCursor; m_options[OPTIONS_KEY_CHAT] = &keyChat;
m_options[OPTIONS_KEY_FOG] = &keyFog;
m_options[OPTIONS_AUTOJUMP] = &autoJump; m_options[OPTIONS_KEY_USE] = &keyUse;
m_options[OPTIONS_LAST_IP] = &lastIp;
} m_options[OPTIONS_KEY_MENU_NEXT] = &keyMenuNext;
m_options[OPTIONS_KEY_MENU_PREV] = &keyMenuPrev;
void Options::set(OptionId key, const std::string& value) { m_options[OPTIONS_KEY_MENU_OK] = &keyMenuOk;
auto option = opt<OptionString>(key); m_options[OPTIONS_KEY_MENU_CANCEL] = &keyMenuCancel;
if (option) { m_options[OPTIONS_FIRST_LAUNCH] = &firstLaunch;
option->set(value);
notifyOptionUpdate(key, value); m_options[OPTIONS_BAR_ON_TOP] = &barOnTop;
} m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint;
} m_options[OPTIONS_RPI_CURSOR] = &rpiCursor;
m_options[OPTIONS_FOLIAGE_TINT] = &foliageTint;
void Options::set(OptionId key, float value) {
auto option = opt<OptionFloat>(key); // more options yay
m_options[OPTIONS_FOG_TYPE] = &fogType;
if (option) {
option->set(value); m_options[OPTIONS_JAVA_HUD] = &javaHud;
notifyOptionUpdate(key, value);
} m_options[OPTIONS_AUTOJUMP] = &autoJump;
} m_options[OPTIONS_LAST_IP] = &lastIp;
}
void Options::set(OptionId key, int value) {
auto option = opt<OptionInt>(key); void Options::set(OptionId key, const std::string& value) {
auto option = opt<OptionString>(key);
if (option) {
option->set(value); if (option) {
notifyOptionUpdate(key, value); option->set(value);
} notifyOptionUpdate(key, value);
} }
}
void Options::toggle(OptionId key) {
auto option = opt<OptionBool>(key); void Options::set(OptionId key, float value) {
auto option = opt<OptionFloat>(key);
if (option) {
option->toggle(); if (option) {
notifyOptionUpdate(key, option->get()); option->set(value);
} notifyOptionUpdate(key, value);
} }
}
void Options::load() {
StringVector optionStrings = optionsFile.getOptionStrings(); void Options::set(OptionId key, int value) {
auto option = opt<OptionInt>(key);
for (auto i = 0; i < optionStrings.size(); i += 2) {
const std::string& key = optionStrings[i]; if (option) {
const std::string& value = optionStrings[i+1]; option->set(value);
notifyOptionUpdate(key, value);
// FIXME: woah this is so slow }
auto opt = std::find_if(m_options.begin(), m_options.end(), [&](auto& it) { }
return it != nullptr && it->getStringId() == key;
}); void Options::toggle(OptionId key) {
auto option = opt<OptionBool>(key);
if (opt == m_options.end()) continue;
if (option) {
(*opt)->parse(value); option->toggle();
/* notifyOptionUpdate(key, option->get());
// //LOGI("reading key: %s (%s)\n", key.c_str(), value.c_str()); }
}
// // Multiplayer
// // if (key == OptionStrings::Multiplayer_Username) username = value; void Options::load() {
// if (key == OptionStrings::Multiplayer_ServerVisible) { StringVector optionStrings = optionsFile.getOptionStrings();
// m_options[OPTIONS_SERVER_VISIBLE] = readBool(value);
// } for (auto i = 0; i < optionStrings.size(); i += 2) {
const std::string& key = optionStrings[i];
// // Controls const std::string& value = optionStrings[i+1];
// if (key == OptionStrings::Controls_Sensitivity) {
// float sens = readFloat(value); // FIXME: woah this is so slow
auto opt = std::find_if(m_options.begin(), m_options.end(), [&](auto& it) {
// // sens is in range [0,1] with default/center at 0.5 (for aesthetics) return it != nullptr && it->getStringId() == key;
// // We wanna map it to something like [0.3, 0.9] BUT keep 0.5 @ ~0.5... });
// m_options[OPTIONS_SENSITIVITY] = 0.3f + std::pow(1.1f * sens, 1.3f) * 0.42f;
// } if (opt == m_options.end()) continue;
// if (key == OptionStrings::Controls_InvertMouse) { (*opt)->parse(value);
// m_options[OPTIONS_INVERT_Y_MOUSE] = readBool(value); /*
// } // //LOGI("reading key: %s (%s)\n", key.c_str(), value.c_str());
// if (key == OptionStrings::Controls_IsLefthanded) { // // Multiplayer
// m_options[OPTIONS_IS_LEFT_HANDED] = readBool(value); // // if (key == OptionStrings::Multiplayer_Username) username = value;
// } // if (key == OptionStrings::Multiplayer_ServerVisible) {
// m_options[OPTIONS_SERVER_VISIBLE] = readBool(value);
// if (key == OptionStrings::Controls_UseTouchJoypad) { // }
// m_options[OPTIONS_IS_JOY_TOUCH_AREA] = readBool(value) && minecraft.useTouchscreen();
// } // // Controls
// if (key == OptionStrings::Controls_Sensitivity) {
// // Feedback // float sens = readFloat(value);
// if (key == OptionStrings::Controls_FeedbackVibration) {
// m_options[OPTIONS_DESTROY_VIBRATION] = readBool(value); // // sens is in range [0,1] with default/center at 0.5 (for aesthetics)
// } // // We wanna map it to something like [0.3, 0.9] BUT keep 0.5 @ ~0.5...
// m_options[OPTIONS_SENSITIVITY] = 0.3f + std::pow(1.1f * sens, 1.3f) * 0.42f;
// // Graphics // }
// if (key == OptionStrings::Graphics_Fancy) {
// m_options[OPTIONS_FANCY_GRAPHICS] = readBool(value); // if (key == OptionStrings::Controls_InvertMouse) {
// } // m_options[OPTIONS_INVERT_Y_MOUSE] = readBool(value);
// }
// // Graphics extras
// if (key == OptionStrings::Graphics_Vsync) { // if (key == OptionStrings::Controls_IsLefthanded) {
// m_options[OPTIONS_VSYNC] = readBool(value); // m_options[OPTIONS_IS_LEFT_HANDED] = readBool(value);
// } // }
// if (key == OptionStrings::Graphics_GUIScale) { // if (key == OptionStrings::Controls_UseTouchJoypad) {
// m_options[OPTIONS_GUI_SCALE] = readInt(value) % 5; // m_options[OPTIONS_IS_JOY_TOUCH_AREA] = readBool(value) && minecraft->useTouchscreen();
// } // }
// // Game // // Feedback
// if (key == OptionStrings::Game_DifficultyLevel) { // if (key == OptionStrings::Controls_FeedbackVibration) {
// readInt(value, difficulty); // m_options[OPTIONS_DESTROY_VIBRATION] = readBool(value);
// // Only support peaceful and normal right now // }
// if (difficulty != Difficulty::PEACEFUL && difficulty != Difficulty::NORMAL)
// difficulty = Difficulty::NORMAL; // // Graphics
// }*/ // if (key == OptionStrings::Graphics_Fancy) {
} // m_options[OPTIONS_FANCY_GRAPHICS] = readBool(value);
} // }
void Options::save() { // // Graphics extras
StringVector stringVec; // if (key == OptionStrings::Graphics_Vsync) {
// m_options[OPTIONS_VSYNC] = readBool(value);
for (auto& it : m_options) { // }
if (it) stringVec.push_back(it->serialize());
} // if (key == OptionStrings::Graphics_GUIScale) {
// m_options[OPTIONS_GUI_SCALE] = readInt(value) % 5;
optionsFile.save(stringVec); // }
}
// // Game
void Options::setOptionsFilePath(const std::string& path) { // if (key == OptionStrings::Game_DifficultyLevel) {
optionsFile.setOptionsPath(path + "/options.txt"); // readInt(value, difficulty);
} // // Only support peaceful and normal right now
// if (difficulty != Difficulty::PEACEFUL && difficulty != Difficulty::NORMAL)
void Options::notifyOptionUpdate(OptionId key, bool value) { // difficulty = Difficulty::NORMAL;
minecraft.optionUpdated(key, value); // }*/
} }
}
void Options::notifyOptionUpdate(OptionId key, float value) {
minecraft.optionUpdated(key, value); void Options::save() {
} StringVector stringVec;
void Options::notifyOptionUpdate(OptionId key, int value) { for (auto& it : m_options) {
minecraft.optionUpdated(key, value); if (it) stringVec.push_back(it->serialize());
} }
optionsFile.save(stringVec);
}
void Options::setOptionsFilePath(const std::string& path) {
optionsFile.setOptionsPath(path + "/options.txt");
}
void Options::notifyOptionUpdate(OptionId key, bool value) {
minecraft->optionUpdated(key, value);
}
void Options::notifyOptionUpdate(OptionId key, float value) {
minecraft->optionUpdated(key, value);
}
void Options::notifyOptionUpdate(OptionId key, int value) {
minecraft->optionUpdated(key, value);
}

View File

@@ -1,164 +1,174 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT__Options_H__
#define NET_MINECRAFT_CLIENT__Options_H__
#define SOUND_MIN_VALUE 0.0f
#define SOUND_MAX_VALUE 1.0f #define SOUND_MIN_VALUE 0.0f
#define MUSIC_MIN_VALUE 0.0f #define SOUND_MAX_VALUE 1.0f
#define MUSIC_MAX_VALUE 1.0f #define MUSIC_MIN_VALUE 0.0f
#define SENSITIVITY_MIN_VALUE 0.0f #define MUSIC_MAX_VALUE 1.0f
#define SENSITIVITY_MAX_VALUE 1.0f #define SENSITIVITY_MIN_VALUE 0.0f
#define PIXELS_PER_MILLIMETER_MIN_VALUE 3.0f #define SENSITIVITY_MAX_VALUE 1.0f
#define PIXELS_PER_MILLIMETER_MAX_VALUE 4.0f #define PIXELS_PER_MILLIMETER_MIN_VALUE 3.0f
#define PIXELS_PER_MILLIMETER_MAX_VALUE 4.0f
//package net.minecraft.client;
//package net.minecraft.client;
//#include "locale/Language.hpp"
//#include "locale/Language.h"
#include <string>
#include <platform/input/Keyboard.hpp> #include <string>
#include <util/StringUtils.hpp> #include <cstdio>
#include "OptionsFile.hpp" #include "../platform/input/Keyboard.h"
#include "Option.hpp" #include "../util/StringUtils.h"
#include <array> #include "OptionsFile.h"
#include "Option.h"
enum OptionId { #include <array>
// General
OPTIONS_DIFFICULTY, enum OptionId {
OPTIONS_HIDEGUI, // General
OPTIONS_THIRD_PERSON_VIEW, OPTIONS_DIFFICULTY,
OPTIONS_GUI_SCALE, OPTIONS_HIDEGUI,
OPTIONS_DESTROY_VIBRATION, OPTIONS_THIRD_PERSON_VIEW,
OPTIONS_MUSIC_VOLUME, OPTIONS_GUI_SCALE,
OPTIONS_SOUND_VOLUME, OPTIONS_DESTROY_VIBRATION,
OPTIONS_SKIN, OPTIONS_MUSIC_VOLUME,
OPTIONS_USERNAME, OPTIONS_SOUND_VOLUME,
OPTIONS_SERVER_VISIBLE, OPTIONS_SKIN,
OPTIONS_BAR_ON_TOP, OPTIONS_USERNAME,
OPTIONS_ALLOW_SPRINT, OPTIONS_SERVER_VISIBLE,
OPTIONS_AUTOJUMP, OPTIONS_BAR_ON_TOP,
OPTIONS_ALLOW_SPRINT,
// Graphics OPTIONS_AUTOJUMP,
OPTIONS_RENDER_DEBUG,
OPTIONS_SMOOTH_CAMERA, // Graphics
OPTIONS_FIXED_CAMERA, OPTIONS_RENDER_DEBUG,
OPTIONS_VIEW_DISTANCE, OPTIONS_SMOOTH_CAMERA,
OPTIONS_VIEW_BOBBING, OPTIONS_FIXED_CAMERA,
OPTIONS_AMBIENT_OCCLUSION, OPTIONS_VIEW_DISTANCE,
OPTIONS_ANAGLYPH_3D, OPTIONS_VIEW_BOBBING,
OPTIONS_LIMIT_FRAMERATE, OPTIONS_AMBIENT_OCCLUSION,
OPTIONS_VSYNC, OPTIONS_ANAGLYPH_3D,
OPTIONS_FANCY_GRAPHICS, OPTIONS_LIMIT_FRAMERATE,
OPTIONS_VSYNC,
// Cheats / debug OPTIONS_FANCY_GRAPHICS,
OPTIONS_FLY_SPEED,
OPTIONS_CAMERA_SPEED, // Cheats / debug
OPTIONS_IS_FLYING, OPTIONS_FLY_SPEED,
OPTIONS_CAMERA_SPEED,
// Control OPTIONS_IS_FLYING,
OPTIONS_USE_MOUSE_FOR_DIGGING,
OPTIONS_IS_LEFT_HANDED, // Control
OPTIONS_IS_JOY_TOUCH_AREA, OPTIONS_USE_MOUSE_FOR_DIGGING,
OPTIONS_SENSITIVITY, OPTIONS_IS_LEFT_HANDED,
OPTIONS_INVERT_Y_MOUSE, OPTIONS_IS_JOY_TOUCH_AREA,
OPTIONS_USE_TOUCHSCREEN, OPTIONS_SENSITIVITY,
OPTIONS_INVERT_Y_MOUSE,
OPTIONS_KEY_FORWARD, OPTIONS_USE_TOUCHSCREEN,
OPTIONS_KEY_LEFT,
OPTIONS_KEY_BACK, OPTIONS_KEY_FORWARD,
OPTIONS_KEY_RIGHT, OPTIONS_KEY_LEFT,
OPTIONS_KEY_JUMP, OPTIONS_KEY_BACK,
OPTIONS_KEY_INVENTORY, OPTIONS_KEY_RIGHT,
OPTIONS_KEY_SNEAK, OPTIONS_KEY_JUMP,
OPTIONS_KEY_DROP, OPTIONS_KEY_INVENTORY,
OPTIONS_KEY_CHAT, OPTIONS_KEY_SNEAK,
OPTIONS_KEY_FOG, OPTIONS_KEY_DROP,
OPTIONS_KEY_USE, OPTIONS_KEY_CHAT,
OPTIONS_KEY_FOG,
OPTIONS_KEY_MENU_NEXT, OPTIONS_KEY_USE,
OPTIONS_KEY_MENU_PREV,
OPTIONS_KEY_MENU_OK, OPTIONS_KEY_MENU_NEXT,
OPTIONS_KEY_MENU_CANCEL, OPTIONS_KEY_MENU_PREV,
OPTIONS_KEY_MENU_OK,
OPTIONS_FIRST_LAUNCH, OPTIONS_KEY_MENU_CANCEL,
OPTIONS_LAST_IP,
OPTIONS_FIRST_LAUNCH,
OPTIONS_RPI_CURSOR, OPTIONS_LAST_IP,
// Should be last!
OPTIONS_COUNT OPTIONS_RPI_CURSOR,
}; OPTIONS_FOLIAGE_TINT,
OPTIONS_FOG_TYPE,
class MinecraftClient; OPTIONS_JAVA_HUD,
typedef std::vector<std::string> StringVector; // Should be last!
OPTIONS_COUNT
class Options };
{
public: class Minecraft;
static bool debugGl; typedef std::vector<std::string> StringVector;
Options(MinecraftClient& minecraft, const std::string& workingDirectory = "") class Options
: minecraft(minecraft) { {
// elements werent initialized so i was getting a garbage pointer and a crash public:
m_options.fill(nullptr); // deepfriedwaffles: for iOS, was getting compile errors saying: No member named 'sound' in 'Options' and No member named 'music' in 'Options' so I floated them here. 1.0f means full volume out of the box, but if everything is too loud, you might want to try adjusting this
initTable(); float sound = 1.0f;
// load() is deferred to init() where path is configured correctly float music = 1.0f;
}
static bool debugGl;
void initTable();
Options(Minecraft* minecraft, const std::string& workingDirectory = "")
int getIntValue(OptionId key) { : minecraft(minecraft) {
auto option = opt<OptionInt>(key); // elements werent initialized so i was getting a garbage pointer and a crash
return (option)? option->get() : 0; m_options.fill(nullptr);
} initTable();
// load() is deferred to init() where path is configured correctly
std::string getStringValue(OptionId key) { }
auto option = opt<OptionString>(key);
return (option)? option->get() : ""; void initTable();
}
int getIntValue(OptionId key) {
float getProgressValue(OptionId key) { auto option = opt<OptionInt>(key);
auto option = opt<OptionFloat>(key); return (option)? option->get() : 0;
return (option)? option->get() : 0.f; }
}
std::string getStringValue(OptionId key) {
bool getBooleanValue(OptionId key) { auto option = opt<OptionString>(key);
auto option = opt<OptionBool>(key); return (option)? option->get() : "";
return (option)? option->get() : false; }
}
float getProgressValue(OptionId key) {
float getProgrssMin(OptionId key) { auto option = opt<OptionFloat>(key);
auto option = opt<OptionFloat>(key); return (option)? option->get() : 0.f;
return (option)? option->getMin() : 0.f; }
}
bool getBooleanValue(OptionId key) {
float getProgrssMax(OptionId key) { auto option = opt<OptionBool>(key);
auto option = opt<OptionFloat>(key); return (option)? option->get() : false;
return (option)? option->getMax() : 0.f; }
}
float getProgrssMin(OptionId key) {
Option* getOpt(OptionId id) { return m_options[id]; } auto option = opt<OptionFloat>(key);
return (option)? option->getMin() : 0.f;
void load(); }
void save();
void set(OptionId key, int value); float getProgrssMax(OptionId key) {
void set(OptionId key, float value); auto option = opt<OptionFloat>(key);
void set(OptionId key, const std::string& value); return (option)? option->getMax() : 0.f;
void setOptionsFilePath(const std::string& path); }
void toggle(OptionId key);
Option* getOpt(OptionId id) { return m_options[id]; }
void notifyOptionUpdate(OptionId key, bool value);
void notifyOptionUpdate(OptionId key, float value); void load();
void notifyOptionUpdate(OptionId key, int value); void save();
void notifyOptionUpdate(OptionId key, const std::string& value) {} void set(OptionId key, int value);
void set(OptionId key, float value);
private: void set(OptionId key, const std::string& value);
template<typename T> void setOptionsFilePath(const std::string& path);
T* opt(OptionId key) { void toggle(OptionId key);
if (m_options[key] == nullptr) return nullptr;
return dynamic_cast<T*>(m_options[key]); void notifyOptionUpdate(OptionId key, bool value);
} void notifyOptionUpdate(OptionId key, float value);
void notifyOptionUpdate(OptionId key, int value);
std::array<Option*, OPTIONS_COUNT> m_options; void notifyOptionUpdate(OptionId key, const std::string& value) {}
OptionsFile optionsFile;
private:
MinecraftClient& minecraft; template<typename T>
}; T* opt(OptionId key) {
if (m_options[key] == nullptr) return nullptr;
return dynamic_cast<T*>(m_options[key]);
}
std::array<Option*, OPTIONS_COUNT> m_options;
OptionsFile optionsFile;
Minecraft* minecraft;
};
#endif /*NET_MINECRAFT_CLIENT__Options_H__*/

View File

@@ -1,98 +1,98 @@
#include "OptionsFile.hpp" #include "OptionsFile.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <platform/log.hpp> #include <platform/log.h>
#if defined(_WIN32) #if defined(_WIN32)
#include <direct.h> #include <direct.h>
#else #else
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#endif #endif
OptionsFile::OptionsFile() { OptionsFile::OptionsFile() {
#ifdef __APPLE__ #ifdef __APPLE__
settingsPath = "./Documents/options.txt"; settingsPath = "./Documents/options.txt";
#elif defined(ANDROID) #elif defined(ANDROID)
settingsPath = "options.txt"; settingsPath = "options.txt";
#elif defined(__EMSCRIPTEN__) #elif defined(__EMSCRIPTEN__)
settingsPath = "/games/com.mojang/options.txt"; settingsPath = "/games/com.mojang/options.txt";
#else #else
settingsPath = "options.txt"; settingsPath = "options.txt";
#endif #endif
} }
void OptionsFile::setOptionsPath(const std::string& path) { void OptionsFile::setOptionsPath(const std::string& path) {
settingsPath = path; settingsPath = path;
} }
std::string OptionsFile::getOptionsPath() const { std::string OptionsFile::getOptionsPath() const {
return settingsPath; return settingsPath;
} }
void OptionsFile::save(const StringVector& settings) { void OptionsFile::save(const StringVector& settings) {
FILE* pFile = fopen(settingsPath.c_str(), "w"); FILE* pFile = fopen(settingsPath.c_str(), "w");
if (!pFile && errno == ENOENT) { if (!pFile && errno == ENOENT) {
std::string dir = settingsPath; std::string dir = settingsPath;
size_t fpos = dir.find_last_of("/\\"); size_t fpos = dir.find_last_of("/\\");
if (fpos != std::string::npos) { if (fpos != std::string::npos) {
dir.resize(fpos); dir.resize(fpos);
std::string toCreate; std::string toCreate;
for (size_t i = 0; i <= dir.size(); ++i) { for (size_t i = 0; i <= dir.size(); ++i) {
if (i == dir.size() || dir[i] == '/' || dir[i] == '\\') { if (i == dir.size() || dir[i] == '/' || dir[i] == '\\') {
if (!toCreate.empty()) { if (!toCreate.empty()) {
#if defined(_WIN32) #if defined(_WIN32)
_mkdir(toCreate.c_str()); _mkdir(toCreate.c_str());
#else #else
mkdir(toCreate.c_str(), 0755); mkdir(toCreate.c_str(), 0755);
#endif #endif
} }
} }
if (i < dir.size()) if (i < dir.size())
toCreate.push_back(dir[i]); toCreate.push_back(dir[i]);
} }
} }
pFile = fopen(settingsPath.c_str(), "w"); pFile = fopen(settingsPath.c_str(), "w");
} }
if (!pFile) { if (!pFile) {
LOGI("OptionsFile::save failed: %s", strerror(errno)); LOGI("OptionsFile::save failed: %s", strerror(errno));
return; return;
} }
for (const auto& s : settings) { for (const auto& s : settings) {
fprintf(pFile, "%s\n", s.c_str()); fprintf(pFile, "%s\n", s.c_str());
} }
fclose(pFile); fclose(pFile);
} }
StringVector OptionsFile::getOptionStrings() { StringVector OptionsFile::getOptionStrings() {
StringVector returnVector; StringVector returnVector;
FILE* pFile = fopen(settingsPath.c_str(), "r"); FILE* pFile = fopen(settingsPath.c_str(), "r");
if(pFile != NULL) { if(pFile != NULL) {
char lineBuff[128]; char lineBuff[128];
while(fgets(lineBuff, sizeof lineBuff, pFile)) { while(fgets(lineBuff, sizeof lineBuff, pFile)) {
// Strip trailing newline // Strip trailing newline
size_t len = strlen(lineBuff); size_t len = strlen(lineBuff);
while(len > 0 && (lineBuff[len-1] == '\n' || lineBuff[len-1] == '\r')) while(len > 0 && (lineBuff[len-1] == '\n' || lineBuff[len-1] == '\r'))
lineBuff[--len] = '\0'; lineBuff[--len] = '\0';
if(len < 3) continue; if(len < 3) continue;
// Split "key:value" into two separate entries to match update() pairing // Split "key:value" into two separate entries to match update() pairing
char* colon = strchr(lineBuff, ':'); char* colon = strchr(lineBuff, ':');
if(colon) { if(colon) {
returnVector.push_back(std::string(lineBuff, colon - lineBuff)); returnVector.push_back(std::string(lineBuff, colon - lineBuff));
returnVector.push_back(std::string(colon + 1)); returnVector.push_back(std::string(colon + 1));
} }
} }
fclose(pFile); fclose(pFile);
} else { } else {
if (errno != ENOENT) if (errno != ENOENT)
LOGI("OptionsFile::getOptionStrings failed to open '%s' for reading: %s", settingsPath.c_str(), strerror(errno)); LOGI("OptionsFile::getOptionStrings failed to open '%s' for reading: %s", settingsPath.c_str(), strerror(errno));
} }
return returnVector; return returnVector;
} }

View File

@@ -1,19 +1,21 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT__OptionsFile_H__
#define NET_MINECRAFT_CLIENT__OptionsFile_H__
//package net.minecraft.client;
#include <string> //package net.minecraft.client;
#include <vector> #include <string>
typedef std::vector<std::string> StringVector; #include <vector>
class OptionsFile typedef std::vector<std::string> StringVector;
{ class OptionsFile
public: {
OptionsFile(); public:
void save(const StringVector& settings); OptionsFile();
StringVector getOptionStrings(); void save(const StringVector& settings);
void setOptionsPath(const std::string& path); StringVector getOptionStrings();
std::string getOptionsPath() const; void setOptionsPath(const std::string& path);
std::string getOptionsPath() const;
private:
std::string settingsPath; private:
}; std::string settingsPath;
};
#endif /* NET_MINECRAFT_CLIENT__OptionsFile_H__ */

View File

@@ -1,122 +1,124 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT__Timer_H__
#define NET_MINECRAFT_CLIENT__Timer_H__
//package net.minecraft.client;
#include "platform/time.hpp" //package net.minecraft.client;
#include "../platform/time.h"
class Timer
{ class Timer
public: {
Timer(float ticksPerSecond) public:
: ticksPerSecond(ticksPerSecond), Timer(float ticksPerSecond)
adjustTime(1.0f), : ticksPerSecond(ticksPerSecond),
timeScale(1.0f), adjustTime(1.0f),
passedTime(0) timeScale(1.0f),
{ passedTime(0)
lastMs = getTimeMs(); {
lastMsSysTime = lastMs; lastMs = getTimeMs();
lastTime = lastMs / 1000.0f; lastMsSysTime = lastMs;
} lastTime = lastMs / 1000.0f;
}
void advanceTime() {
long nowMs = getTimeMs(); void advanceTime() {
long passedMs = nowMs - lastMs; long nowMs = getTimeMs();
long msSysTime = nowMs;//System.nanoTime() / 1000000; long passedMs = nowMs - lastMs;
long msSysTime = nowMs;//System.nanoTime() / 1000000;
if (passedMs > 1000) {
long passedMsSysTime = msSysTime - lastMsSysTime; if (passedMs > 1000) {
if (passedMsSysTime == 0) long passedMsSysTime = msSysTime - lastMsSysTime;
passedMs = passedMsSysTime = 1; if (passedMsSysTime == 0)
passedMs = passedMsSysTime = 1;
float adjustTimeT = passedMs / (float) passedMsSysTime;
adjustTime += (adjustTimeT - adjustTime) * 0.2f; float adjustTimeT = passedMs / (float) passedMsSysTime;
adjustTime += (adjustTimeT - adjustTime) * 0.2f;
lastMs = nowMs;
lastMsSysTime = msSysTime; lastMs = nowMs;
} lastMsSysTime = msSysTime;
if (passedMs < 0) { }
lastMs = nowMs; if (passedMs < 0) {
lastMsSysTime = msSysTime; lastMs = nowMs;
} lastMsSysTime = msSysTime;
}
float now = msSysTime / 1000.0f;
float passedSeconds = (now - lastTime) * adjustTime; float now = msSysTime / 1000.0f;
lastTime = now; float passedSeconds = (now - lastTime) * adjustTime;
lastTime = now;
if (passedSeconds < 0) passedSeconds = 0;
if (passedSeconds > 1) passedSeconds = 1; if (passedSeconds < 0) passedSeconds = 0;
//LOGI("passed s: %f\n", passedSeconds); if (passedSeconds > 1) passedSeconds = 1;
//LOGI("passed s: %f\n", passedSeconds);
passedTime += passedSeconds * timeScale * ticksPerSecond;
passedTime += passedSeconds * timeScale * ticksPerSecond;
ticks = (int) passedTime;
passedTime -= ticks; ticks = (int) passedTime;
if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE; passedTime -= ticks;
a = passedTime; if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE;
} a = passedTime;
}
/**
* Advances time the max number of ticks per second. /**
*/ * Advances time the max number of ticks per second.
void advanceTimeQuickly() { */
void advanceTimeQuickly() {
float passedSeconds = (float) MAX_TICKS_PER_UPDATE / (float) ticksPerSecond;
float passedSeconds = (float) MAX_TICKS_PER_UPDATE / (float) ticksPerSecond;
passedTime += passedSeconds * timeScale * ticksPerSecond;
ticks = (int) passedTime; passedTime += passedSeconds * timeScale * ticksPerSecond;
passedTime -= ticks; ticks = (int) passedTime;
a = passedTime; passedTime -= ticks;
a = passedTime;
lastMs = getTimeMs();//System.currentTimeMillis();
lastMsSysTime = lastMs; lastMs = getTimeMs();//System.currentTimeMillis();
} lastMsSysTime = lastMs;
}
void skipTime() {
long nowMs = getTimeMs();//System.currentTimeMillis(); void skipTime() {
long passedMs = nowMs - lastMs; long nowMs = getTimeMs();//System.currentTimeMillis();
long msSysTime = nowMs;//System.nanoTime() / 1000000; long passedMs = nowMs - lastMs;
long msSysTime = nowMs;//System.nanoTime() / 1000000;
if (passedMs > 1000) {
long passedMsSysTime = msSysTime - lastMsSysTime; if (passedMs > 1000) {
if (passedMsSysTime == 0) long passedMsSysTime = msSysTime - lastMsSysTime;
passedMs = passedMsSysTime = 1; if (passedMsSysTime == 0)
passedMs = passedMsSysTime = 1;
float adjustTimeT = passedMs / (float) passedMsSysTime;
adjustTime += (adjustTimeT - adjustTime) * 0.2f; float adjustTimeT = passedMs / (float) passedMsSysTime;
adjustTime += (adjustTimeT - adjustTime) * 0.2f;
lastMs = nowMs;
lastMsSysTime = msSysTime; lastMs = nowMs;
} lastMsSysTime = msSysTime;
if (passedMs < 0) { }
lastMs = nowMs; if (passedMs < 0) {
lastMsSysTime = msSysTime; lastMs = nowMs;
} lastMsSysTime = msSysTime;
}
float now = msSysTime / 1000.0f;
float passedSeconds = (now - lastTime) * adjustTime; float now = msSysTime / 1000.0f;
lastTime = now; float passedSeconds = (now - lastTime) * adjustTime;
lastTime = now;
if (passedSeconds < 0) passedSeconds = 0;
if (passedSeconds > 1) passedSeconds = 1; if (passedSeconds < 0) passedSeconds = 0;
if (passedSeconds > 1) passedSeconds = 1;
passedTime += passedSeconds * timeScale * ticksPerSecond;
passedTime += passedSeconds * timeScale * ticksPerSecond;
ticks = (int) 0;
if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE; ticks = (int) 0;
passedTime -= ticks; if (ticks > MAX_TICKS_PER_UPDATE) ticks = MAX_TICKS_PER_UPDATE;
} passedTime -= ticks;
}
public:
float ticksPerSecond; public:
int ticks; float ticksPerSecond;
float a; int ticks;
float timeScale; float a;
float passedTime; float timeScale;
private: float passedTime;
static const int MAX_TICKS_PER_UPDATE = 10; private:
static const int MAX_TICKS_PER_UPDATE = 10;
float lastTime;
long lastMs; float lastTime;
long lastMsSysTime; long lastMs;
float adjustTime; long lastMsSysTime;
}; float adjustTime;
};
#endif /*NET_MINECRAFT_CLIENT__Timer_H__*/

View File

@@ -0,0 +1,56 @@
#include "CreativeMode.h"
#include "../Minecraft.h"
#ifndef STANDALONE_SERVER
#include "../particle/ParticleEngine.h"
#endif
#include "../player/LocalPlayer.h"
#ifndef STANDALONE_SERVER
#include "../renderer/LevelRenderer.h"
#include "../sound/SoundEngine.h"
#endif
#include "../../world/level/Level.h"
//#include "../../network/Packet.h"
#include "../../network/packet/RemoveBlockPacket.h"
#include "../../world/entity/player/Abilities.h"
static const int DestructionTickDelay = 5;
CreativeMode::CreativeMode(Minecraft* minecraft)
: super(minecraft)
{
}
void CreativeMode::startDestroyBlock(int x, int y, int z, int face) {
if(minecraft->player->getCarriedItem() != NULL && minecraft->player->getCarriedItem()->id == Item::bow->id)
return;
creativeDestroyBlock(x, y, z, face);
destroyDelay = DestructionTickDelay;
}
void CreativeMode::creativeDestroyBlock(int x, int y, int z, int face) {
minecraft->level->extinguishFire(x, y, z, face);
destroyBlock(x, y, z, face);
}
void CreativeMode::continueDestroyBlock(int x, int y, int z, int face) {
destroyDelay--;
if (destroyDelay <= 0) {
destroyDelay = DestructionTickDelay;
creativeDestroyBlock(x, y, z, face);
}
}
void CreativeMode::stopDestroyBlock() {
destroyDelay = 0;
}
void CreativeMode::initAbilities( Abilities& abilities ) {
abilities.mayfly = true;
abilities.instabuild = true;
abilities.invulnerable = true;
}
bool CreativeMode::isCreativeType() {
return true;
}

View File

@@ -0,0 +1,26 @@
#ifndef NET_MINECRAFT_CLIENT_GAMEMODE__CreativeMode_H__
#define NET_MINECRAFT_CLIENT_GAMEMODE__CreativeMode_H__
//package net.minecraft.client.gamemode;
#include "GameMode.h"
class CreativeMode: public GameMode
{
typedef GameMode super;
public:
CreativeMode(Minecraft* minecraft);
void startDestroyBlock(int x, int y, int z, int face);
void continueDestroyBlock(int x, int y, int z, int face);
void stopDestroyBlock();
bool isCreativeType();
void initAbilities(Abilities& abilities);
private:
void creativeDestroyBlock(int x, int y, int z, int face);
};
#endif /*NET_MINECRAFT_CLIENT_GAMEMODE__CreativeMode_H__*/

View File

@@ -0,0 +1,102 @@
#include "CreatorMode.h"
#include "../Minecraft.h"
#include "../particle/ParticleEngine.h"
#include "../player/LocalPlayer.h"
#include "../renderer/LevelRenderer.h"
#include "../sound/SoundEngine.h"
#include "../../world/level/Level.h"
//#include "../../network/Packet.h"
#include "../../network/packet/RemoveBlockPacket.h"
#include "../../world/entity/player/Abilities.h"
static const int DestructionTickDelay = 5;
class Creator: public ICreator {
//virtual void getEvents();
public:
Creator(/*int eventLifeTime*/)
: _tileEvents(32),
_tickId(0)
{
}
void setTick(int tick) {
_tickId = tick;
}
EventList<TileEvent>& getTileEvents() { return _tileEvents; }
void addevent_blockUse(int entityId, int x, int y, int z, int face) {
TileEvent t = {
entityId,
x,y,z,
face
};
_tileEvents.add(t, _tickId);
}
private:
EventList<TileEvent> _tileEvents;
int _tickId;
};
CreatorMode::CreatorMode(Minecraft* minecraft)
: super(minecraft)
{
_creator = new Creator();
}
CreatorMode::~CreatorMode() {
delete _creator;
}
void CreatorMode::startDestroyBlock(int x, int y, int z, int face) {
if(minecraft->player->getCarriedItem() != NULL && minecraft->player->getCarriedItem()->id == Item::bow->id)
return;
CreatorDestroyBlock(x, y, z, face);
destroyDelay = DestructionTickDelay;
}
void CreatorMode::CreatorDestroyBlock(int x, int y, int z, int face) {
minecraft->level->extinguishFire(x, y, z, face);
destroyBlock(x, y, z, face);
}
void CreatorMode::continueDestroyBlock(int x, int y, int z, int face) {
destroyDelay--;
if (destroyDelay <= 0) {
destroyDelay = DestructionTickDelay;
CreatorDestroyBlock(x, y, z, face);
}
}
bool CreatorMode::useItemOn( Player* player, Level* level, ItemInstance* item, int x, int y, int z, int face, const Vec3& hit ) {
if (item && item->id == ((Item*)Item::sword_iron)->id)
_creator->addevent_blockUse(player->entityId, x, y, z, face);
return super::useItemOn(player, level, item, x, y, z, face, hit);
}
void CreatorMode::stopDestroyBlock() {
destroyDelay = 0;
}
void CreatorMode::initAbilities( Abilities& abilities ) {
abilities.mayfly = true;
abilities.instabuild = true;
abilities.invulnerable = true;
}
bool CreatorMode::isCreativeType() {
return true;
}
ICreator* CreatorMode::getCreator() {
return _creator;
}
void CreatorMode::tick() {
_creator->setTick(minecraft->level->getTime());
super::tick();
}

View File

@@ -1,9 +1,10 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT_GAMEMODE__CreatorMode_H__
#define NET_MINECRAFT_CLIENT_GAMEMODE__CreatorMode_H__
//package net.minecraft.client.gamemode; //package net.minecraft.client.gamemode;
#include "GameMode.hpp" #include "GameMode.h"
#include <world/PosTranslator.hpp> #include "../../world/PosTranslator.h"
class ICreator { class ICreator {
public: public:
@@ -101,12 +102,12 @@ class CreatorMode: public GameMode
{ {
typedef GameMode super; typedef GameMode super;
public: public:
CreatorMode(Minecraft& minecraft); CreatorMode(Minecraft* minecraft);
~CreatorMode(); ~CreatorMode();
void startDestroyBlock(Player* player, int x, int y, int z, int face); void startDestroyBlock(int x, int y, int z, int face);
void continueDestroyBlock(Player* player, int x, int y, int z, int face); void continueDestroyBlock(int x, int y, int z, int face);
void stopDestroyBlock(Player* player); void stopDestroyBlock();
bool useItemOn(Player* player, Level* level, ItemInstance* item, int x, int y, int z, int face, const Vec3& hit); bool useItemOn(Player* player, Level* level, ItemInstance* item, int x, int y, int z, int face, const Vec3& hit);
@@ -117,10 +118,10 @@ public:
void initAbilities(Abilities& abilities); void initAbilities(Abilities& abilities);
void releaseUsingItem(Player* player);
private: private:
void CreatorDestroyBlock(Player* player, int x, int y, int z, int face); void CreatorDestroyBlock(int x, int y, int z, int face);
Creator* _creator; Creator* _creator;
}; };
#endif /*NET_MINECRAFT_CLIENT_GAMEMODE__CreatorMode_H__*/

View File

@@ -1,15 +1,35 @@
#include "GameMode.hpp" #include "GameMode.h"
#include <Minecraft.hpp> #include "../Minecraft.h"
#include <network/packet/UseItemPacket.hpp> #include "../../network/packet/UseItemPacket.h"
#include <network/packet/PlayerActionPacket.hpp> #include "../../network/packet/PlayerActionPacket.h"
#include <world/level/Level.hpp> #include "../../world/level/Level.h"
#include <world/item/ItemInstance.hpp> #include "../../world/item/ItemInstance.h"
#include <client/player/LocalPlayer.hpp> #include "../player/LocalPlayer.h"
#include <client/Options.hpp> #include "client/Options.h"
#include <network/RakNetInstance.hpp> #ifndef STANDALONE_SERVER
#include <network/packet/RemoveBlockPacket.hpp> #include "../sound/SoundEngine.h"
#include <world/level/material/Material.hpp> #include "../particle/ParticleEngine.h"
#endif
#include "../../network/RakNetInstance.h"
#include "../../network/packet/RemoveBlockPacket.h"
#ifndef STANDALONE_SERVER
#include "../renderer/LevelRenderer.h"
#endif
#include "../../world/level/material/Material.h"
GameMode::GameMode( Minecraft* minecraft)
: minecraft(minecraft),
destroyProgress(0),
oDestroyProgress(0),
destroyTicks(0),
destroyDelay(0)
{
}
/*virtual*/
Player* GameMode::createPlayer(Level* level) {
return new LocalPlayer(minecraft, level, minecraft->options.getStringValue(OPTIONS_USERNAME), level->dimension->id, isCreativeType());
}
/*virtual*/ /*virtual*/
void GameMode::interact(Player* player, Entity* entity) { void GameMode::interact(Player* player, Entity* entity) {
@@ -18,24 +38,23 @@ void GameMode::interact(Player* player, Entity* entity) {
/*virtual*/ /*virtual*/
void GameMode::attack(Player* player, Entity* entity) { void GameMode::attack(Player* player, Entity* entity) {
if (minecraft.level->adventureSettings.noPvP && entity->isPlayer()) if (minecraft->level->adventureSettings.noPvP && entity->isPlayer())
return; return;
if (minecraft.level->adventureSettings.noPvM && entity->isMob()) if (minecraft->level->adventureSettings.noPvM && entity->isMob())
return; return;
player->attack(entity); player->attack(entity);
} }
/* virtual */ /* virtual */
void GameMode::startDestroyBlock(Player* player, int x, int y, int z, int face ) { void GameMode::startDestroyBlock( int x, int y, int z, int face ) {
if(player->getCarriedItem() != NULL && player->getCarriedItem()->id == Item::bow->id) if(minecraft->player->getCarriedItem() != NULL && minecraft->player->getCarriedItem()->id == Item::bow->id)
return; return;
destroyBlock(x, y, z, face);
destroyBlock(player, x, y, z, face);
} }
/*virtual*/ /*virtual*/
bool GameMode::destroyBlock(Player* player, int x, int y, int z, int face) { bool GameMode::destroyBlock(int x, int y, int z, int face) {
Level* level = minecraft.level; Level* level = minecraft->level;
Tile* oldTile = Tile::tiles[level->getTile(x, y, z)]; Tile* oldTile = Tile::tiles[level->getTile(x, y, z)];
if (!oldTile) if (!oldTile)
return false; return false;
@@ -46,12 +65,22 @@ bool GameMode::destroyBlock(Player* player, int x, int y, int z, int face) {
return false; return false;
} }
} }
#ifndef STANDALONE_SERVER
minecraft->particleEngine->destroy(x, y, z);
#endif
int data = level->getData(x, y, z); int data = level->getData(x, y, z);
bool changed = level->setTile(x, y, z, 0); bool changed = level->setTile(x, y, z, 0);
if (changed) { if (changed) {
#ifndef STANDALONE_SERVER
minecraft->soundEngine->play(oldTile->soundType->getBreakSound(), x + 0.5f, y + 0.5f, z + 0.5f, (oldTile->soundType->getVolume() + 1) / 2, oldTile->soundType->getPitch() * 0.8f);
#endif
oldTile->destroy(level, x, y, z, data); oldTile->destroy(level, x, y, z, data);
minecraft.onBlockDestroyed(player, x, y, z, face); if (minecraft->options.getBooleanValue(OPTIONS_DESTROY_VIBRATION)) minecraft->platform()->vibrate(24);
if (minecraft->isOnline()) {
RemoveBlockPacket packet(minecraft->player, x, y, z);
minecraft->raknetInstance->send(packet);
}
} }
return changed; return changed;
} }
@@ -60,10 +89,10 @@ bool GameMode::useItemOn(Player* player, Level* level, ItemInstance* item, int x
float clickX = hit.x - x; float clickX = hit.x - x;
float clickY = hit.y - y; float clickY = hit.y - y;
float clickZ = hit.z - z; float clickZ = hit.z - z;
item = player->inventory->getSelected(); if (level->isClientSide) {
if(level->isClientSide) { item = player->inventory->getSelected();
UseItemPacket packet(x, y, z, face, item, player->entityId, clickX, clickY, clickZ); UseItemPacket packet(x, y, z, face, item, player->entityId, clickX, clickY, clickZ);
minecraft.raknetInstance->send(packet); minecraft->raknetInstance->send(packet);
} }
int t = level->getTile(x, y, z); int t = level->getTile(x, y, z);
if (t == Tile::invisible_bedrock->id) return false; if (t == Tile::invisible_bedrock->id) return false;
@@ -89,7 +118,7 @@ bool GameMode::useItem( Player* player, Level* level, ItemInstance* item ) {
ItemInstance* itemInstance = item->use(level, player); ItemInstance* itemInstance = item->use(level, player);
if(level->isClientSide) { if(level->isClientSide) {
UseItemPacket packet(item, player->entityId, player->aimDirection); UseItemPacket packet(item, player->entityId, player->aimDirection);
minecraft.raknetInstance->send(packet); minecraft->raknetInstance->send(packet);
} }
if (itemInstance != item || (itemInstance != NULL && itemInstance->count != oldCount)) { if (itemInstance != item || (itemInstance != NULL && itemInstance->count != oldCount)) {
//player.inventory.items[player.inventory.selected] = itemInstance; //player.inventory.items[player.inventory.selected] = itemInstance;
@@ -120,9 +149,9 @@ void GameMode::initPlayer( Player* player ) {
} }
void GameMode::releaseUsingItem(Player* player){ void GameMode::releaseUsingItem(Player* player){
if(minecraft.level->isClientSide) { if (minecraft->level->isClientSide && player->isUsingItem()) {
PlayerActionPacket packet(PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 0, player->entityId); PlayerActionPacket packet(PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 0, player->entityId);
minecraft.raknetInstance->send(packet); minecraft->raknetInstance->send(packet);
} }
player->releaseUsingItem(); player->releaseUsingItem();
} }
@@ -131,3 +160,15 @@ void GameMode::tick() {
oDestroyProgress = destroyProgress; oDestroyProgress = destroyProgress;
} }
void GameMode::render( float a ) {
#ifndef STANDALONE_SERVER
if (destroyProgress <= 0) {
minecraft->gui.progress = 0;
minecraft->levelRenderer->destroyProgress = 0;
} else {
float dp = oDestroyProgress + (destroyProgress - oDestroyProgress) * a;
minecraft->gui.progress = dp;
minecraft->levelRenderer->destroyProgress = dp;
}
#endif
}

View File

@@ -1,59 +1,63 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT_GAMEMODE__GameMode_H__
#define NET_MINECRAFT_CLIENT_GAMEMODE__GameMode_H__
//package net.minecraft.client.gamemode;
//package net.minecraft.client.gamemode;
#include <world/level/tile/Tile.hpp>
#include "../../world/level/tile/Tile.h"
class ItemInstance;
class Minecraft; class ItemInstance;
class Level; class Minecraft;
class Player; class Level;
class Abilities; class Player;
class Abilities;
class GameMode {
protected: class GameMode
Minecraft& minecraft; {
protected:
public: Minecraft* minecraft;
GameMode(Minecraft& minecraft) : minecraft(minecraft) {} public:
virtual ~GameMode() {} GameMode(Minecraft* minecraft);
virtual ~GameMode() {}
virtual void initLevel(Level* level) {}
virtual void initLevel(Level* level) {}
virtual void startDestroyBlock(Player* player, int x, int y, int z, int face);
virtual bool destroyBlock(Player* player, int x, int y, int z, int face); virtual void startDestroyBlock(int x, int y, int z, int face);
virtual void continueDestroyBlock(Player* player, int x, int y, int z, int face) = 0; virtual bool destroyBlock(int x, int y, int z, int face);
virtual void stopDestroyBlock(Player* player) {} virtual void continueDestroyBlock(int x, int y, int z, int face) = 0;
virtual void stopDestroyBlock() {}
virtual void tick();
virtual void tick();
virtual float getPickRange(); virtual void render(float a);
/* void postLevelGen(LevelGen levelGen, Level level) {} */
virtual float getPickRange();
virtual bool useItem(Player* player, Level* level, ItemInstance* item); /* void postLevelGen(LevelGen levelGen, Level level) {} */
virtual bool useItemOn(Player* player, Level* level, ItemInstance* item, int x, int y, int z, int face, const Vec3& hit);
virtual bool useItem(Player* player, Level* level, ItemInstance* item);
virtual void initPlayer(Player* player); virtual bool useItemOn(Player* player, Level* level, ItemInstance* item, int x, int y, int z, int face, const Vec3& hit);
virtual void adjustPlayer(Player* player) {}
virtual bool canHurtPlayer() { return false; } virtual Player* createPlayer(Level* level);
virtual void initPlayer(Player* player);
virtual void interact(Player* player, Entity* entity); virtual void adjustPlayer(Player* player) {}
virtual void attack(Player* player, Entity* entity); virtual bool canHurtPlayer() { return false; }
virtual ItemInstance* handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, Player* player); virtual void interact(Player* player, Entity* entity);
virtual void handleCloseInventory(int containerId, Player* player); virtual void attack(Player* player, Entity* entity);
virtual bool isCreativeType() { return false; } virtual ItemInstance* handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, Player* player);
virtual bool isSurvivalType() { return false; } virtual void handleCloseInventory(int containerId, Player* player);
virtual void initAbilities(Abilities& abilities) {} virtual bool isCreativeType() { return false; }
virtual bool isSurvivalType() { return false; }
virtual void releaseUsingItem(Player* player);
virtual void initAbilities(Abilities& abilities) {}
float oDestroyProgress = 0;
float destroyProgress = 0; virtual void releaseUsingItem(Player* player);
protected:
int destroyTicks = 0; float oDestroyProgress;
int destroyDelay = 0; float destroyProgress;
}; protected:
int destroyTicks;
int destroyDelay;
};
#endif /*NET_MINECRAFT_CLIENT_GAMEMODE__GameMode_H__*/

View File

@@ -0,0 +1,98 @@
#include "SurvivalMode.h"
#include "../Minecraft.h"
#include "../player/LocalPlayer.h"
#ifndef STANDALONE_SERVER
#include "../particle/ParticleEngine.h"
#include "../sound/SoundEngine.h"
#endif
#include "../../world/level/Level.h"
#include "../../world/entity/player/Abilities.h"
SurvivalMode::SurvivalMode( Minecraft* minecraft )
: super(minecraft),
xDestroyBlock(-1),
yDestroyBlock(-1),
zDestroyBlock(-1)
{
}
void SurvivalMode::continueDestroyBlock( int x, int y, int z, int face ) {
if (destroyDelay > 0) {
destroyDelay--;
return;
}
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock) {
int t = minecraft->level->getTile(x, y, z);
if (t == 0) return;
Tile* tile = Tile::tiles[t];
destroyProgress += tile->getDestroyProgress(minecraft->player);
if ((++destroyTicks & 3) == 1) {
#ifndef STANDALONE_SERVER
if (tile != NULL) {
minecraft->soundEngine->play(tile->soundType->getStepSound(), x + 0.5f, y + 0.5f, z + 0.5f, (tile->soundType->getVolume() + 1) / 8, tile->soundType->getPitch() * 0.5f);
}
#endif
}
if (destroyProgress >= 1) {
destroyBlock(x, y, z, face);
destroyProgress = 0;
oDestroyProgress = 0;
destroyTicks = 0;
destroyDelay = 5;
}
} else {
destroyProgress = 0;
oDestroyProgress = 0;
destroyTicks = 0;
xDestroyBlock = x;
yDestroyBlock = y;
zDestroyBlock = z;
}
}
bool SurvivalMode::destroyBlock( int x, int y, int z, int face ) {
int t = minecraft->level->getTile(x, y, z);
int data = minecraft->level->getData(x, y, z);
bool changed = GameMode::destroyBlock(x, y, z, face);
bool couldDestroy = minecraft->player->canDestroy(Tile::tiles[t]);
ItemInstance* item = minecraft->player->inventory->getSelected();
if (item != NULL) {
item->mineBlock(t, x, y, z);
if (item->count == 0) {
//item->snap(minecraft->player);
minecraft->player->inventory->clearSlot(minecraft->player->inventory->selected);
}
}
if (changed && couldDestroy) {
ItemInstance instance(t, 1, data);
Tile::tiles[t]->playerDestroy(minecraft->level, minecraft->player, x, y, z, data);
}
return changed;
}
void SurvivalMode::stopDestroyBlock() {
destroyProgress = 0;
destroyDelay = 0;
}
void SurvivalMode::initAbilities( Abilities& abilities ) {
abilities.flying = false;
abilities.mayfly = false;
abilities.instabuild = false;
abilities.invulnerable = false;
}
void SurvivalMode::startDestroyBlock( int x, int y, int z, int face ) {
if(minecraft->player->getCarriedItem() != NULL && minecraft->player->getCarriedItem()->id == Item::bow->id)
return;
int t = minecraft->level->getTile(x, y, z);
if (t > 0 && destroyProgress == 0) Tile::tiles[t]->attack(minecraft->level, x, y, z, minecraft->player);
if (t > 0 && Tile::tiles[t]->getDestroyProgress(minecraft->player) >= 1)
destroyBlock(x, y, z, face);
}

View File

@@ -0,0 +1,31 @@
#ifndef NET_MINECRAFT_CLIENT_GAMEMODE__SurvivalMode_H__
#define NET_MINECRAFT_CLIENT_GAMEMODE__SurvivalMode_H__
#include "GameMode.h"
class Abilities;
class Minecraft;
class SurvivalMode: public GameMode
{
typedef GameMode super;
public:
SurvivalMode(Minecraft* minecraft);
bool destroyBlock(int x, int y, int z, int face);
void startDestroyBlock(int x, int y, int z, int face);
void continueDestroyBlock(int x, int y, int z, int face);
void stopDestroyBlock();
bool canHurtPlayer() { return true; }
bool isSurvivalType() { return true; }
void initAbilities( Abilities& abilities );
private:
int xDestroyBlock;
int yDestroyBlock;
int zDestroyBlock;
};
#endif /*NET_MINECRAFT_CLIENT_GAMEMODE__SurvivalMode_H__*/

View File

@@ -1,372 +1,372 @@
#include "Font.hpp" #include "Font.h"
//#include "SharedConstants.hpp" //#include "SharedConstants.h"
#include "client/Options.hpp" #include "../Options.h"
#include "client/renderer/Textures.hpp" #include "../renderer/Textures.h"
#include "client/renderer/Tesselator.hpp" #include "../renderer/Tesselator.h"
#include "util/Mth.hpp" #include "../../util/Mth.h"
#include <cstring> #include <cstring>
Font::Font( Options* options, const std::string& name, Textures& textures ) Font::Font( Options* options, const std::string& name, Textures* textures )
: options(options), : options(options),
fontTexture(0), fontTexture(0),
fontName(name), fontName(name),
index(0), index(0),
count(0), count(0),
_textures(textures), _textures(textures),
_x(0), _y(0), _x(0), _y(0),
_cols(16), _rows(16), _cols(16), _rows(16),
_charOffset(0), _charOffset(0),
lineHeight(DefaultLineHeight) lineHeight(DefaultLineHeight)
{ {
init(options); init(options);
} }
//Font::Font( Options* options, const std::string& name, Textures& textures, int imgW, int imgH, int x, int y, int cols, int rows, unsigned char charOffset ) //Font::Font( Options* options, const std::string& name, Textures* textures, int imgW, int imgH, int x, int y, int cols, int rows, unsigned char charOffset )
//: options(options), //: options(options),
// fontTexture(0), // fontTexture(0),
// fontName(name), // fontName(name),
// index(0), // index(0),
// count(0), // count(0),
// _textures(textures), // _textures(textures),
// _x(x), _y(y), // _x(x), _y(y),
// _cols(cols), _rows(rows), // _cols(cols), _rows(rows),
// _charOffset(charOffset) // _charOffset(charOffset)
//{ //{
// init(options); // init(options);
//} //}
void Font::onGraphicsReset() void Font::onGraphicsReset()
{ {
init(options); init(options);
} }
void Font::init( Options* options ) void Font::init( Options* options )
{ {
TextureId fontTexture = _textures->loadTexture(fontName); TextureId fontTexture = _textures->loadTexture(fontName);
const TextureData* tex = _textures->getTemporaryTextureData(fontTexture); const TextureData* tex = _textures->getTemporaryTextureData(fontTexture);
if (!tex) if (!tex)
return; return;
unsigned char* rawPixels = tex->data; unsigned char* rawPixels = tex->data;
const int numChars = _rows * _cols; const int numChars = _rows * _cols;
for (int i = 0; i < numChars; i++) { for (int i = 0; i < numChars; i++) {
int xt = i % _cols; int xt = i % _cols;
int yt = i / _cols; int yt = i / _cols;
int x = 7; int x = 7;
for (; x >= 0; x--) { for (; x >= 0; x--) {
int xPixel = _x + xt * 8 + x; int xPixel = _x + xt * 8 + x;
bool emptyColumn = true; bool emptyColumn = true;
for (int y = 0; y < 8 && emptyColumn; y++) { for (int y = 0; y < 8 && emptyColumn; y++) {
int yPixel = _y + (yt * 8 + y) * tex->w; int yPixel = _y + (yt * 8 + y) * tex->w;
unsigned char pixelalpha = rawPixels[(xPixel + yPixel) << 2]; unsigned char pixelalpha = rawPixels[(xPixel + yPixel) << 2];
if (pixelalpha > 0) emptyColumn = false; if (pixelalpha > 0) emptyColumn = false;
} }
if (!emptyColumn) { if (!emptyColumn) {
break; break;
} }
} }
if (i == ' ') x = 4 - 2; if (i == ' ') x = 4 - 2;
charWidths[i] = x + 2; charWidths[i] = x + 2;
fcharWidths[i] = (float) charWidths[i]; fcharWidths[i] = (float) charWidths[i];
} }
#ifdef USE_VBO #ifdef USE_VBO
return; // this <1 return; // this <1
#endif #endif
#ifndef USE_VBO #ifndef USE_VBO
listPos = glGenLists(256 + 32); listPos = glGenLists(256 + 32);
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
glNewList(listPos + i, GL_COMPILE); glNewList(listPos + i, GL_COMPILE);
// @attn @huge @note: This is some dangerous code right here / Aron, added ^1 // @attn @huge @note: This is some dangerous code right here / Aron, added ^1
t.begin(); t.begin();
buildChar(i); buildChar(i);
t.end(false, -1); t.end(false, -1);
glTranslatef2((GLfloat)charWidths[i], 0.0f, 0.0f); glTranslatef2((GLfloat)charWidths[i], 0.0f, 0.0f);
glEndList(); glEndList();
} }
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
int br = ((i >> 3) & 1) * 0x55; int br = ((i >> 3) & 1) * 0x55;
int r = ((i >> 2) & 1) * 0xaa + br; int r = ((i >> 2) & 1) * 0xaa + br;
int g = ((i >> 1) & 1) * 0xaa + br; int g = ((i >> 1) & 1) * 0xaa + br;
int b = ((i >> 0) & 1) * 0xaa + br; int b = ((i >> 0) & 1) * 0xaa + br;
if (i == 6) { if (i == 6) {
r += 0x55; r += 0x55;
} }
bool darken = i >= 16; bool darken = i >= 16;
if (options->anaglyph3d) { if (options->anaglyph3d) {
int cr = (r * 30 + g * 59 + b * 11) / 100; int cr = (r * 30 + g * 59 + b * 11) / 100;
int cg = (r * 30 + g * 70) / (100); int cg = (r * 30 + g * 70) / (100);
int cb = (r * 30 + b * 70) / (100); int cb = (r * 30 + b * 70) / (100);
r = cr; r = cr;
g = cg; g = cg;
b = cb; b = cb;
} }
// color = r << 16 | g << 8 | b; // color = r << 16 | g << 8 | b;
if (darken) { if (darken) {
r /= 4; r /= 4;
g /= 4; g /= 4;
b /= 4; b /= 4;
} }
glNewList(listPos + 256 + i, GL_COMPILE); glNewList(listPos + 256 + i, GL_COMPILE);
glColor3f(r / 255.0f, g / 255.0f, b / 255.0f); glColor3f(r / 255.0f, g / 255.0f, b / 255.0f);
glEndList(); glEndList();
} }
#endif #endif
} }
void Font::drawShadow( const std::string& str, float x, float y, int color ) void Font::drawShadow( const std::string& str, float x, float y, int color )
{ {
draw(str, x + 1, y + 1, color, true); draw(str, x + 1, y + 1, color, true);
draw(str, x, y, color); draw(str, x, y, color);
} }
void Font::drawShadow( const char* str, float x, float y, int color ) void Font::drawShadow( const char* str, float x, float y, int color )
{ {
draw(str, x + 1, y + 1, color, true); draw(str, x + 1, y + 1, color, true);
draw(str, x, y, color); draw(str, x, y, color);
} }
void Font::draw( const std::string& str, float x, float y, int color ) void Font::draw( const std::string& str, float x, float y, int color )
{ {
draw(str, x, y, color, false); draw(str, x, y, color, false);
} }
void Font::draw( const char* str, float x, float y, int color ) void Font::draw( const char* str, float x, float y, int color )
{ {
draw(str, x, y, color, false); draw(str, x, y, color, false);
} }
void Font::draw( const char* str, float x, float y, int color, bool darken ) void Font::draw( const char* str, float x, float y, int color, bool darken )
{ {
#ifdef USE_VBO #ifdef USE_VBO
drawSlow(str, x, y, color, darken); drawSlow(str, x, y, color, darken);
#endif #endif
} }
void Font::draw( const std::string& str, float x, float y, int color, bool darken ) void Font::draw( const std::string& str, float x, float y, int color, bool darken )
{ {
#ifdef USE_VBO #ifdef USE_VBO
drawSlow(str, x, y, color, darken); drawSlow(str, x, y, color, darken);
return; return;
#endif #endif
if (str.empty()) return; if (str.empty()) return;
if (darken) { if (darken) {
int oldAlpha = color & 0xff000000; int oldAlpha = color & 0xff000000;
color = (color & 0xfcfcfc) >> 2; color = (color & 0xfcfcfc) >> 2;
color += oldAlpha; color += oldAlpha;
} }
_textures->loadAndBindTexture(fontName); _textures->loadAndBindTexture(fontName);
float r = ((color >> 16) & 0xff) / 255.0f; float r = ((color >> 16) & 0xff) / 255.0f;
float g = ((color >> 8) & 0xff) / 255.0f; float g = ((color >> 8) & 0xff) / 255.0f;
float b = ((color) & 0xff) / 255.0f; float b = ((color) & 0xff) / 255.0f;
float a = ((color >> 24) & 0xff) / 255.0f; float a = ((color >> 24) & 0xff) / 255.0f;
if (a == 0) a = 1; if (a == 0) a = 1;
glColor4f2(r, g, b, a); glColor4f2(r, g, b, a);
static const std::string hex("0123456789abcdef"); static const std::string hex("0123456789abcdef");
index = 0; index = 0;
glPushMatrix2(); glPushMatrix2();
glTranslatef2((GLfloat)x, (GLfloat)y, 0.0f); glTranslatef2((GLfloat)x, (GLfloat)y, 0.0f);
for (unsigned int i = 0; i < str.length(); i++) { for (unsigned int i = 0; i < str.length(); i++) {
while (str.length() > i + 1 && str[i] == '\xa7') { while (str.length() > i + 1 && str[i] == '\xa7') {
int cc = hex.find((char)tolower(str[i + 1])); int cc = hex.find((char)tolower(str[i + 1]));
if (cc < 0 || cc > 15) cc = 15; if (cc < 0 || cc > 15) cc = 15;
lists[index++] = listPos + 256 + cc + (darken ? 16 : 0); lists[index++] = listPos + 256 + cc + (darken ? 16 : 0);
if (index == 1024) { if (index == 1024) {
count = index; count = index;
index = 0; index = 0;
#ifndef USE_VBO #ifndef USE_VBO
glCallLists(count, GL_UNSIGNED_INT, lists); glCallLists(count, GL_UNSIGNED_INT, lists);
#endif #endif
count = 1024; count = 1024;
} }
i += 2; i += 2;
} }
if (i < str.length()) { if (i < str.length()) {
//int ch = SharedConstants.acceptableLetters.indexOf(str.charAt(i)); //int ch = SharedConstants.acceptableLetters.indexOf(str.charAt(i));
char ch = str[i]; char ch = str[i];
if (ch >= 0) { if (ch >= 0) {
//ib.put(listPos + ch + 32); //ib.put(listPos + ch + 32);
lists[index++] = listPos + ch; lists[index++] = listPos + ch;
} }
} }
if (index == 1024) { if (index == 1024) {
count = index; count = index;
index = 0; index = 0;
#ifndef USE_VBO #ifndef USE_VBO
glCallLists(count, GL_UNSIGNED_INT, lists); glCallLists(count, GL_UNSIGNED_INT, lists);
#endif #endif
count = 1024; count = 1024;
} }
} }
count = index; count = index;
index = 0; index = 0;
#ifndef USE_VBO #ifndef USE_VBO
glCallLists(count, GL_UNSIGNED_INT, lists); glCallLists(count, GL_UNSIGNED_INT, lists);
#endif #endif
glPopMatrix2(); glPopMatrix2();
} }
int Font::width( const std::string& str ) int Font::width( const std::string& str )
{ {
int maxLen = 0; int maxLen = 0;
int len = 0; int len = 0;
for (unsigned int i = 0; i < str.length(); i++) { for (unsigned int i = 0; i < str.length(); i++) {
if (str[i] == '\xa7') { if (str[i] == '\xa7') {
i++; i++;
} else { } else {
//int ch = SharedConstants.acceptableLetters.indexOf(str.charAt(i)); //int ch = SharedConstants.acceptableLetters.indexOf(str.charAt(i));
//if (ch >= 0) { //if (ch >= 0) {
// len += charWidths[ch + 32]; // len += charWidths[ch + 32];
//} //}
if (str[i] == '\n') { if (str[i] == '\n') {
if (len > maxLen) maxLen = len; if (len > maxLen) maxLen = len;
len = 0; len = 0;
} }
else { else {
int charWidth = charWidths[ (unsigned char) str[i] ]; int charWidth = charWidths[ (unsigned char) str[i] ];
len += charWidth; len += charWidth;
} }
} }
} }
return maxLen>len? maxLen : len; return maxLen>len? maxLen : len;
} }
int Font::height( const std::string& str ) { int Font::height( const std::string& str ) {
int h = 0; int h = 0;
bool hasLine = false; bool hasLine = false;
for (unsigned int i = 0; i < str.length(); ++i) { for (unsigned int i = 0; i < str.length(); ++i) {
if (str[i] == '\n') hasLine = true; if (str[i] == '\n') hasLine = true;
else { else {
if (hasLine) h += lineHeight; if (hasLine) h += lineHeight;
hasLine = false; hasLine = false;
} }
} }
return h; return h;
} }
std::string Font::sanitize( const std::string& str ) std::string Font::sanitize( const std::string& str )
{ {
std::string sanitized(str.length() + 1, 0); std::string sanitized(str.length() + 1, 0);
int j = 0; int j = 0;
for (unsigned int i = 0; i < str.length(); i++) { for (unsigned int i = 0; i < str.length(); i++) {
if (str[i] == '\xa7') { if (str[i] == '\xa7') {
i++; i++;
//} else if (SharedConstants.acceptableLetters.indexOf(str.charAt(i)) >= 0) { //} else if (SharedConstants.acceptableLetters.indexOf(str.charAt(i)) >= 0) {
} else { } else {
sanitized[j++] = str[i]; sanitized[j++] = str[i];
} }
} }
return sanitized.erase(j); return sanitized.erase(j);
} }
void Font::drawWordWrap( const std::string& str, float x, float y, float w, int col ) void Font::drawWordWrap( const std::string& str, float x, float y, float w, int col )
{ {
char* cstr = new char[str.length() + 1]; char* cstr = new char[str.length() + 1];
strncpy(cstr, str.c_str(), str.length()); strncpy(cstr, str.c_str(), str.length());
cstr[str.length()] = 0; cstr[str.length()] = 0;
const char* lims = " \n\t\r"; const char* lims = " \n\t\r";
char* ptok = strtok(cstr, lims); char* ptok = strtok(cstr, lims);
std::vector<std::string> words; std::vector<std::string> words;
while (ptok != NULL) { while (ptok != NULL) {
words.push_back( ptok ); words.push_back( ptok );
ptok = strtok(NULL, lims); ptok = strtok(NULL, lims);
} }
delete[] cstr; delete[] cstr;
int pos = 0; int pos = 0;
while (pos < (int)words.size()) { while (pos < (int)words.size()) {
std::string line = words[pos++] + " "; std::string line = words[pos++] + " ";
while (pos < (int)words.size() && width(line + words[pos]) < w) { while (pos < (int)words.size() && width(line + words[pos]) < w) {
line += words[pos++] + " "; line += words[pos++] + " ";
} }
drawShadow(line, x, y, col); drawShadow(line, x, y, col);
y += lineHeight; y += lineHeight;
} }
} }
void Font::drawSlow( const std::string& str, float x, float y, int color, bool darken /*= false*/ ) { void Font::drawSlow( const std::string& str, float x, float y, int color, bool darken /*= false*/ ) {
drawSlow(str.c_str(), x, y, color, darken); drawSlow(str.c_str(), x, y, color, darken);
} }
void Font::drawSlow( const char* str, float x, float y, int color, bool darken /*= false*/ ) void Font::drawSlow( const char* str, float x, float y, int color, bool darken /*= false*/ )
{ {
if (!str) return; if (!str) return;
if (darken) { if (darken) {
int oldAlpha = color & 0xff000000; int oldAlpha = color & 0xff000000;
color = (color & 0xfcfcfc) >> 2; color = (color & 0xfcfcfc) >> 2;
color += oldAlpha; color += oldAlpha;
} }
_textures->loadAndBindTexture(fontName); _textures->loadAndBindTexture(fontName);
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
t.begin(); t.begin();
int alpha = (0xff000000 & color) >> 24; int alpha = (0xff000000 & color) >> 24;
if (!alpha) alpha = 0xff; if (!alpha) alpha = 0xff;
t.color((color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff, alpha); t.color((color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff, alpha);
t.addOffset((float)x, (float)y, 0); t.addOffset((float)x, (float)y, 0);
float xOffset = 0; float xOffset = 0;
float yOffset = 0; float yOffset = 0;
while (unsigned char ch = *(str++)) { while (unsigned char ch = *(str++)) {
if (ch == '\n') { if (ch == '\n') {
xOffset = 0; xOffset = 0;
yOffset += lineHeight; yOffset += lineHeight;
} else { } else {
buildChar(ch, xOffset, yOffset); buildChar(ch, xOffset, yOffset);
xOffset += fcharWidths[ch]; xOffset += fcharWidths[ch];
} }
} }
t.draw(); t.draw();
t.addOffset(-(float)x, -(float)y, 0); t.addOffset(-(float)x, -(float)y, 0);
} }
void Font::buildChar( unsigned char i, float x /*= 0*/, float y /*=0*/ ) void Font::buildChar( unsigned char i, float x /*= 0*/, float y /*=0*/ )
{ {
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
//i -= _charOffset; //i -= _charOffset;
//int ix = (i % _cols) * 8 + _x; //int ix = (i % _cols) * 8 + _x;
//int iy = (i / _cols) * 8 + _y; //int iy = (i / _cols) * 8 + _y;
float ix = (float)((i & 15) * 8); float ix = (float)((i & 15) * 8);
float iy = (float)((i >> 4) * 8); float iy = (float)((i >> 4) * 8);
float s = 7.99f; float s = 7.99f;
float uo = (0.0f) / 128.0f; float uo = (0.0f) / 128.0f;
float vo = (0.0f) / 128.0f; float vo = (0.0f) / 128.0f;
t.vertexUV(x, y + s, 0, ix / 128.0f + uo, (iy + s) / 128.0f + vo); t.vertexUV(x, y + s, 0, ix / 128.0f + uo, (iy + s) / 128.0f + vo);
t.vertexUV(x + s, y + s, 0, (ix + s) / 128.0f + uo, (iy + s) / 128.0f + vo); t.vertexUV(x + s, y + s, 0, (ix + s) / 128.0f + uo, (iy + s) / 128.0f + vo);
t.vertexUV(x + s, y, 0, (ix + s) / 128.0f + uo, iy / 128.0f + vo); t.vertexUV(x + s, y, 0, (ix + s) / 128.0f + uo, iy / 128.0f + vo);
t.vertexUV(x, y, 0, ix / 128.0f + uo, iy / 128.0f + vo); t.vertexUV(x, y, 0, ix / 128.0f + uo, iy / 128.0f + vo);
} }

View File

@@ -1,61 +1,63 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT_GUI__Font_H__
#define NET_MINECRAFT_CLIENT_GUI__Font_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include <string>
#include <cctype> #include <string>
#include <cctype>
#include "client/renderer/gles.hpp"
#include "../renderer/gles.h"
class Textures;
class Options; class Textures;
class Options;
class Font
{ class Font
public: {
Font(Options* options, const std::string& name, Textures& textures); public:
//Font(Options* options, const std::string& name, Textures& textures, int imgW, int imgH, int x, int y, int cols, int rows, unsigned char charOffset); Font(Options* options, const std::string& name, Textures* textures);
//Font(Options* options, const std::string& name, Textures* textures, int imgW, int imgH, int x, int y, int cols, int rows, unsigned char charOffset);
void init(Options* options);
void onGraphicsReset(); void init(Options* options);
void onGraphicsReset();
void draw(const char* str, float x, float y, int color);
void draw(const std::string& str, float x, float y, int color); void draw(const char* str, float x, float y, int color);
void draw(const char* str, float x, float y, int color, bool darken); void draw(const std::string& str, float x, float y, int color);
void draw(const std::string& str, float x, float y, int color, bool darken); void draw(const char* str, float x, float y, int color, bool darken);
void drawShadow(const std::string& str, float x, float y, int color); void draw(const std::string& str, float x, float y, int color, bool darken);
void drawShadow(const char* str, float x, float y, int color); void drawShadow(const std::string& str, float x, float y, int color);
void drawWordWrap(const std::string& str, float x, float y, float w, int col); void drawShadow(const char* str, float x, float y, int color);
void drawWordWrap(const std::string& str, float x, float y, float w, int col);
int width(const std::string& str);
int height(const std::string& str); int width(const std::string& str);
int height(const std::string& str);
static std::string sanitize(const std::string& str);
private: static std::string sanitize(const std::string& str);
void buildChar(unsigned char i, float x = 0, float y = 0); private:
void drawSlow(const std::string& str, float x, float y, int color, bool darken = false); void buildChar(unsigned char i, float x = 0, float y = 0);
void drawSlow(const char* str, float x, float y, int color, bool darken = false); void drawSlow(const std::string& str, float x, float y, int color, bool darken = false);
public: void drawSlow(const char* str, float x, float y, int color, bool darken = false);
int fontTexture; public:
int lineHeight; int fontTexture;
static const int DefaultLineHeight = 10; int lineHeight;
private: static const int DefaultLineHeight = 10;
int charWidths[256]; private:
float fcharWidths[256]; int charWidths[256];
int listPos; float fcharWidths[256];
int listPos;
int index;
int count; int index;
GLuint lists[1024]; int count;
GLuint lists[1024];
std::string fontName;
Textures* _textures; std::string fontName;
Textures* _textures;
Options* options;
Options* options;
int _x, _y;
int _cols; int _x, _y;
int _rows; int _cols;
unsigned char _charOffset; int _rows;
}; unsigned char _charOffset;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__Font_H__*/

View File

@@ -1,30 +1,30 @@
#include "Gui.hpp" #include "Gui.h"
#include "Font.hpp" #include "Font.h"
#include <MinecraftClient.hpp> #include "client/Options.h"
#include "client/Options.hpp" #include "platform/input/Keyboard.h"
#include "platform/input/Keyboard.hpp" #include "screens/IngameBlockSelectionScreen.h"
#include "screens/IngameBlockSelectionScreen.hpp" #include "screens/ChatScreen.h"
#include "screens/ChatScreen.hpp" #include "screens/ConsoleScreen.h"
#include <Minecraft.hpp> #include "../Minecraft.h"
#include "client/player/LocalPlayer.hpp" #include "../player/LocalPlayer.h"
#include "client/renderer/Tesselator.hpp" #include "../renderer/Tesselator.h"
#include "client/renderer/TileRenderer.hpp" #include "../renderer/TileRenderer.h"
#include "client/renderer/LevelRenderer.hpp" #include "../renderer/LevelRenderer.h"
#include "client/renderer/GameRenderer.hpp" #include "../renderer/GameRenderer.h"
#include "client/renderer/entity/ItemRenderer.hpp" #include "../renderer/entity/ItemRenderer.h"
#include "client/player/input/IInputHolder.hpp" #include "../player/input/IInputHolder.h"
#include <gamemode/GameMode.hpp> #include "../gamemode/GameMode.h"
#include "gamemode/CreativeMode.hpp" #include "../gamemode/CreativeMode.h"
#include "client/renderer/Textures.hpp" #include "../renderer/Textures.h"
// #include "AppConstants.hpp" #include "../../AppConstants.h"
#include "world/entity/player/Inventory.hpp" #include "../../world/entity/player/Inventory.h"
#include "world/level/material/Material.hpp" #include "../../world/level/material/Material.h"
#include "world/item/Item.hpp" #include "../../world/item/Item.h"
#include "world/item/ItemInstance.hpp" #include "../../world/item/ItemInstance.h"
#include "platform/input/Mouse.hpp" #include "../../platform/input/Mouse.h"
#include "world/level/Level.hpp" #include "../../world/level/Level.h"
#include "world/PosTranslator.hpp" #include "../../world/PosTranslator.h"
#include "platform/time.hpp" #include "../../platform/time.h"
#include <cmath> #include <cmath>
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>
@@ -35,15 +35,33 @@ const float Gui::DropTicks = 40.0f;
//#include <android/log.h> //#include <android/log.h>
// @todo virtual controlConfigurationChanged() when player switches from keyboard to touch for example Gui::Gui(Minecraft* minecraft)
Gui::Gui(MinecraftClient& minecraft) : minecraft(minecraft), _openInventorySlot(minecraft.useTouchscreen()) { : minecraft(minecraft),
tickCount(0),
progress(0),
overlayMessageTime(0),
animateOverlayMessageColor(false),
chatScrollOffset(0),
tbr(1),
_inventoryNeedsUpdate(true),
_flashSlotId(-1),
_flashSlotStartTime(-1),
_slotFont(NULL),
_numSlots(4),
_currentDropTicks(-1),
_currentDropSlot(-1),
MAX_MESSAGE_WIDTH(240),
itemNameOverlayTime(2),
_openInventorySlot(minecraft->useTouchscreen())
{
glGenBuffers2(1, &_inventoryRc.vboId); glGenBuffers2(1, &_inventoryRc.vboId);
glGenBuffers2(1, &rcFeedbackInner.vboId); glGenBuffers2(1, &rcFeedbackInner.vboId);
glGenBuffers2(1, &rcFeedbackOuter.vboId); glGenBuffers2(1, &rcFeedbackOuter.vboId);
//Gui::InvGuiScale = 1.0f / (int) (3 * Minecraft::width / 854); //Gui::InvGuiScale = 1.0f / (int) (3 * Minecraft::width / 854);
} }
Gui::~Gui() { Gui::~Gui()
{
if (_slotFont) if (_slotFont)
delete _slotFont; delete _slotFont;
@@ -51,30 +69,31 @@ Gui::~Gui() {
} }
void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
if (!minecraft.level || !minecraft.player())
if (!minecraft->level || !minecraft->player)
return; return;
//minecraft.gameRenderer->setupGuiScreen(); //minecraft->gameRenderer->setupGuiScreen();
Font* font = minecraft.font(); Font* font = minecraft->font;
const bool isTouchInterface = minecraft.useTouchscreen(); const bool isTouchInterface = minecraft->useTouchscreen();
const int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale); const int screenWidth = (int)(minecraft->width * InvGuiScale);
const int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale); const int screenHeight = (int)(minecraft->height * InvGuiScale);
blitOffset = -90; blitOffset = -90;
renderProgressIndicator(isTouchInterface, screenWidth, screenHeight, a); renderProgressIndicator(isTouchInterface, screenWidth, screenHeight, a);
glColor4f2(1, 1, 1, 1); glColor4f2(1, 1, 1, 1);
// H: 4 // H: 4
// T: 7 // T: 7
// L: 6 // L: 6
// F: 3 // F: 3
int ySlot = screenHeight - 16 - 3; int ySlot = screenHeight - 16 - 3;
if (!minecraft.options().getBooleanValue(OPTIONS_HIDEGUI)) { if (!minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) {
if (minecraft.gameMode->canHurtPlayer()) { if (minecraft->gameMode->canHurtPlayer()) {
minecraft.textures().loadAndBindTexture("gui/icons.png"); minecraft->textures->loadAndBindTexture("gui/icons.png");
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
t.beginOverride(); t.beginOverride();
t.colorABGR(0xffffffff); t.colorABGR(0xffffffff);
@@ -84,7 +103,13 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
} }
} }
if(minecraft.player()->getSleepTimer() > 0) { // @todo - Shredder: I added this here but currently viginette is broken so i cant do much about it.
// if (minecraft->options.getBooleanValue(OPTIONS_FANCY_GRAPHICS)){
// this->renderVignette(this->minecraft->player->getBrightness(a), screenWidth, screenHeight);
// }
// shredder end
if(minecraft->player->getSleepTimer() > 0) {
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
@@ -93,42 +118,45 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
glEnable(GL_ALPHA_TEST); glEnable(GL_ALPHA_TEST);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
} }
if (!minecraft.options().getBooleanValue(OPTIONS_HIDEGUI)) { if (!minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) {
renderToolBar(a, ySlot, screenWidth); renderToolBar(a, ySlot, screenWidth);
glEnable(GL_BLEND); glEnable(GL_BLEND);
bool isChatting = minecraft.getScreen() && dynamic_cast<ChatScreen*>(minecraft.getScreen()); bool isChatting = (minecraft->screen && (dynamic_cast<ChatScreen*>(minecraft->screen) || dynamic_cast<ConsoleScreen*>(minecraft->screen)));
unsigned int max = 10; unsigned int max = 10;
if (isChatting) { if (isChatting) {
int lineHeight = 9; int lineHeight = 9;
max = (screenHeight - 48) / lineHeight; max = (screenHeight - 48) / lineHeight;
if (max < 1) max = 1; if (max < 1) max = 1;
int maxScroll = (int)guiMessages.size() - (int)max; int maxScroll = (int)guiMessages.size() - (int)max;
if (maxScroll < 0) maxScroll = 0; if (maxScroll < 0) maxScroll = 0;
if (chatScrollOffset > maxScroll) chatScrollOffset = maxScroll; if (chatScrollOffset > maxScroll) chatScrollOffset = maxScroll;
} else { } else {
chatScrollOffset = 0; chatScrollOffset = 0;
} }
if (font != nullptr) { renderChatMessages(screenHeight, max, isChatting, font);
renderChatMessages(screenHeight, max, isChatting, *font); #if !defined(RPI)
renderOnSelectItemNameText(screenWidth, *font, ySlot); renderOnSelectItemNameText(screenWidth, font, ySlot);
#endif
#if defined(RPI)
renderDebugInfo();
#endif
if (Keyboard::isKeyDown(Keyboard::KEY_TAB)) { if (Keyboard::isKeyDown(Keyboard::KEY_TAB)) {
renderPlayerList(*font, screenWidth, screenHeight); renderPlayerList(font, screenWidth, screenHeight);
} }
if (minecraft.options().getBooleanValue(OPTIONS_RENDER_DEBUG)) if (minecraft->options.getBooleanValue(OPTIONS_RENDER_DEBUG))
renderDebugInfo(); renderDebugInfo();
}
} }
glDisable(GL_BLEND); glDisable(GL_BLEND);
glEnable2(GL_ALPHA_TEST); glEnable2(GL_ALPHA_TEST);
} }
int Gui::getSlotIdAt(int x, int y) { int Gui::getSlotIdAt(int x, int y) {
int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale); int screenWidth = (int)(minecraft->width * InvGuiScale);
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale); int screenHeight = (int)(minecraft->height * InvGuiScale);
x = (int)(x * InvGuiScale); x = (int)(x * InvGuiScale);
y = (int)(y * InvGuiScale); y = (int)(y * InvGuiScale);
@@ -158,24 +186,24 @@ void Gui::flashSlot(int slotId) {
} }
void Gui::getSlotPos(int slot, int& posX, int& posY) { void Gui::getSlotPos(int slot, int& posX, int& posY) {
int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale); int screenWidth = (int)(minecraft->width * InvGuiScale);
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale); int screenHeight = (int)(minecraft->height * InvGuiScale);
posX = screenWidth / 2 - getNumSlots() * 10 + slot * 20, posX = screenWidth / 2 - getNumSlots() * 10 + slot * 20,
posY = screenHeight - 22; posY = screenHeight - 22;
} }
RectangleArea Gui::getRectangleArea(int extendSide) { RectangleArea Gui::getRectangleArea(int extendSide) {
const int Spacing = 3; const int Spacing = 3;
const float pCenterX = 2.0f + (float)(minecraft.getScreenWidth() / 2); const float pCenterX = 2.0f + (float)(minecraft->width / 2);
const float pHalfWidth = (1.0f + (getNumSlots() * 10 + Spacing)) * Gui::GuiScale; const float pHalfWidth = (1.0f + (getNumSlots() * 10 + Spacing)) * Gui::GuiScale;
const float pHeight = (22 + Spacing) * Gui::GuiScale; const float pHeight = (22 + Spacing) * Gui::GuiScale;
if (extendSide < 0) if (extendSide < 0)
return RectangleArea(0, (float)minecraft.getScreenHeight()-pHeight, pCenterX+pHalfWidth+2, (float)minecraft.getScreenHeight()); return RectangleArea(0, (float)minecraft->height-pHeight, pCenterX+pHalfWidth+2, (float)minecraft->height);
if (extendSide > 0) if (extendSide > 0)
return RectangleArea(pCenterX-pHalfWidth, (float)minecraft.getScreenHeight()-pHeight, (float)minecraft.getScreenWidth(), (float)minecraft.getScreenHeight()); return RectangleArea(pCenterX-pHalfWidth, (float)minecraft->height-pHeight, (float)minecraft->width, (float)minecraft->height);
return RectangleArea(pCenterX-pHalfWidth, (float)minecraft.getScreenHeight()-pHeight, pCenterX+pHalfWidth+2, (float)minecraft.getScreenHeight()); return RectangleArea(pCenterX-pHalfWidth, (float)minecraft->height-pHeight, pCenterX+pHalfWidth+2, (float)minecraft->height);
} }
void Gui::handleClick(int button, int x, int y) { void Gui::handleClick(int button, int x, int y) {
@@ -184,9 +212,9 @@ void Gui::handleClick(int button, int x, int y) {
int slot = getSlotIdAt(x, y); int slot = getSlotIdAt(x, y);
if (slot != -1) { if (slot != -1) {
if (_openInventorySlot && slot == (getNumSlots()-1)) { if (_openInventorySlot && slot == (getNumSlots()-1)) {
minecraft.screenChooser().setScreen(SCREEN_BLOCKSELECTION); minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
} else { } else {
minecraft.player()->inventory->selectSlot(slot); minecraft->player->inventory->selectSlot(slot);
itemNameOverlayTime = 0; itemNameOverlayTime = 0;
} }
} }
@@ -194,7 +222,7 @@ void Gui::handleClick(int button, int x, int y) {
void Gui::handleKeyPressed(int key) void Gui::handleKeyPressed(int key)
{ {
bool isChatting = (minecraft.getScreen() && dynamic_cast<ChatScreen*>(minecraft.getScreen())); bool isChatting = (minecraft->screen && (dynamic_cast<ChatScreen*>(minecraft->screen) || dynamic_cast<ConsoleScreen*>(minecraft->screen)));
if (isChatting) { if (isChatting) {
// Allow scrolling the chat history with the mouse/keyboard when chat is open // Allow scrolling the chat history with the mouse/keyboard when chat is open
if (key == 38) { // VK_UP if (key == 38) { // VK_UP
@@ -205,12 +233,12 @@ void Gui::handleKeyPressed(int key)
return; return;
} else if (key == 33) { // VK_PRIOR (Page Up) } else if (key == 33) { // VK_PRIOR (Page Up)
// Scroll by a page // Scroll by a page
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale); int screenHeight = (int)(minecraft->height * InvGuiScale);
int maxVisible = (screenHeight - 48) / 9; int maxVisible = (screenHeight - 48) / 9;
scrollChat(maxVisible); scrollChat(maxVisible);
return; return;
} else if (key == 34) { // VK_NEXT (Page Down) } else if (key == 34) { // VK_NEXT (Page Down)
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale); int screenHeight = (int)(minecraft->height * InvGuiScale);
int maxVisible = (screenHeight - 48) / 9; int maxVisible = (screenHeight - 48) / 9;
scrollChat(-maxVisible); scrollChat(-maxVisible);
return; return;
@@ -218,30 +246,30 @@ void Gui::handleKeyPressed(int key)
} }
if (key == Keyboard::KEY_F1) { if (key == Keyboard::KEY_F1) {
minecraft.options().toggle(OPTIONS_HIDEGUI); minecraft->options.toggle(OPTIONS_HIDEGUI);
} }
if (key == 99) if (key == 99)
{ {
if (minecraft.player()->inventory->selected > 0) if (minecraft->player->inventory->selected > 0)
{ {
minecraft.player()->inventory->selected--; minecraft->player->inventory->selected--;
} }
} }
else if (key == 4) else if (key == 4)
{ {
if (minecraft.player()->inventory->selected < (getNumSlots() - 2)) if (minecraft->player->inventory->selected < (getNumSlots() - 2))
{ {
minecraft.player()->inventory->selected++; minecraft->player->inventory->selected++;
} }
} }
else if (key == 100) else if (key == 100)
{ {
minecraft.screenChooser().setScreen(SCREEN_BLOCKSELECTION); minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
} }
else if (key == minecraft.options().getIntValue(OPTIONS_KEY_DROP)) else if (key == minecraft->options.getIntValue(OPTIONS_KEY_DROP))
{ {
minecraft.player()->inventory->dropSlot(minecraft.player()->inventory->selected, false); minecraft->player->inventory->dropSlot(minecraft->player->inventory->selected, false);
} }
} }
@@ -249,7 +277,7 @@ void Gui::scrollChat(int delta) {
if (delta == 0) if (delta == 0)
return; return;
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale); int screenHeight = (int)(minecraft->height * InvGuiScale);
int maxVisible = (screenHeight - 48) / 9; int maxVisible = (screenHeight - 48) / 9;
if (maxVisible <= 0) if (maxVisible <= 0)
return; return;
@@ -268,21 +296,21 @@ void Gui::tick() {
if(itemNameOverlayTime < 2) if(itemNameOverlayTime < 2)
itemNameOverlayTime += 1.0f / SharedConstants::TicksPerSecond; itemNameOverlayTime += 1.0f / SharedConstants::TicksPerSecond;
for (unsigned int i = 0; i < guiMessages.size(); i++) { for (unsigned int i = 0; i < guiMessages.size(); i++) {
guiMessages.at(i).ticks++; guiMessages.at(i).ticks++;
} }
if (!minecraft.isCreativeMode()) if (!minecraft->isCreativeMode())
tickItemDrop(); tickItemDrop();
} }
void Gui::addMessage(const std::string& _string) { void Gui::addMessage(const std::string& _string) {
if (!minecraft.font()) if (!minecraft->font)
return; return;
std::string string = _string; std::string string = _string;
while (minecraft.font()->width(string) > maxMessageWidth) { while (minecraft->font->width(string) > MAX_MESSAGE_WIDTH) {
unsigned int i = 1; unsigned int i = 1;
while (i < string.length() && minecraft.font()->width(string.substr(0, i + 1)) <= maxMessageWidth) { while (i < string.length() && minecraft->font->width(string.substr(0, i + 1)) <= MAX_MESSAGE_WIDTH) {
i++; i++;
} }
addMessage(string.substr(0, i)); addMessage(string.substr(0, i));
@@ -322,6 +350,8 @@ void Gui::displayClientMessage(const std::string& messageId) {
addMessage(messageId); addMessage(messageId);
} }
// @todo - shredder: Function seems to be completely fine and ported over from java beta, but renders opaque??? need to investigate
void Gui::renderVignette(float br, int w, int h) { void Gui::renderVignette(float br, int w, int h) {
br = 1 - br; br = 1 - br;
if (br < 0) br = 0; if (br < 0) br = 0;
@@ -332,7 +362,10 @@ void Gui::renderVignette(float br, int w, int h) {
glDepthMask(false); glDepthMask(false);
glBlendFunc2(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); glBlendFunc2(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
glColor4f2(tbr, tbr, tbr, 1); glColor4f2(tbr, tbr, tbr, 1);
minecraft.textures().loadAndBindTexture("misc/vignette.png");
minecraft->textures->loadAndBindTexture("misc/vignette.png");
glTexParameteri2(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri2(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
t.begin(); t.begin();
@@ -348,14 +381,14 @@ void Gui::renderVignette(float br, int w, int h) {
} }
void Gui::renderSlot(int slot, int x, int y, float a) { void Gui::renderSlot(int slot, int x, int y, float a) {
ItemInstance* item = minecraft.player()->inventory->getItem(slot); ItemInstance* item = minecraft->player->inventory->getItem(slot);
if (!item) { if (!item) {
//LOGW("Warning: item @ Gui::renderSlot is NULL\n"); //LOGW("Warning: item @ Gui::renderSlot is NULL\n");
return; return;
} }
const bool fancy = true; const bool fancy = true;
ItemRenderer::renderGuiItem(minecraft.font(), minecraft.textures(), item, (float)x, (float)y, fancy); ItemRenderer::renderGuiItem(minecraft->font, minecraft->textures, item, (float)x, (float)y, fancy);
} }
void Gui::renderSlotText( const ItemInstance* item, float x, float y, bool hasFinite, bool shadow ) void Gui::renderSlotText( const ItemInstance* item, float x, float y, bool hasFinite, bool shadow )
@@ -375,9 +408,9 @@ void Gui::renderSlotText( const ItemInstance* item, float x, float y, bool hasFi
//LOGI("slot: %d - %s\n", slot, buffer); //LOGI("slot: %d - %s\n", slot, buffer);
if (shadow) if (shadow)
minecraft.font()->drawShadow(buffer, x, y, item->count>0?0xffcccccc:0x60cccccc); minecraft->font->drawShadow(buffer, x, y, item->count>0?0xffcccccc:0x60cccccc);
else else
minecraft.font()->draw(buffer, x, y, item->count>0?0xffcccccc:0x60cccccc); minecraft->font->draw(buffer, x, y, item->count>0?0xffcccccc:0x60cccccc);
} }
void Gui::inventoryUpdated() { void Gui::inventoryUpdated() {
@@ -385,11 +418,11 @@ void Gui::inventoryUpdated() {
} }
void Gui::onGraphicsReset() { void Gui::onGraphicsReset() {
inventoryUpdated(); inventoryUpdated();
} }
void Gui::texturesLoaded( Textures* textures ) { void Gui::texturesLoaded( Textures* textures ) {
//_slotFont = new Font(&minecraft.options, "gui/gui_blocks.png", textures, 0, 504, 10, 1, '0'); //_slotFont = new Font(&minecraft->options, "gui/gui_blocks.png", textures, 0, 504, 10, 1, '0');
} }
void Gui::onConfigChanged( const Config& c ) { void Gui::onConfigChanged( const Config& c ) {
@@ -404,7 +437,7 @@ void Gui::onConfigChanged( const Config& c ) {
#else #else
const float mm = 50; //20 const float mm = 50; //20
#endif #endif
const float maxRadius = minecraft.pixelCalcUi().millimetersToPixels(mm); const float maxRadius = minecraft->pixelCalcUi.millimetersToPixels(mm);
const float radius = Mth::Min(80.0f/2, maxRadius); const float radius = Mth::Min(80.0f/2, maxRadius);
//LOGI("radius, maxradius: %f, %f\n", radius, maxRadius); //LOGI("radius, maxradius: %f, %f\n", radius, maxRadius);
const float radiusInner = radius * 0.95f; const float radiusInner = radius * 0.95f;
@@ -449,12 +482,10 @@ void Gui::onConfigChanged( const Config& c ) {
} }
rcFeedbackInner = t.end(true, rcFeedbackInner.vboId); rcFeedbackInner = t.end(true, rcFeedbackInner.vboId);
if (c.minecraft->useTouchscreen()) {
if (c.minecraft.useTouchscreen()) {
// I'll bump this up to 6. // I'll bump this up to 6.
int num = 6; // without "..." dots int num = 6; // without "..." dots
if (!c.minecraft.options().getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA) && c.width > 480) { if (!c.minecraft->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA) && c.width > 480) {
while (num < Inventory::MAX_SELECTION_SIZE - 1) { while (num < Inventory::MAX_SELECTION_SIZE - 1) {
int x0, x1, y; int x0, x1, y;
getSlotPos(0, x0, y); getSlotPos(0, x0, y);
@@ -473,8 +504,7 @@ void Gui::onConfigChanged( const Config& c ) {
} else { } else {
_numSlots = Inventory::MAX_SELECTION_SIZE; // Xperia Play _numSlots = Inventory::MAX_SELECTION_SIZE; // Xperia Play
} }
MAX_MESSAGE_WIDTH = c.guiWidth;
maxMessageWidth = c.guiWidth;
} }
float Gui::floorAlignToScreenPixel(float v) { float Gui::floorAlignToScreenPixel(float v) {
@@ -521,8 +551,8 @@ void Gui::tickItemDrop()
} }
isCurrentlyActive = true; isCurrentlyActive = true;
if ((_currentDropTicks += 1.0f) >= DropTicks) { if ((_currentDropTicks += 1.0f) >= DropTicks) {
minecraft.player()->inventory->dropSlot(slot, false); minecraft->player->inventory->dropSlot(slot, false);
minecraft.level->playSound(minecraft.player(), "random.pop", 0.3f, 1); minecraft->level->playSound(minecraft->player, "random.pop", 0.3f, 1);
isCurrentlyActive = false; isCurrentlyActive = false;
} }
} }
@@ -549,7 +579,7 @@ void Gui::postError( int errCode )
void Gui::setScissorRect( const IntRectangle& bbox ) void Gui::setScissorRect( const IntRectangle& bbox )
{ {
GLuint x = (GLuint)(GuiScale * bbox.x); GLuint x = (GLuint)(GuiScale * bbox.x);
GLuint y = minecraft.getScreenHeight() - (GLuint)(GuiScale * (bbox.y + bbox.h)); GLuint y = minecraft->height - (GLuint)(GuiScale * (bbox.y + bbox.h));
GLuint w = (GLuint)(GuiScale * bbox.w); GLuint w = (GLuint)(GuiScale * bbox.w);
GLuint h = (GLuint)(GuiScale * bbox.h); GLuint h = (GLuint)(GuiScale * bbox.h);
glScissor(x, y, w, h); glScissor(x, y, w, h);
@@ -562,33 +592,33 @@ float Gui::cubeSmoothStep(float percentage, float min, float max) {
} }
void Gui::renderProgressIndicator( const bool isTouchInterface, const int screenWidth, const int screenHeight, float a ) { void Gui::renderProgressIndicator( const bool isTouchInterface, const int screenWidth, const int screenHeight, float a ) {
ItemInstance* currentItem = minecraft.player()->inventory->getSelected(); ItemInstance* currentItem = minecraft->player->inventory->getSelected();
bool bowEquipped = currentItem != NULL ? currentItem->getItem() == Item::bow : false; bool bowEquipped = currentItem != NULL ? currentItem->getItem() == Item::bow : false;
bool itemInUse = currentItem != NULL ? currentItem->getItem() == minecraft.player()->getUseItem()->getItem() : false; bool itemInUse = currentItem != NULL ? currentItem->getItem() == minecraft->player->getUseItem()->getItem() : false;
if ((!isTouchInterface || minecraft.options().getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA) if ((!isTouchInterface || minecraft->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA)
|| (bowEquipped && itemInUse)) && !minecraft.options().getBooleanValue(OPTIONS_HIDEGUI)) { || (bowEquipped && itemInUse)) && !minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) {
minecraft.textures().loadAndBindTexture("gui/icons.png"); minecraft->textures->loadAndBindTexture("gui/icons.png");
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc2(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR); glBlendFunc2(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
blit(screenWidth/2 - 8, screenHeight/2 - 8, 0, 0, 16, 16); blit(screenWidth/2 - 8, screenHeight/2 - 8, 0, 0, 16, 16);
glDisable(GL_BLEND); glDisable(GL_BLEND);
} else if(!bowEquipped) { } else if(!bowEquipped) {
const float tprogress = minecraft.gameMode->destroyProgress; const float tprogress = minecraft->gameMode->destroyProgress;
const float alpha = Mth::clamp(minecraft.inputHolder()->alpha, 0.0f, 1.0f); const float alpha = Mth::clamp(minecraft->inputHolder->alpha, 0.0f, 1.0f);
//LOGI("alpha: %f\n", alpha); //LOGI("alpha: %f\n", alpha);
if (tprogress <= 0 && minecraft.inputHolder()->alpha >= 0) { if (tprogress <= 0 && minecraft->inputHolder->alpha >= 0) {
glDisable2(GL_TEXTURE_2D); glDisable2(GL_TEXTURE_2D);
glEnable2(GL_BLEND); glEnable2(GL_BLEND);
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (minecraft.hitResult.isHit()) if (minecraft->hitResult.isHit())
glColor4f2(1, 1, 1, 0.8f * alpha); glColor4f2(1, 1, 1, 0.8f * alpha);
else else
glColor4f2(1, 1, 1, Mth::Min(0.4f, alpha*0.4f)); glColor4f2(1, 1, 1, Mth::Min(0.4f, alpha*0.4f));
//LOGI("alpha2: %f\n", alpha); //LOGI("alpha2: %f\n", alpha);
const float x = InvGuiScale * minecraft.inputHolder()->mousex; const float x = InvGuiScale * minecraft->inputHolder->mousex;
const float y = InvGuiScale * minecraft.inputHolder()->mousey; const float y = InvGuiScale * minecraft->inputHolder->mousey;
glTranslatef2(x, y, 0); glTranslatef2(x, y, 0);
drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 24); drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 24);
glTranslatef2(-x, -y, 0); glTranslatef2(-x, -y, 0);
@@ -596,7 +626,7 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
glEnable2(GL_TEXTURE_2D); glEnable2(GL_TEXTURE_2D);
glDisable(GL_BLEND); glDisable(GL_BLEND);
} else if (tprogress > 0) { } else if (tprogress > 0) {
const float oProgress = minecraft.gameMode->oDestroyProgress; const float oProgress = minecraft->gameMode->oDestroyProgress;
const float progress = 0.5f * (oProgress + (tprogress - oProgress) * a); const float progress = 0.5f * (oProgress + (tprogress - oProgress) * a);
//static Stopwatch w; //static Stopwatch w;
@@ -607,8 +637,8 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
const float x = InvGuiScale * minecraft.inputHolder()->mousex; const float x = InvGuiScale * minecraft->inputHolder->mousex;
const float y = InvGuiScale * minecraft.inputHolder()->mousey; const float y = InvGuiScale * minecraft->inputHolder->mousey;
glPushMatrix2(); glPushMatrix2();
glTranslatef2(x, y, 0); glTranslatef2(x, y, 0);
drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 24); drawArrayVT(rcFeedbackOuter.vboId, rcFeedbackOuter.vertexCount, 24);
@@ -629,27 +659,27 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
} }
void Gui::renderHearts() { void Gui::renderHearts() {
bool blink = (minecraft.player()->invulnerableTime / 3) % 2 == 1; bool blink = (minecraft->player->invulnerableTime / 3) % 2 == 1;
if (minecraft.player()->invulnerableTime < 10) blink = false; if (minecraft->player->invulnerableTime < 10) blink = false;
int h = minecraft.player()->health; int h = minecraft->player->health;
int oh = minecraft.player()->lastHealth; int oh = minecraft->player->lastHealth;
random.setSeed(tickCount * 312871); random.setSeed(tickCount * 312871);
int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale); int screenWidth = (int)(minecraft->width * InvGuiScale);
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale); int screenHeight = (int)(minecraft->height * InvGuiScale);
int xx = (minecraft.options().getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenWidth / 2 - getNumSlots() * 10 - 1 : 2; int xx = (minecraft->options.getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenWidth / 2 - getNumSlots() * 10 - 1 : 2;
int armor = minecraft.player()->getArmorValue(); int armor = minecraft->player->getArmorValue();
for (int i = 0; i < Player::MAX_HEALTH / 2; i++) { for (int i = 0; i < Player::MAX_HEALTH / 2; i++) {
int yo = (minecraft.options().getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenHeight - 32 : 2; int yo = (minecraft->options.getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenHeight - 32 : 2;
int ip2 = i + i + 1; int ip2 = i + i + 1;
if (armor > 0) { if (armor > 0) {
int xo = xx + 80 + i * 8 + 4; int xo = xx + 80 + i * 8 + 4;
if (ip2 < armor) blit(xo, yo, 16 + 2 * 9, 9 * 1, 9, 9); if (ip2 < armor) blit(xo, yo, 16 + 2 * 9, 9 * 1, 9, 9);
else if (ip2 == armor) blit(xo, yo, 16 + 4 * 9, 9 * 1, 9, 9); else if (ip2 == armor) blit(xo, yo, 16 + 4 * 9, 9 * 1, 9, 9);
else if (ip2 > armor) blit(xo, yo, 16 + 0 * 9, 9 * 1, 9, 9); else if (ip2 > armor) blit(xo, yo, 16 + 0 * 9, 9 * 1, 9, 9);
} }
int bg = 0; int bg = 0;
@@ -669,14 +699,14 @@ void Gui::renderHearts() {
} }
void Gui::renderBubbles() { void Gui::renderBubbles() {
if (minecraft.player()->isUnderLiquid(Material::water)) { if (minecraft->player->isUnderLiquid(Material::water)) {
int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale); int screenWidth = (int)(minecraft->width * InvGuiScale);
int screenHeight = (int)(minecraft.getScreenHeight() * InvGuiScale); int screenHeight = (int)(minecraft->height * InvGuiScale);
int xx = (minecraft.options().getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenWidth / 2 - getNumSlots() * 10 - 1 : 2; int xx = (minecraft->options.getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenWidth / 2 - getNumSlots() * 10 - 1 : 2;
int yo = (minecraft.options().getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenHeight - 42 : 12; int yo = (minecraft->options.getBooleanValue(OPTIONS_BAR_ON_TOP)) ? screenHeight - 42 : 12;
int count = (int) std::ceil((minecraft.player()->airSupply - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY); int count = (int) std::ceil((minecraft->player->airSupply - 2) * 10.0f / Player::TOTAL_AIR_SUPPLY);
int extra = (int) std::ceil((minecraft.player()->airSupply) * 10.0f / Player::TOTAL_AIR_SUPPLY) - count; int extra = (int) std::ceil((minecraft->player->airSupply) * 10.0f / Player::TOTAL_AIR_SUPPLY) - count;
for (int i = 0; i < count + extra; i++) { for (int i = 0; i < count + extra; i++) {
int xo = i * 8 + xx; int xo = i * 8 + xx;
if (i < count) blit(xo, yo, 16, 9 * 2, 9, 9); if (i < count) blit(xo, yo, 16, 9 * 2, 9, 9);
@@ -687,7 +717,7 @@ void Gui::renderBubbles() {
static OffsetPosTranslator posTranslator; static OffsetPosTranslator posTranslator;
void Gui::onLevelGenerated() { void Gui::onLevelGenerated() {
if (Level* level = minecraft.level) { if (Level* level = minecraft->level) {
Pos p = level->getSharedSpawnPos(); Pos p = level->getSharedSpawnPos();
posTranslator = OffsetPosTranslator((float)-p.x, (float)-p.y, (float)-p.z); posTranslator = OffsetPosTranslator((float)-p.x, (float)-p.y, (float)-p.z);
} }
@@ -706,8 +736,8 @@ void Gui::renderDebugInfo() {
fpsLastTime = now; fpsLastTime = now;
} }
LocalPlayer* p = minecraft.player(); LocalPlayer* p = minecraft->player;
Level* lvl = minecraft.level; Level* lvl = minecraft->level;
// Position // Position
float px = p->x, py = p->y - p->heightOffset, pz = p->z; float px = p->x, py = p->y - p->heightOffset, pz = p->z;
@@ -753,7 +783,7 @@ void Gui::renderDebugInfo() {
const float LH = (float)Font::DefaultLineHeight; // 10 font-pixels const float LH = (float)Font::DefaultLineHeight; // 10 font-pixels
const float MGN = 2.0f; // left/top margin in font-pixels const float MGN = 2.0f; // left/top margin in font-pixels
const float PAD = 2.0f; // horizontal padding for background const float PAD = 2.0f; // horizontal padding for background
Font* font = minecraft.font(); Font* font = minecraft->font;
// 1) Draw semi-transparent background boxes behind each line // 1) Draw semi-transparent background boxes behind each line
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
@@ -778,12 +808,12 @@ void Gui::renderDebugInfo() {
t.endOverrideAndDraw(); t.endOverrideAndDraw();
} }
void Gui::renderPlayerList(Font& font, int screenWidth, int screenHeight) { void Gui::renderPlayerList(Font* font, int screenWidth, int screenHeight) {
// only show when in game, no other screen // only show when in game, no other screen
// if (!minecraft.level) return; // if (!minecraft->level) return;
// only show the overlay while connected to a multiplayer server // only show the overlay while connected to a multiplayer server
Level* level = minecraft.level; Level* level = minecraft->level;
if (!level) return; if (!level) return;
if (!level->isClientSide) return; if (!level->isClientSide) return;
@@ -805,7 +835,7 @@ void Gui::renderPlayerList(Font& font, int screenWidth, int screenHeight) {
float maxNameWidth = 0.0f; float maxNameWidth = 0.0f;
// find the longest name so we can size the box accordingly // find the longest name so we can size the box accordingly
for (const std::string& name : playerNames) { for (const std::string& name : playerNames) {
float nameWidth = font.width(name); float nameWidth = font->width(name);
if (nameWidth > maxNameWidth) if (nameWidth > maxNameWidth)
maxNameWidth = nameWidth; maxNameWidth = nameWidth;
} }
@@ -814,7 +844,7 @@ void Gui::renderPlayerList(Font& font, int screenWidth, int screenHeight) {
std::ostringstream titleStream; std::ostringstream titleStream;
titleStream << "Players (" << playerNames.size() << ")"; titleStream << "Players (" << playerNames.size() << ")";
std::string titleText = titleStream.str(); std::string titleText = titleStream.str();
float titleWidth = font.width(titleText); float titleWidth = font->width(titleText);
if (titleWidth > maxNameWidth) if (titleWidth > maxNameWidth)
maxNameWidth = titleWidth; maxNameWidth = titleWidth;
@@ -844,21 +874,21 @@ void Gui::renderPlayerList(Font& font, int screenWidth, int screenHeight) {
//glScalef2(textScale, textScale, 1); //glScalef2(textScale, textScale, 1);
// draw title // draw title
//font.draw(titleText, titleX * invTextScale, titleY * invTextScale, 0xFFFFFFFF); //font->draw(titleText, titleX * invTextScale, titleY * invTextScale, 0xFFFFFFFF);
font.draw(titleText, titleX, titleY, 0xFFFFFFFF); font->draw(titleText, titleX, titleY, 0xFFFFFFFF);
// draw player names // draw player names
// we should add ping icons here eventually, but for now just show names // we should add ping icons here eventually, but for now just show names
float currentY = boxTop + padding + lineHeight; float currentY = boxTop + padding + lineHeight;
for (const std::string& name : playerNames) { for (const std::string& name : playerNames) {
font.draw(name, (boxLeft + padding), currentY, 0xFFDDDDDD); font->draw(name, (boxLeft + padding), currentY, 0xFFDDDDDD);
currentY += lineHeight; currentY += lineHeight;
} }
//glPopMatrix2(); //glPopMatrix2();
} }
void Gui::renderSleepAnimation( const int screenWidth, const int screenHeight ) { void Gui::renderSleepAnimation( const int screenWidth, const int screenHeight ) {
int timer = minecraft.player()->getSleepTimer(); int timer = minecraft->player->getSleepTimer();
float amount = (float) timer / (float) Player::SLEEP_DURATION; float amount = (float) timer / (float) Player::SLEEP_DURATION;
if (amount > 1) { if (amount > 1) {
// waking up // waking up
@@ -869,11 +899,11 @@ void Gui::renderSleepAnimation( const int screenWidth, const int screenHeight )
fill(0, 0, screenWidth, screenHeight, color); fill(0, 0, screenWidth, screenHeight, color);
} }
void Gui::renderOnSelectItemNameText( const int screenWidth, Font& font, int ySlot ) { void Gui::renderOnSelectItemNameText( const int screenWidth, Font* font, int ySlot ) {
if(itemNameOverlayTime < 1.0f) { if(itemNameOverlayTime < 1.0f) {
ItemInstance* item = minecraft.player()->inventory->getSelected(); ItemInstance* item = minecraft->player->inventory->getSelected();
if(item != NULL) { if(item != NULL) {
float x = float(screenWidth / 2 - font.width(item->getName()) / 2); float x = float(screenWidth / 2 - font->width(item->getName()) / 2);
float y = float(ySlot - 22); float y = float(ySlot - 22);
int alpha = 255; int alpha = 255;
if(itemNameOverlayTime > 0.75) { if(itemNameOverlayTime > 0.75) {
@@ -882,7 +912,7 @@ void Gui::renderOnSelectItemNameText( const int screenWidth, Font& font, int ySl
alpha = int(percentage * 255); alpha = int(percentage * 255);
} }
if(alpha != 0) if(alpha != 0)
font.drawShadow(item->getName(), x, y, 0x00ffffff + (alpha << 24)); font->drawShadow(item->getName(), x, y, 0x00ffffff + (alpha << 24));
} }
} }
} }
@@ -891,67 +921,67 @@ void Gui::renderOnSelectItemNameText( const int screenWidth, Font& font, int ySl
// helper structure used by drawColoredString // helper structure used by drawColoredString
struct ColorSegment { struct ColorSegment {
std::string text; std::string text;
uint32_t color; uint32_t color;
}; };
// parse [tag] and [/tag] markers; tags may contain a color name (gold, green, etc.) // parse [tag] and [/tag] markers; tags may contain a color name (gold, green, etc.)
static void parseColorTags(const std::string& in, std::vector<ColorSegment>& out) { static void parseColorTags(const std::string& in, std::vector<ColorSegment>& out) {
uint32_t curColor = 0xffffff; uint32_t curColor = 0xffffff;
size_t pos = 0; size_t pos = 0;
while (pos < in.size()) { while (pos < in.size()) {
size_t open = in.find('[', pos); size_t open = in.find('[', pos);
if (open == std::string::npos) { if (open == std::string::npos) {
out.push_back({in.substr(pos), curColor}); out.push_back({in.substr(pos), curColor});
break; break;
} }
if (open > pos) { if (open > pos) {
out.push_back({in.substr(pos, open - pos), curColor}); out.push_back({in.substr(pos, open - pos), curColor});
} }
size_t close = in.find(']', open); size_t close = in.find(']', open);
if (close == std::string::npos) { if (close == std::string::npos) {
out.push_back({in.substr(open), curColor}); out.push_back({in.substr(open), curColor});
break; break;
} }
std::string tag = in.substr(open + 1, close - open - 1); std::string tag = in.substr(open + 1, close - open - 1);
if (!tag.empty() && tag[0] == '/') { if (!tag.empty() && tag[0] == '/') {
curColor = 0xffffff; curColor = 0xffffff;
} else { } else {
std::string lower; std::string lower;
lower.resize(tag.size()); lower.resize(tag.size());
std::transform(tag.begin(), tag.end(), lower.begin(), ::tolower); std::transform(tag.begin(), tag.end(), lower.begin(), ::tolower);
if (lower.find("gold") != std::string::npos) curColor = 0xffd700; if (lower.find("gold") != std::string::npos) curColor = 0xffd700;
else if (lower.find("green") != std::string::npos) curColor = 0x00ff00; else if (lower.find("green") != std::string::npos) curColor = 0x00ff00;
else if (lower.find("yellow") != std::string::npos) curColor = 0xffff00; else if (lower.find("yellow") != std::string::npos) curColor = 0xffff00;
else if (lower.find("red") != std::string::npos) curColor = 0xff0000; else if (lower.find("red") != std::string::npos) curColor = 0xff0000;
else if (lower.find("blue") != std::string::npos) curColor = 0x0000ff; else if (lower.find("blue") != std::string::npos) curColor = 0x0000ff;
} }
pos = close + 1; pos = close + 1;
} }
} }
void Gui::drawColoredString(Font& font, const std::string& text, float x, float y, int alpha) { void Gui::drawColoredString(Font* font, const std::string& text, float x, float y, int alpha) {
std::vector<ColorSegment> segs; std::vector<ColorSegment> segs;
parseColorTags(text, segs); parseColorTags(text, segs);
float cx = x; float cx = x;
for (auto &s : segs) { for (auto &s : segs) {
int color = s.color + (alpha << 24); int color = s.color + (alpha << 24);
font.drawShadow(s.text, cx, y, color); font->drawShadow(s.text, cx, y, color);
cx += font.width(s.text); cx += font->width(s.text);
} }
} }
float Gui::getColoredWidth(Font& font, const std::string& text) { float Gui::getColoredWidth(Font* font, const std::string& text) {
std::vector<ColorSegment> segs; std::vector<ColorSegment> segs;
parseColorTags(text, segs); parseColorTags(text, segs);
float w = 0; float w = 0;
for (auto &s : segs) { for (auto &s : segs) {
w += font.width(s.text); w += font->width(s.text);
} }
return w; return w;
} }
void Gui::renderChatMessages( const int screenHeight, unsigned int max, bool isChatting, Font& font ) { void Gui::renderChatMessages( const int screenHeight, unsigned int max, bool isChatting, Font* font ) {
// if (minecraft.screen instanceof ChatScreen) { // if (minecraft.screen instanceof ChatScreen) {
// max = 20; // max = 20;
// isChatting = true; // isChatting = true;
@@ -988,17 +1018,17 @@ void Gui::renderChatMessages( const int screenHeight, unsigned int max, bool isC
const float x = 2; const float x = 2;
const float y = (float)(baseY - i * 9); const float y = (float)(baseY - i * 9);
std::string msg = message.message; std::string msg = message.message;
this->fill(x, y - 1, x + maxMessageWidth, y + 8, (alpha / 2) << 24); this->fill(x, y - 1, x + MAX_MESSAGE_WIDTH, y + 8, (alpha / 2) << 24);
glEnable(GL_BLEND); glEnable(GL_BLEND);
// special-case join/leave announcements // special-case join/leave announcements
int baseColor = 0xffffff; int baseColor = 0xffffff;
if (msg.find(" joined the game") != std::string::npos || if (msg.find(" joined the game") != std::string::npos ||
msg.find(" left the game") != std::string::npos) { msg.find(" left the game") != std::string::npos) {
baseColor = 0xffff00; // yellow baseColor = 0xffff00; // yellow
} }
// replace previous logic; allow full colour tags now // replace previous logic; allow full colour tags now
Gui::drawColoredString(font, msg, x, y, alpha); Gui::drawColoredString(font, msg, x, y, alpha);
} }
} }
} }
@@ -1006,9 +1036,9 @@ void Gui::renderChatMessages( const int screenHeight, unsigned int max, bool isC
void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) { void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
glColor4f2(1, 1, 1, .5); glColor4f2(1, 1, 1, .5);
minecraft.textures().loadAndBindTexture("gui/gui.png"); minecraft->textures->loadAndBindTexture("gui/gui.png");
Inventory* inventory = minecraft.player()->inventory; Inventory* inventory = minecraft->player->inventory;
int xBase, yBase; int xBase, yBase;
getSlotPos(0, xBase, yBase); getSlotPos(0, xBase, yBase);
@@ -1065,7 +1095,7 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
blit(screenWidth / 2 + 10 * getNumSlots() - 20 + 4, ySlot + 6, 242, 252, 14, 4, 14, 4); blit(screenWidth / 2 + 10 * getNumSlots() - 20 + 4, ySlot + 6, 242, 252, 14, 4, 14, 4);
} }
minecraft.textures().loadAndBindTexture("gui/gui_blocks.png"); minecraft->textures->loadAndBindTexture("gui/gui_blocks.png");
t.endOverrideAndDraw(); t.endOverrideAndDraw();
// Render damaged items (@todo: investigate if it's faster by drawing in same batch) // Render damaged items (@todo: investigate if it's faster by drawing in same batch)
@@ -1074,7 +1104,7 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
t.beginOverride(); t.beginOverride();
x = baseItemX; x = baseItemX;
for (int i = 0; i < slots; i++) { for (int i = 0; i < slots; i++) {
ItemRenderer::renderGuiItemDecorations(minecraft.player()->inventory->getItem(i), x, (float)ySlot); ItemRenderer::renderGuiItemDecorations(minecraft->player->inventory->getItem(i), x, (float)ySlot);
x += 20; x += 20;
} }
t.endOverrideAndDraw(); t.endOverrideAndDraw();
@@ -1086,22 +1116,41 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
// Draw count // Draw count
//Tesselator& t = Tesselator::instance; //Tesselator& t = Tesselator::instance;
glPushMatrix2();
glScalef2(InvGuiScale + InvGuiScale, InvGuiScale + InvGuiScale, 1);
const float k = 0.5f * GuiScale; const float k = 0.5f * GuiScale;
if (minecraft->options.getBooleanValue(OPTIONS_JAVA_HUD)) // if true enables the java beta item count size and color and calls the java items decorations
t.beginOverride(); {
if (minecraft.gameMode->isSurvivalType()) { t.beginOverride();
x = baseItemX; if (minecraft->gameMode->isSurvivalType()) {
for (int i = 0; i < slots; i++) { x = baseItemX;
ItemInstance* item = minecraft.player()->inventory->getItem(i); for (int i = 0; i < slots; i++) {
if (item && item->count >= 0) ItemInstance* item = minecraft->player->inventory->getItem(i);
renderSlotText(item, k*x, k*ySlot + 1, true, true); if (item && item->count >= 0)
x += 20; ItemRenderer::renderGuiItemDecorations(minecraft->font, minecraft->textures, minecraft->player->inventory->getItem(i), x, (float)ySlot);
x += 20;
}
} }
minecraft->textures->loadAndBindTexture("font/default8.png");
t.endOverrideAndDraw();
}
else { // otherwise uses the normal pocket edition one
glPushMatrix2();
glScalef2(InvGuiScale + InvGuiScale, InvGuiScale + InvGuiScale, 1);
t.beginOverride();
if (minecraft->gameMode->isSurvivalType()) {
x = baseItemX;
for (int i = 0; i < slots; i++) {
ItemInstance* item = minecraft->player->inventory->getItem(i);
if (item && item->count >= 0)
renderSlotText(item, k*x, k*ySlot, true, true);
x += 20;
}
}
minecraft->textures->loadAndBindTexture("font/default8.png");
t.endOverrideAndDraw();
glPopMatrix2();
} }
minecraft.textures().loadAndBindTexture("font/default8.png");
t.endOverrideAndDraw();
glPopMatrix2();
} }

View File

@@ -1,133 +1,134 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT_GUI__Gui_H__
#define NET_MINECRAFT_CLIENT_GUI__Gui_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include "GuiComponent.hpp"
#include "Font.hpp" #include "GuiComponent.h"
#include "client/player/input/touchscreen/TouchAreaModel.hpp" #include "Font.h"
#include "client/renderer/RenderChunk.hpp" #include "../player/input/touchscreen/TouchAreaModel.h"
#include "util/Random.hpp" #include "../renderer/RenderChunk.h"
#include "client/IConfigListener.hpp" #include "../../util/Random.h"
#include "../IConfigListener.h"
class MinecraftClient;
class ItemInstance; class Minecraft;
class Textures; class ItemInstance;
class Tesselator; class Textures;
struct IntRectangle; class Tesselator;
struct IntRectangle;
struct GuiMessage
{ struct GuiMessage
std::string message; {
int ticks; std::string message;
}; int ticks;
};
typedef std::vector<GuiMessage> GuiMessageList;
typedef std::vector<GuiMessage> GuiMessageList;
class Gui: public GuiComponent, IConfigListener
{ class Gui: public GuiComponent, IConfigListener
public: {
Gui(MinecraftClient& minecraft); public:
~Gui(); Gui(Minecraft* minecraft);
~Gui();
int getSlotIdAt(int x, int y);
void flashSlot(int slotId); int getSlotIdAt(int x, int y);
bool isInside(int x, int y); void flashSlot(int slotId);
RectangleArea getRectangleArea(int extendSide); bool isInside(int x, int y);
void getSlotPos(int slot, int& posX, int& posY); RectangleArea getRectangleArea(int extendSide);
int getNumSlots(); void getSlotPos(int slot, int& posX, int& posY);
int getNumSlots();
void handleClick(int button, int x, int y);
void handleKeyPressed( int key ); void handleClick(int button, int x, int y);
void scrollChat(int delta); void handleKeyPressed( int key );
void scrollChat(int delta);
void tick();
void render(float a, bool mouseFree, int xMouse, int yMouse); void tick();
void render(float a, bool mouseFree, int xMouse, int yMouse);
void renderToolBar( float a, int ySlot, const int screenWidth );
void renderToolBar( float a, int ySlot, const int screenWidth );
void renderChatMessages( const int screenHeight, unsigned int max, bool isChatting, Font& font );
void renderChatMessages( const int screenHeight, unsigned int max, bool isChatting, Font* font );
// draw a string containing simple [color]...[/color] tags; color names are matched
// case-insensitively and default to white. alpha is applied to each segment. // draw a string containing simple [color]...[/color] tags; color names are matched
// draw tagged string (ignores simple [color]…[/color] tags) // case-insensitively and default to white. alpha is applied to each segment.
static void drawColoredString(Font& font, const std::string& text, float x, float y, int alpha); // draw tagged string (ignores simple [color]…[/color] tags)
static float getColoredWidth(Font& font, const std::string& text); static void drawColoredString(Font* font, const std::string& text, float x, float y, int alpha);
static float getColoredWidth(Font* font, const std::string& text);
void renderOnSelectItemNameText( const int screenWidth, Font& font, int ySlot );
void renderOnSelectItemNameText( const int screenWidth, Font* font, int ySlot );
void renderSleepAnimation( const int screenWidth, const int screenHeight );
void renderSleepAnimation( const int screenWidth, const int screenHeight );
void renderBubbles();
void renderHearts(); void renderBubbles();
void renderDebugInfo(); void renderHearts();
void renderPlayerList(Font& font, int screenWidth, int screenHeight); void renderDebugInfo();
void renderPlayerList(Font* font, int screenWidth, int screenHeight);
void renderProgressIndicator( const bool isTouchInterface, const int screenWidth, const int screenHeight, float a );
void renderProgressIndicator( const bool isTouchInterface, const int screenWidth, const int screenHeight, float a );
void addMessage(const std::string& string);
void clearMessages(); void addMessage(const std::string& string);
void postError(int errCode); void clearMessages();
void postError(int errCode);
void onGraphicsReset();
void inventoryUpdated(); void onGraphicsReset();
void inventoryUpdated();
void setNowPlaying(const std::string& string);
void displayClientMessage(const std::string& messageId); void setNowPlaying(const std::string& string);
void renderSlotText(const ItemInstance* item, float x, float y, bool hasFinite, bool shadow); void displayClientMessage(const std::string& messageId);
void texturesLoaded( Textures* textures ); void renderSlotText(const ItemInstance* item, float x, float y, bool hasFinite, bool shadow);
void texturesLoaded( Textures* textures );
void onConfigChanged(const Config& config);
void onLevelGenerated(); void onConfigChanged(const Config& config);
void onLevelGenerated();
void setScissorRect(const IntRectangle& rect);
void setScissorRect(const IntRectangle& rect);
static float floorAlignToScreenPixel(float);
static int itemCountItoa(char* buf, int count); static float floorAlignToScreenPixel(float);
private: static int itemCountItoa(char* buf, int count);
void renderVignette(float br, int w, int h); private:
void renderSlot(int slot, int x, int y, float a); void renderVignette(float br, int w, int h);
void tickItemDrop(); void renderSlot(int slot, int x, int y, float a);
float cubeSmoothStep(float percentage, float min, float max); void tickItemDrop();
public: float cubeSmoothStep(float percentage, float min, float max);
float progress = 0.f; public:
std::string selectedName; float progress;
static float InvGuiScale; std::string selectedName;
static float GuiScale; static float InvGuiScale;
static float GuiScale;
private:
//ItemRenderer itemRenderer; private:
GuiMessageList guiMessages; int MAX_MESSAGE_WIDTH;
int chatScrollOffset = 0; //ItemRenderer itemRenderer;
Random random; GuiMessageList guiMessages;
int chatScrollOffset;
MinecraftClient& minecraft; Random random;
int tickCount = 0;
float itemNameOverlayTime = 2; Minecraft* minecraft;
std::string overlayMessageString; int tickCount;
int overlayMessageTime = 0; float itemNameOverlayTime;
bool animateOverlayMessageColor = false; std::string overlayMessageString;
int overlayMessageTime;
float tbr = 1.f; bool animateOverlayMessageColor;
RenderChunk _inventoryRc; float tbr;
bool _inventoryNeedsUpdate = true;
RenderChunk _inventoryRc;
int _flashSlotId = -1; bool _inventoryNeedsUpdate;
float _flashSlotStartTime = -1;
int _flashSlotId;
Font* _slotFont = nullptr; float _flashSlotStartTime;
int _numSlots = 4;
Font* _slotFont;
RenderChunk rcFeedbackOuter; int _numSlots;
RenderChunk rcFeedbackInner;
RenderChunk rcFeedbackOuter;
// For dropping RenderChunk rcFeedbackInner;
static const float DropTicks;
float _currentDropTicks = -1; // For dropping
int _currentDropSlot = -1; static const float DropTicks;
float _currentDropTicks;
bool _openInventorySlot; int _currentDropSlot;
int maxMessageWidth = 240; bool _openInventorySlot;
}; };
#endif /*NET_MINECRAFT_CLIENT_GUI__Gui_H__*/

View File

@@ -1,156 +1,156 @@
#include "GuiComponent.hpp" #include "GuiComponent.h"
#include "client/renderer/Tesselator.hpp" #include "../renderer/Tesselator.h"
#include "client/renderer/gles.hpp" #include "../renderer/gles.h"
#include "Font.hpp" #include "Font.h"
GuiComponent::GuiComponent() GuiComponent::GuiComponent()
: blitOffset(0) : blitOffset(0)
{ {
} }
GuiComponent::~GuiComponent() GuiComponent::~GuiComponent()
{ {
} }
void GuiComponent::drawCenteredString( Font& font, const std::string& str, int x, int y, int color ) void GuiComponent::drawCenteredString( Font* font, const std::string& str, int x, int y, int color )
{ {
font.drawShadow(str, (float)(x - font.width(str) / 2), (float)(y - font.height(str) / 2), color); font->drawShadow(str, (float)(x - font->width(str) / 2), (float)(y - font->height(str) / 2), color);
} }
void GuiComponent::drawString( Font& font, const std::string& str, int x, int y, int color ) void GuiComponent::drawString( Font* font, const std::string& str, int x, int y, int color )
{ {
font.drawShadow(str, (float)x, (float)y /*- font.height(str)/2*/, color); font->drawShadow(str, (float)x, (float)y /*- font->height(str)/2*/, color);
} }
void GuiComponent::blit( int x, int y, int sx, int sy, int w, int h, int sw/*=0*/, int sh/*=0*/ ) void GuiComponent::blit( int x, int y, int sx, int sy, int w, int h, int sw/*=0*/, int sh/*=0*/ )
{ {
if (!sw) sw = w; if (!sw) sw = w;
if (!sh) sh = h; if (!sh) sh = h;
float us = 1 / 256.0f; float us = 1 / 256.0f;
float vs = 1 / 256.0f; float vs = 1 / 256.0f;
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
t.begin(); t.begin();
t.vertexUV((float)(x) , (float)(y + h), blitOffset, (float)(sx ) * us, (float)(sy + sh) * vs); t.vertexUV((float)(x) , (float)(y + h), blitOffset, (float)(sx ) * us, (float)(sy + sh) * vs);
t.vertexUV((float)(x + w), (float)(y + h), blitOffset, (float)(sx + sw) * us, (float)(sy + sh) * vs); t.vertexUV((float)(x + w), (float)(y + h), blitOffset, (float)(sx + sw) * us, (float)(sy + sh) * vs);
t.vertexUV((float)(x + w), (float)(y) , blitOffset, (float)(sx + sw) * us, (float)(sy ) * vs); t.vertexUV((float)(x + w), (float)(y) , blitOffset, (float)(sx + sw) * us, (float)(sy ) * vs);
t.vertexUV((float)(x) , (float)(y) , blitOffset, (float)(sx ) * us, (float)(sy ) * vs); t.vertexUV((float)(x) , (float)(y) , blitOffset, (float)(sx ) * us, (float)(sy ) * vs);
t.draw(); t.draw();
} }
void GuiComponent::blit( float x, float y, int sx, int sy, float w, float h, int sw/*=0*/, int sh/*=0*/ ) void GuiComponent::blit( float x, float y, int sx, int sy, float w, float h, int sw/*=0*/, int sh/*=0*/ )
{ {
if (!sw) sw = (int)w; if (!sw) sw = (int)w;
if (!sh) sh = (int)h; if (!sh) sh = (int)h;
float us = 1 / 256.0f; float us = 1 / 256.0f;
float vs = 1 / 256.0f; float vs = 1 / 256.0f;
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
t.begin(); t.begin();
t.vertexUV(x , y + h, blitOffset, (float)(sx ) * us, (float)(sy + sh) * vs); t.vertexUV(x , y + h, blitOffset, (float)(sx ) * us, (float)(sy + sh) * vs);
t.vertexUV(x + w, y + h, blitOffset, (float)(sx + sw) * us, (float)(sy + sh) * vs); t.vertexUV(x + w, y + h, blitOffset, (float)(sx + sw) * us, (float)(sy + sh) * vs);
t.vertexUV(x + w, y , blitOffset, (float)(sx + sw) * us, (float)(sy ) * vs); t.vertexUV(x + w, y , blitOffset, (float)(sx + sw) * us, (float)(sy ) * vs);
t.vertexUV(x , y , blitOffset, (float)(sx ) * us, (float)(sy ) * vs); t.vertexUV(x , y , blitOffset, (float)(sx ) * us, (float)(sy ) * vs);
t.draw(); t.draw();
} }
void GuiComponent::fill( int x0, int y0, int x1, int y1, int col ) { void GuiComponent::fill( int x0, int y0, int x1, int y1, int col ) {
fill((float)x0, (float)y0, (float)x1, (float)y1, col); fill((float)x0, (float)y0, (float)x1, (float)y1, col);
} }
void GuiComponent::fill( float x0, float y0, float x1, float y1, int col ) void GuiComponent::fill( float x0, float y0, float x1, float y1, int col )
{ {
//float a = ((col >> 24) & 0xff) / 255.0f; //float a = ((col >> 24) & 0xff) / 255.0f;
//float r = ((col >> 16) & 0xff) / 255.0f; //float r = ((col >> 16) & 0xff) / 255.0f;
//float g = ((col >> 8) & 0xff) / 255.0f; //float g = ((col >> 8) & 0xff) / 255.0f;
//float b = ((col) & 0xff) / 255.0f; //float b = ((col) & 0xff) / 255.0f;
//glColor4f2(r, g, b, a); //glColor4f2(r, g, b, a);
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
glEnable2(GL_BLEND); glEnable2(GL_BLEND);
glDisable2(GL_TEXTURE_2D); glDisable2(GL_TEXTURE_2D);
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//LOGI("col: %f, %f, %f, %f\n", r, g, b, a); //LOGI("col: %f, %f, %f, %f\n", r, g, b, a);
t.begin(); t.begin();
const int color = (col&0xff00ff00) | ((col&0xff0000) >> 16) | ((col&0xff) << 16); const int color = (col&0xff00ff00) | ((col&0xff0000) >> 16) | ((col&0xff) << 16);
t.colorABGR(color); t.colorABGR(color);
t.vertex(x0, y1, 0); t.vertex(x0, y1, 0);
t.vertex(x1, y1, 0); t.vertex(x1, y1, 0);
t.vertex(x1, y0, 0); t.vertex(x1, y0, 0);
t.vertex(x0, y0, 0); t.vertex(x0, y0, 0);
t.draw(); t.draw();
glEnable2(GL_TEXTURE_2D); glEnable2(GL_TEXTURE_2D);
glDisable2(GL_BLEND); glDisable2(GL_BLEND);
} }
void GuiComponent::fillGradient( int x0, int y0, int x1, int y1, int col1, int col2 ) { void GuiComponent::fillGradient( int x0, int y0, int x1, int y1, int col1, int col2 ) {
fillGradient((float)x0, (float)y0, (float)x1, (float)y1, col1, col2); fillGradient((float)x0, (float)y0, (float)x1, (float)y1, col1, col2);
} }
void GuiComponent::fillGradient( float x0, float y0, float x1, float y1, int col1, int col2 ) void GuiComponent::fillGradient( float x0, float y0, float x1, float y1, int col1, int col2 )
{ {
float a1 = ((col1 >> 24) & 0xff) / 255.0f; float a1 = ((col1 >> 24) & 0xff) / 255.0f;
float r1 = ((col1 >> 16) & 0xff) / 255.0f; float r1 = ((col1 >> 16) & 0xff) / 255.0f;
float g1 = ((col1 >> 8) & 0xff) / 255.0f; float g1 = ((col1 >> 8) & 0xff) / 255.0f;
float b1 = ((col1) & 0xff) / 255.0f; float b1 = ((col1) & 0xff) / 255.0f;
float a2 = ((col2 >> 24) & 0xff) / 255.0f; float a2 = ((col2 >> 24) & 0xff) / 255.0f;
float r2 = ((col2 >> 16) & 0xff) / 255.0f; float r2 = ((col2 >> 16) & 0xff) / 255.0f;
float g2 = ((col2 >> 8) & 0xff) / 255.0f; float g2 = ((col2 >> 8) & 0xff) / 255.0f;
float b2 = ((col2) & 0xff) / 255.0f; float b2 = ((col2) & 0xff) / 255.0f;
glDisable2(GL_TEXTURE_2D); glDisable2(GL_TEXTURE_2D);
glEnable2(GL_BLEND); glEnable2(GL_BLEND);
glDisable2(GL_ALPHA_TEST); glDisable2(GL_ALPHA_TEST);
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel2(GL_SMOOTH); glShadeModel2(GL_SMOOTH);
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
t.begin(); t.begin();
t.color(r1, g1, b1, a1); t.color(r1, g1, b1, a1);
t.vertex(x1, y0, 0); t.vertex(x1, y0, 0);
t.vertex(x0, y0, 0); t.vertex(x0, y0, 0);
t.color(r2, g2, b2, a2); t.color(r2, g2, b2, a2);
t.vertex(x0, y1, 0); t.vertex(x0, y1, 0);
t.vertex(x1, y1, 0); t.vertex(x1, y1, 0);
t.draw(); t.draw();
glShadeModel2(GL_FLAT); glShadeModel2(GL_FLAT);
glDisable2(GL_BLEND); glDisable2(GL_BLEND);
glEnable2(GL_ALPHA_TEST); glEnable2(GL_ALPHA_TEST);
glEnable2(GL_TEXTURE_2D); glEnable2(GL_TEXTURE_2D);
} }
void GuiComponent::fillHorizontalGradient( int x0, int y0, int x1, int y1, int col1, int col2 ) { void GuiComponent::fillHorizontalGradient( int x0, int y0, int x1, int y1, int col1, int col2 ) {
fillHorizontalGradient((float)x0, (float)y0, (float)x1, (float)y1, col1, col2); fillHorizontalGradient((float)x0, (float)y0, (float)x1, (float)y1, col1, col2);
} }
void GuiComponent::fillHorizontalGradient( float x0, float y0, float x1, float y1, int col1, int col2 ) void GuiComponent::fillHorizontalGradient( float x0, float y0, float x1, float y1, int col1, int col2 )
{ {
float a1 = ((col1 >> 24) & 0xff) / 255.0f; float a1 = ((col1 >> 24) & 0xff) / 255.0f;
float r1 = ((col1 >> 16) & 0xff) / 255.0f; float r1 = ((col1 >> 16) & 0xff) / 255.0f;
float g1 = ((col1 >> 8) & 0xff) / 255.0f; float g1 = ((col1 >> 8) & 0xff) / 255.0f;
float b1 = ((col1) & 0xff) / 255.0f; float b1 = ((col1) & 0xff) / 255.0f;
float a2 = ((col2 >> 24) & 0xff) / 255.0f; float a2 = ((col2 >> 24) & 0xff) / 255.0f;
float r2 = ((col2 >> 16) & 0xff) / 255.0f; float r2 = ((col2 >> 16) & 0xff) / 255.0f;
float g2 = ((col2 >> 8) & 0xff) / 255.0f; float g2 = ((col2 >> 8) & 0xff) / 255.0f;
float b2 = ((col2) & 0xff) / 255.0f; float b2 = ((col2) & 0xff) / 255.0f;
glDisable2(GL_TEXTURE_2D); glDisable2(GL_TEXTURE_2D);
glEnable2(GL_BLEND); glEnable2(GL_BLEND);
glDisable2(GL_ALPHA_TEST); glDisable2(GL_ALPHA_TEST);
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glShadeModel2(GL_SMOOTH); glShadeModel2(GL_SMOOTH);
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
t.begin(); t.begin();
t.color(r2, g2, b2, a2); t.color(r2, g2, b2, a2);
t.vertex(x1, y0, 0); t.vertex(x1, y0, 0);
t.color(r1, g1, b1, a1); t.color(r1, g1, b1, a1);
t.vertex(x0, y0, 0); t.vertex(x0, y0, 0);
t.color(r1, g1, b1, a1); t.color(r1, g1, b1, a1);
t.vertex(x0, y1, 0); t.vertex(x0, y1, 0);
t.color(r2, g2, b2, a2); t.color(r2, g2, b2, a2);
t.vertex(x1, y1, 0); t.vertex(x1, y1, 0);
t.draw(); t.draw();
glShadeModel2(GL_FLAT); glShadeModel2(GL_FLAT);
glDisable2(GL_BLEND); glDisable2(GL_BLEND);
glEnable2(GL_ALPHA_TEST); glEnable2(GL_ALPHA_TEST);
glEnable2(GL_TEXTURE_2D); glEnable2(GL_TEXTURE_2D);
} }

View File

@@ -1,30 +1,34 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT_GUI__GuiComponent_H__
#define NET_MINECRAFT_CLIENT_GUI__GuiComponent_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include <string>
class Font; #include <string>
class Font;
class GuiComponent class Minecraft;
{
public: class GuiComponent
GuiComponent(); {
virtual ~GuiComponent(); public:
GuiComponent();
void drawString(Font& font, const std::string& str, int x, int y, int color); virtual ~GuiComponent();
void drawCenteredString(Font& font, const std::string& str, int x, int y, int color);
void drawString(Font* font, const std::string& str, int x, int y, int color);
void blit(int x, int y, int sx, int sy, int w, int h, int sw=0, int sh=0); void drawCenteredString(Font* font, const std::string& str, int x, int y, int color);
void blit(float x, float y, int sx, int sy, float w, float h, int sw=0, int sh=0);
void blit(int x, int y, int sx, int sy, int w, int h, int sw=0, int sh=0);
protected: void blit(float x, float y, int sx, int sy, float w, float h, int sw=0, int sh=0);
void fill(int x0, int y0, int x1, int y1, int col);
void fill(float x0, float y0, float x1, float y1, int col); protected:
void fillGradient(int x0, int y0, int x1, int y1, int col1, int col2); void fill(int x0, int y0, int x1, int y1, int col);
void fillGradient(float x0, float y0, float x1, float y1, int col1, int col2); void fill(float x0, float y0, float x1, float y1, int col);
void fillHorizontalGradient(int x0, int y0, int x1, int y1, int col1, int col2); void fillGradient(int x0, int y0, int x1, int y1, int col1, int col2);
void fillHorizontalGradient(float x0, float y0, float x1, float y1, int col1, int col2); void fillGradient(float x0, float y0, float x1, float y1, int col1, int col2);
void fillHorizontalGradient(int x0, int y0, int x1, int y1, int col1, int col2);
float blitOffset; void fillHorizontalGradient(float x0, float y0, float x1, float y1, int col1, int col2);
};
float blitOffset;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__GuiComponent_H__*/

View File

@@ -1,291 +1,291 @@
#include "Screen.hpp" #include "Screen.h"
#include "components/Button.hpp" #include "components/Button.h"
#include "components/TextBox.hpp" #include "components/TextBox.h"
#include <Minecraft.hpp> #include "../Minecraft.h"
#include "client/renderer/Tesselator.hpp" #include "../renderer/Tesselator.h"
#include "client/sound/SoundEngine.hpp" #include "../sound/SoundEngine.h"
#include "platform/input/Keyboard.hpp" #include "../../platform/input/Keyboard.h"
#include "platform/input/Mouse.hpp" #include "../../platform/input/Mouse.h"
#include "client/renderer/Textures.hpp" #include "../renderer/Textures.h"
#include <MinecraftClient.hpp>
Screen::Screen()
Screen::Screen(MinecraftClient& minecraft) : passEvents(false),
: passEvents(false), clickedButton(NULL),
clickedButton(NULL), tabButtonIndex(0),
tabButtonIndex(0), width(1),
width(1), height(1),
height(1), minecraft(NULL),
minecraft(minecraft), font(NULL)
font(NULL) {
{ }
}
void Screen::render( int xm, int ym, float a )
void Screen::render( int xm, int ym, float a ) {
{ for (unsigned int i = 0; i < buttons.size(); i++) {
for (unsigned int i = 0; i < buttons.size(); i++) { Button* button = buttons[i];
Button* button = buttons[i]; button->render(minecraft, xm, ym);
button->render(minecraft, xm, ym); }
}
// render any text boxes after buttons
// render any text boxes after buttons for (unsigned int i = 0; i < textBoxes.size(); i++) {
for (unsigned int i = 0; i < textBoxes.size(); i++) { TextBox* textbox = textBoxes[i];
TextBox* textbox = textBoxes[i]; textbox->render(minecraft, xm, ym);
textbox->render(minecraft, xm, ym); }
} }
}
void Screen::init( Minecraft* minecraft, int width, int height )
void Screen::init(int width, int height) {
{ //particles = /*new*/ GuiParticles(minecraft);
//particles = /*new*/ GuiParticles(minecraft); this->minecraft = minecraft;
this->font = minecraft.font(); this->font = minecraft->font;
this->width = width; this->width = width;
this->height = height; this->height = height;
init(); init();
setupPositions(); setupPositions();
updateTabButtonSelection(); updateTabButtonSelection();
} }
void Screen::init() void Screen::init()
{ {
} }
void Screen::setSize( int width, int height ) void Screen::setSize( int width, int height )
{ {
this->width = width; this->width = width;
this->height = height; this->height = height;
setupPositions(); setupPositions();
} }
bool Screen::handleBackEvent( bool isDown ) bool Screen::handleBackEvent( bool isDown )
{ {
return false; return false;
} }
void Screen::updateEvents() void Screen::updateEvents()
{ {
if (passEvents) if (passEvents)
return; return;
while (Mouse::next()) while (Mouse::next())
mouseEvent(); mouseEvent();
while (Keyboard::next()) while (Keyboard::next())
keyboardEvent(); keyboardEvent();
while (Keyboard::nextTextChar()) while (Keyboard::nextTextChar())
keyboardTextEvent(); keyboardTextEvent();
} }
void Screen::mouseEvent() void Screen::mouseEvent()
{ {
const MouseAction& e = Mouse::getEvent(); const MouseAction& e = Mouse::getEvent();
// forward wheel events to subclasses // forward wheel events to subclasses
if (e.action == MouseAction::ACTION_WHEEL) { if (e.action == MouseAction::ACTION_WHEEL) {
int xm = e.x * width / minecraft.getScreenWidth(); int xm = e.x * width / minecraft->width;
int ym = e.y * height / minecraft.getScreenHeight() - 1; int ym = e.y * height / minecraft->height - 1;
mouseWheel(e.dx, e.dy, xm, ym); mouseWheel(e.dx, e.dy, xm, ym);
return; return;
} }
if (!e.isButton()) if (!e.isButton())
return; return;
if (Mouse::getEventButtonState()) { if (Mouse::getEventButtonState()) {
int xm = e.x * width / minecraft.getScreenWidth(); int xm = e.x * width / minecraft->width;
int ym = e.y * height / minecraft.getScreenHeight() - 1; int ym = e.y * height / minecraft->height - 1;
mouseClicked(xm, ym, Mouse::getEventButton()); mouseClicked(xm, ym, Mouse::getEventButton());
} else { } else {
int xm = e.x * width / minecraft.getScreenWidth(); int xm = e.x * width / minecraft->width;
int ym = e.y * height / minecraft.getScreenHeight() - 1; int ym = e.y * height / minecraft->height - 1;
mouseReleased(xm, ym, Mouse::getEventButton()); mouseReleased(xm, ym, Mouse::getEventButton());
} }
} }
void Screen::keyboardEvent() void Screen::keyboardEvent()
{ {
if (Keyboard::getEventKeyState()) { if (Keyboard::getEventKeyState()) {
//if (Keyboard.getEventKey() == Keyboard.KEY_F11) { //if (Keyboard.getEventKey() == Keyboard.KEY_F11) {
// minecraft.toggleFullScreen(); // minecraft->toggleFullScreen();
// return; // return;
//} //}
keyPressed(Keyboard::getEventKey()); keyPressed(Keyboard::getEventKey());
} }
} }
void Screen::keyboardTextEvent() void Screen::keyboardTextEvent()
{ {
charPressed(Keyboard::getChar()); charPressed(Keyboard::getChar());
} }
void Screen::renderBackground() void Screen::renderBackground()
{ {
renderBackground(0); renderBackground(0);
} }
void Screen::renderBackground( int vo ) void Screen::renderBackground( int vo )
{ {
if (minecraft.isLevelGenerated()) { if (minecraft->isLevelGenerated()) {
fillGradient(0, 0, width, height, 0xc0101010, 0xd0101010); fillGradient(0, 0, width, height, 0xc0101010, 0xd0101010);
} else { } else {
renderDirtBackground(vo); renderDirtBackground(vo);
} }
} }
void Screen::renderDirtBackground( int vo ) void Screen::renderDirtBackground( int vo )
{ {
//glDisable2(GL_LIGHTING); //glDisable2(GL_LIGHTING);
glDisable2(GL_FOG); glDisable2(GL_FOG);
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
minecraft.textures().loadAndBindTexture("gui/background.png"); minecraft->textures->loadAndBindTexture("gui/background.png");
glColor4f2(1, 1, 1, 1); glColor4f2(1, 1, 1, 1);
float s = 32; float s = 32;
float fvo = (float) vo; float fvo = (float) vo;
t.begin(); t.begin();
t.color(0x404040); t.color(0x404040);
t.vertexUV(0, (float)height, 0, 0, height / s + fvo); t.vertexUV(0, (float)height, 0, 0, height / s + fvo);
t.vertexUV((float)width, (float)height, 0, width / s, (float)height / s + fvo); t.vertexUV((float)width, (float)height, 0, width / s, (float)height / s + fvo);
t.vertexUV((float)width, 0, 0, (float)width / s, 0 + fvo); t.vertexUV((float)width, 0, 0, (float)width / s, 0 + fvo);
t.vertexUV(0, 0, 0, 0, 0 + fvo); t.vertexUV(0, 0, 0, 0, 0 + fvo);
t.draw(); t.draw();
} }
bool Screen::isPauseScreen() bool Screen::isPauseScreen()
{ {
return true; return true;
} }
bool Screen::isErrorScreen() bool Screen::isErrorScreen()
{ {
return false; return false;
} }
bool Screen::isInGameScreen() bool Screen::isInGameScreen()
{ {
return true; return true;
} }
bool Screen::closeOnPlayerHurt() { bool Screen::closeOnPlayerHurt() {
return false; return false;
} }
void Screen::keyPressed( int eventKey ) void Screen::keyPressed( int eventKey )
{ {
if (eventKey == Keyboard::KEY_ESCAPE) { if (eventKey == Keyboard::KEY_ESCAPE) {
minecraft.setScreen(NULL); minecraft->setScreen(NULL);
//minecraft.grabMouse(); //minecraft->grabMouse();
} }
// pass key events to any text boxes first // pass key events to any text boxes first
for (auto& textbox : textBoxes) { for (auto& textbox : textBoxes) {
textbox->keyPressed(minecraft, eventKey); textbox->keyPressed(minecraft, eventKey);
} }
#ifdef TABBING #ifdef TABBING
if (minecraft.useTouchscreen()) if (minecraft->useTouchscreen())
return; return;
// "Tabbing" the buttons (walking with keys) // "Tabbing" the buttons (walking with keys)
const int tabButtonCount = tabButtons.size(); const int tabButtonCount = tabButtons.size();
if (!tabButtonCount) if (!tabButtonCount)
return; return;
Options& o = minecraft.options; Options& o = minecraft->options;
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_NEXT)) if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_NEXT))
if (++tabButtonIndex == tabButtonCount) tabButtonIndex = 0; if (++tabButtonIndex == tabButtonCount) tabButtonIndex = 0;
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_PREV)) if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_PREV))
if (--tabButtonIndex == -1) tabButtonIndex = tabButtonCount-1; if (--tabButtonIndex == -1) tabButtonIndex = tabButtonCount-1;
if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_OK)) { if (eventKey == o.getIntValue(OPTIONS_KEY_MENU_OK)) {
Button* button = tabButtons[tabButtonIndex]; Button* button = tabButtons[tabButtonIndex];
if (button->active) { if (button->active) {
minecraft.soundEngine()->playUI("random.click", 1, 1); minecraft->soundEngine->playUI("random.click", 1, 1);
buttonClicked(button); buttonClicked(button);
} }
} }
updateTabButtonSelection(); updateTabButtonSelection();
#endif #endif
} }
void Screen::charPressed(char inputChar) { void Screen::charPressed(char inputChar) {
for (auto& textbox : textBoxes) { for (auto& textbox : textBoxes) {
textbox->charPressed(minecraft, inputChar); textbox->charPressed(minecraft, inputChar);
} }
} }
void Screen::updateTabButtonSelection() void Screen::updateTabButtonSelection()
{ {
#ifdef TABBING #ifdef TABBING
if (minecraft.useTouchscreen()) if (minecraft->useTouchscreen())
return; return;
for (unsigned int i = 0; i < tabButtons.size(); ++i) for (unsigned int i = 0; i < tabButtons.size(); ++i)
tabButtons[i]->selected = (i == tabButtonIndex); tabButtons[i]->selected = (i == tabButtonIndex);
#endif #endif
} }
void Screen::mouseClicked( int x, int y, int buttonNum ) void Screen::mouseClicked( int x, int y, int buttonNum )
{ {
if (buttonNum == MouseAction::ACTION_LEFT) { if (buttonNum == MouseAction::ACTION_LEFT) {
for (unsigned int i = 0; i < buttons.size(); ++i) { for (unsigned int i = 0; i < buttons.size(); ++i) {
Button* button = buttons[i]; Button* button = buttons[i];
//LOGI("Hit-testing button: %p\n", button); //LOGI("Hit-testing button: %p\n", button);
if (button->clicked(minecraft, x, y)) { if (button->clicked(minecraft, x, y)) {
button->setPressed(); button->setPressed();
//LOGI("Hit-test successful: %p\n", button); //LOGI("Hit-test successful: %p\n", button);
clickedButton = button; clickedButton = button;
/* /*
#if !defined(ANDROID) && !defined(__APPLE__) //if (!minecraft.isTouchscreen()) { #if !defined(ANDROID) && !defined(__APPLE__) //if (!minecraft->isTouchscreen()) {
minecraft.soundEngine()->playUI("random.click", 1, 1); minecraft->soundEngine->playUI("random.click", 1, 1);
buttonClicked(button); buttonClicked(button);
#endif } #endif }
*/ */
} }
} }
} }
// let textboxes see the click regardless // let textboxes see the click regardless
for (auto& textbox : textBoxes) { for (auto& textbox : textBoxes) {
textbox->mouseClicked(minecraft, x, y, buttonNum); textbox->mouseClicked(minecraft, x, y, buttonNum);
} }
} }
void Screen::mouseReleased( int x, int y, int buttonNum ) void Screen::mouseReleased( int x, int y, int buttonNum )
{ {
//LOGI("b_id: %d, (%p), text: %s\n", buttonNum, clickedButton, clickedButton?clickedButton->msg.c_str():"<null>"); //LOGI("b_id: %d, (%p), text: %s\n", buttonNum, clickedButton, clickedButton?clickedButton->msg.c_str():"<null>");
if (!clickedButton || buttonNum != MouseAction::ACTION_LEFT) return; if (!clickedButton || buttonNum != MouseAction::ACTION_LEFT) return;
#if 1 #if 1
//#if defined(ANDROID) || defined(__APPLE__) //if (minecraft.isTouchscreen()) { //#if defined(ANDROID) || defined(__APPLE__) //if (minecraft->isTouchscreen()) {
for (unsigned int i = 0; i < buttons.size(); ++i) { for (unsigned int i = 0; i < buttons.size(); ++i) {
Button* button = buttons[i]; Button* button = buttons[i];
if (clickedButton == button && button->clicked(minecraft, x, y)) { if (clickedButton == button && button->clicked(minecraft, x, y)) {
buttonClicked(button); buttonClicked(button);
minecraft.soundEngine()->playUI("random.click", 1, 1); minecraft->soundEngine->playUI("random.click", 1, 1);
clickedButton->released(x, y); clickedButton->released(x, y);
} }
} }
# else // } else { # else // } else {
clickedButton->released(x, y); clickedButton->released(x, y);
#endif // } #endif // }
clickedButton = NULL; clickedButton = NULL;
} }
bool Screen::renderGameBehind() { bool Screen::renderGameBehind() {
return true; return true;
} }
bool Screen::hasClippingArea( IntRectangle& out ) bool Screen::hasClippingArea( IntRectangle& out )
{ {
return false; return false;
} }
void Screen::lostFocus() { void Screen::lostFocus() {
for(auto it = textBoxes.begin(); it != textBoxes.end(); ++it) { for(std::vector<TextBox*>::iterator it = textBoxes.begin(); it != textBoxes.end(); ++it) {
TextBox* tb = *it; TextBox* tb = *it;
tb->loseFocus(minecraft); tb->loseFocus(minecraft);
} }
} }
void Screen::toGUICoordinate( int& x, int& y ) { void Screen::toGUICoordinate( int& x, int& y ) {
x = x * width / minecraft.getScreenWidth(); x = x * width / minecraft->width;
y = y * height / minecraft.getScreenHeight() - 1; y = y * height / minecraft->height - 1;
} }

View File

@@ -1,81 +1,83 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT_GUI__Screen_H__
#define NET_MINECRAFT_CLIENT_GUI__Screen_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include <vector>
#include "GuiComponent.hpp" #include <vector>
#include "GuiComponent.h"
class Font;
class MinecraftClient; class Font;
class Button; class Minecraft;
class TextBox; class Button;
struct IntRectangle; class TextBox;
struct IntRectangle;
class Screen: public GuiComponent
{ class Screen: public GuiComponent
public: {
Screen(MinecraftClient& minecraft); public:
Screen();
virtual void render(int xm, int ym, float a);
virtual void render(int xm, int ym, float a);
void init(int width, int height);
virtual void init(); void init(Minecraft* minecraft, int width, int height);
virtual void init();
void setSize(int width, int height);
virtual void setupPositions() {}; void setSize(int width, int height);
virtual void setupPositions() {};
virtual void updateEvents();
virtual void mouseEvent(); virtual void updateEvents();
virtual void keyboardEvent(); virtual void mouseEvent();
virtual void keyboardTextEvent(); virtual void keyboardEvent();
virtual bool handleBackEvent(bool isDown); virtual void keyboardTextEvent();
virtual bool handleBackEvent(bool isDown);
virtual void tick() {}
virtual void tick() {}
virtual void removed() {}
virtual void removed() {}
virtual void renderBackground();
virtual void renderBackground(int vo); virtual void renderBackground();
virtual void renderDirtBackground(int vo); virtual void renderBackground(int vo);
// query virtual void renderDirtBackground(int vo);
virtual bool renderGameBehind(); // query
virtual bool hasClippingArea(IntRectangle& out); virtual bool renderGameBehind();
virtual bool hasClippingArea(IntRectangle& out);
virtual bool isPauseScreen();
virtual bool isErrorScreen(); virtual bool isPauseScreen();
virtual bool isInGameScreen(); virtual bool isErrorScreen();
virtual bool closeOnPlayerHurt(); virtual bool isInGameScreen();
virtual bool closeOnPlayerHurt();
virtual void confirmResult(bool result, int id) {}
virtual void lostFocus(); virtual void confirmResult(bool result, int id) {}
virtual void toGUICoordinate(int& x, int& y); virtual void lostFocus();
protected: virtual void toGUICoordinate(int& x, int& y);
void updateTabButtonSelection(); protected:
void updateTabButtonSelection();
virtual void buttonClicked(Button* button) {}
virtual void mouseClicked(int x, int y, int buttonNum); virtual void buttonClicked(Button* button) {}
virtual void mouseReleased(int x, int y, int buttonNum); virtual void mouseClicked(int x, int y, int buttonNum);
virtual void mouseReleased(int x, int y, int buttonNum);
// mouse wheel movement (dx/dy are wheel deltas, xm/ym are GUI coords)
virtual void mouseWheel(int dx, int dy, int xm, int ym) {} // mouse wheel movement (dx/dy are wheel deltas, xm/ym are GUI coords)
virtual void mouseWheel(int dx, int dy, int xm, int ym) {}
virtual void keyPressed(int eventKey);
virtual void charPressed(char inputChar); virtual void keyPressed(int eventKey);
public: virtual void charPressed(char inputChar);
int width; public:
int height; int width;
bool passEvents; int height;
//GuiParticles* particles; bool passEvents;
protected: //GuiParticles* particles;
MinecraftClient& minecraft; protected:
std::vector<Button*> buttons; Minecraft* minecraft;
std::vector<TextBox*> textBoxes; std::vector<Button*> buttons;
std::vector<TextBox*> textBoxes;
std::vector<Button*> tabButtons;
int tabButtonIndex; std::vector<Button*> tabButtons;
int tabButtonIndex;
Font* font;
private: Font* font;
Button* clickedButton; private:
}; Button* clickedButton;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__Screen_H__*/

11
src/client/gui/TweenData.h Executable file
View File

@@ -0,0 +1,11 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__TweenData_H__
#define NET_MINECRAFT_CLIENT_GUI__TweenData_H__
typedef struct TweenData {
float cur;
float dur;
float start;
float stop;
} TweenData;
#endif /*NET_MINECRAFT_CLIENT_GUI__TweenData_H__*/

View File

@@ -1,9 +0,0 @@
#pragma once
typedef struct TweenData {
float cur;
float dur;
float start;
float stop;
} TweenData;

View File

@@ -1,228 +1,219 @@
#include "Button.hpp" #include "Button.h"
#include <MinecraftClient.hpp> #include "../../Minecraft.h"
#include <cstddef> #include "../../renderer/Textures.h"
#include "client/renderer/Textures.hpp"
Button::Button(int id, const std::string& msg)
Button::Button(int id, const std::string& msg) : GuiElement(true, true, 0, 0, 200, 24),
: GuiElement(true, true, 0, 0, 200, 24), id(id),
id(id), msg(msg),
msg(msg), selected(false),
selected(false), _currentlyDown(false)
_currentlyDown(false) {
{ }
}
Button::Button( int id, int x, int y, const std::string& msg )
Button::Button( int id, int x, int y, const std::string& msg ) : GuiElement(true, true, x, y, 200, 24),
: GuiElement(true, true, x, y, 200, 24), id(id),
id(id), msg(msg),
msg(msg), selected(false),
selected(false), _currentlyDown(false)
_currentlyDown(false) {
{ }
}
Button::Button( int id, int x, int y, int w, int h, const std::string& msg )
Button::Button( int id, int x, int y, int w, int h, const std::string& msg ) : GuiElement(true, true, x, y, w, h),
: GuiElement(true, true, x, y, w, h), id(id),
id(id), msg(msg),
msg(msg), selected(false),
selected(false), _currentlyDown(false)
_currentlyDown(false) {
{ }
}
void Button::render( Minecraft* minecraft, int xm, int ym )
void Button::render( MinecraftClient& minecraft, int xm, int ym ) {
{ if (!visible) return;
if (!visible) return;
/*
/* minecraft->textures->loadAndBindTexture("gui/gui.png");
minecraft.textures().loadAndBindTexture("gui/gui.png"); glColor4f2(1, 1, 1, 1);
glColor4f2(1, 1, 1, 1);
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym); int yImage = getYImage(hovered || selected);
int yImage = getYImage(hovered || selected);
blit(x, y, 0, 46 + yImage * 20, w / 2, h, 0, 20);
blit(x, y, 0, 46 + yImage * 20, w / 2, h, 0, 20); blit(x + w / 2, y, 200 - w / 2, 46 + yImage * 20, w / 2, h, 0, 20);
blit(x + w / 2, y, 200 - w / 2, 46 + yImage * 20, w / 2, h, 0, 20); */
*/
renderBg(minecraft, xm, ym);
renderBg(minecraft, xm, ym); renderFace(minecraft, xm , ym);
renderFace(minecraft, xm , ym); }
}
void Button::released( int mx, int my ) {
void Button::released( int mx, int my ) { _currentlyDown = false;
_currentlyDown = false; }
}
bool Button::clicked( Minecraft* minecraft, int mx, int my )
bool Button::clicked( MinecraftClient& minecraft, int mx, int my ) {
{ return active && mx >= x && my >= y && mx < x + width && my < y + height;
return active && mx >= x && my >= y && mx < x + width && my < y + height; }
}
void Button::setPressed() {
void Button::setPressed() { _currentlyDown = true;
_currentlyDown = true; }
}
int Button::getYImage( bool hovered )
int Button::getYImage( bool hovered ) {
{ int res = 1;
int res = 1; if (!active) res = 0;
if (!active) res = 0; else if (hovered) res = 2;
else if (hovered) res = 2; return res;
return res; }
}
void Button::renderFace(Minecraft* mc, int xm, int ym) {
void Button::renderFace(MinecraftClient& mc, int xm, int ym) { Font* font = mc->font;
Font* font = mc.font(); if (!active) {
drawCenteredString(font, msg, x + width / 2, y + (height - 8) / 2, 0xffa0a0a0);
if (font == nullptr) { } else {
return; if (hovered(mc, xm, ym) || selected) {
} drawCenteredString(font, msg, x + width / 2, y + (height - 8) / 2, 0xffffa0);
} else {
if (!active) { drawCenteredString(font, msg, x + width / 2, y + (height - 8) / 2, 0xe0e0e0);
drawCenteredString(*font, msg, x + width / 2, y + (height - 8) / 2, 0xffa0a0a0); }
} else { }
if (hovered(mc, xm, ym) || selected) { }
drawCenteredString(*font, msg, x + width / 2, y + (height - 8) / 2, 0xffffa0);
} else { void Button::renderBg( Minecraft* minecraft, int xm, int ym )
drawCenteredString(*font, msg, x + width / 2, y + (height - 8) / 2, 0xe0e0e0); {
} minecraft->textures->loadAndBindTexture("gui/gui.png");
} glColor4f2(1, 1, 1, 1);
}
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
void Button::renderBg( MinecraftClient& minecraft, int xm, int ym ) int yImage = getYImage(selected || hovered(minecraft, xm, ym));;
{
minecraft.textures().loadAndBindTexture("gui/gui.png"); blit(x, y, 0, 46 + yImage * 20, width / 2, height, 0, 20);
glColor4f2(1, 1, 1, 1); blit(x + width / 2, y, 200 - width / 2, 46 + yImage * 20, width / 2, height, 0, 20);
}
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
int yImage = getYImage(selected || hovered(minecraft, xm, ym));; bool Button::hovered(Minecraft* minecraft, int xm , int ym) {
return minecraft->useTouchscreen()? (_currentlyDown && isInside(xm, ym)) : isInside(xm, ym);
blit(x, y, 0, 46 + yImage * 20, width / 2, height, 0, 20); }
blit(x + width / 2, y, 200 - width / 2, 46 + yImage * 20, width / 2, height, 0, 20);
} bool Button::isInside( int xm, int ym ) {
return xm >= x && ym >= y && xm < x + width && ym < y + height;
bool Button::hovered(MinecraftClient& minecraft, int xm , int ym) { }
return minecraft.useTouchscreen()? (_currentlyDown && isInside(xm, ym)) : isInside(xm, ym);
} //
// BlankButton
bool Button::isInside( int xm, int ym ) { //
return xm >= x && ym >= y && xm < x + width && ym < y + height; BlankButton::BlankButton(int id)
} : super(id, "")
{
// visible = false;
// BlankButton }
//
BlankButton::BlankButton(int id) BlankButton::BlankButton(int id, int x, int y, int w, int h)
: super(id, "") : super(id, x, y, w, h, "")
{ {
visible = false; visible = false;
} }
BlankButton::BlankButton(int id, int x, int y, int w, int h) //
: super(id, x, y, w, h, "") // The Touch-interface button
{ //
visible = false; namespace Touch {
}
TButton::TButton(int id, const std::string& msg)
// : super(id, msg)
// The Touch-interface button {
// width = 66;
namespace Touch { height = 26;
}
TButton::TButton(int id, const std::string& msg)
: super(id, msg) TButton::TButton( int id, int x, int y, const std::string& msg )
{ : super(id, x, y, msg)
width = 66; {
height = 26; width = 66;
} height = 26;
}
TButton::TButton( int id, int x, int y, const std::string& msg )
: super(id, x, y, msg) TButton::TButton( int id, int x, int y, int w, int h, const std::string& msg )
{ : super(id, x, y, w, h, msg)
width = 66; {
height = 26; }
}
void TButton::renderBg( Minecraft* minecraft, int xm, int ym )
TButton::TButton( int id, int x, int y, int w, int h, const std::string& msg ) {
: super(id, x, y, w, h, msg) bool hovered = active && (minecraft->useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
{ // bool hovered = active && (_currentlyDown && isInside(xm, ym));
}
minecraft->textures->loadAndBindTexture("gui/touchgui.png");
void TButton::renderBg( MinecraftClient& minecraft, int xm, int ym )
{ //printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
bool hovered = active && (minecraft.useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym)); if (active)
// bool hovered = active && (_currentlyDown && isInside(xm, ym)); glColor4f2(1, 1, 1, 1);
else
minecraft.textures().loadAndBindTexture("gui/touchgui.png"); glColor4f2(0.5f, 0.5f, 0.5f, 1);
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym); blit(x, y, hovered?66:0, 0, width, height, 66, 26);
if (active) //blit(x + w / 2, y, 200 - w / 2, 46 + yImage * 20, w / 2, h, 0, 20);
glColor4f2(1, 1, 1, 1); }
else
glColor4f2(0.5f, 0.5f, 0.5f, 1);
//
blit(x, y, hovered?66:0, 0, width, height, 66, 26); // Header spacing in Touchscreen mode
//blit(x + w / 2, y, 200 - w / 2, 46 + yImage * 20, w / 2, h, 0, 20); //
} THeader::THeader(int id, const std::string& msg)
: super(id, msg),
xText(-99999)
// {
// Header spacing in Touchscreen mode active = false;
// width = 66;
THeader::THeader(int id, const std::string& msg) height = 26;
: super(id, msg), }
xText(-99999)
{ THeader::THeader( int id, int x, int y, const std::string& msg )
active = false; : super(id, x, y, msg),
width = 66; xText(-99999)
height = 26; {
} active = false;
width = 66;
THeader::THeader( int id, int x, int y, const std::string& msg ) height = 26;
: super(id, x, y, msg), }
xText(-99999)
{ THeader::THeader( int id, int x, int y, int w, int h, const std::string& msg )
active = false; : super(id, x, y, w, h, msg),
width = 66; xText(-99999)
height = 26; {
} active = false;
}
THeader::THeader( int id, int x, int y, int w, int h, const std::string& msg )
: super(id, x, y, w, h, msg), void THeader::render( Minecraft* minecraft, int xm, int ym ) {
xText(-99999) Font* font = minecraft->font;
{ renderBg(minecraft, xm, ym);
active = false;
} int xx = x + width/2;
if (xText != -99999)
void THeader::render( MinecraftClient& minecraft, int xm, int ym ) { xx = xText;
Font* font = minecraft.font(); drawCenteredString(font, msg, xx, y + (height - 8) / 2, 0xe0e0e0);
renderBg(minecraft, xm, ym); }
int xx = x + width/2; void THeader::renderBg( Minecraft* minecraft, int xm, int ym )
if (xText != -99999) {
xx = xText; minecraft->textures->loadAndBindTexture("gui/touchgui.png");
if (font != nullptr) { //printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
drawCenteredString(*font, msg, xx, y + (height - 8) / 2, 0xe0e0e0); glColor4f2(1, 1, 1, 1);
}
} // Left cap
blit(x, y, 150, 26, 2, height-1, 2, 25);
void THeader::renderBg( MinecraftClient& minecraft, int xm, int ym ) // Middle
{ blit(x+2, y, 153, 26, width-3, height-1, 8, 25);
minecraft.textures().loadAndBindTexture("gui/touchgui.png"); // Right cap
blit(x+width-2, y, 162, 26, 2, height-1, 2, 25);
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym); // Shadow
glColor4f2(1, 1, 1, 1); glEnable2(GL_BLEND);
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Left cap blit(x, y+height-1, 153, 52, width, 3, 8, 3);
blit(x, y, 150, 26, 2, height-1, 2, 25); }
// Middle
blit(x+2, y, 153, 26, width-3, height-1, 8, 25); };
// Right cap
blit(x+width-2, y, 162, 26, 2, height-1, 2, 25);
// Shadow
glEnable2(GL_BLEND);
glBlendFunc2(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
blit(x, y+height-1, 153, 52, width, 3, 8, 3);
}
};

View File

@@ -1,78 +1,80 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Button_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Button_H__
//package net.minecraft.client.gui;
//package net.minecraft.client.gui;
#include <string>
#include "GuiElement.hpp" #include <string>
#include "client/Options.hpp" #include "GuiElement.h"
#include "../../Options.h"
class Font;
class MinecraftClient; class Font;
class Minecraft;
class Button: public GuiElement
{ class Button: public GuiElement
public: {
Button(int id, const std::string& msg); public:
Button(int id, int x, int y, const std::string& msg); Button(int id, const std::string& msg);
Button(int id, int x, int y, int w, int h, const std::string& msg); Button(int id, int x, int y, const std::string& msg);
virtual ~Button() {} Button(int id, int x, int y, int w, int h, const std::string& msg);
virtual void render(MinecraftClient& minecraft, int xm, int ym); virtual ~Button() {}
virtual void render(Minecraft* minecraft, int xm, int ym);
virtual bool clicked(MinecraftClient& minecraft, int mx, int my);
virtual void released(int mx, int my); virtual bool clicked(Minecraft* minecraft, int mx, int my);
virtual void setPressed(); virtual void released(int mx, int my);
virtual void setPressed();
bool isInside(int xm, int ym);
protected: bool isInside(int xm, int ym);
virtual int getYImage(bool hovered); protected:
virtual void renderBg(MinecraftClient& minecraft, int xm, int ym); virtual int getYImage(bool hovered);
virtual void renderBg(Minecraft* minecraft, int xm, int ym);
virtual void renderFace(MinecraftClient& minecraft, int xm, int ym);
bool hovered(MinecraftClient& minecraft, int xm, int ym); virtual void renderFace(Minecraft* minecraft, int xm, int ym);
public: bool hovered(Minecraft* minecraft, int xm, int ym);
std::string msg; public:
int id; std::string msg;
int id;
bool selected;
protected: bool selected;
bool _currentlyDown; protected:
}; bool _currentlyDown;
};
// @note: A bit backwards, but this is a button that
// only reacts to clicks, but isn't rendered. // @note: A bit backwards, but this is a button that
class BlankButton: public Button // only reacts to clicks, but isn't rendered.
{ class BlankButton: public Button
typedef Button super; {
public: typedef Button super;
BlankButton(int id); public:
BlankButton(int id, int x, int y, int w, int h); BlankButton(int id);
}; BlankButton(int id, int x, int y, int w, int h);
};
namespace Touch {
class TButton: public Button namespace Touch {
{ class TButton: public Button
typedef Button super; {
public: typedef Button super;
TButton(int id, const std::string& msg); public:
TButton(int id, int x, int y, const std::string& msg); TButton(int id, const std::string& msg);
TButton(int id, int x, int y, int w, int h, const std::string& msg); TButton(int id, int x, int y, const std::string& msg);
protected: TButton(int id, int x, int y, int w, int h, const std::string& msg);
virtual void renderBg(MinecraftClient& minecraft, int xm, int ym); protected:
}; virtual void renderBg(Minecraft* minecraft, int xm, int ym);
};
// "Header" in Touchscreen mode
class THeader: public Button { // "Header" in Touchscreen mode
typedef Button super; class THeader: public Button {
public: typedef Button super;
THeader(int id, const std::string& msg); public:
THeader(int id, int x, int y, const std::string& msg); THeader(int id, const std::string& msg);
THeader(int id, int x, int y, int w, int h, const std::string& msg); THeader(int id, int x, int y, const std::string& msg);
protected: THeader(int id, int x, int y, int w, int h, const std::string& msg);
virtual void renderBg(MinecraftClient& minecraft, int xm, int ym); protected:
void render( MinecraftClient& minecraft, int xm, int ym ); virtual void renderBg(Minecraft* minecraft, int xm, int ym);
public: void render( Minecraft* minecraft, int xm, int ym );
int xText; public:
}; int xText;
} };
}
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Button_H__*/

View File

@@ -1 +1 @@
#include "GuiElement.hpp" #include "GuiElement.h"

View File

@@ -1,53 +1,55 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT_GUI__GButton_H__
#include "Button.hpp" #define NET_MINECRAFT_CLIENT_GUI__GButton_H__
#include "Button.h"
class GButton: public Button {
typedef Button super; class GButton: public Button {
public: typedef Button super;
static const int LayerDefault = 1; public:
static const int LayerSelected = 2; static const int LayerDefault = 1;
static const int LayerMax = 4; static const int LayerSelected = 2;
static const int LayerMax = 4;
GButton(int id)
: super(id, "") GButton(int id)
{} : super(id, "")
~GButton() { {}
for (unsigned int i = 0; i < layers.size(); ++i) { ~GButton() {
delete layers[i].first; for (unsigned int i = 0; i < layers.size(); ++i) {
} delete layers[i].first;
} }
}
void addElement(int layerId, GuiElement* e) {
if (!e || layerId < 0 || layerId >= LayerMax) { void addElement(int layerId, GuiElement* e) {
LOGE("Error @ GButton::element : Trying to add element %p at layer: %d\n", e, layerId); if (!e || layerId < 0 || layerId >= LayerMax) {
return; LOGE("Error @ GButton::element : Trying to add element %p at layer: %d\n", e, layerId);
} return;
layers.push_back(std::make_pair(e, layerId)); }
} layers.push_back(std::make_pair(e, layerId));
}
void render( MinecraftClient& minecraft, int xm, int ym )
{ void render( Minecraft* minecraft, int xm, int ym )
if (!visible) return; {
if (!visible) return;
bool isHovered = minecraft.isTouchscreen()?
(_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height): false; bool isHovered = minecraft->isTouchscreen()?
(_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height): false;
int layer = isHovered? LayerSelected : LayerDefault;
if (layer < 0) return; int layer = isHovered? LayerSelected : LayerDefault;
if (layer < 0) return;
Tesselator& t = Tesselator::instance;
t.addOffset((float)x, (float)y, 0); Tesselator& t = Tesselator::instance;
t.addOffset((float)x, (float)y, 0);
for (unsigned int i = 0; i < layers.size(); ++i) {
if ((layers[i].second & layer) != 0) for (unsigned int i = 0; i < layers.size(); ++i) {
layers[i].first->render(minecraft, 0, 0); if ((layers[i].second & layer) != 0)
} layers[i].first->render(minecraft, 0, 0);
}
t.addOffset((float)-x, (float)-y, 0);
} t.addOffset((float)-x, (float)-y, 0);
}
private:
std::vector<std::pair<GuiElement*, int> > layers; private:
}; std::vector<std::pair<GuiElement*, int> > layers;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__GButton_H__*/

View File

@@ -1,20 +1,20 @@
#include "GuiElement.hpp" #include "GuiElement.h"
GuiElement::GuiElement( bool active/*=false*/, bool visible/*=true*/, int x /*= 0*/, int y /*= 0*/, int width/*=24*/, int height/*=24*/ ) GuiElement::GuiElement( bool active/*=false*/, bool visible/*=true*/, int x /*= 0*/, int y /*= 0*/, int width/*=24*/, int height/*=24*/ )
: active(active), : active(active),
visible(visible), visible(visible),
x(x), x(x),
y(y), y(y),
width(width), width(width),
height(height) { height(height) {
} }
bool GuiElement::pointInside( int x, int y ) { bool GuiElement::pointInside( int x, int y ) {
if(x >= this->x && x < this->x + this->width) { if(x >= this->x && x < this->x + this->width) {
if(y >= this->y && y < this->y + this->height) { if(y >= this->y && y < this->y + this->height) {
return true; return true;
} }
} }
return false; return false;
} }

View File

@@ -0,0 +1,34 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__GuiElement_H__
#define NET_MINECRAFT_CLIENT_GUI__GuiElement_H__
#include "../GuiComponent.h"
class Tesselator;
class Minecraft;
class GuiElement : public GuiComponent {
public:
GuiElement(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
virtual ~GuiElement() {}
virtual void tick(Minecraft* minecraft) {}
virtual void render(Minecraft* minecraft, int xm, int ym) { }
virtual void setupPositions() {}
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {}
virtual void mouseReleased(Minecraft* minecraft, int x, int y, int buttonNum) {}
virtual void keyPressed(Minecraft* minecraft, int key) {}
virtual void charPressed(Minecraft* minecraft, char key) {}
virtual bool pointInside(int x, int y);
void setVisible(bool visible);
bool active;
bool visible;
int x;
int y;
int width;
int height;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__GuiElement_H__*/

View File

@@ -1,32 +0,0 @@
#pragma once
#include "client/gui/GuiComponent.hpp"
class Tesselator;
class MinecraftClient;
class GuiElement : public GuiComponent {
public:
GuiElement(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
virtual ~GuiElement() {}
virtual void tick(MinecraftClient& minecraft) {}
virtual void render(MinecraftClient& minecraft, int xm, int ym) { }
virtual void setupPositions() {}
virtual void mouseClicked(MinecraftClient& minecraft, int x, int y, int buttonNum) {}
virtual void mouseReleased(MinecraftClient& minecraft, int x, int y, int buttonNum) {}
virtual void keyPressed(MinecraftClient& minecraft, int key) {}
virtual void charPressed(MinecraftClient& minecraft, char key) {}
virtual bool pointInside(int x, int y);
void setVisible(bool visible);
bool active;
bool visible;
int x;
int y;
int width;
int height;
};

View File

@@ -1,66 +1,66 @@
#include "GuiElementContainer.hpp" #include "GuiElementContainer.h"
#include <algorithm> #include <algorithm>
GuiElementContainer::GuiElementContainer( bool active/*=false*/, bool visible/*=true*/, int x /*= 0*/, int y /*= 0*/, int width/*=24*/, int height/*=24*/ ) GuiElementContainer::GuiElementContainer( bool active/*=false*/, bool visible/*=true*/, int x /*= 0*/, int y /*= 0*/, int width/*=24*/, int height/*=24*/ )
: GuiElement(active, visible, x, y, width, height) { : GuiElement(active, visible, x, y, width, height) {
} }
GuiElementContainer::~GuiElementContainer() { GuiElementContainer::~GuiElementContainer() {
while(!children.empty()) { while(!children.empty()) {
GuiElement* element = children.back(); GuiElement* element = children.back();
children.pop_back(); children.pop_back();
delete element; delete element;
} }
} }
void GuiElementContainer::render( MinecraftClient& minecraft, int xm, int ym ) { void GuiElementContainer::render( Minecraft* minecraft, int xm, int ym ) {
for(auto it = children.begin(); it != children.end(); ++it) { for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
(*it)->render(minecraft, xm, ym); (*it)->render(minecraft, xm, ym);
} }
} }
void GuiElementContainer::setupPositions() { void GuiElementContainer::setupPositions() {
for(auto it = children.begin(); it != children.end(); ++it) { for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
(*it)->setupPositions(); (*it)->setupPositions();
} }
} }
void GuiElementContainer::addChild( GuiElement* element ) { void GuiElementContainer::addChild( GuiElement* element ) {
children.push_back(element); children.push_back(element);
} }
void GuiElementContainer::removeChild( GuiElement* element ) { void GuiElementContainer::removeChild( GuiElement* element ) {
auto it = std::find(children.begin(), children.end(), element); std::vector<GuiElement*>::iterator it = std::find(children.begin(), children.end(), element);
if(it != children.end()) if(it != children.end())
children.erase(it); children.erase(it);
} }
void GuiElementContainer::tick( MinecraftClient& minecraft ) { void GuiElementContainer::tick( Minecraft* minecraft ) {
for(auto it = children.begin(); it != children.end(); ++it) { for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
(*it)->tick(minecraft); (*it)->tick(minecraft);
} }
} }
void GuiElementContainer::mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum ) { void GuiElementContainer::mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum ) {
for(auto it = children.begin(); it != children.end(); ++it) { for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
(*it)->mouseClicked(minecraft, x, y, buttonNum); (*it)->mouseClicked(minecraft, x, y, buttonNum);
} }
} }
void GuiElementContainer::mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum ) { void GuiElementContainer::mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum ) {
for(auto it = children.begin(); it != children.end(); ++it) { for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
(*it)->mouseReleased(minecraft, x, y, buttonNum); (*it)->mouseReleased(minecraft, x, y, buttonNum);
} }
} }
void GuiElementContainer::keyPressed(MinecraftClient& minecraft, int key) { void GuiElementContainer::keyPressed(Minecraft* minecraft, int key) {
for(auto it = children.begin(); it != children.end(); ++it) { for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
(*it)->keyPressed(minecraft, key); (*it)->keyPressed(minecraft, key);
} }
} }
void GuiElementContainer::charPressed(MinecraftClient& minecraft, char key) { void GuiElementContainer::charPressed(Minecraft* minecraft, char key) {
for(auto it = children.begin(); it != children.end(); ++it) { for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
(*it)->charPressed(minecraft, key); (*it)->charPressed(minecraft, key);
} }
} }

View File

@@ -0,0 +1,28 @@
#ifndef NET_MINECRAFT_CLIENT_GUI__GuiElementContainer_H__
#define NET_MINECRAFT_CLIENT_GUI__GuiElementContainer_H__
#include "GuiElement.h"
#include <vector>
class Tesselator;
class Minecraft;
class GuiElementContainer : public GuiElement {
public:
GuiElementContainer(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
virtual ~GuiElementContainer();
virtual void render(Minecraft* minecraft, int xm, int ym);
virtual void setupPositions();
virtual void addChild(GuiElement* element);
virtual void removeChild(GuiElement* element);
virtual void tick( Minecraft* minecraft );
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
virtual void keyPressed(Minecraft* minecraft, int key);
virtual void charPressed(Minecraft* minecraft, char key);
protected:
std::vector<GuiElement*> children;
};
#endif /*NET_MINECRAFT_CLIENT_GUI__GuiElementContainer_H__*/

View File

@@ -1,26 +0,0 @@
#pragma once
#include "GuiElement.hpp"
#include <vector>
class Tesselator;
class MinecraftClient;
class GuiElementContainer : public GuiElement {
public:
GuiElementContainer(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
virtual ~GuiElementContainer();
virtual void render(MinecraftClient& minecraft, int xm, int ym);
virtual void setupPositions();
virtual void addChild(GuiElement* element);
virtual void removeChild(GuiElement* element);
virtual void tick( MinecraftClient& minecraft );
virtual void mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum );
virtual void mouseReleased( MinecraftClient& minecraft, int x, int y, int buttonNum );
virtual void keyPressed(MinecraftClient& minecraft, int key);
virtual void charPressed(MinecraftClient& minecraft, char key);
protected:
std::vector<GuiElement*> children;
};

View File

@@ -1,135 +1,135 @@
#include "ImageButton.hpp" #include "ImageButton.h"
#include "client/renderer/Tesselator.hpp" #include "../../renderer/Tesselator.h"
#include <MinecraftClient.hpp> #include "../../Minecraft.h"
#include "platform/log.hpp" #include "../../../platform/log.h"
#include "util/Mth.hpp" #include "../../../util/Mth.h"
#include "client/renderer/Textures.hpp" #include "../../renderer/Textures.h"
#include <client/Option.hpp> #include <client/Option.h>
ImageButton::ImageButton(int id, const std::string& msg) ImageButton::ImageButton(int id, const std::string& msg)
: super(id, msg) : super(id, msg)
{ {
setupDefault(); setupDefault();
} }
ImageButton::ImageButton(int id, const std::string& msg, const ImageDef& imagedef) ImageButton::ImageButton(int id, const std::string& msg, const ImageDef& imagedef)
: super(id, msg), : super(id, msg),
_imageDef(imagedef) _imageDef(imagedef)
{ {
setupDefault(); setupDefault();
} }
void ImageButton::setupDefault() { void ImageButton::setupDefault() {
width = 48; width = 48;
height = 48; height = 48;
scaleWhenPressed = true; scaleWhenPressed = true;
} }
void ImageButton::setImageDef(const ImageDef& imageDef, bool setButtonSize) { void ImageButton::setImageDef(const ImageDef& imageDef, bool setButtonSize) {
_imageDef = imageDef; _imageDef = imageDef;
if (setButtonSize) { if (setButtonSize) {
width = (int)_imageDef.width; width = (int)_imageDef.width;
height = (int)_imageDef.height; height = (int)_imageDef.height;
} }
} }
void ImageButton::render(MinecraftClient& minecraft, int xm, int ym) { void ImageButton::render(Minecraft* minecraft, int xm, int ym) {
if (!visible) return; if (!visible) return;
Font* font = minecraft.font(); Font* font = minecraft->font;
//minecraft.textures().loadAndBindTexture("gui/gui.png"); //minecraft->textures->loadAndBindTexture("gui/gui.png");
glColor4f2(1, 1, 1, 1); glColor4f2(1, 1, 1, 1);
bool hovered = active && (minecraft.useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym)); bool hovered = active && (minecraft->useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
bool IsSecondImage = isSecondImage(hovered); bool IsSecondImage = isSecondImage(hovered);
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym); //printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
//int yImage = getYImage(hovered || selected); //int yImage = getYImage(hovered || selected);
//blit(x, y, 0, 46 + yImage * 20, w / 2, h, 0, 20); //blit(x, y, 0, 46 + yImage * 20, w / 2, h, 0, 20);
//blit(x + w / 2, y, 200 - w / 2, 46 + yImage * 20, w / 2, h, 0, 20); //blit(x + w / 2, y, 200 - w / 2, 46 + yImage * 20, w / 2, h, 0, 20);
renderBg(minecraft, xm, ym); renderBg(minecraft, xm, ym);
TextureId texId = (_imageDef.name.length() > 0)? minecraft.textures().loadAndBindTexture(_imageDef.name) : Textures::InvalidId; TextureId texId = (_imageDef.name.length() > 0)? minecraft->textures->loadAndBindTexture(_imageDef.name) : Textures::InvalidId;
if ( Textures::isTextureIdValid(texId) ) { if ( Textures::isTextureIdValid(texId) ) {
const ImageDef& d = _imageDef; const ImageDef& d = _imageDef;
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
t.begin(); t.begin();
if (!active) t.color(0xff808080); if (!active) t.color(0xff808080);
//else if (hovered||selected) t.color(0xffffffff); //else if (hovered||selected) t.color(0xffffffff);
//else t.color(0xffe0e0e0); //else t.color(0xffe0e0e0);
else t.color(0xffffffff); else t.color(0xffffffff);
float hx = ((float) d.width) * 0.5f; float hx = ((float) d.width) * 0.5f;
float hy = ((float) d.height) * 0.5f; float hy = ((float) d.height) * 0.5f;
const float cx = ((float)x+d.x) + hx; const float cx = ((float)x+d.x) + hx;
const float cy = ((float)y+d.y) + hy; const float cy = ((float)y+d.y) + hy;
if (scaleWhenPressed && hovered) { if (scaleWhenPressed && hovered) {
hx *= 0.95f; hx *= 0.95f;
hy *= 0.95f; hy *= 0.95f;
} }
const IntRectangle* src = _imageDef.getSrc(); const IntRectangle* src = _imageDef.getSrc();
if (src) { if (src) {
const TextureData* d = minecraft.textures().getTemporaryTextureData(texId); const TextureData* d = minecraft->textures->getTemporaryTextureData(texId);
if (d != NULL) { if (d != NULL) {
float u0 = (src->x+(IsSecondImage?src->w:0)) / (float)d->w; float u0 = (src->x+(IsSecondImage?src->w:0)) / (float)d->w;
float u1 = (src->x+(IsSecondImage?2*src->w:src->w)) / (float)d->w; float u1 = (src->x+(IsSecondImage?2*src->w:src->w)) / (float)d->w;
float v0 = src->y / (float)d->h; float v0 = src->y / (float)d->h;
float v1 = (src->y+src->h) / (float)d->h; float v1 = (src->y+src->h) / (float)d->h;
t.vertexUV(cx-hx, cy-hy, blitOffset, u0, v0); 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, u0, v1);
t.vertexUV(cx+hx, cy+hy, blitOffset, u1, v1); t.vertexUV(cx+hx, cy+hy, blitOffset, u1, v1);
t.vertexUV(cx+hx, cy-hy, blitOffset, u1, v0); t.vertexUV(cx+hx, cy-hy, blitOffset, u1, v0);
} }
} else { } else {
t.vertexUV(cx-hx, cy-hy, blitOffset, 0, 0); t.vertexUV(cx-hx, cy-hy, blitOffset, 0, 0);
t.vertexUV(cx-hx, cy+hy, blitOffset, 0, 1); t.vertexUV(cx-hx, cy+hy, blitOffset, 0, 1);
t.vertexUV(cx+hx, cy+hy, blitOffset, 1, 1); t.vertexUV(cx+hx, cy+hy, blitOffset, 1, 1);
t.vertexUV(cx+hx, cy-hy, blitOffset, 1, 0); t.vertexUV(cx+hx, cy-hy, blitOffset, 1, 0);
} }
t.draw(); t.draw();
} }
//blit(0, 0, 0, 0, 64, 64, 256, 256); //blit(0, 0, 0, 0, 64, 64, 256, 256);
//LOGI("%d %d\n", x+d.x, x+d.x+d.w); //LOGI("%d %d\n", x+d.x, x+d.x+d.w);
if (!active) { if (!active) {
drawCenteredString(font, msg, x + width / 2, y + 16/*(h - 16)*/, 0xffa0a0a0); drawCenteredString(font, msg, x + width / 2, y + 16/*(h - 16)*/, 0xffa0a0a0);
} else { } else {
if (hovered || selected) { if (hovered || selected) {
drawCenteredString(font, msg, x + width / 2, y + 17/*(h - 16)*/, 0xffffa0); drawCenteredString(font, msg, x + width / 2, y + 17/*(h - 16)*/, 0xffffa0);
} else { } else {
drawCenteredString(font, msg, x + width / 2, y + 16/*(h - 48)*/, 0xe0e0e0); drawCenteredString(font, msg, x + width / 2, y + 16/*(h - 48)*/, 0xe0e0e0);
} }
} }
} }
// //
// A toggleable Button // A toggleable Button
// //
OptionButton::OptionButton(OptionId option) : m_optId(option), super(ButtonId, "") {} OptionButton::OptionButton(OptionId option) : m_optId(option), super(ButtonId, "") {}
void OptionButton::toggle(Options* options) { void OptionButton::toggle(Options* options) {
options->toggle(m_optId); options->toggle(m_optId);
// Update graphics here // Update graphics here
updateImage(options); updateImage(options);
} }
void OptionButton::updateImage(Options* options) { void OptionButton::updateImage(Options* options) {
_secondImage = options->getBooleanValue(m_optId); _secondImage = options->getBooleanValue(m_optId);
} }
void OptionButton::mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum ) { void OptionButton::mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum ) {
if(buttonNum == MouseAction::ACTION_LEFT) { if(buttonNum == MouseAction::ACTION_LEFT) {
if(clicked(minecraft, x, y)) { if(clicked(minecraft, x, y)) {
toggle(&minecraft.options); toggle(&minecraft->options);
} }
} }
} }

View File

@@ -1,95 +1,97 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ImageButton_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ImageButton_H__
#include "Button.hpp"
#include "Button.h"
typedef struct IntRectangle {
IntRectangle() typedef struct IntRectangle {
: x(0), IntRectangle()
y(0), : x(0),
w(1), y(0),
h(1) w(1),
{} h(1)
IntRectangle(int x, int y, int w, int h) {}
: x(x), IntRectangle(int x, int y, int w, int h)
y(y), : x(x),
w(w), y(y),
h(h) w(w),
{} h(h)
{}
int x, y;
int w, h; int x, y;
} IntRectangle; int w, h;
} IntRectangle;
typedef struct ImageDef {
ImageDef() typedef struct ImageDef {
: hasSrc(false), ImageDef()
x(0), : hasSrc(false),
y(0), x(0),
width(16), y(0),
height(16) width(16),
{} height(16)
{}
std::string name;
int x; std::string name;
int y; int x;
float width; int y;
float height; float width;
float height;
ImageDef& setSrc(const IntRectangle& srcRect) {
hasSrc = true; ImageDef& setSrc(const IntRectangle& srcRect) {
src = srcRect; hasSrc = true;
return *this; src = srcRect;
} return *this;
IntRectangle* getSrc() { }
return hasSrc? &src : NULL; IntRectangle* getSrc() {
} return hasSrc? &src : NULL;
protected: }
IntRectangle src; protected:
bool hasSrc; IntRectangle src;
} ImageDef; bool hasSrc;
} ImageDef;
class ImageButton: public Button
{ class ImageButton: public Button
typedef Button super; {
public: typedef Button super;
ImageButton(int id, const std::string& msg); public:
ImageButton(int id, const std::string& msg, const ImageDef& imageDef); ImageButton(int id, const std::string& msg);
void setImageDef(const ImageDef& imageDef, bool setButtonSize); ImageButton(int id, const std::string& msg, const ImageDef& imageDef);
void setImageDef(const ImageDef& imageDef, bool setButtonSize);
void render(MinecraftClient& minecraft, int xm, int ym);
void renderBg(MinecraftClient& minecraft, int xm, int ym) {} void render(Minecraft* minecraft, int xm, int ym);
void renderBg(Minecraft* minecraft, int xm, int ym) {}
protected:
virtual void setupDefault(); protected:
virtual bool isSecondImage(bool hovered) { return hovered; } virtual void setupDefault();
virtual bool isSecondImage(bool hovered) { return hovered; }
ImageDef _imageDef;
public: ImageDef _imageDef;
bool scaleWhenPressed; public:
}; bool scaleWhenPressed;
};
//
// A toggleable Button //
// // A toggleable Button
class OptionButton: public ImageButton //
{ class OptionButton: public ImageButton
typedef ImageButton super; {
public: typedef ImageButton super;
OptionButton(OptionId optId); public:
OptionButton(OptionId optId);
void toggle(Options* options);
void updateImage(Options* options); void toggle(Options* options);
void updateImage(Options* options);
static const int ButtonId = 9999999;
protected: static const int ButtonId = 9999999;
bool isSecondImage(bool hovered) { return _secondImage; } protected:
bool isSecondImage(bool hovered) { return _secondImage; }
virtual void mouseClicked( MinecraftClient& minecraft, int x, int y, int buttonNum );
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
private:
OptionId m_optId; private:
bool _secondImage; OptionId m_optId;
}; bool _secondImage;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__ImageButton_H__*/

View File

@@ -1,206 +1,206 @@
#include "InventoryPane.hpp" #include "InventoryPane.h"
#include "client/gui/Gui.hpp" #include "../Gui.h"
#include <MinecraftClient.hpp> #include "../../Minecraft.h"
#include "client/player/input/touchscreen/TouchAreaModel.hpp" #include "../../player/input/touchscreen/TouchAreaModel.h"
#include "client/renderer/entity/ItemRenderer.hpp" #include "../../renderer/entity/ItemRenderer.h"
#include "client/renderer/Tesselator.hpp" #include "../../renderer/Tesselator.h"
#include "client/renderer/Textures.hpp" #include "../../renderer/Textures.h"
#include "world/item/ItemInstance.hpp" #include "../../../world/item/ItemInstance.h"
#include "world/entity/player/Inventory.hpp" #include "../../../world/entity/player/Inventory.h"
namespace Touch { namespace Touch {
static const int By = 6; // Border Frame height static const int By = 6; // Border Frame height
InventoryPane::InventoryPane( IInventoryPaneCallback* screen, MinecraftClient& mc, const IntRectangle& rect, int paneWidth, float clickMarginH, int numItems, int itemSize, int itemBorderSize) InventoryPane::InventoryPane( IInventoryPaneCallback* screen, Minecraft* mc, const IntRectangle& rect, int paneWidth, float clickMarginH, int numItems, int itemSize, int itemBorderSize)
: screen(screen), : screen(screen),
mc(mc), mc(mc),
paneWidth(paneWidth), paneWidth(paneWidth),
rect(rect), rect(rect),
super( super(
SF_LockX|/*SF_Scissor|*/SF_ShowScrollbar|SF_NoHoldSelect, SF_LockX|/*SF_Scissor|*/SF_ShowScrollbar|SF_NoHoldSelect,
rect, // Pane rect rect, // Pane rect
IntRectangle(0, 0, itemSize, itemSize), // Item rect IntRectangle(0, 0, itemSize, itemSize), // Item rect
0, numItems, Gui::GuiScale), 0, numItems, Gui::GuiScale),
BorderPixels(itemBorderSize), BorderPixels(itemBorderSize),
lastItemIndex(-1), lastItemIndex(-1),
lastItemTicks(-1), lastItemTicks(-1),
fillMarginX(2), fillMarginX(2),
fillMarginY(4), fillMarginY(4),
markerType(1), markerType(1),
markerIndex(-1), markerIndex(-1),
markerShare(0), markerShare(0),
renderDecorations(true) renderDecorations(true)
{ {
_clickArea = new RectangleArea(0, 0, 0, 0); _clickArea = new RectangleArea(0, 0, 0, 0);
area._x0 = rect.x - clickMarginH; area._x0 = rect.x - clickMarginH;
area._x1 = rect.x + rect.w + clickMarginH; area._x1 = rect.x + rect.w + clickMarginH;
area._y0 -= By; area._y0 -= By;
area._y1 += By; area._y1 += By;
/* /*
const int left = bbox.x + (bbox.w - paneWidth) / 2; const int left = bbox.x + (bbox.w - paneWidth) / 2;
bg.x = left; bg.x = left;
bg.w = left + paneWidth; // @note: read as x1, not width bg.w = left + paneWidth; // @note: read as x1, not width
bg.y = bbox.y - fillMarginY; bg.y = bbox.y - fillMarginY;
bg.h = bbox.y + bbox.h + fillMarginY; // @note: read as y1, not width bg.h = bbox.y + bbox.h + fillMarginY; // @note: read as y1, not width
*/ */
} }
InventoryPane::~InventoryPane() { InventoryPane::~InventoryPane() {
delete _clickArea; delete _clickArea;
} }
void InventoryPane::renderBatch( std::vector<GridItem>& items, float alpha ) void InventoryPane::renderBatch( std::vector<GridItem>& items, float alpha )
{ {
//fill(bg.x, bg.y, bg.w, bg.h, 0xff333333); //fill(bg.x, bg.y, bg.w, bg.h, 0xff333333);
fill((float)(bbox.x-fillMarginX-1), (float)(bbox.y-fillMarginY), (float)(bbox.x + bbox.w + fillMarginX+1), (float)(bbox.y + bbox.h + fillMarginY), 0xff333333); fill((float)(bbox.x-fillMarginX-1), (float)(bbox.y-fillMarginY), (float)(bbox.x + bbox.w + fillMarginX+1), (float)(bbox.y + bbox.h + fillMarginY), 0xff333333);
//fill(0.0f, (float)(bbox.y-fillMarginY), 400.0f, (float)(bbox.y + bbox.h + fillMarginY), 0xff333333);//(float)(bbox.x-fillMarginX), (float)(bbox.y-fillMarginY), (float)(bbox.x + bbox.w + fillMarginX), (float)(bbox.y + bbox.h + fillMarginY), 0xff333333); //fill(0.0f, (float)(bbox.y-fillMarginY), 400.0f, (float)(bbox.y + bbox.h + fillMarginY), 0xff333333);//(float)(bbox.x-fillMarginX), (float)(bbox.y-fillMarginY), (float)(bbox.x + bbox.w + fillMarginX), (float)(bbox.y + bbox.h + fillMarginY), 0xff333333);
glEnable2(GL_BLEND); glEnable2(GL_BLEND);
glDisable2(GL_ALPHA_TEST); glDisable2(GL_ALPHA_TEST);
std::vector<const ItemInstance*> inventoryItems = screen->getItems(this); std::vector<const ItemInstance*> inventoryItems = screen->getItems(this);
glEnable2(GL_SCISSOR_TEST); glEnable2(GL_SCISSOR_TEST);
GLuint x = (GLuint)(screenScale * bbox.x); GLuint x = (GLuint)(screenScale * bbox.x);
GLuint y = mc.getScreenHeight() - (GLuint)(screenScale * (bbox.y + bbox.h)); GLuint y = mc->height - (GLuint)(screenScale * (bbox.y + bbox.h));
GLuint w = (GLuint)(screenScale * bbox.w); GLuint w = (GLuint)(screenScale * bbox.w);
GLuint h = (GLuint)(screenScale * bbox.h); GLuint h = (GLuint)(screenScale * bbox.h);
glScissor(x, y, w, h); glScissor(x, y, w, h);
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
t.beginOverride(); t.beginOverride();
t.colorABGR(0xffffffff); t.colorABGR(0xffffffff);
for (unsigned int i = 0; i < items.size(); ++i) { for (unsigned int i = 0; i < items.size(); ++i) {
GridItem& item = items[i]; GridItem& item = items[i];
blit(item.xf, item.yf, 200, 46, (float)itemBbox.w, (float)itemBbox.h, 16, 16); blit(item.xf, item.yf, 200, 46, (float)itemBbox.w, (float)itemBbox.h, 16, 16);
} }
mc.textures().loadAndBindTexture("gui/gui.png"); mc->textures->loadAndBindTexture("gui/gui.png");
t.endOverrideAndDraw(); t.endOverrideAndDraw();
GridItem* marked = NULL; GridItem* marked = NULL;
float mxx, myy; float mxx, myy;
t.beginOverride(); t.beginOverride();
for (unsigned int i = 0; i < items.size(); ++i) { for (unsigned int i = 0; i < items.size(); ++i) {
GridItem& item = items[i]; GridItem& item = items[i];
int j = item.id; int j = item.id;
const ItemInstance* citem = inventoryItems[j]; const ItemInstance* citem = inventoryItems[j];
if (!citem) continue; if (!citem) continue;
bool allowed = true; bool allowed = true;
t.enableColor(); t.enableColor();
//#ifdef DEMO_MODE //@huge @attn //#ifdef DEMO_MODE //@huge @attn
if (!screen->isAllowed(j)) { allowed = false; t.color( 64, 64, 64); } if (!screen->isAllowed(j)) { allowed = false; t.color( 64, 64, 64); }
else else
//#endif //#endif
if (lastItemTicks > 0 && lastItemIndex == j) { if (lastItemTicks > 0 && lastItemIndex == j) {
int gv = 255 - lastItemTicks * 15; int gv = 255 - lastItemTicks * 15;
t.color(gv, gv, gv, (allowed && citem->count <= 0)?0x60:0xff); t.color(gv, gv, gv, (allowed && citem->count <= 0)?0x60:0xff);
} else { } else {
t.color(255, 255, 255, (allowed && citem->count <= 0)?0x60:0xff); t.color(255, 255, 255, (allowed && citem->count <= 0)?0x60:0xff);
} }
t.noColor(); t.noColor();
float xx = Gui::floorAlignToScreenPixel(item.xf + BorderPixels + 4); float xx = Gui::floorAlignToScreenPixel(item.xf + BorderPixels + 4);
float yy = Gui::floorAlignToScreenPixel(item.yf + BorderPixels + 4); float yy = Gui::floorAlignToScreenPixel(item.yf + BorderPixels + 4);
ItemRenderer::renderGuiItem(NULL, mc.textures(), citem, xx, yy, 16, 16, false); ItemRenderer::renderGuiItem(NULL, mc->textures, citem, xx, yy, 16, 16, false);
if (j == markerIndex && markerShare >= 0) if (j == markerIndex && markerShare >= 0)
marked = &item, mxx = xx, myy = yy; marked = &item, mxx = xx, myy = yy;
} }
t.endOverrideAndDraw(); t.endOverrideAndDraw();
if (marked) { if (marked) {
glDisable2(GL_TEXTURE_2D); glDisable2(GL_TEXTURE_2D);
const float yy0 = myy - 5.0f; const float yy0 = myy - 5.0f;
const float yy1 = yy0 + 2; const float yy1 = yy0 + 2;
fill(mxx, yy0, mxx + 16.0f, yy1, 0xff606060); fill(mxx, yy0, mxx + 16.0f, yy1, 0xff606060);
fill(mxx, yy0, mxx + markerShare * 16.0f, yy1, markerType==1?0xff00ff00:0xff476543); fill(mxx, yy0, mxx + markerShare * 16.0f, yy1, markerType==1?0xff00ff00:0xff476543);
glEnable2(GL_BLEND); glEnable2(GL_BLEND);
glEnable2(GL_TEXTURE_2D); glEnable2(GL_TEXTURE_2D);
} }
if (!mc.isCreativeMode()) { if (!mc->isCreativeMode()) {
const float ikText = Gui::InvGuiScale + Gui::InvGuiScale; const float ikText = Gui::InvGuiScale + Gui::InvGuiScale;
const float kText = 0.5f * Gui::GuiScale; const float kText = 0.5f * Gui::GuiScale;
t.beginOverride(); t.beginOverride();
t.scale2d(ikText, ikText); t.scale2d(ikText, ikText);
for (unsigned int i = 0; i < items.size(); ++i) { for (unsigned int i = 0; i < items.size(); ++i) {
GridItem& item = items[i]; GridItem& item = items[i];
const ItemInstance* citem = inventoryItems[item.id]; const ItemInstance* citem = inventoryItems[item.id];
if (!citem) continue; if (!citem) continue;
char buf[64] = {0}; char buf[64] = {0};
/*int c = */ Gui::itemCountItoa(buf, citem->count); /*int c = */ Gui::itemCountItoa(buf, citem->count);
float tx = Gui::floorAlignToScreenPixel(kText * (item.xf + BorderPixels + 3)); float tx = Gui::floorAlignToScreenPixel(kText * (item.xf + BorderPixels + 3));
float ty = Gui::floorAlignToScreenPixel(kText * (item.yf + BorderPixels + 3)); float ty = Gui::floorAlignToScreenPixel(kText * (item.yf + BorderPixels + 3));
mc.gui().renderSlotText(citem, tx, ty, true, true); mc->gui.renderSlotText(citem, tx, ty, true, true);
} }
t.resetScale(); t.resetScale();
glEnable2(GL_BLEND); glEnable2(GL_BLEND);
t.endOverrideAndDraw(); t.endOverrideAndDraw();
} }
if (renderDecorations) { if (renderDecorations) {
t.beginOverride(); t.beginOverride();
for (unsigned int i = 0; i < items.size(); ++i) { for (unsigned int i = 0; i < items.size(); ++i) {
GridItem& item = items[i]; GridItem& item = items[i];
const ItemInstance* citem = inventoryItems[item.id]; const ItemInstance* citem = inventoryItems[item.id];
if (!citem || citem->isNull()) continue; if (!citem || citem->isNull()) continue;
if (citem->isDamaged()) { if (citem->isDamaged()) {
ItemRenderer::renderGuiItemDecorations(citem, item.xf + 8, item.yf + 12); ItemRenderer::renderGuiItemDecorations(citem, item.xf + 8, item.yf + 12);
} }
} }
glDisable2(GL_TEXTURE_2D); glDisable2(GL_TEXTURE_2D);
t.endOverrideAndDraw(); t.endOverrideAndDraw();
glEnable2(GL_TEXTURE_2D); glEnable2(GL_TEXTURE_2D);
} }
glDisable2(GL_SCISSOR_TEST); glDisable2(GL_SCISSOR_TEST);
//fillGradient(bbox.x - 1, bbox.y, bbox.x + bbox.w + 1, bbox.y + 20, 0x99000000, 0x00000000); //fillGradient(bbox.x - 1, bbox.y, bbox.x + bbox.w + 1, bbox.y + 20, 0x99000000, 0x00000000);
//fillGradient(bbox.x - 1, bbox.y + bbox.h - 20, bbox.x + bbox.w + 1, bbox.y + bbox.h, 0x00000000, 0x99000000); //fillGradient(bbox.x - 1, bbox.y + bbox.h - 20, bbox.x + bbox.w + 1, bbox.y + bbox.h, 0x00000000, 0x99000000);
fillGradient(bg.x - fillMarginX, bbox.y, bg.w + fillMarginX, bbox.y + 20, 0x99000000, 0x00000000); fillGradient(bg.x - fillMarginX, bbox.y, bg.w + fillMarginX, bbox.y + 20, 0x99000000, 0x00000000);
fillGradient(bg.x - fillMarginX, bbox.y + bbox.h - 20, bg.w + fillMarginX, bbox.y + bbox.h, 0x00000000, 0x99000000); fillGradient(bg.x - fillMarginX, bbox.y + bbox.h - 20, bg.w + fillMarginX, bbox.y + bbox.h, 0x00000000, 0x99000000);
drawScrollBar(hScroll); drawScrollBar(hScroll);
drawScrollBar(vScroll); drawScrollBar(vScroll);
} }
bool InventoryPane::onSelect( int gridId, bool selected ) bool InventoryPane::onSelect( int gridId, bool selected )
{ {
//screen->onItemSelected(gridId); //screen->onItemSelected(gridId);
if (screen->isAllowed(gridId)) if (screen->isAllowed(gridId))
if (screen->addItem(this, gridId)) { if (screen->addItem(this, gridId)) {
lastItemIndex = gridId; lastItemIndex = gridId;
lastItemTicks = 7; lastItemTicks = 7;
} }
return false; return false;
} }
void InventoryPane::drawScrollBar( ScrollBar& sb ) { void InventoryPane::drawScrollBar( ScrollBar& sb ) {
if (sb.alpha <= 0) if (sb.alpha <= 0)
return; return;
const int color = ((int)(255.0f * sb.alpha) << 24) | 0xaaaaaa; const int color = ((int)(255.0f * sb.alpha) << 24) | 0xaaaaaa;
const float xx = (float)(bbox.x + bbox.w); const float xx = (float)(bbox.x + bbox.w);
fill(xx - sb.w, sb.y, xx, sb.y + sb.h, color); fill(xx - sb.w, sb.y, xx, sb.y + sb.h, color);
} }
void InventoryPane::tick() void InventoryPane::tick()
{ {
--lastItemTicks; --lastItemTicks;
super::tick(); super::tick();
} }
void InventoryPane::setRenderDecorations( bool value ) { void InventoryPane::setRenderDecorations( bool value ) {
renderDecorations = value; renderDecorations = value;
} }
} }

View File

@@ -1,60 +1,62 @@
#pragma once #ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__InventoryPane_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__InventoryPane_H__
#include "ScrollingPane.hpp"
#include "ImageButton.hpp" #include "ScrollingPane.h"
#include "ImageButton.h"
class MinecraftClient;
class ItemInstance; class Minecraft;
class Font; class ItemInstance;
class IArea; class Font;
class IArea;
namespace Touch {
namespace Touch {
class IInventoryPaneCallback;
class IInventoryPaneCallback;
class InventoryPane: public ScrollingPane
{ class InventoryPane: public ScrollingPane
typedef ScrollingPane super; {
public: typedef ScrollingPane super;
InventoryPane(IInventoryPaneCallback* screen, MinecraftClient& mc, const IntRectangle& rect, int paneWidth, float clickMarginH, int numItems, int itemSize, int itemBorderSize); public:
~InventoryPane(); InventoryPane(IInventoryPaneCallback* screen, Minecraft* mc, const IntRectangle& rect, int paneWidth, float clickMarginH, int numItems, int itemSize, int itemBorderSize);
~InventoryPane();
void tick();
void renderBatch( std::vector<GridItem>& item, float alpha ); void tick();
bool onSelect( int gridId, bool selected ); void renderBatch( std::vector<GridItem>& item, float alpha );
void drawScrollBar( ScrollBar& hScroll ); bool onSelect( int gridId, bool selected );
void drawScrollBar( ScrollBar& hScroll );
void setRenderDecorations(bool value);
void setRenderDecorations(bool value);
IntRectangle rect;
int paneWidth; IntRectangle rect;
IArea* _clickArea; int paneWidth;
IInventoryPaneCallback* screen; IArea* _clickArea;
MinecraftClient& mc; IInventoryPaneCallback* screen;
Minecraft* mc;
int fillMarginX;
int fillMarginY; int fillMarginX;
int fillMarginY;
int markerType;
int markerIndex; int markerType;
float markerShare; int markerIndex;
private: float markerShare;
int lastItemIndex; private:
int lastItemTicks; int lastItemIndex;
int BorderPixels; int lastItemTicks;
bool renderDecorations; int BorderPixels;
bool renderDecorations;
IntRectangle bg;
}; IntRectangle bg;
};
class IInventoryPaneCallback
{ class IInventoryPaneCallback
public: {
virtual ~IInventoryPaneCallback() {} public:
virtual bool addItem(const InventoryPane* forPane, int index) = 0; virtual ~IInventoryPaneCallback() {}
virtual bool isAllowed( int slot ) = 0; virtual bool addItem(const InventoryPane* forPane, int index) = 0;
virtual std::vector<const ItemInstance*> getItems(const InventoryPane* forPane) = 0; virtual bool isAllowed( int slot ) = 0;
}; virtual std::vector<const ItemInstance*> getItems(const InventoryPane* forPane) = 0;
};
}
}
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__InventoryPane_H__*/

View File

@@ -1,148 +1,148 @@
#include "ItemPane.hpp" #include "ItemPane.h"
#include "client/gui/Gui.hpp" #include "../Gui.h"
#include "client/renderer/gles.hpp" #include "../../renderer/gles.h"
#include "client/renderer/Tesselator.hpp" #include "../../renderer/Tesselator.h"
#include "NinePatch.hpp" #include "NinePatch.h"
#include "client/renderer/entity/ItemRenderer.hpp" #include "../../renderer/entity/ItemRenderer.h"
const int rgbActive = 0xfff0f0f0; const int rgbActive = 0xfff0f0f0;
const int rgbInactive = 0xc0635558; const int rgbInactive = 0xc0635558;
const int rgbInactiveShadow = 0xc0aaaaaa; const int rgbInactiveShadow = 0xc0aaaaaa;
ItemPane::ItemPane( IItemPaneCallback* screen, ItemPane::ItemPane( IItemPaneCallback* screen,
Textures* textures, Textures* textures,
const IntRectangle& rect, const IntRectangle& rect,
int numItems, int numItems,
int guiHeight, int guiHeight,
int physicalScreenHeight, int physicalScreenHeight,
bool isVertical /*= true*/) bool isVertical /*= true*/)
: super( : super(
(isVertical?SF_LockX:SF_LockY)/*|SF_Scissor*/|SF_ShowScrollbar, (isVertical?SF_LockX:SF_LockY)/*|SF_Scissor*/|SF_ShowScrollbar,
rect, // Pane rect rect, // Pane rect
isVertical?IntRectangle(0, 0, rect.w, 22) // Item rect if vertical isVertical?IntRectangle(0, 0, rect.w, 22) // Item rect if vertical
:IntRectangle(0, 0, 32, rect.h), // Item rect if horizontal :IntRectangle(0, 0, 32, rect.h), // Item rect if horizontal
isVertical?1:numItems, numItems, Gui::GuiScale), isVertical?1:numItems, numItems, Gui::GuiScale),
screen(screen), screen(screen),
textures(textures), textures(textures),
physicalScreenHeight(physicalScreenHeight), physicalScreenHeight(physicalScreenHeight),
guiSlotItem(NULL), guiSlotItem(NULL),
guiSlotItemSelected(NULL), guiSlotItemSelected(NULL),
isVertical(isVertical) isVertical(isVertical)
{ {
// Expand the area to make it easier to scroll // Expand the area to make it easier to scroll
area._x0 -= 4; area._x0 -= 4;
area._x1 += 4; area._x1 += 4;
area._y0 = 0; area._y0 = 0;
area._y1 = (float)guiHeight; area._y1 = (float)guiHeight;
// GUI // GUI
NinePatchFactory builder(textures, "gui/spritesheet.png"); NinePatchFactory builder(textures, "gui/spritesheet.png");
guiSlotItem = builder.createSymmetrical(IntRectangle(20, 32, 8, 8), 2, 2); guiSlotItem = builder.createSymmetrical(IntRectangle(20, 32, 8, 8), 2, 2);
guiSlotItemSelected = builder.createSymmetrical(IntRectangle(28, 32, 8, 8), 2, 2); guiSlotItemSelected = builder.createSymmetrical(IntRectangle(28, 32, 8, 8), 2, 2);
guiSlotItem->setSize((float)rect.w + 4, 22); guiSlotItem->setSize((float)rect.w + 4, 22);
guiSlotItemSelected->setSize((float)rect.w + 4, 22); guiSlotItemSelected->setSize((float)rect.w + 4, 22);
} }
ItemPane::~ItemPane() { ItemPane::~ItemPane() {
delete guiSlotItem; delete guiSlotItem;
delete guiSlotItemSelected; delete guiSlotItemSelected;
} }
void ItemPane::renderBatch( std::vector<GridItem>& items, float alpha ) void ItemPane::renderBatch( std::vector<GridItem>& items, float alpha )
{ {
//fill(bbox.x, bbox.y, bbox.x + bbox.w, bbox.y + bbox.h, 0xff666666); //fill(bbox.x, bbox.y, bbox.x + bbox.w, bbox.y + bbox.h, 0xff666666);
const std::vector<CItem*>& cat = screen->getItems(this); const std::vector<CItem*>& cat = screen->getItems(this);
if (cat.empty()) return; if (cat.empty()) return;
glEnable2(GL_SCISSOR_TEST); glEnable2(GL_SCISSOR_TEST);
GLuint x = (GLuint)(screenScale * bbox.x); GLuint x = (GLuint)(screenScale * bbox.x);
GLuint y = physicalScreenHeight - (GLuint)(screenScale * (bbox.y + bbox.h)); GLuint y = physicalScreenHeight - (GLuint)(screenScale * (bbox.y + bbox.h));
GLuint w = (GLuint)(screenScale * bbox.w); GLuint w = (GLuint)(screenScale * bbox.w);
GLuint h = (GLuint)(screenScale * bbox.h); GLuint h = (GLuint)(screenScale * bbox.h);
glScissor(x, y, w, h); glScissor(x, y, w, h);
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
t.beginOverride(); t.beginOverride();
for (unsigned int i = 0; i < items.size(); ++i) { for (unsigned int i = 0; i < items.size(); ++i) {
GridItem& item = items[i]; GridItem& item = items[i];
(item.selected? guiSlotItemSelected : guiSlotItem)->draw(t, Gui::floorAlignToScreenPixel(item.xf-1), Gui::floorAlignToScreenPixel(item.yf)); (item.selected? guiSlotItemSelected : guiSlotItem)->draw(t, Gui::floorAlignToScreenPixel(item.xf-1), Gui::floorAlignToScreenPixel(item.yf));
} }
t.endOverrideAndDraw(); t.endOverrideAndDraw();
t.beginOverride(); t.beginOverride();
for (unsigned int i = 0; i < items.size(); ++i) { for (unsigned int i = 0; i < items.size(); ++i) {
GridItem& item = items[i]; GridItem& item = items[i];
CItem* citem = cat[item.id]; CItem* citem = cat[item.id];
ItemRenderer::renderGuiItem(NULL, textures, &citem->item, ItemRenderer::renderGuiItem(NULL, textures, &citem->item,
Gui::floorAlignToScreenPixel(item.xf + itemBbox.w - 16), Gui::floorAlignToScreenPixel(item.xf + itemBbox.w - 16),
Gui::floorAlignToScreenPixel(2 + item.yf), 16, 16, false); Gui::floorAlignToScreenPixel(2 + item.yf), 16, 16, false);
} }
t.endOverrideAndDraw(); t.endOverrideAndDraw();
t.beginOverride(); t.beginOverride();
for (unsigned int i = 0; i < items.size(); ++i) { for (unsigned int i = 0; i < items.size(); ++i) {
GridItem& item = items[i]; GridItem& item = items[i];
CItem* citem = cat[item.id]; CItem* citem = cat[item.id];
char buf[64] = {0}; char buf[64] = {0};
int c = Gui::itemCountItoa(buf, citem->inventoryCount); int c = Gui::itemCountItoa(buf, citem->inventoryCount);
float xf = item.xf - 1; float xf = item.xf - 1;
if (citem->canCraft()) { if (citem->canCraft()) {
f->drawShadow(citem->text, f->drawShadow(citem->text,
Gui::floorAlignToScreenPixel(xf + 2), Gui::floorAlignToScreenPixel(xf + 2),
Gui::floorAlignToScreenPixel(item.yf + 6), rgbActive); Gui::floorAlignToScreenPixel(item.yf + 6), rgbActive);
t.scale2d(0.6667f, 0.6667f); t.scale2d(0.6667f, 0.6667f);
f->drawShadow(buf, f->drawShadow(buf,
Gui::floorAlignToScreenPixel(1.5f * (xf + itemBbox.w - c*4)), Gui::floorAlignToScreenPixel(1.5f * (xf + itemBbox.w - c*4)),
Gui::floorAlignToScreenPixel(1.5f * (item.yf + itemBbox.h - 8)), rgbActive); Gui::floorAlignToScreenPixel(1.5f * (item.yf + itemBbox.h - 8)), rgbActive);
t.resetScale(); t.resetScale();
} else { } else {
f->draw(citem->text, f->draw(citem->text,
Gui::floorAlignToScreenPixel(xf + 3), Gui::floorAlignToScreenPixel(xf + 3),
Gui::floorAlignToScreenPixel(item.yf + 7), rgbInactiveShadow); Gui::floorAlignToScreenPixel(item.yf + 7), rgbInactiveShadow);
f->draw(citem->text, f->draw(citem->text,
Gui::floorAlignToScreenPixel(xf + 2), Gui::floorAlignToScreenPixel(xf + 2),
Gui::floorAlignToScreenPixel(item.yf + 6), rgbInactive); Gui::floorAlignToScreenPixel(item.yf + 6), rgbInactive);
t.scale2d(0.6667f, 0.6667f); t.scale2d(0.6667f, 0.6667f);
f->draw(buf, f->draw(buf,
Gui::floorAlignToScreenPixel(1.5f * (xf + itemBbox.w - c*4)), Gui::floorAlignToScreenPixel(1.5f * (xf + itemBbox.w - c*4)),
Gui::floorAlignToScreenPixel(1.5f * (item.yf + itemBbox.h - 8)), rgbInactive); Gui::floorAlignToScreenPixel(1.5f * (item.yf + itemBbox.h - 8)), rgbInactive);
t.resetScale(); t.resetScale();
} }
} }
t.endOverrideAndDraw(); t.endOverrideAndDraw();
//fillGradient(bbox.x, bbox.y, bbox.x + bbox.w, 20, 0x00000000, 0x80ff0000) //fillGradient(bbox.x, bbox.y, bbox.x + bbox.w, 20, 0x00000000, 0x80ff0000)
if (isVertical) { if (isVertical) {
fillGradient(bbox.x, bbox.y, bbox.x + bbox.w, bbox.y + 28, 0xbb000000, 0x00000000); fillGradient(bbox.x, bbox.y, bbox.x + bbox.w, bbox.y + 28, 0xbb000000, 0x00000000);
fillGradient(bbox.x, bbox.y + bbox.h - 28, bbox.x + bbox.w, bbox.y + bbox.h, 0x00000000, 0xbb000000);//0xbb2A272B); fillGradient(bbox.x, bbox.y + bbox.h - 28, bbox.x + bbox.w, bbox.y + bbox.h, 0x00000000, 0xbb000000);//0xbb2A272B);
} else { } else {
fillHorizontalGradient(bbox.x, bbox.y, bbox.x + 28, bbox.y + bbox.h, 0xbb000000, 0x00000000); fillHorizontalGradient(bbox.x, bbox.y, bbox.x + 28, bbox.y + bbox.h, 0xbb000000, 0x00000000);
fillHorizontalGradient(bbox.x + bbox.w - 28, bbox.y, bbox.x + bbox.w, bbox.y + bbox.h, 0x00000000, 0xbb000000);//0xbb2A272B); fillHorizontalGradient(bbox.x + bbox.w - 28, bbox.y, bbox.x + bbox.w, bbox.y + bbox.h, 0x00000000, 0xbb000000);//0xbb2A272B);
} }
//LOGI("scroll: %f - %f, %f :: %f, %f\n", hScroll.alpha, hScroll.x, hScroll.y, hScroll.w, hScroll.h); //LOGI("scroll: %f - %f, %f :: %f, %f\n", hScroll.alpha, hScroll.x, hScroll.y, hScroll.w, hScroll.h);
glDisable2(GL_SCISSOR_TEST); glDisable2(GL_SCISSOR_TEST);
drawScrollBar(hScroll); drawScrollBar(hScroll);
drawScrollBar(vScroll); drawScrollBar(vScroll);
} }
bool ItemPane::onSelect( int gridId, bool selected ) bool ItemPane::onSelect( int gridId, bool selected )
{ {
if (selected) if (selected)
screen->onItemSelected(this, gridId); screen->onItemSelected(this, gridId);
return selected; return selected;
} }
void ItemPane::drawScrollBar( ScrollBar& sb ) { void ItemPane::drawScrollBar( ScrollBar& sb ) {
if (sb.alpha <= 0) if (sb.alpha <= 0)
return; return;
int color = ((int)(255.0f * sb.alpha) << 24) | 0xffffff; int color = ((int)(255.0f * sb.alpha) << 24) | 0xffffff;
fill(2 + sb.x, sb.y, 2 + sb.x + sb.w, sb.y + sb.h, color); fill(2 + sb.x, sb.y, 2 + sb.x + sb.w, sb.y + sb.h, color);
} }

View File

@@ -1,93 +1,95 @@
#pragma once #ifndef ITEMPANE_H__
#define ITEMPANE_H__
#include <string>
#include <vector> #include <string>
#include "ScrollingPane.hpp" #include <vector>
#include "world/item/ItemInstance.hpp" #include "ScrollingPane.h"
#include "../../../world/item/ItemInstance.h"
class Font;
class Textures; class Font;
class NinePatchLayer; class Textures;
class Recipe; class NinePatchLayer;
class ItemPane; class Recipe;
class ItemPane;
class CItem
{ class CItem
public: {
CItem(const ItemInstance& ins, Recipe* recipe, const std::string& text) public:
: item(ins), CItem(const ItemInstance& ins, Recipe* recipe, const std::string& text)
recipe(recipe), : item(ins),
text(text), recipe(recipe),
sortText(text), text(text),
//maxBuildCount(0), sortText(text),
numBuilt(0), //maxBuildCount(0),
inventoryCount(0), numBuilt(0),
_canCraft(false) inventoryCount(0),
{ _canCraft(false)
} {
}
typedef struct ReqItem {
ReqItem() {} typedef struct ReqItem {
ReqItem(const ItemInstance& needItem, int has) ReqItem() {}
: item(needItem), has(has) {} ReqItem(const ItemInstance& needItem, int has)
ItemInstance item; : item(needItem), has(has) {}
int has; ItemInstance item;
bool enough() { return has >= item.count; } int has;
} ReqItem; bool enough() { return has >= item.count; }
} ReqItem;
bool canCraft() {
return _canCraft;// || maxBuildCount > 0; bool canCraft() {
} return _canCraft;// || maxBuildCount > 0;
void setCanCraft(bool status) { }
_canCraft = status; void setCanCraft(bool status) {
} _canCraft = status;
}
ItemInstance item;
Recipe* recipe; ItemInstance item;
std::string text; Recipe* recipe;
std::string sortText; std::string text;
//int maxBuildCount; std::string sortText;
int numBuilt; //int maxBuildCount;
int inventoryCount; int numBuilt;
std::vector<ReqItem> neededItems; int inventoryCount;
private: std::vector<ReqItem> neededItems;
bool _canCraft; private:
}; bool _canCraft;
};
class IItemPaneCallback
{ class IItemPaneCallback
public: {
virtual ~IItemPaneCallback() {} public:
virtual void onItemSelected(const ItemPane* forPane, int index) = 0; virtual ~IItemPaneCallback() {}
virtual const std::vector<CItem*>& getItems(const ItemPane* forPane) = 0; virtual void onItemSelected(const ItemPane* forPane, int index) = 0;
}; virtual const std::vector<CItem*>& getItems(const ItemPane* forPane) = 0;
};
class ItemPane: public ScrollingPane
{ class ItemPane: public ScrollingPane
typedef ScrollingPane super; {
public: typedef ScrollingPane super;
ItemPane( IItemPaneCallback* screen, public:
Textures* textures, ItemPane( IItemPaneCallback* screen,
const IntRectangle& rect, Textures* textures,
int numItems, const IntRectangle& rect,
int guiHeight, int numItems,
int physicalScreenHeight, int guiHeight,
bool isVertical = true); int physicalScreenHeight,
~ItemPane(); bool isVertical = true);
~ItemPane();
void renderBatch( std::vector<GridItem>& item, float alpha );
bool onSelect( int gridId, bool selected ); void renderBatch( std::vector<GridItem>& item, float alpha );
void drawScrollBar( ScrollBar& hScroll ); bool onSelect( int gridId, bool selected );
//void setSize() void drawScrollBar( ScrollBar& hScroll );
//void setSize()
Font* f;
Textures* textures; Font* f;
IItemPaneCallback* screen; Textures* textures;
IItemPaneCallback* screen;
int physicalScreenHeight; // Needed for glScissor
bool isVertical; int physicalScreenHeight; // Needed for glScissor
bool isVertical;
NinePatchLayer* guiSlotItem;
NinePatchLayer* guiSlotItemSelected; NinePatchLayer* guiSlotItem;
}; NinePatchLayer* guiSlotItemSelected;
};
#endif /*ITEMPANE_H__*/

View File

@@ -1,22 +1,22 @@
#include "KeyOption.hpp" #include "KeyOption.h"
#include <MinecraftClient.hpp> #include <client/Minecraft.h>
KeyOption::KeyOption(MinecraftClient& minecraft, OptionId optId) KeyOption::KeyOption(Minecraft* minecraft, OptionId optId)
: Touch::TButton((int)optId, Keyboard::getKeyName(minecraft.options().getIntValue(optId))) {} : Touch::TButton((int)optId, Keyboard::getKeyName(minecraft->options.getIntValue(optId))) {}
void KeyOption::mouseClicked(MinecraftClient& minecraft, int x, int y, int buttonNum) { void KeyOption::mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {
selected = isInside(x, y); selected = isInside(x, y);
msg = (selected)? "..." : Keyboard::getKeyName(minecraft.options().getIntValue((OptionId)id)); msg = (selected)? "..." : Keyboard::getKeyName(minecraft->options.getIntValue((OptionId)id));
} }
void KeyOption::keyPressed(MinecraftClient& minecraft, int key) { void KeyOption::keyPressed(Minecraft* minecraft, int key) {
if (!selected) return; if (!selected) return;
if (key != Keyboard::KEY_ESCAPE) { if (key != Keyboard::KEY_ESCAPE) {
minecraft.options().set((OptionId)id, key); minecraft->options.set((OptionId)id, key);
} }
selected = false; selected = false;
msg = Keyboard::getKeyName(minecraft.options().getIntValue((OptionId)id)); msg = Keyboard::getKeyName(minecraft->options.getIntValue((OptionId)id));
} }

View File

@@ -0,0 +1,14 @@
#pragma once
#include "Button.h"
#include <client/Options.h>
class KeyOption : public Touch::TButton {
public:
KeyOption(Minecraft* minecraft, OptionId optId);
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum);
virtual void released(int mx, int my) {}
virtual void keyPressed(Minecraft* minecraft, int key);
protected:
bool m_captureMode;
};

View File

@@ -1,14 +0,0 @@
#pragma once
#include "Button.hpp"
#include <client/Options.hpp>
class KeyOption : public Touch::TButton {
public:
KeyOption(MinecraftClient& minecraft, OptionId optId);
virtual void mouseClicked(MinecraftClient& minecraft, int x, int y, int buttonNum);
virtual void released(int mx, int my) {}
virtual void keyPressed(MinecraftClient& minecraft, int key);
protected:
bool m_captureMode;
};

View File

@@ -1,104 +1,104 @@
#include "LargeImageButton.hpp" #include "LargeImageButton.h"
#include "client/renderer/Tesselator.hpp" #include "../../renderer/Tesselator.h"
#include <MinecraftClient.hpp> #include "../../Minecraft.h"
#include "util/Mth.hpp" #include "../../../util/Mth.h"
#include "platform/log.hpp" #include "../../../platform/log.h"
#include "util/Mth.hpp" #include "../../../util/Mth.h"
#include "client/renderer/Textures.hpp" #include "../../renderer/Textures.h"
LargeImageButton::LargeImageButton(int id, const std::string& msg) LargeImageButton::LargeImageButton(int id, const std::string& msg)
: super(id, msg) : super(id, msg)
{ {
setupDefault(); setupDefault();
} }
LargeImageButton::LargeImageButton(int id, const std::string& msg, ImageDef& imagedef) LargeImageButton::LargeImageButton(int id, const std::string& msg, ImageDef& imagedef)
: super(id, msg) : super(id, msg)
{ {
_imageDef = imagedef; _imageDef = imagedef;
setupDefault(); setupDefault();
} }
void LargeImageButton::setupDefault() { void LargeImageButton::setupDefault() {
_buttonScale = 1; _buttonScale = 1;
width = 72; width = 72;
height = 72; height = 72;
} }
void LargeImageButton::render(MinecraftClient& minecraft, int xm, int ym) { void LargeImageButton::render(Minecraft* minecraft, int xm, int ym) {
if (!visible) return; if (!visible) return;
Font* font = minecraft.font(); Font* font = minecraft->font;
//minecraft.textures().loadAndBindTexture("gui/gui.png"); //minecraft->textures->loadAndBindTexture("gui/gui.png");
glColor4f2(1, 1, 1, 1); glColor4f2(1, 1, 1, 1);
bool hovered = active && (minecraft.useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym)); bool hovered = active && (minecraft->useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
//printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym); //printf("ButtonId: %d - Hovered? %d (cause: %d, %d, %d, %d, <> %d, %d)\n", id, hovered, x, y, x+w, y+h, xm, ym);
//int yImage = getYImage(hovered || selected); //int yImage = getYImage(hovered || selected);
//blit(x, y, 0, 46 + yImage * 20, w / 2, h, 0, 20); //blit(x, y, 0, 46 + yImage * 20, w / 2, h, 0, 20);
//blit(x + w / 2, y, 200 - w / 2, 46 + yImage * 20, w / 2, h, 0, 20); //blit(x + w / 2, y, 200 - w / 2, 46 + yImage * 20, w / 2, h, 0, 20);
renderBg(minecraft, xm, ym); renderBg(minecraft, xm, ym);
TextureId texId = (_imageDef.name.length() > 0)? minecraft.textures().loadAndBindTexture(_imageDef.name) : Textures::InvalidId; TextureId texId = (_imageDef.name.length() > 0)? minecraft->textures->loadAndBindTexture(_imageDef.name) : Textures::InvalidId;
if ( Textures::isTextureIdValid(texId) ) { if ( Textures::isTextureIdValid(texId) ) {
const ImageDef& d = _imageDef; const ImageDef& d = _imageDef;
Tesselator& t = Tesselator::instance; Tesselator& t = Tesselator::instance;
t.begin(); t.begin();
if (!active) t.color(0xff808080); if (!active) t.color(0xff808080);
//else if (hovered||selected) t.color(0xffffffff); //else if (hovered||selected) t.color(0xffffffff);
//else t.color(0xffe0e0e0); //else t.color(0xffe0e0e0);
else t.color(0xffffffff); else t.color(0xffffffff);
float hx = ((float) d.width) * 0.5f; float hx = ((float) d.width) * 0.5f;
float hy = ((float) d.height) * 0.5f; float hy = ((float) d.height) * 0.5f;
const float cx = ((float)x+d.x) + hx; const float cx = ((float)x+d.x) + hx;
const float cy = ((float)y+d.y) + hy; const float cy = ((float)y+d.y) + hy;
if (hovered) if (hovered)
_buttonScale = Mth::Max(0.95f, _buttonScale-0.025f); _buttonScale = Mth::Max(0.95f, _buttonScale-0.025f);
else else
_buttonScale = Mth::Min(1.00f, _buttonScale+0.025f); _buttonScale = Mth::Min(1.00f, _buttonScale+0.025f);
hx *= _buttonScale; hx *= _buttonScale;
hy *= _buttonScale; hy *= _buttonScale;
const IntRectangle* src = _imageDef.getSrc(); const IntRectangle* src = _imageDef.getSrc();
if (src) { if (src) {
const TextureData* d = minecraft.textures().getTemporaryTextureData(texId); const TextureData* d = minecraft->textures->getTemporaryTextureData(texId);
if (d != NULL) { if (d != NULL) {
float u0 = (src->x+(hovered?src->w:0)) / (float)d->w; float u0 = (src->x+(hovered?src->w:0)) / (float)d->w;
float u1 = (src->x+(hovered?2*src->w:src->w)) / (float)d->w; float u1 = (src->x+(hovered?2*src->w:src->w)) / (float)d->w;
float v0 = src->y / (float)d->h; float v0 = src->y / (float)d->h;
float v1 = (src->y+src->h) / (float)d->h; float v1 = (src->y+src->h) / (float)d->h;
t.vertexUV(cx-hx, cy-hy, blitOffset, u0, v0); 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, u0, v1);
t.vertexUV(cx+hx, cy+hy, blitOffset, u1, v1); t.vertexUV(cx+hx, cy+hy, blitOffset, u1, v1);
t.vertexUV(cx+hx, cy-hy, blitOffset, u1, v0); t.vertexUV(cx+hx, cy-hy, blitOffset, u1, v0);
} }
} else { } else {
t.vertexUV(cx-hx, cy-hy, blitOffset, 0, 0); t.vertexUV(cx-hx, cy-hy, blitOffset, 0, 0);
t.vertexUV(cx-hx, cy+hy, blitOffset, 0, 1); t.vertexUV(cx-hx, cy+hy, blitOffset, 0, 1);
t.vertexUV(cx+hx, cy+hy, blitOffset, 1, 1); t.vertexUV(cx+hx, cy+hy, blitOffset, 1, 1);
t.vertexUV(cx+hx, cy-hy, blitOffset, 1, 0); t.vertexUV(cx+hx, cy-hy, blitOffset, 1, 0);
} }
t.draw(); t.draw();
} }
//blit(0, 0, 0, 0, 64, 64, 256, 256); //blit(0, 0, 0, 0, 64, 64, 256, 256);
//LOGI("%d %d\n", x+d.x, x+d.x+d.w); //LOGI("%d %d\n", x+d.x, x+d.x+d.w);
if (!active) { if (!active) {
drawCenteredString(font, msg, x + width / 2, y + 11/*(h - 16)*/, 0xffa0a0a0); drawCenteredString(font, msg, x + width / 2, y + 11/*(h - 16)*/, 0xffa0a0a0);
} else { } else {
if (hovered || selected) { if (hovered || selected) {
drawCenteredString(font, msg, x + width / 2, y + 11/*(h - 16)*/, 0xffffa0); drawCenteredString(font, msg, x + width / 2, y + 11/*(h - 16)*/, 0xffffa0);
} else { } else {
drawCenteredString(font, msg, x + width / 2, y + 11/*(h - 48)*/, 0xe0e0e0); drawCenteredString(font, msg, x + width / 2, y + 11/*(h - 48)*/, 0xe0e0e0);
} }
} }
} }

View File

@@ -0,0 +1,21 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__LargeImageButton_H__
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__LargeImageButton_H__
#include "ImageButton.h"
class LargeImageButton: public ImageButton
{
typedef ImageButton super;
public:
LargeImageButton(int id, const std::string& msg);
LargeImageButton(int id, const std::string& msg, ImageDef& imageDef);
void render(Minecraft* minecraft, int xm, int ym);
private:
void setupDefault();
float _buttonScale;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__LargeImageButton_H__*/

Some files were not shown because too many files have changed in this diff Show More