44
.github/workflows/build.yml
vendored
@@ -46,6 +46,50 @@ jobs:
|
||||
sudo apt-get install --no-install-recommends -y cmake ninja-build
|
||||
- name: Build
|
||||
run: ./build-wasm.sh
|
||||
macos:
|
||||
name: macOS
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Install MacPorts
|
||||
uses: melusina-org/setup-macports@v1
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
sudo port install libsdl2 +universal
|
||||
sudo port install libpng +universal
|
||||
- name: Build macOS Archive
|
||||
run: |
|
||||
cd platforms/macos/projects/Minecraft
|
||||
xcodebuild -scheme "MinecraftClient.SDL2" \
|
||||
-archivePath $RUNNER_TEMP/GitHubActions_MacOS_SDL2.xcarchive \
|
||||
-sdk macosx \
|
||||
-configuration "Release (Default)" \
|
||||
-destination generic/platform=macOS \
|
||||
GCC_PREPROCESSOR_DEFINITIONS='MISSING_SOUND_DATA $(GCC_PREPROCESSOR_DEFINITIONS)' \
|
||||
-quiet \
|
||||
clean archive
|
||||
# @NOTE: Newer versions of Xcode will complain and refuse to build old XIB files or target old iOS versions
|
||||
#ios:
|
||||
# runs-on: macos-latest
|
||||
# steps:
|
||||
# - name: Checkout Repository
|
||||
# uses: actions/checkout@v3
|
||||
# with:
|
||||
# submodules: true
|
||||
# - name: Build iOS Archive
|
||||
# run: |
|
||||
# cd platforms/macos/projects/Minecraft
|
||||
# xcodebuild -scheme "minecraftpe" \
|
||||
# -archivePath $RUNNER_TEMP/GitHubActions_iOS.xcarchive \
|
||||
# -sdk iphoneos \
|
||||
# -configuration "Release (iOS)" \
|
||||
# -destination generic/platform=iOS \
|
||||
# GCC_PREPROCESSOR_DEFINITIONS='MISSING_SOUND_DATA $(GCC_PREPROCESSOR_DEFINITIONS)' \
|
||||
# -quiet \
|
||||
# clean archive
|
||||
android:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
2
.gitignore
vendored
@@ -201,4 +201,6 @@ xcuserdata/
|
||||
# Ignore options.txt - where your configuration will be saved
|
||||
/game/options.txt
|
||||
/game/assetsO
|
||||
/game/assets/gui/feedback_fill.png
|
||||
/game/assets/gui/feedback_outer.png
|
||||
/game/assets/snow.png
|
||||
|
||||
@@ -22,13 +22,19 @@ enum eSDLVirtualKeys
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#elif __APPLE__
|
||||
// https://i.stack.imgur.com/LD8pT.png
|
||||
#define AKEYCODE_FORWARD_DEL 0x75
|
||||
#define AKEYCODE_ARROW_LEFT 0x7B
|
||||
#define AKEYCODE_ARROW_RIGHT 0x7C
|
||||
#define AKEYCODE_DEL 0x33
|
||||
#endif
|
||||
|
||||
#ifdef USE_NATIVE_ANDROID
|
||||
#include <android/keycodes.h>
|
||||
#include <android/keycodes.h>
|
||||
|
||||
#define AKEYCODE_ARROW_LEFT AKEYCODE_DPAD_LEFT
|
||||
#define AKEYCODE_ARROW_RIGHT AKEYCODE_DPAD_RIGHT
|
||||
#define AKEYCODE_ARROW_LEFT AKEYCODE_DPAD_LEFT
|
||||
#define AKEYCODE_ARROW_RIGHT AKEYCODE_DPAD_RIGHT
|
||||
#endif
|
||||
|
||||
13
compat/LegacyCPPCompatibility.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef USE_OLD_CPP
|
||||
#ifndef constexpr
|
||||
#define constexpr const
|
||||
#endif
|
||||
#ifndef nullptr
|
||||
#define nullptr NULL
|
||||
#endif
|
||||
#ifndef override
|
||||
#define override
|
||||
#endif
|
||||
#endif
|
||||
17
compat/PlatformDefinitions.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// PlatformDefinitions.h
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 11/27/23.
|
||||
//
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
#define MC_TARGET_OS_SIMULATOR (TARGET_OS_SIMULATOR || TARGET_IPHONE_SIMULATOR)
|
||||
#define MC_TARGET_OS_IOS (TARGET_OS_IPHONE && (TARGET_OS_IOS || !defined(TARGET_OS_IOS)))
|
||||
#define MC_TARGET_OS_MAC (TARGET_OS_MAC)
|
||||
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 119 KiB |
BIN
game/assets/ios/Default-568h@2x.png
Executable file
|
After Width: | Height: | Size: 678 KiB |
BIN
game/assets/ios/Default-Landscape~ipad.png
Executable file
|
After Width: | Height: | Size: 730 KiB |
BIN
game/assets/ios/Default.png
Executable file
|
After Width: | Height: | Size: 177 KiB |
BIN
game/assets/ios/Default@2x.png
Executable file
|
After Width: | Height: | Size: 569 KiB |
0
game/assets/patches/patch_data.txt
Normal file → Executable file
0
game/assets/readme.txt
Normal file → Executable file
25
platforms/ios/AppContext.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// AppContext.hpp
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 10/13/23.
|
||||
// Copyright (c) 2023 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "client/app/AppPlatform.hpp"
|
||||
|
||||
class AppContext
|
||||
{
|
||||
public:
|
||||
AppContext()
|
||||
{
|
||||
platform = nullptr;
|
||||
}
|
||||
|
||||
AppPlatform *platform;
|
||||
std::string doRender;
|
||||
};
|
||||
58
platforms/ios/AppPlatform_iOS.h
Normal file
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// AppPlatform_iOS.h
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 10/30/23.
|
||||
// Copyright (c) 2023 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#import "minecraftpeViewController.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "client/app/AppPlatform.hpp"
|
||||
|
||||
#include "client/player/input/Mouse.hpp"
|
||||
#include "client/player/input/Keyboard.hpp"
|
||||
#include "common/Logger.hpp"
|
||||
|
||||
class AppPlatform_iOS : public AppPlatform
|
||||
{
|
||||
public:
|
||||
AppPlatform_iOS(minecraftpeViewController *viewController);
|
||||
~AppPlatform_iOS();
|
||||
|
||||
void initSoundSystem() override;
|
||||
|
||||
int checkLicense() override;
|
||||
int getScreenWidth() const override;
|
||||
int getScreenHeight() const override;
|
||||
Texture loadTexture(const std::string& path, bool b = false) override;
|
||||
int getUserInputStatus() override;
|
||||
bool isTouchscreen() override;
|
||||
std::string getAssetPath(const std::string &path) const override;
|
||||
std::string getPatchData() override;
|
||||
SoundSystem* const getSoundSystem() const override { return m_pSoundSystem; }
|
||||
|
||||
// Also add these to allow proper text input within the game.
|
||||
bool shiftPressed() override;
|
||||
void setShiftPressed(bool b, bool isLeft);
|
||||
void showKeyboard() override;
|
||||
void hideKeyboard() override;
|
||||
int getKeyboardUpOffset() override;
|
||||
|
||||
// Also add these to allow saving options.
|
||||
bool hasFileSystemAccess() override;
|
||||
private:
|
||||
Logger* m_pLogger;
|
||||
SoundSystem* m_pSoundSystem;
|
||||
|
||||
minecraftpeViewController* m_pViewController;
|
||||
|
||||
bool m_bShiftPressed[2];
|
||||
|
||||
bool m_bIsKeyboardShown;
|
||||
};
|
||||
|
||||
180
platforms/ios/AppPlatform_iOS.mm
Normal file
@@ -0,0 +1,180 @@
|
||||
//
|
||||
// AppPlatform_iOS.m
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 10/30/23.
|
||||
// Copyright (c) 2023 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#include "AppPlatform_iOS.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
#include "platforms/openal/SoundSystemAL.hpp"
|
||||
|
||||
AppPlatform_iOS::AppPlatform_iOS(minecraftpeViewController *viewController)
|
||||
{
|
||||
m_bShiftPressed[0] = false;
|
||||
m_bShiftPressed[1] = false;
|
||||
|
||||
m_bIsKeyboardShown = false;
|
||||
|
||||
m_pLogger = new Logger;
|
||||
m_pSoundSystem = nullptr;
|
||||
|
||||
m_pViewController = viewController;
|
||||
}
|
||||
|
||||
void AppPlatform_iOS::initSoundSystem()
|
||||
{
|
||||
if (!m_pSoundSystem)
|
||||
{
|
||||
LOG_I("Initializing OpenAL SoundSystem...");
|
||||
m_pSoundSystem = new SoundSystemAL();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_E("Trying to initialize SoundSystem more than once!");
|
||||
}
|
||||
}
|
||||
|
||||
AppPlatform_iOS::~AppPlatform_iOS()
|
||||
{
|
||||
SAFE_DELETE(m_pSoundSystem);
|
||||
|
||||
// DELETE THIS LAST
|
||||
SAFE_DELETE(m_pLogger);
|
||||
}
|
||||
|
||||
int AppPlatform_iOS::checkLicense()
|
||||
{
|
||||
// we own the game!!
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AppPlatform_iOS::getScreenWidth() const
|
||||
{
|
||||
return m_pViewController.width;
|
||||
}
|
||||
|
||||
int AppPlatform_iOS::getScreenHeight() const
|
||||
{
|
||||
return m_pViewController.height;
|
||||
}
|
||||
|
||||
Texture AppPlatform_iOS::loadTexture(const std::string& path, bool b)
|
||||
{
|
||||
Texture out;
|
||||
out.field_C = 1;
|
||||
out.field_D = 0;
|
||||
|
||||
std::string realPath = getAssetPath(path);
|
||||
|
||||
UIImage * image = [UIImage imageWithContentsOfFile:
|
||||
[NSString stringWithUTF8String: realPath.c_str()]];
|
||||
|
||||
if (!image || !image.CGImage)
|
||||
{
|
||||
LOG_E("Couldn't find file: %s", path.c_str());
|
||||
return out;
|
||||
}
|
||||
|
||||
out.m_width = CGImageGetWidth(image.CGImage);
|
||||
out.m_height = CGImageGetHeight(image.CGImage);
|
||||
out.m_pixels = new uint32_t[out.m_width * out.m_height];
|
||||
|
||||
CGColorSpace *colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
CGContextRef context = CGBitmapContextCreate(out.m_pixels, out.m_width, out.m_height, 8u, sizeof(uint32_t) * out.m_width, colorSpace, 0x4001u);
|
||||
CGColorSpaceRelease(colorSpace);
|
||||
|
||||
CGRect rect;
|
||||
rect.origin.x = 0.0;
|
||||
rect.origin.y = 0.0;
|
||||
rect.size.width = static_cast<float>(out.m_width);
|
||||
rect.size.height = static_cast<float>(out.m_height);
|
||||
CGContextClearRect(context, rect);
|
||||
CGContextTranslateCTM(context, 0.0, 0.0);
|
||||
CGContextDrawImage(context, rect, image.CGImage);
|
||||
CGContextRelease(context);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
bool AppPlatform_iOS::shiftPressed()
|
||||
{
|
||||
return m_bShiftPressed[0] || m_bShiftPressed[1];
|
||||
}
|
||||
|
||||
void AppPlatform_iOS::setShiftPressed(bool b, bool isLeft)
|
||||
{
|
||||
m_bShiftPressed[isLeft ? 0 : 1] = b;
|
||||
}
|
||||
|
||||
void AppPlatform_iOS::showKeyboard()
|
||||
{
|
||||
[m_pViewController showKeyboard];
|
||||
m_bIsKeyboardShown = true;
|
||||
}
|
||||
|
||||
void AppPlatform_iOS::hideKeyboard()
|
||||
{
|
||||
[m_pViewController hideKeyboard];
|
||||
m_bIsKeyboardShown = false;
|
||||
}
|
||||
|
||||
int AppPlatform_iOS::getKeyboardUpOffset()
|
||||
{
|
||||
// @TODO
|
||||
// For now we'll just return 1/2 of the screen height. That ought to cover most cases.
|
||||
return m_pViewController.height / 2;
|
||||
}
|
||||
|
||||
int AppPlatform_iOS::getUserInputStatus()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool AppPlatform_iOS::isTouchscreen()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppPlatform_iOS::hasFileSystemAccess()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AppPlatform_iOS::getAssetPath(const std::string &path) const
|
||||
{
|
||||
size_t dotPos = path.rfind(".", -1, 1);
|
||||
size_t slashPos = path.rfind("/", -1, 1);
|
||||
size_t dotPos2 = path.rfind('.', -1);
|
||||
std::string fileName;
|
||||
std::string fileExtension = dotPos2 != std::string::npos ? path.substr(dotPos2+1, path.length()-dotPos2) : "";
|
||||
if ((slashPos & dotPos) != std::string::npos)
|
||||
{
|
||||
// "." & "/" exist in path
|
||||
fileName = path.substr(slashPos+1, dotPos - (slashPos+1));
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = path;
|
||||
}
|
||||
|
||||
return [[[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:fileName.c_str()] ofType:[NSString stringWithUTF8String:fileExtension.c_str()]] UTF8String];
|
||||
}
|
||||
|
||||
std::string AppPlatform_iOS::getPatchData()
|
||||
{
|
||||
std::ifstream ifs(getAssetPath("patches/patch_data.txt").c_str());
|
||||
if (!ifs.is_open())
|
||||
return "";
|
||||
|
||||
std::stringstream ss;
|
||||
ss << ifs.rdbuf();
|
||||
ifs.close();
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
37
platforms/ios/EAGLView.h
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// EAGLView.h
|
||||
// GLBase
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <OpenGLES/ES1/gl.h>
|
||||
#import <OpenGLES/ES1/glext.h>
|
||||
#import <OpenGLES/ES2/gl.h>
|
||||
#import <OpenGLES/ES2/glext.h>
|
||||
|
||||
// This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
|
||||
// The view content is basically an EAGL surface you render your OpenGL scene into.
|
||||
// Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
|
||||
@interface EAGLView : UIView
|
||||
{
|
||||
@private
|
||||
EAGLContext *context;
|
||||
|
||||
// The pixel dimensions of the CAEAGLLayer.
|
||||
GLint framebufferWidth;
|
||||
GLint framebufferHeight;
|
||||
|
||||
// The OpenGL ES names for the framebuffer and renderbuffer used to render to this view.
|
||||
GLuint defaultFramebuffer, colorRenderbuffer;
|
||||
GLuint depthRenderbuffer;
|
||||
|
||||
CGFloat viewScale;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) EAGLContext *context;
|
||||
|
||||
- (void)setFramebuffer;
|
||||
- (BOOL)presentFramebuffer;
|
||||
|
||||
@end
|
||||
189
platforms/ios/EAGLView.m
Normal file
@@ -0,0 +1,189 @@
|
||||
//
|
||||
// EAGLView.m
|
||||
// GLBase
|
||||
//
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
#import "EAGLView.h"
|
||||
|
||||
@interface EAGLView (PrivateMethods)
|
||||
- (void)createFramebuffer;
|
||||
- (void)deleteFramebuffer;
|
||||
@end
|
||||
|
||||
@implementation EAGLView
|
||||
|
||||
@dynamic context;
|
||||
|
||||
// You must implement this method
|
||||
+ (Class)layerClass
|
||||
{
|
||||
return [CAEAGLLayer class];
|
||||
}
|
||||
|
||||
//The EAGL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:.
|
||||
- (id)initWithCoder:(NSCoder*)coder
|
||||
{
|
||||
self = [super initWithCoder:coder];
|
||||
if (self)
|
||||
{
|
||||
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
|
||||
|
||||
eaglLayer.opaque = TRUE;
|
||||
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
|
||||
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
|
||||
nil];
|
||||
self->viewScale = 1.0;
|
||||
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
|
||||
{
|
||||
self->viewScale = [[UIScreen mainScreen] scale];
|
||||
if ([self respondsToSelector:@selector(setContentScaleFactor:)])
|
||||
{
|
||||
[self setContentScaleFactor:self->viewScale];
|
||||
[eaglLayer setContentsScale:self->viewScale];
|
||||
}
|
||||
}
|
||||
NSLog(@"Scale is : %f\n", self->viewScale);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self deleteFramebuffer];
|
||||
#if !__has_feature(objc_arc)
|
||||
[context release];
|
||||
|
||||
[super dealloc];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (EAGLContext *)context
|
||||
{
|
||||
return context;
|
||||
}
|
||||
|
||||
- (void)setContext:(EAGLContext *)newContext
|
||||
{
|
||||
if (context != newContext)
|
||||
{
|
||||
[self deleteFramebuffer];
|
||||
|
||||
context = newContext;
|
||||
|
||||
[EAGLContext setCurrentContext:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)createFramebuffer
|
||||
{
|
||||
if (context && !defaultFramebuffer)
|
||||
{
|
||||
[EAGLContext setCurrentContext:context];
|
||||
|
||||
// Create default framebuffer object.
|
||||
glGenFramebuffers(1, &defaultFramebuffer);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
|
||||
|
||||
// Create color render buffer and allocate backing store.
|
||||
glGenRenderbuffers(1, &colorRenderbuffer);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
|
||||
BOOL success = [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer *)self.layer];
|
||||
if (!success)
|
||||
NSLog(@"Failed to bind CAEAGLayer to renderbuffer object!\n");
|
||||
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &framebufferWidth);
|
||||
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &framebufferHeight);
|
||||
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
|
||||
|
||||
// Add depth buffer
|
||||
glGenRenderbuffers(1, &depthRenderbuffer);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16 /*GL_DEPTH24_STENCIL8*/,
|
||||
framebufferWidth, framebufferHeight);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
GL_RENDERBUFFER, depthRenderbuffer );
|
||||
|
||||
// Doing stencil stuff isn't supported on iOS 4.1, and I can't see any reason to be using it to begin with
|
||||
/*glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
||||
GL_RENDERBUFFER, depthRenderbuffer );*/
|
||||
NSLog(@"Created framebuffer with size %d, %d\n", framebufferWidth, framebufferHeight);
|
||||
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
NSLog(@"Failed to make complete framebuffer object %x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER));
|
||||
}
|
||||
}
|
||||
|
||||
- (void)deleteFramebuffer
|
||||
{
|
||||
if (context)
|
||||
{
|
||||
[EAGLContext setCurrentContext:context];
|
||||
|
||||
if (defaultFramebuffer)
|
||||
{
|
||||
glDeleteFramebuffers(1, &defaultFramebuffer);
|
||||
defaultFramebuffer = 0;
|
||||
}
|
||||
|
||||
if (colorRenderbuffer)
|
||||
{
|
||||
glDeleteRenderbuffers(1, &colorRenderbuffer);
|
||||
colorRenderbuffer = 0;
|
||||
}
|
||||
|
||||
if (depthRenderbuffer)
|
||||
{
|
||||
glDeleteRenderbuffers(1, &depthRenderbuffer);
|
||||
depthRenderbuffer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setFramebuffer
|
||||
{
|
||||
if (context)
|
||||
{
|
||||
[EAGLContext setCurrentContext:context];
|
||||
|
||||
if (!defaultFramebuffer)
|
||||
[self createFramebuffer];
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, defaultFramebuffer);
|
||||
|
||||
glViewport(0, 0, framebufferWidth, framebufferHeight);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)presentFramebuffer
|
||||
{
|
||||
BOOL success = FALSE;
|
||||
|
||||
if (context)
|
||||
{
|
||||
[EAGLContext setCurrentContext:context];
|
||||
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, self->defaultFramebuffer);
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_4_0 && __IPHONE_OS_VERSION_MIN_REQUIRED <= __IPHONE_12_0
|
||||
GLenum discards[] = { GL_DEPTH_ATTACHMENT, GL_COLOR_ATTACHMENT0, GL_STENCIL_ATTACHMENT };
|
||||
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 3, discards);
|
||||
#endif
|
||||
|
||||
success = [context presentRenderbuffer:GL_RENDERBUFFER];
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
// The framebuffer will be re-created at the beginning of the next setFramebuffer method call.
|
||||
[self deleteFramebuffer];
|
||||
}
|
||||
|
||||
@end
|
||||
105
platforms/ios/MainWindow.xib
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">0</int>
|
||||
<string key="IBDocument.SystemVersion">10K549</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
|
||||
<string key="IBDocument.AppKitVersion">1038.36</string>
|
||||
<string key="IBDocument.HIToolboxVersion">461.00</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="NS.object.0">933</string>
|
||||
</object>
|
||||
<array key="IBDocument.IntegratedClassDependencies">
|
||||
<string>IBProxyObject</string>
|
||||
<string>IBUIView</string>
|
||||
</array>
|
||||
<array key="IBDocument.PluginDependencies">
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</array>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
|
||||
<integer value="1" key="NS.object.0"/>
|
||||
</object>
|
||||
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
|
||||
<object class="IBProxyObject" id="372490531">
|
||||
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBProxyObject" id="975951072">
|
||||
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBUIView" id="191373211">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<string key="NSFrameSize">{480, 320}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
</object>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
<bool key="IBUIUserInteractionEnabled">NO</bool>
|
||||
<object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
|
||||
<int key="IBUIInterfaceOrientation">3</int>
|
||||
<int key="interfaceOrientation">3</int>
|
||||
</object>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<array class="NSMutableArray" key="connectionRecords"/>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<array key="object" id="0"/>
|
||||
<reference key="children" ref="1000"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">1</int>
|
||||
<reference key="object" ref="191373211"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-1</int>
|
||||
<reference key="object" ref="372490531"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">File's Owner</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="975951072"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
<string key="-1.CustomClassName">minecraftpeViewController</string>
|
||||
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="-2.CustomClassName">UIResponder</string>
|
||||
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">2</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes"/>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
|
||||
<real value="0.0" key="NS.object.0"/>
|
||||
</object>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
<string key="IBCocoaTouchPluginVersion">933</string>
|
||||
</data>
|
||||
</archive>
|
||||
13
platforms/ios/PlatformDefinitions_iOS.h
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// PlatformDefinitions_iOS.h
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 12/19/23.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#ifndef NS_DEPRECATED_IOS
|
||||
#define NS_DEPRECATED_IOS(_iosIntro, _iosDep) NS_DEPRECATED_IPHONE(_iosIntro, _iosDep)
|
||||
#endif
|
||||
14
platforms/ios/Shaders/Shader.fsh
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Shader.fsh
|
||||
// minecraftpe
|
||||
//
|
||||
// Created by Brent on 10/12/23.
|
||||
// Copyright (c) 2023 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
varying lowp vec4 colorVarying;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = colorVarying;
|
||||
}
|
||||
28
platforms/ios/Shaders/Shader.vsh
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Shader.vsh
|
||||
// minecraftpe
|
||||
//
|
||||
// Created by Brent on 10/12/23.
|
||||
// Copyright (c) 2023 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
attribute vec4 position;
|
||||
attribute vec3 normal;
|
||||
|
||||
varying lowp vec4 colorVarying;
|
||||
|
||||
uniform mat4 modelViewProjectionMatrix;
|
||||
uniform mat3 normalMatrix;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 eyeNormal = normalize(normalMatrix * normal);
|
||||
vec3 lightPosition = vec3(0.0, 0.0, 1.0);
|
||||
vec4 diffuseColor = vec4(0.4, 0.4, 1.0, 1.0);
|
||||
|
||||
float nDotVP = max(0.0, dot(eyeNormal, normalize(lightPosition)));
|
||||
|
||||
colorVarying = diffuseColor * nDotVP;
|
||||
|
||||
gl_Position = modelViewProjectionMatrix * position;
|
||||
}
|
||||
23
platforms/ios/ShowKeyboardView.h
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// ShowKeyboardView.h
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 12/4/23.
|
||||
//
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#include "Minecraft.hpp"
|
||||
|
||||
@interface ShowKeyboardView : UIView<UITextFieldDelegate>
|
||||
{
|
||||
|
||||
}
|
||||
- (id)initWithMinecraft:(Minecraft*)app;
|
||||
- (BOOL)hasText;
|
||||
- (BOOL)canBecomeFirstResponder;
|
||||
- (void)showKeyboard;
|
||||
- (void)hideKeyboard;
|
||||
- (void)textFieldDidChange:(NSNotification*)field;
|
||||
- (void)textFieldShouldReturn:(UITextField *)field;
|
||||
@end
|
||||
118
platforms/ios/ShowKeyboardView.mm
Normal file
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// ShowKeyboardView.m
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 12/4/23.
|
||||
//
|
||||
//
|
||||
|
||||
#import "ShowKeyboardView.h"
|
||||
|
||||
@implementation ShowKeyboardView
|
||||
|
||||
UITextField *textField;
|
||||
NSString *lastString;
|
||||
Minecraft* _app;
|
||||
|
||||
- (id)initWithMinecraft:(Minecraft*)app
|
||||
{
|
||||
self = [self init];
|
||||
if (self)
|
||||
_app = app;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
// Initialization code
|
||||
textField = [[UITextField alloc] init];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:@"UITextFieldTextDidChangeNotification" object:textField];
|
||||
[textField setDelegate:self];
|
||||
[textField setAutocorrectionType:UITextAutocorrectionTypeNo];
|
||||
[textField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
|
||||
[self addSubview:textField];
|
||||
lastString = @"AAAA";
|
||||
[textField setText:lastString];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)hasText
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeFirstResponder
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)showKeyboard
|
||||
{
|
||||
[textField becomeFirstResponder];
|
||||
}
|
||||
|
||||
- (void)hideKeyboard
|
||||
{
|
||||
[textField resignFirstResponder];
|
||||
[self resignFirstResponder];
|
||||
}
|
||||
|
||||
- (void)textFieldDidChange:(NSNotification*)event
|
||||
{
|
||||
UITextField *field = [event object];
|
||||
if (field.text != lastString)
|
||||
{
|
||||
if (lastString.length <= field.text.length)
|
||||
{
|
||||
if ([field.text characterAtIndex:field.text.length - 1] != '\n')
|
||||
{
|
||||
if (lastString.length != field.text.length)
|
||||
{
|
||||
/*unichar lastUniChar = [field.text characterAtIndex:field.text.length - 1];
|
||||
const char* last = [[NSString stringWithCharacters:&lastUniChar length:1] UTF8String ];
|
||||
if (last)
|
||||
{
|
||||
// Feed new character into handler
|
||||
_app->handleCharInput(last[0]);
|
||||
}*/
|
||||
const char* str = [[field.text substringFromIndex:(field.text.length - (field.text.length - lastString.length))] UTF8String];
|
||||
for (const char *c = str; *c != '\0'; c++)
|
||||
{
|
||||
// Feed new characters into handler
|
||||
_app->handleCharInput(*c);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Simulate backspace
|
||||
_app->handleCharInput(0x08);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Simulate carriage return
|
||||
_app->handleCharInput(0x0D);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Simulate backspace
|
||||
_app->handleCharInput(0x08);
|
||||
}
|
||||
|
||||
if (textField.text.length < 4)
|
||||
textField.text = @"AAAA";
|
||||
}
|
||||
lastString = [[NSString stringWithString:field.text] retain];
|
||||
}
|
||||
|
||||
- (void)textFieldShouldReturn:(UITextField *)field
|
||||
{
|
||||
// Simulate carriage return
|
||||
_app->handleCharInput(0x0D);
|
||||
}
|
||||
|
||||
@end
|
||||
2
platforms/ios/en.lproj/InfoPlist.strings
Normal file
@@ -0,0 +1,2 @@
|
||||
/* Localized versions of Info.plist keys */
|
||||
|
||||
117
platforms/ios/en.lproj/minecraftpeViewController.xib
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">0</int>
|
||||
<string key="IBDocument.SystemVersion">10K549</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
|
||||
<string key="IBDocument.AppKitVersion">1038.36</string>
|
||||
<string key="IBDocument.HIToolboxVersion">461.00</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="NS.object.0">933</string>
|
||||
</object>
|
||||
<array key="IBDocument.IntegratedClassDependencies">
|
||||
<string>IBProxyObject</string>
|
||||
<string>IBUIView</string>
|
||||
</array>
|
||||
<array key="IBDocument.PluginDependencies">
|
||||
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</array>
|
||||
<object class="NSMutableDictionary" key="IBDocument.Metadata">
|
||||
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
|
||||
<integer value="1" key="NS.object.0"/>
|
||||
</object>
|
||||
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
|
||||
<object class="IBProxyObject" id="841351856">
|
||||
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBProxyObject" id="371349661">
|
||||
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
<object class="IBUIView" id="184854543">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<string key="NSFrameSize">{480, 320}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
</object>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
<bool key="IBUIMultipleTouchEnabled">YES</bool>
|
||||
<object class="IBUISimulatedOrientationMetrics" key="IBUISimulatedOrientationMetrics">
|
||||
<int key="IBUIInterfaceOrientation">3</int>
|
||||
<int key="interfaceOrientation">3</int>
|
||||
</object>
|
||||
<object class="IBUIAccessibilityConfiguration" key="IBUIAccessibilityConfiguration">
|
||||
<integer value="532" key="IBUIAccessibilityTraits"/>
|
||||
</object>
|
||||
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<array class="NSMutableArray" key="connectionRecords">
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBCocoaTouchOutletConnection" key="connection">
|
||||
<string key="label">view</string>
|
||||
<reference key="source" ref="841351856"/>
|
||||
<reference key="destination" ref="184854543"/>
|
||||
</object>
|
||||
<int key="connectionID">3</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<array key="object" id="0"/>
|
||||
<reference key="children" ref="1000"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-1</int>
|
||||
<reference key="object" ref="841351856"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">File's Owner</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="371349661"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">2</int>
|
||||
<reference key="object" ref="184854543"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
<string key="-1.CustomClassName">minecraftpeViewController</string>
|
||||
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="-2.CustomClassName">UIResponder</string>
|
||||
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
<string key="2.CustomClassName">EAGLView</string>
|
||||
<string key="2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">4</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes"/>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
|
||||
<real value="0.0" key="NS.object.0"/>
|
||||
</object>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
<string key="IBCocoaTouchPluginVersion">933</string>
|
||||
</data>
|
||||
</archive>
|
||||
18
platforms/ios/main.m
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// main.m
|
||||
// minecraftpe
|
||||
//
|
||||
// Created by Brent on 10/12/23.
|
||||
// Copyright (c) 2023 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "minecraftpeAppDelegate.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([minecraftpeAppDelegate class]));
|
||||
}
|
||||
}
|
||||
50
platforms/ios/minecraftpe-Info.plist
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Minecraft PE</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array/>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.mojang.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.games</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainWindow</string>
|
||||
<key>UIPrerenderedIcon</key>
|
||||
<true/>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array/>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
8
platforms/ios/minecraftpe.entitlements
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>get-task-allow</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
28
platforms/ios/minecraftpeAppDelegate.h
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// minecraftpeAppDelegate.h
|
||||
// minecraftpe
|
||||
//
|
||||
// Created by Brent on 10/12/23.
|
||||
// Copyright (c) 2023 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <AVFoundation/AVAudioSession.h>
|
||||
|
||||
#import "PlatformDefinitions_iOS.h"
|
||||
|
||||
@class minecraftpeViewController;
|
||||
|
||||
@interface minecraftpeAppDelegate : NSObject <UIApplicationDelegate, AVAudioSessionDelegate> {
|
||||
UIWindow *window;
|
||||
minecraftpeViewController *viewController;
|
||||
AVAudioSession *audioSession;
|
||||
NSString *audioSessionSoundCategory;
|
||||
UIBackgroundTaskIdentifier bgTask NS_AVAILABLE_IOS(4_0);
|
||||
}
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
@property (strong, nonatomic) minecraftpeViewController *viewController;
|
||||
|
||||
- (void)setAudioEnabled:(BOOL)audioEnabled;
|
||||
|
||||
@end
|
||||
173
platforms/ios/minecraftpeAppDelegate.mm
Normal file
@@ -0,0 +1,173 @@
|
||||
//
|
||||
// minecraftpeAppDelegate.m
|
||||
// minecraftpe
|
||||
//
|
||||
// Created by Brent on 10/12/23.
|
||||
// Copyright (c) 2023 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "minecraftpeAppDelegate.h"
|
||||
|
||||
#import "minecraftpeViewController.h"
|
||||
#import "AppPlatform_iOS.h"
|
||||
|
||||
NSError *G_audioSessionError = nil;
|
||||
|
||||
@interface minecraftpeAppDelegate ()
|
||||
- (void)initAudio;
|
||||
@end
|
||||
|
||||
@implementation minecraftpeAppDelegate
|
||||
|
||||
@synthesize window;
|
||||
@synthesize viewController;
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
||||
{
|
||||
[self initAudio];
|
||||
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||
// Override point for customization after application launch.
|
||||
self.viewController = [[minecraftpeViewController alloc] initWithNibName:@"minecraftpeViewController" bundle:nil];
|
||||
if ([self.window respondsToSelector:@selector(setRootViewController:)])
|
||||
{
|
||||
[self.window setRootViewController:self.viewController];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self.window addSubview:self.viewController.view];
|
||||
}
|
||||
NSLog(@"ViewController: %p\n", self.viewController);
|
||||
[self.window makeKeyAndVisible];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
*/
|
||||
NSLog(@"resign-active: %@\n", [NSThread currentThread]);
|
||||
[self.viewController stopAnimation];
|
||||
//AppPlatform_iOS *platform = [self.viewController platform];
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
*/
|
||||
|
||||
void (^handler)() = ^()
|
||||
{
|
||||
[application endBackgroundTask:bgTask];
|
||||
bgTask = UIBackgroundTaskInvalid;
|
||||
NSLog(@"TIME RAN OUT %p\n", pthread_self()); // This originally used std::out, not sure why
|
||||
};
|
||||
bgTask = [application beginBackgroundTaskWithExpirationHandler:handler];
|
||||
viewController->suspended = YES;
|
||||
AppPlatform_iOS *platform = [self.viewController platform];
|
||||
platform->_fireAppSuspended();
|
||||
[application endBackgroundTask:bgTask];
|
||||
bgTask = UIBackgroundTaskInvalid;
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
||||
*/
|
||||
viewController->suspended = NO;
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
*/
|
||||
NSLog(@"become-active: %@\n", [NSThread currentThread]);
|
||||
[self.viewController startAnimation];
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application
|
||||
{
|
||||
/*
|
||||
Called when the application is about to terminate.
|
||||
Save data if appropriate.
|
||||
See also applicationDidEnterBackground:.
|
||||
*/
|
||||
[self.viewController stopAnimation];
|
||||
}
|
||||
|
||||
- (void)beginInterruption
|
||||
{
|
||||
NSLog(@"beginInterruption\n");
|
||||
[self setAudioEnabled:NO];
|
||||
}
|
||||
|
||||
- (void)endInterruption
|
||||
{
|
||||
NSLog(@"endInterruption\n");
|
||||
[self setAudioEnabled:YES];
|
||||
}
|
||||
|
||||
- (void)initAudio
|
||||
{
|
||||
self->audioSession = [AVAudioSession sharedInstance];
|
||||
|
||||
self->audioSessionSoundCategory = AVAudioSessionCategoryAmbient;
|
||||
[audioSession setCategory:audioSessionSoundCategory error:&G_audioSessionError];
|
||||
if (G_audioSessionError)
|
||||
NSLog(@"Warning; Couldn't init audio\n");
|
||||
|
||||
[audioSession setDelegate:self];
|
||||
|
||||
G_audioSessionError = nil;
|
||||
[audioSession setActive:YES error:&G_audioSessionError];
|
||||
if (G_audioSessionError)
|
||||
NSLog(@"Warning; Couldn't set audio active\n");
|
||||
}
|
||||
|
||||
- (void)setAudioEnabled:(BOOL)audioEnabled
|
||||
{
|
||||
NSLog(@"set-audio-enabled: :%d %@\n", audioEnabled, [NSThread currentThread]);
|
||||
if (audioEnabled)
|
||||
{
|
||||
[audioSession setCategory:audioSessionSoundCategory error:&G_audioSessionError];
|
||||
if (G_audioSessionError)
|
||||
{
|
||||
NSLog(@"ERROR - SoundManager: Unable to set the audio session category with error: %@\n", G_audioSessionError);
|
||||
return;
|
||||
}
|
||||
[audioSession setActive:YES error:&G_audioSessionError];
|
||||
if (G_audioSessionError)
|
||||
{
|
||||
NSLog(@"ERROR - SoundManager: Unable to set the audio session state to YES with error: %@\n", G_audioSessionError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"INFO - SoundManager: OpenAL Inactive\n");
|
||||
[audioSession setActive:NO error:&G_audioSessionError];
|
||||
if (G_audioSessionError)
|
||||
{
|
||||
NSLog(@"ERROR - SoundManager: Unable to set the audio session state to NO with error: %@\n", G_audioSessionError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
[self.viewController setAudioEnabled:audioEnabled];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
#if !__has_feature(objc_arc)
|
||||
[self.window release];
|
||||
[self.viewController release];
|
||||
|
||||
[super dealloc];
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
44
platforms/ios/minecraftpeViewController.h
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// minecraftpeViewController.h
|
||||
// minecraftpe
|
||||
//
|
||||
// Created by Brent on 10/12/23.
|
||||
// Copyright (c) 2023 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <QuartzCore/CADisplayLink.h>
|
||||
|
||||
class AppPlatform_iOS;
|
||||
|
||||
@interface minecraftpeViewController : UIViewController
|
||||
{
|
||||
EAGLContext *context;
|
||||
GLuint program;
|
||||
|
||||
BOOL animating;
|
||||
NSInteger animationFrameInterval;
|
||||
CADisplayLink *displayLink;
|
||||
//BaseDialogController *dialog;
|
||||
|
||||
@public
|
||||
bool suspended;
|
||||
}
|
||||
|
||||
@property (readonly, nonatomic, getter=isAnimating) BOOL animating;
|
||||
@property (nonatomic) NSInteger animationFrameInterval;
|
||||
@property (readonly, nonatomic) AppPlatform_iOS* platform;
|
||||
//@property (readonly, nonatomic) BaseDialogController *dialog;
|
||||
|
||||
- (void)startAnimation;
|
||||
- (void)stopAnimation;
|
||||
|
||||
- (void)setAudioEnabled:(BOOL)audioEnabled;
|
||||
- (void)showKeyboard;
|
||||
- (void)hideKeyboard;
|
||||
- (void)handleCharInput:(char)c;
|
||||
|
||||
- (int)width;
|
||||
- (int)height;
|
||||
|
||||
@end
|
||||
526
platforms/ios/minecraftpeViewController.mm
Normal file
@@ -0,0 +1,526 @@
|
||||
//
|
||||
// minecraftpeViewController.m
|
||||
// minecraftpe
|
||||
//
|
||||
// Created by Brent on 10/12/23.
|
||||
// Copyright (c) 2023 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "minecraftpeViewController.h"
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
#import "AppPlatform_iOS.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "client/app/App.hpp"
|
||||
#include "client/app/NinecraftApp.hpp"
|
||||
#include "AppContext.hpp"
|
||||
#include "client/player/input/Multitouch.hpp"
|
||||
|
||||
#include "client/gui/screens/ProgressScreen.hpp"
|
||||
|
||||
#include "EAGLView.h"
|
||||
#include "ShowKeyboardView.h"
|
||||
|
||||
extern bool g_bIsMenuBackgroundAvailable;
|
||||
|
||||
NSThread *G_drawFrameThread = nil;
|
||||
|
||||
@interface minecraftpeViewController () {
|
||||
GLuint _program;
|
||||
|
||||
float _rotation;
|
||||
|
||||
GLuint _vertexArray;
|
||||
GLuint _vertexBuffer;
|
||||
|
||||
Minecraft *_app;
|
||||
AppContext *_context;
|
||||
AppPlatform_iOS *_platform;
|
||||
UITouch *_touchMap[12];
|
||||
int _dialogResultStatus;
|
||||
std::vector<std::string> _dialogResultStrings;
|
||||
ShowKeyboardView *_keyboardView;
|
||||
//ThreadSafeQueue<std::function<void ()> > mMainQueue;
|
||||
//ImagePickingCallback *mPickingCallback
|
||||
float viewScale;
|
||||
//GameControllerHandler_iOS *_gameControllerHandler;
|
||||
//UIPopoverController *_imagePickerPopoverController;
|
||||
}
|
||||
@property (nonatomic, retain) EAGLContext *context;
|
||||
@property (nonatomic, retain) CADisplayLink *displayLink;
|
||||
//@property (strong, nonatomic) IASKAppSettingsViewController *appSettingsViewController;
|
||||
|
||||
- (void)initView;
|
||||
- (int)_startTrackingTouch:(UITouch *)touch;
|
||||
- (int)_stopTrackingTouch:(UITouch *)touch;
|
||||
- (int)_getIndexForTouch:(UITouch *)touch;
|
||||
|
||||
@end
|
||||
|
||||
@implementation minecraftpeViewController
|
||||
|
||||
@synthesize animating, context, displayLink;
|
||||
@synthesize platform = _platform;
|
||||
|
||||
- (int)width
|
||||
{
|
||||
CGRect bounds;
|
||||
UIScreen *screen = [UIScreen mainScreen];
|
||||
if (screen)
|
||||
{
|
||||
bounds = screen.bounds;
|
||||
}
|
||||
else
|
||||
{
|
||||
bounds.origin.x = 0, bounds.origin.y = 0;
|
||||
bounds.size.width = 0, bounds.size.height = 0;
|
||||
}
|
||||
if (bounds.size.width > bounds.size.height)
|
||||
bounds.size.height = bounds.size.width;
|
||||
return bounds.size.width * self->viewScale;
|
||||
}
|
||||
|
||||
- (int)height
|
||||
{
|
||||
CGRect bounds;
|
||||
UIScreen *screen = [UIScreen mainScreen];
|
||||
if (screen)
|
||||
{
|
||||
bounds = screen.bounds;
|
||||
}
|
||||
else
|
||||
{
|
||||
bounds.origin.x = 0, bounds.origin.y = 0;
|
||||
bounds.size.width = 0, bounds.size.height = 0;
|
||||
}
|
||||
if (bounds.size.width > bounds.size.height)
|
||||
bounds.size.height = bounds.size.width;
|
||||
return bounds.size.height * self->viewScale;
|
||||
}
|
||||
|
||||
- (void)updateDrawSize
|
||||
{
|
||||
// NOTE: Swapping width & height because of device orientation
|
||||
// I guess when the device is sideways, the view doesn't rotate to be upright?
|
||||
Minecraft::width = self.height;
|
||||
Minecraft::height = self.width;
|
||||
self->_app->sizeUpdate(self.height, self.width);
|
||||
NSLog(@"Updated draw size to %d, %d\n", self.height, self.width);
|
||||
}
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
|
||||
// Moved to viewDidLoad - wasn't working here & supposedly makes no difference
|
||||
}
|
||||
|
||||
- (void)drawFrame
|
||||
{
|
||||
if (!suspended)
|
||||
{
|
||||
NSThread *currentThread = [NSThread currentThread];
|
||||
NSThread *thread = G_drawFrameThread;
|
||||
if (!G_drawFrameThread)
|
||||
{
|
||||
G_drawFrameThread = currentThread;
|
||||
thread = currentThread;
|
||||
}
|
||||
if (currentThread != thread)
|
||||
{
|
||||
NSLog(@"Warning! draw-frame thread changed (%@ -> %@)\n", G_drawFrameThread, thread);
|
||||
G_drawFrameThread = thread;
|
||||
}
|
||||
|
||||
[(EAGLView *)self.view setFramebuffer];
|
||||
|
||||
// In 0.12.2 we loop through self->mMainQueue & call some functions, then run _app->update() after each. Not sure what it's really doing though...
|
||||
_app->update();
|
||||
|
||||
BOOL success = [(EAGLView *)self.view presentFramebuffer];
|
||||
if (!success)
|
||||
{
|
||||
NSLog(@"Failed to present renderbuffer object %x\n", glCheckFramebufferStatus(GL_RENDERBUFFER));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
//_keyboardView = [[ShowKeyboardView alloc] init];
|
||||
[super viewDidLoad];
|
||||
|
||||
//EAGLContext *aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||
//
|
||||
//if (!aContext)
|
||||
//{
|
||||
// aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
|
||||
//}
|
||||
|
||||
EAGLContext *aContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
|
||||
|
||||
if (!aContext)
|
||||
NSLog(@"Failed to create ES context");
|
||||
else if (![EAGLContext setCurrentContext:aContext])
|
||||
NSLog(@"Failed to set ES context current");
|
||||
|
||||
self.context = aContext;
|
||||
|
||||
[(EAGLView *)self.view setContext:context];
|
||||
[(EAGLView *)self.view setFramebuffer];
|
||||
|
||||
//if ([context API] == kEAGLRenderingAPIOpenGLES2)
|
||||
// [self loadShaders];
|
||||
|
||||
animating = FALSE;
|
||||
animationFrameInterval = 1;
|
||||
self.displayLink = nil;
|
||||
|
||||
g_bIsMenuBackgroundAvailable = true;
|
||||
|
||||
AppPlatform_iOS *platform = new AppPlatform_iOS(self);
|
||||
self->_platform = platform;
|
||||
|
||||
AppContext *ctx = new AppContext();
|
||||
ctx->platform = platform;
|
||||
self->_context = ctx;
|
||||
self->viewScale = 1.0;
|
||||
self->suspended = NO;
|
||||
|
||||
NSString *dir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 1u, YES) objectAtIndex:0];
|
||||
NinecraftApp *app = new NinecraftApp();
|
||||
app->m_externalStorageDir = [dir UTF8String];
|
||||
self->_app = app;
|
||||
|
||||
[self initView];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
//if (program)
|
||||
//{
|
||||
// glDeleteProgram(program);
|
||||
// program = 0;
|
||||
//}
|
||||
|
||||
// Tear down context.
|
||||
if ([EAGLContext currentContext] == context)
|
||||
[EAGLContext setCurrentContext:nil];
|
||||
|
||||
#if !__has_feature(objc_arc)
|
||||
if (_app) delete _app;
|
||||
if (_platform) delete _platform;
|
||||
// This is what was done, but should we really be doing this?
|
||||
if (_touchMap) delete[] (UITouch **)_touchMap;
|
||||
|
||||
[self.context release];
|
||||
|
||||
[super dealloc];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[self startAnimation];
|
||||
|
||||
[super viewWillAppear:animated];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
[self stopAnimation];
|
||||
|
||||
[super viewWillDisappear:animated];
|
||||
}
|
||||
|
||||
- (void)viewDidUnload
|
||||
{
|
||||
[super viewDidUnload];
|
||||
|
||||
//if (program)
|
||||
//{
|
||||
// glDeleteProgram(program);
|
||||
// program = 0;
|
||||
//}
|
||||
|
||||
// Tear down context.
|
||||
if ([EAGLContext currentContext] == context)
|
||||
[EAGLContext setCurrentContext:nil];
|
||||
self.context = nil;
|
||||
}
|
||||
|
||||
- (void)initView
|
||||
{
|
||||
_keyboardView = [[ShowKeyboardView alloc] initWithMinecraft:self->_app];
|
||||
|
||||
if ([self.view respondsToSelector:@selector(contentScaleFactor)])
|
||||
{
|
||||
self->viewScale = [self.view contentScaleFactor];
|
||||
}
|
||||
App *app = self->_app;
|
||||
|
||||
app->m_pPlatform = self->_context->platform;
|
||||
app->init();
|
||||
|
||||
/*var1 = app->field_10;
|
||||
app->var3 = *self->_context;
|
||||
if ( var1 )
|
||||
{
|
||||
((void (__fastcall *)(App *))var0[15])(app);
|
||||
}
|
||||
else
|
||||
{
|
||||
((void (__fastcall *)(App *))var0[14])(app);
|
||||
app->field_10 = 1;
|
||||
}*/
|
||||
|
||||
[self updateDrawSize];
|
||||
// Update draw size when device orientation changes (this accounts for typical view resizes)
|
||||
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDrawSize) name:UIDeviceOrientationDidChangeNotification object:nil];
|
||||
|
||||
/*Minecraft *mc = (Minecraft *)app;
|
||||
mc->selectLevel("TestWorld", "Test", (int)"iOS");
|
||||
mc->hostMultiplayer();
|
||||
mc->setScreen(new ProgressScreen);*/
|
||||
}
|
||||
|
||||
- (NSInteger)animationFrameInterval
|
||||
{
|
||||
return animationFrameInterval;
|
||||
}
|
||||
|
||||
- (void)setAnimationFrameInterval:(NSInteger)frameInterval
|
||||
{
|
||||
/*
|
||||
Frame interval defines how many display frames must pass between each time the display link fires.
|
||||
The display link will only fire 30 times a second when the frame internal is two on a display that refreshes 60 times a second. The default frame interval setting of one will fire 60 times a second when the display refreshes at 60 times a second. A frame interval setting of less than one results in undefined behavior.
|
||||
*/
|
||||
if (frameInterval >= 1)
|
||||
{
|
||||
animationFrameInterval = frameInterval;
|
||||
NSLog(@"Set animationFrameInterval to %d\n", animationFrameInterval);
|
||||
|
||||
if (animating)
|
||||
{
|
||||
[self stopAnimation];
|
||||
[self startAnimation];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)startAnimation
|
||||
{
|
||||
if (![self isViewLoaded])
|
||||
NSLog(@"Warning! Tried to startAnimation before view was loaded!\n");
|
||||
|
||||
if (!animating)
|
||||
{
|
||||
CADisplayLink *aDisplayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawFrame)];
|
||||
[aDisplayLink setFrameInterval:animationFrameInterval];
|
||||
[aDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
|
||||
self.displayLink = aDisplayLink;
|
||||
NSLog(@"start-animation: %@\n", [NSThread currentThread]);
|
||||
animating = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)stopAnimation
|
||||
{
|
||||
if (![self isViewLoaded])
|
||||
NSLog(@"Warning! Tried to stopAnimation before view was loaded!\n");
|
||||
|
||||
if (animating)
|
||||
{
|
||||
[self.displayLink invalidate];
|
||||
self.displayLink = nil;
|
||||
animating = FALSE;
|
||||
NSLog(@"stop-animation: %@\n", [NSThread currentThread]);
|
||||
|
||||
// HACK: applicationWillTerminate simply does not serve its purpose
|
||||
_app->saveOptions();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setAudioEnabled:(BOOL)audioEnabled
|
||||
{
|
||||
if (audioEnabled)
|
||||
_platform->getSoundSystem()->startEngine();
|
||||
else
|
||||
_platform->getSoundSystem()->stopEngine();
|
||||
}
|
||||
|
||||
- (void)showKeyboard
|
||||
{
|
||||
for (UIView *view in self.view.subviews)
|
||||
{
|
||||
if ([view isKindOfClass:[ShowKeyboardView class]])
|
||||
{
|
||||
[((ShowKeyboardView*)view) showKeyboard];
|
||||
}
|
||||
}
|
||||
[self.view insertSubview:_keyboardView atIndex:0];
|
||||
[_keyboardView showKeyboard];
|
||||
}
|
||||
|
||||
- (void)hideKeyboard
|
||||
{
|
||||
for (UIView *view in self.view.subviews)
|
||||
{
|
||||
if ([view isKindOfClass:[ShowKeyboardView class]])
|
||||
{
|
||||
[((ShowKeyboardView*)view) hideKeyboard];
|
||||
[((ShowKeyboardView*)view) removeFromSuperview];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleCharInput:(char)c
|
||||
{
|
||||
_app->handleCharInput(c);
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
// Release any cached data, images, etc. that aren't in use.
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
// Return YES for supported orientations
|
||||
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown &&
|
||||
interfaceOrientation != UIInterfaceOrientationPortrait
|
||||
);
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
for (UITouch *touch in touches)
|
||||
{
|
||||
int touchIndex = [self _startTrackingTouch: touch];
|
||||
if (touchIndex > -1)
|
||||
{
|
||||
CGPoint point;
|
||||
float posX, posY;
|
||||
if (touch)
|
||||
{
|
||||
point = [touch locationInView:self.view];
|
||||
}
|
||||
else
|
||||
{
|
||||
point.x = 0, point.y = 0;
|
||||
//point2.x = 0, point2.y = 0;
|
||||
}
|
||||
posX = viewScale * point.x;
|
||||
posY = viewScale * point.y;
|
||||
|
||||
Mouse::feed(BUTTON_LEFT, true, posX, posY);
|
||||
Multitouch::feed(BUTTON_LEFT, true, posX, posY, touchIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
for (UITouch *touch in touches)
|
||||
{
|
||||
int touchIndex = [self _getIndexForTouch: touch];
|
||||
if (touchIndex > -1)
|
||||
{
|
||||
CGPoint point;
|
||||
float posX, posY;
|
||||
if (touch)
|
||||
{
|
||||
point = [touch locationInView:self.view];
|
||||
}
|
||||
else
|
||||
{
|
||||
point.x = 0, point.y = 0;
|
||||
//point2.x = 0, point2.y = 0;
|
||||
}
|
||||
posX = viewScale * point.x;
|
||||
posY = viewScale * point.y;
|
||||
|
||||
Mouse::feed(BUTTON_NONE, false, posX, posY);
|
||||
Multitouch::feed(BUTTON_NONE, false, posX, posY, touchIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
for (UITouch *touch in touches)
|
||||
{
|
||||
int touchIndex = [self _stopTrackingTouch: touch];
|
||||
if (touchIndex > -1)
|
||||
{
|
||||
CGPoint point;
|
||||
float posX, posY;
|
||||
if (touch)
|
||||
{
|
||||
point = [touch locationInView:self.view];
|
||||
}
|
||||
else
|
||||
{
|
||||
point.x = 0, point.y = 0;
|
||||
//point2.x = 0, point2.y = 0;
|
||||
}
|
||||
posX = viewScale * point.x;
|
||||
posY = viewScale * point.y;
|
||||
|
||||
Mouse::feed(BUTTON_LEFT, false, posX, posY);
|
||||
Multitouch::feed(BUTTON_LEFT, false, posX, posY, touchIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[self touchesEnded:touches withEvent:event];
|
||||
}
|
||||
|
||||
- (int)_startTrackingTouch:(UITouch *)touch
|
||||
{
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
if (!_touchMap[i])
|
||||
{
|
||||
_touchMap[i] = touch;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (int)_stopTrackingTouch:(UITouch *)touch
|
||||
{
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
if (_touchMap[i] == touch)
|
||||
{
|
||||
_touchMap[i] = nil;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
- (int)_getIndexForTouch:(UITouch *)touch
|
||||
{
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
if (_touchMap[i] == touch)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// DebugSettings.xcconfig
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 12/4/23.
|
||||
//
|
||||
//
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS_DEBUG = _DEBUG=1 DEBUG=1
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_DEBUG)
|
||||
|
||||
ONLY_ACTIVE_ARCH_DEBUG = YES
|
||||
ONLY_ACTIVE_ARCH = $(ONLY_ACTIVE_ARCH_DEBUG)
|
||||
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN_DEBUG = NO
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = $(GCC_SYMBOLS_PRIVATE_EXTERN_DEBUG)
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// GlobalSettings.xcconfig
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 11/27/23.
|
||||
//
|
||||
//
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS_GLOBAL = $(inherited) USE_OPENAL HANDLE_CHARS_SEPARATELY USE_OLD_CPP
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_GLOBAL)
|
||||
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN_GLOBAL = YES
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = $(GCC_SYMBOLS_PRIVATE_EXTERN_GLOBAL)
|
||||
22
platforms/macos/projects/Configuration/Settings_iOS.xcconfig
Normal file
@@ -0,0 +1,22 @@
|
||||
//
|
||||
// Settings_iOS.xcconfig
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 12/4/23.
|
||||
//
|
||||
//
|
||||
|
||||
#include "GlobalSettings.xcconfig"
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS_IOS = USE_GLES $(GCC_PREPROCESSOR_DEFINITIONS_GLOBAL)
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_IOS)
|
||||
|
||||
SDKROOT_IOS = iphoneos
|
||||
SDKROOT = $(SDKROOT_IOS)
|
||||
|
||||
// Target as many architectures as we can
|
||||
ARCHS_IOS = armv6 armv7 armv7s arm64
|
||||
ARCHS = $(ARCHS_IOS)
|
||||
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 3.0 // iOS 3.0
|
||||
TARGETED_DEVICE_FAMILY = 1,2 // iPhone/iPad
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Settings_iOS_Debug.xcconfig
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 12/4/23.
|
||||
//
|
||||
//
|
||||
|
||||
#include "Settings_iOS.xcconfig"
|
||||
#include "GlobalDebugSettings.xcconfig"
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_IOS) $(GCC_PREPROCESSOR_DEFINITIONS_DEBUG)
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Settings_macOS.xcconfig
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 12/4/23.
|
||||
//
|
||||
//
|
||||
|
||||
#include "GlobalSettings.xcconfig"
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS_MACOS = USE_SDL SDL_DISABLE_IMMINTRIN_H $(GCC_PREPROCESSOR_DEFINITIONS_GLOBAL)
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_MACOS)
|
||||
|
||||
ARCHS_MACOS_PPC = ppc ppc64 ppc7400 ppc970
|
||||
ARCHS_MACOS_X86 = i386 x86_64
|
||||
ARCHS_MACOS_ARM = arm64
|
||||
|
||||
VALID_ARCHS_MACOS = $(ARCHS_MACOS_PPC) $(ARCHS_MACOS_X86) $(ARCHS_MACOS_ARM)
|
||||
VALID_ARCHS = $(VALID_ARCHS_MACOS)
|
||||
|
||||
// Compile for (almost) everything ever
|
||||
// @NOTE: New Xcode versions will bitch and moan about having to compile for i386
|
||||
//ARCHS_MACOS = $(ARCHS_MACOS_X86) $(ARCHS_MACOS_ARM)
|
||||
//ARCHS = $(ARCHS_MACOS)
|
||||
// Just use whatever Xcode is trying to use...
|
||||
ARCHS = $(ARCHS)
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Settings_macOS_Debug.xcconfig
|
||||
// Minecraft
|
||||
//
|
||||
// Created by Brent on 12/4/23.
|
||||
//
|
||||
//
|
||||
|
||||
#include "Settings_macOS.xcconfig"
|
||||
#include "GlobalDebugSettings.xcconfig"
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_MACOS) $(GCC_PREPROCESSOR_DEFINITIONS_DEBUG)
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1420"
|
||||
version = "1.3">
|
||||
LastUpgradeVersion = "0440"
|
||||
version = "1.8">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
@@ -15,37 +15,37 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8489B0962A86D4B2004CA8EC"
|
||||
BuildableName = "Minecraft"
|
||||
BlueprintName = "Minecraft"
|
||||
BuildableName = "MinecraftClient.SDL2"
|
||||
BlueprintName = "MinecraftClient.SDL2"
|
||||
ReferencedContainer = "container:Minecraft.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug (Default)"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug (Default)">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8489B0962A86D4B2004CA8EC"
|
||||
BuildableName = "Minecraft"
|
||||
BlueprintName = "Minecraft"
|
||||
BuildableName = "MinecraftClient.SDL2"
|
||||
BlueprintName = "MinecraftClient.SDL2"
|
||||
ReferencedContainer = "container:Minecraft.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug (Default)"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "YES"
|
||||
customWorkingDirectory = "$(MC_ROOT)/game"
|
||||
buildConfiguration = "Debug (Default)"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
@@ -57,25 +57,27 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8489B0962A86D4B2004CA8EC"
|
||||
BuildableName = "Minecraft"
|
||||
BlueprintName = "Minecraft"
|
||||
BuildableName = "MinecraftClient.SDL2"
|
||||
BlueprintName = "MinecraftClient.SDL2"
|
||||
ReferencedContainer = "container:Minecraft.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release (Default)"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release (Default)"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8489B0962A86D4B2004CA8EC"
|
||||
BuildableName = "Minecraft"
|
||||
BlueprintName = "Minecraft"
|
||||
BuildableName = "MinecraftClient.SDL2"
|
||||
BlueprintName = "MinecraftClient.SDL2"
|
||||
ReferencedContainer = "container:Minecraft.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0440"
|
||||
version = "1.8">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug (iOS)">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8492591C2AD8FCFC0081F5B9"
|
||||
BuildableName = "minecraftpe.app"
|
||||
BlueprintName = "minecraftpe"
|
||||
ReferencedContainer = "container:Minecraft.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug (iOS)"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
enablesOpenGLESFrameCapture = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8492591C2AD8FCFC0081F5B9"
|
||||
BuildableName = "minecraftpe.app"
|
||||
BlueprintName = "minecraftpe"
|
||||
ReferencedContainer = "container:Minecraft.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release (iOS)"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8492591C2AD8FCFC0081F5B9"
|
||||
BuildableName = "minecraftpe.app"
|
||||
BlueprintName = "minecraftpe"
|
||||
ReferencedContainer = "container:Minecraft.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug (iOS)">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release (iOS)"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -5,77 +5,16 @@
|
||||
|
||||
SoundSystemAL::SoundSystemAL()
|
||||
{
|
||||
loaded = false;
|
||||
|
||||
device = alcOpenDevice(NULL);
|
||||
if (!device)
|
||||
{
|
||||
LOG_E("Unable To Load Audio Engine");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create Context
|
||||
context = alcCreateContext(device, NULL);
|
||||
ALCenum err = alcGetError(device);
|
||||
if (err != ALC_NO_ERROR)
|
||||
{
|
||||
LOG_E("Unable To Open Audio Context: %s", alcGetString(device, err));
|
||||
return;
|
||||
}
|
||||
|
||||
// Select Context
|
||||
alcMakeContextCurrent(context);
|
||||
err = alcGetError(device);
|
||||
if (err != ALC_NO_ERROR)
|
||||
{
|
||||
LOG_E("Unable To Select Audio Context: %s", alcGetString(device, err));
|
||||
return;
|
||||
}
|
||||
|
||||
// Set Distance Model
|
||||
alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
|
||||
|
||||
// Mark As Loaded
|
||||
loaded = true;
|
||||
_initialized = false;
|
||||
_listenerVolume = 1.0;
|
||||
_audioMuted = false;
|
||||
|
||||
startEngine();
|
||||
}
|
||||
|
||||
SoundSystemAL::~SoundSystemAL()
|
||||
{
|
||||
if (!loaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete Audio Sources
|
||||
delete_sources();
|
||||
|
||||
// Delete Audio Buffers
|
||||
delete_buffers();
|
||||
|
||||
// Deselect Context
|
||||
alcMakeContextCurrent(NULL);
|
||||
ALCenum err = alcGetError(device);
|
||||
if (err != ALC_NO_ERROR)
|
||||
{
|
||||
LOG_E("Unable To Deselect Audio Context: %s", alcGetString(device, err));
|
||||
}
|
||||
|
||||
// Destroy Context
|
||||
alcDestroyContext(context);
|
||||
err = alcGetError(device);
|
||||
if (err != ALC_NO_ERROR)
|
||||
{
|
||||
LOG_E("Unable To Destroy Audio Context: %s", alcGetString(device, err));
|
||||
}
|
||||
|
||||
// Close Device
|
||||
alcCloseDevice(device);
|
||||
// Can't check for error because device is closed
|
||||
/*err = alcGetError(device);
|
||||
if (err != ALC_NO_ERROR)
|
||||
{
|
||||
LOG_E("Unable To Close Audio Device: %s", alcGetString(device, err));
|
||||
}*/
|
||||
stopEngine();
|
||||
}
|
||||
|
||||
// Error Checking
|
||||
@@ -93,30 +32,30 @@ SoundSystemAL::~SoundSystemAL()
|
||||
// Delete Sources
|
||||
void SoundSystemAL::delete_sources()
|
||||
{
|
||||
if (loaded)
|
||||
if (_initialized)
|
||||
{
|
||||
for (std::vector<ALuint>::iterator source = idle_sources.begin(); source != idle_sources.end(); source++)
|
||||
for (std::vector<ALuint>::iterator source = _sources_idle.begin(); source != _sources_idle.end(); source++)
|
||||
{
|
||||
alDeleteSources(1, &*source);
|
||||
AL_ERROR_CHECK();
|
||||
}
|
||||
for (std::vector<ALuint>::iterator source = sources.begin(); source != sources.end(); source++)
|
||||
for (std::vector<ALuint>::iterator source = _sources.begin(); source != _sources.end(); source++)
|
||||
{
|
||||
alDeleteSources(1, &*source);
|
||||
AL_ERROR_CHECK();
|
||||
}
|
||||
}
|
||||
idle_sources.clear();
|
||||
sources.clear();
|
||||
_sources_idle.clear();
|
||||
_sources.clear();
|
||||
}
|
||||
|
||||
// Delete Buffers
|
||||
void SoundSystemAL::delete_buffers()
|
||||
{
|
||||
if (loaded)
|
||||
if (_initialized)
|
||||
{
|
||||
for (std::map<void *, ALuint>::iterator it = buffers.begin(); it != buffers.end(); it++)
|
||||
//for (auto &it : buffers)
|
||||
for (std::map<void *, ALuint>::iterator it = _buffers.begin(); it != _buffers.end(); it++)
|
||||
//for (auto &it : _buffers)
|
||||
{
|
||||
if (it->second && alIsBuffer(it->second))
|
||||
{
|
||||
@@ -125,15 +64,15 @@ void SoundSystemAL::delete_buffers()
|
||||
}
|
||||
}
|
||||
}
|
||||
buffers.clear();
|
||||
_buffers.clear();
|
||||
}
|
||||
|
||||
// Get Buffer
|
||||
ALuint SoundSystemAL::get_buffer(const SoundDesc& sound)
|
||||
{
|
||||
if (buffers.count(sound.m_pData) > 0)
|
||||
if (_buffers.count(sound.m_pData) > 0)
|
||||
{
|
||||
return buffers[sound.m_pData];
|
||||
return _buffers[sound.m_pData];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -159,14 +98,14 @@ ALuint SoundSystemAL::get_buffer(const SoundDesc& sound)
|
||||
AL_ERROR_CHECK();
|
||||
|
||||
// Store
|
||||
buffers[sound.m_pData] = buffer;
|
||||
_buffers[sound.m_pData] = buffer;
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
bool SoundSystemAL::isAvailable()
|
||||
{
|
||||
return loaded;
|
||||
return _initialized;
|
||||
}
|
||||
|
||||
void SoundSystemAL::setListenerPos(float x, float y, float z)
|
||||
@@ -174,7 +113,7 @@ void SoundSystemAL::setListenerPos(float x, float y, float z)
|
||||
// Update Listener Position
|
||||
alListener3f(AL_POSITION, x, y, z);
|
||||
AL_ERROR_CHECK();
|
||||
lastListenerPos = Vec3(x, y, z);
|
||||
_lastListenerPos = Vec3(x, y, z);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -190,19 +129,18 @@ void SoundSystemAL::setListenerAngle(float yaw, float pitch)
|
||||
void SoundSystemAL::update()
|
||||
{
|
||||
// Check
|
||||
if (!loaded)
|
||||
if (!_initialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Update Listener Volume
|
||||
float volume = 1;
|
||||
alListenerf(AL_GAIN, volume);
|
||||
alListenerf(AL_GAIN, _listenerVolume);
|
||||
AL_ERROR_CHECK();
|
||||
|
||||
// Clear Finished Sources
|
||||
std::vector<ALuint>::iterator it = sources.begin();
|
||||
while (it != sources.end())
|
||||
std::vector<ALuint>::iterator it = _sources.begin();
|
||||
while (it != _sources.end())
|
||||
{
|
||||
ALuint source = *it;
|
||||
bool remove = false;
|
||||
@@ -217,9 +155,9 @@ void SoundSystemAL::update()
|
||||
{
|
||||
// Finished Playing
|
||||
remove = true;
|
||||
if (idle_sources.size() < MAX_IDLE_SOURCES)
|
||||
if (_sources_idle.size() < MAX_IDLE_SOURCES)
|
||||
{
|
||||
idle_sources.push_back(source);
|
||||
_sources_idle.push_back(source);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -235,7 +173,7 @@ void SoundSystemAL::update()
|
||||
}
|
||||
// Remove If Needed
|
||||
if (remove) {
|
||||
it = sources.erase(it);
|
||||
it = _sources.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -247,12 +185,12 @@ void SoundSystemAL::update()
|
||||
void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, float volume, float pitch)
|
||||
{
|
||||
// Check
|
||||
if (!loaded)
|
||||
if (!_initialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (volume <= 0.0f)
|
||||
if (_audioMuted || volume <= 0.0f)
|
||||
return;
|
||||
|
||||
bool bIsGUI = AL_FALSE;
|
||||
@@ -263,7 +201,7 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl
|
||||
}
|
||||
else
|
||||
{
|
||||
distance = Vec3(x, y, z).distanceTo(lastListenerPos);
|
||||
distance = Vec3(x, y, z).distanceTo(_lastListenerPos);
|
||||
if (distance >= MAX_DISTANCE)
|
||||
return;
|
||||
}
|
||||
@@ -275,11 +213,11 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl
|
||||
|
||||
// Get Source
|
||||
ALuint al_source;
|
||||
if (idle_sources.size() > 0)
|
||||
if (_sources_idle.size() > 0)
|
||||
{
|
||||
// Use Idle Source
|
||||
al_source = idle_sources.back();
|
||||
idle_sources.pop_back();
|
||||
al_source = _sources_idle.back();
|
||||
_sources_idle.pop_back();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -302,6 +240,8 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl
|
||||
// Set Properties
|
||||
alSourcef(al_source, AL_PITCH, pitch);
|
||||
AL_ERROR_CHECK();
|
||||
// There is a problem with Apple's OpenAL implementation on older Mac OS X versions
|
||||
// https://stackoverflow.com/questions/6960731/openal-problem-changing-gain-of-source
|
||||
alSourcef(al_source, AL_GAIN, volume);
|
||||
AL_ERROR_CHECK();
|
||||
alSource3f(al_source, AL_POSITION, x, y, z);
|
||||
@@ -328,7 +268,92 @@ void SoundSystemAL::playAt(const SoundDesc& sound, float x, float y, float z, fl
|
||||
// Play
|
||||
alSourcePlay(al_source);
|
||||
AL_ERROR_CHECK();
|
||||
sources.push_back(al_source);
|
||||
_sources.push_back(al_source);
|
||||
}
|
||||
|
||||
void SoundSystemAL::startEngine()
|
||||
{
|
||||
if (_initialized) return;
|
||||
|
||||
_device = alcOpenDevice(NULL);
|
||||
if (!_device)
|
||||
{
|
||||
LOG_E("Unable To Load Audio Engine");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create Context
|
||||
_context = alcCreateContext(_device, NULL);
|
||||
ALCenum err = alcGetError(_device);
|
||||
if (err != ALC_NO_ERROR)
|
||||
{
|
||||
LOG_E("Unable To Open Audio Context: %s", alcGetString(_device, err));
|
||||
return;
|
||||
}
|
||||
|
||||
// Select Context
|
||||
alcMakeContextCurrent(_context);
|
||||
err = alcGetError(_device);
|
||||
if (err != ALC_NO_ERROR)
|
||||
{
|
||||
LOG_E("Unable To Select Audio Context: %s", alcGetString(_device, err));
|
||||
return;
|
||||
}
|
||||
|
||||
// Set Distance Model
|
||||
alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
|
||||
|
||||
// Mark As loaded
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
void SoundSystemAL::stopEngine()
|
||||
{
|
||||
if (!_initialized) return;
|
||||
|
||||
// Delete Audio Sources
|
||||
delete_sources();
|
||||
|
||||
// Delete Audio Buffers
|
||||
delete_buffers();
|
||||
|
||||
// Deselect Context
|
||||
alcMakeContextCurrent(NULL);
|
||||
ALCenum err = alcGetError(_device);
|
||||
if (err != ALC_NO_ERROR)
|
||||
{
|
||||
LOG_E("Unable To Deselect Audio Context: %s", alcGetString(_device, err));
|
||||
}
|
||||
|
||||
// Destroy Context
|
||||
alcDestroyContext(_context);
|
||||
err = alcGetError(_device);
|
||||
if (err != ALC_NO_ERROR)
|
||||
{
|
||||
LOG_E("Unable To Destroy Audio Context: %s", alcGetString(_device, err));
|
||||
}
|
||||
|
||||
// Close Device
|
||||
alcCloseDevice(_device);
|
||||
// Can't check for error because _device is closed
|
||||
/*err = alcGetError(_device);
|
||||
if (err != ALC_NO_ERROR)
|
||||
{
|
||||
LOG_E("Unable To Close Audio Device: %s", alcGetString(_device, err));
|
||||
}*/
|
||||
|
||||
// Mark as unloaded
|
||||
_initialized = false;
|
||||
}
|
||||
|
||||
void SoundSystemAL::muteAudio()
|
||||
{
|
||||
_audioMuted = true;
|
||||
}
|
||||
|
||||
void SoundSystemAL::unMuteAudio()
|
||||
{
|
||||
_audioMuted = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -35,19 +35,27 @@ public:
|
||||
|
||||
virtual void setListenerPos(float x, float y, float z);
|
||||
virtual void setListenerAngle(float yaw, float pitch);
|
||||
|
||||
virtual void startEngine();
|
||||
virtual void stopEngine();
|
||||
virtual void muteAudio();
|
||||
virtual void unMuteAudio();
|
||||
|
||||
private:
|
||||
void delete_sources();
|
||||
void delete_buffers();
|
||||
ALuint get_buffer(const SoundDesc& sound);
|
||||
|
||||
ALCdevice *device;
|
||||
ALCcontext *context;
|
||||
bool loaded;
|
||||
std::vector<ALuint> sources;
|
||||
std::vector<ALuint> idle_sources;
|
||||
std::map<void *, ALuint> buffers;
|
||||
ALCdevice *_device;
|
||||
ALCcontext *_context;
|
||||
bool _initialized;
|
||||
std::vector<ALuint> _sources;
|
||||
std::vector<ALuint> _sources_idle;
|
||||
std::map<void *, ALuint> _buffers;
|
||||
|
||||
Vec3 lastListenerPos;
|
||||
Vec3 _lastListenerPos;
|
||||
float _listenerVolume;
|
||||
bool _audioMuted;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -56,8 +56,8 @@ void AppPlatform_sdl_base::initSoundSystem()
|
||||
{
|
||||
if (!m_pSoundSystem)
|
||||
{
|
||||
m_pSoundSystem = new SoundSystemAL();
|
||||
LOG_I("Initializing OpenAL SoundSystem...");
|
||||
m_pSoundSystem = new SoundSystemAL();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -197,3 +197,27 @@ bool AppPlatform_sdl::hasFileSystemAccess()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AppPlatform_sdl::getPatchData()
|
||||
{
|
||||
std::string path = getAssetPath("patches/patch_data.txt");
|
||||
SDL_RWops *io = SDL_RWFromFile(path.c_str(), "rb");
|
||||
|
||||
if (!io)
|
||||
{
|
||||
LOG_W("Couldn't find patch data file!");
|
||||
return "";
|
||||
}
|
||||
size_t size = io->size(io);
|
||||
if (size == -1)
|
||||
{
|
||||
LOG_E("Error determining the size of the patch data file!");
|
||||
}
|
||||
|
||||
char *buf = new char[size];
|
||||
SDL_RWread(io, buf, size, 1);
|
||||
|
||||
SDL_RWclose(io);
|
||||
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
bool doesTextureExist(const std::string& path) override;
|
||||
|
||||
bool hasFileSystemAccess() override;
|
||||
std::string getPatchData() override;
|
||||
|
||||
protected:
|
||||
void ensureDirectoryExists(const char* path) override;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio Version 17
|
||||
# Visual Studio Version 10
|
||||
VisualStudioVersion = 17.6.33723.286
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZLib", "projects\ZLib\ZLib.vcxproj", "{5DA292FD-FA40-45D8-900A-6652C9662913}"
|
||||
|
||||
@@ -248,6 +248,7 @@
|
||||
<ClCompile Include="$(MC_ROOT)\source\common\Util.cpp" />
|
||||
<ClCompile Include="$(MC_ROOT)\source\common\Utils.cpp" />
|
||||
<ClCompile Include="$(MC_ROOT)\source\common\SmoothFloat.cpp" />
|
||||
<ClCompile Include="$(MC_ROOT)\compat\LegacyCPPCompatibility.hpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="$(MC_ROOT)\source\common\CThread.hpp" />
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
<ClCompile Include="$(MC_ROOT)\source\common\SmoothFloat.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="$(MC_ROOT)\compat\LegacyCPPCompatibility.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="$(MC_ROOT)\source\common\CThread.hpp">
|
||||
|
||||
@@ -60,4 +60,5 @@ void App::update()
|
||||
|
||||
void App::sizeUpdate(int newWidth, int newHeight)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ std::string AppPlatform::getDateString(int time)
|
||||
}
|
||||
|
||||
// ??? AppPlatform::getOptionStrings()
|
||||
// To whoever is confused about the above, we moved it to Options::getOptionStrings()
|
||||
|
||||
int AppPlatform::getScreenWidth() const
|
||||
{
|
||||
@@ -140,6 +141,31 @@ bool AppPlatform::shiftPressed()
|
||||
return false;
|
||||
}
|
||||
|
||||
void AppPlatform::showKeyboard(int x, int y, int w, int h)
|
||||
{
|
||||
showKeyboard();
|
||||
}
|
||||
|
||||
void AppPlatform::showKeyboard()
|
||||
{
|
||||
}
|
||||
|
||||
void AppPlatform::showKeyboard(bool bShown)
|
||||
{
|
||||
if (bShown)
|
||||
showKeyboard();
|
||||
else
|
||||
hideKeyboard();
|
||||
}
|
||||
|
||||
void AppPlatform::hideKeyboard()
|
||||
{
|
||||
}
|
||||
|
||||
void AppPlatform::onHideKeyboard()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef USE_NATIVE_ANDROID
|
||||
int AppPlatform::getKeyboardUpOffset()
|
||||
{
|
||||
@@ -147,6 +173,36 @@ int AppPlatform::getKeyboardUpOffset()
|
||||
}
|
||||
#endif
|
||||
|
||||
void AppPlatform::_fireLowMemory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AppPlatform::_fireAppSuspended()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AppPlatform::_fireAppResumed()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AppPlatform::_fireAppFocusLost()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AppPlatform::_fireAppFocusGained()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AppPlatform::_fireAppTerminated()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool AppPlatform::hasFileSystemAccess()
|
||||
{
|
||||
return false;
|
||||
@@ -178,11 +234,3 @@ std::string AppPlatform::getAssetPath(const std::string &path) const
|
||||
|
||||
return realPath;
|
||||
}
|
||||
|
||||
void AppPlatform::showKeyboard(int x, int y, int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
void AppPlatform::hideKeyboard()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -59,18 +59,29 @@ public:
|
||||
virtual void updateFocused(bool focused);
|
||||
// Also add this to allow proper text input within the game.
|
||||
virtual bool shiftPressed();
|
||||
// On-screen keyboard
|
||||
virtual void showKeyboard(int x, int y, int w, int h);
|
||||
virtual void showKeyboard();
|
||||
virtual void showKeyboard(bool bShown); // @TODO: Why on earth is this here?
|
||||
// virtual void showKeyboard(std::string const ¤tText, int maxLength, bool limitInput);
|
||||
virtual void hideKeyboard();
|
||||
virtual void onHideKeyboard(); // called by the runner, not the game
|
||||
#ifdef USE_NATIVE_ANDROID
|
||||
virtual int getKeyboardUpOffset();
|
||||
#endif
|
||||
|
||||
void _fireLowMemory();
|
||||
void _fireAppSuspended();
|
||||
void _fireAppResumed();
|
||||
void _fireAppFocusLost();
|
||||
void _fireAppFocusGained();
|
||||
void _fireAppTerminated();
|
||||
|
||||
virtual bool hasFileSystemAccess();
|
||||
// Also add this to allow dynamic patching.
|
||||
virtual std::string getPatchData();
|
||||
virtual void initSoundSystem();
|
||||
virtual SoundSystem* const getSoundSystem() const;
|
||||
// On-screen keyboard
|
||||
virtual void showKeyboard(int x, int y, int w, int h);
|
||||
virtual void hideKeyboard();
|
||||
#ifdef USE_NATIVE_ANDROID
|
||||
virtual int getKeyboardUpOffset();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
#include "client/renderer/GrassColor.hpp"
|
||||
#include "client/renderer/FoliageColor.hpp"
|
||||
|
||||
// custom:
|
||||
// custom:
|
||||
#include "client/renderer/PatchManager.hpp"
|
||||
|
||||
int Minecraft::width = C_DEFAULT_SCREEN_WIDTH;
|
||||
int Minecraft::width = C_DEFAULT_SCREEN_WIDTH;
|
||||
int Minecraft::height = C_DEFAULT_SCREEN_HEIGHT;
|
||||
float Minecraft::guiScaleMultiplier = 1.0f;
|
||||
bool Minecraft::useAmbientOcclusion = false;
|
||||
@@ -53,7 +53,7 @@ const char* Minecraft::progressMessages[] =
|
||||
};
|
||||
|
||||
Minecraft::Minecraft() :
|
||||
m_gui(this)
|
||||
m_gui(this)
|
||||
{
|
||||
m_options = nullptr;
|
||||
field_18 = false;
|
||||
@@ -149,7 +149,7 @@ void Minecraft::setScreen(Screen* pScreen)
|
||||
m_pQueuedScreen = pScreen;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (pScreen && pScreen->isErrorScreen())
|
||||
{
|
||||
// not in original
|
||||
@@ -167,7 +167,8 @@ void Minecraft::setScreen(Screen* pScreen)
|
||||
if (pScreen)
|
||||
{
|
||||
releaseMouse();
|
||||
pScreen->init(this, int(width * Gui::InvGuiScale), int(height * Gui::InvGuiScale));
|
||||
// the ceil prevents under-drawing
|
||||
pScreen->init(this, ceil(width * Gui::InvGuiScale), ceil(height * Gui::InvGuiScale));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -330,13 +331,13 @@ void Minecraft::handleBuildAction(BuildActionIntention* pAction)
|
||||
{
|
||||
switch (m_hitResult.m_hitSide)
|
||||
{
|
||||
case HitResult::NOHIT: break;
|
||||
case HitResult::MINY: dy--; break;
|
||||
case HitResult::MAXY: dy++; break;
|
||||
case HitResult::MINZ: dz--; break;
|
||||
case HitResult::MAXZ: dz++; break;
|
||||
case HitResult::MINX: dx--; break;
|
||||
case HitResult::MAXX: dx++; break;
|
||||
case HitResult::NOHIT: break;
|
||||
case HitResult::MINY: dy--; break;
|
||||
case HitResult::MAXY: dy++; break;
|
||||
case HitResult::MINZ: dz--; break;
|
||||
case HitResult::MAXZ: dz++; break;
|
||||
case HitResult::MINX: dx--; break;
|
||||
case HitResult::MAXX: dx++; break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -431,7 +432,7 @@ void Minecraft::tickInput()
|
||||
#ifdef ENH_ALLOW_SCROLL_WHEEL
|
||||
if (Mouse::getEventButton() == BUTTON_SCROLLWHEEL)
|
||||
{
|
||||
int slot = m_pLocalPlayer->m_pInventory->m_SelectedHotbarSlot;
|
||||
int slot = m_pLocalPlayer->m_pInventory->m_selectedHotbarSlot;
|
||||
|
||||
int maxItems = m_gui.getNumUsableSlots() - 1;
|
||||
|
||||
@@ -498,7 +499,7 @@ void Minecraft::tickInput()
|
||||
{
|
||||
getOptions()->m_bDebugText = !getOptions()->m_bDebugText;
|
||||
}
|
||||
#ifdef ENH_ALLOW_AO
|
||||
#ifdef ENH_ALLOW_AO
|
||||
else if (getOptions()->isKey(KM_TOGGLEAO, keyCode))
|
||||
{
|
||||
// Toggle ambient occlusion.
|
||||
@@ -506,7 +507,7 @@ void Minecraft::tickInput()
|
||||
Minecraft::useAmbientOcclusion = getOptions()->m_bAmbientOcclusion;
|
||||
m_pLevelRenderer->allChanged();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (getOptions()->field_19)
|
||||
@@ -533,14 +534,14 @@ void Minecraft::tickInput()
|
||||
|
||||
if (b && !bai.isRemoveContinue())
|
||||
handleBuildAction(&bai);
|
||||
|
||||
|
||||
bool flag =
|
||||
// If we are mouse operated, the LMB is held down and it's not in the GUI
|
||||
((m_options->field_19 && Mouse::isButtonDown(BUTTON_LEFT) && !bIsInGUI) ||
|
||||
// We are instead keyboard operated, so check for the KM_DESTROY key being held down
|
||||
(!m_options->field_19 && Keyboard::isKeyDown(m_options->m_keyMappings[KM_DESTROY].value)) ||
|
||||
// The build action intention is a remove one
|
||||
(b && bai.isRemove()));
|
||||
// We are instead keyboard operated, so check for the KM_DESTROY key being held down
|
||||
(!m_options->field_19 && Keyboard::isKeyDown(m_options->m_keyMappings[KM_DESTROY].value)) ||
|
||||
// The build action intention is a remove one
|
||||
(b && bai.isRemove()));
|
||||
|
||||
if (flag && !m_pScreen && (field_DA8 - field_DAC) >= (m_timer.m_ticksPerSecond * 0.25f))
|
||||
{
|
||||
@@ -649,11 +650,11 @@ void Minecraft::_reloadInput()
|
||||
{
|
||||
m_pInputHolder = new CustomInputHolder(
|
||||
new KeyboardInput(m_options),
|
||||
#ifdef ORIGINAL_CODE
|
||||
#ifdef ORIGINAL_CODE
|
||||
new ControllerTurnInput,
|
||||
#else
|
||||
#else
|
||||
new MouseTurnInput(this),
|
||||
#endif
|
||||
#endif
|
||||
new IBuildInput
|
||||
);
|
||||
}
|
||||
@@ -662,7 +663,7 @@ void Minecraft::_reloadInput()
|
||||
|
||||
if (m_pLevel && m_pLocalPlayer)
|
||||
{
|
||||
m_pLocalPlayer->m_pMoveInput = m_pInputHolder->getMoveInput();
|
||||
m_pLocalPlayer->m_pMoveInput = m_pInputHolder->getMoveInput();
|
||||
}
|
||||
|
||||
m_options->field_19 = !isTouchscreen();
|
||||
@@ -780,7 +781,7 @@ void Minecraft::update()
|
||||
m_pGameRenderer->render(m_timer.m_renderTicks);
|
||||
|
||||
double time = double(getTimeS());
|
||||
m_fDeltaTime = time - m_fLastUpdated;
|
||||
m_fDeltaTime = time - m_fLastUpdated;
|
||||
m_fLastUpdated = time;
|
||||
|
||||
// Added by iProgramInCpp
|
||||
@@ -830,7 +831,8 @@ void Minecraft::init()
|
||||
m_pGameMode = new CreativeMode(this);
|
||||
#endif
|
||||
|
||||
m_pFont = new Font(m_options, "font/default.png", m_pTextures);
|
||||
// "Default.png" for the launch image overwrites "default.png" for the font during app packaging
|
||||
m_pFont = new Font(m_options, "font/default8.png", m_pTextures);
|
||||
|
||||
if (GrassColor::isAvailable())
|
||||
{
|
||||
@@ -894,7 +896,7 @@ void Minecraft::prepareLevel(const std::string& unused)
|
||||
float time1 = getTimeS();
|
||||
|
||||
// generating all the chunks at once
|
||||
(void) m_pLevel->getTile(i, (C_MAX_Y + C_MIN_Y) / 2, j);
|
||||
(void)m_pLevel->getTile(i, (C_MAX_Y + C_MIN_Y) / 2, j);
|
||||
|
||||
if (time1 != -1.0f)
|
||||
getTimeS();
|
||||
@@ -972,8 +974,9 @@ void Minecraft::sizeUpdate(int newWidth, int newHeight)
|
||||
// re-calculate the GUI scale.
|
||||
Gui::InvGuiScale = getBestScaleForThisScreenSize(newWidth, newHeight) / guiScaleMultiplier;
|
||||
|
||||
// the ceil prevents under-drawing
|
||||
if (m_pScreen)
|
||||
m_pScreen->setSize(int(Minecraft::width * Gui::InvGuiScale), int(Minecraft::height * Gui::InvGuiScale));
|
||||
m_pScreen->setSize(ceil(Minecraft::width * Gui::InvGuiScale), ceil(Minecraft::height * Gui::InvGuiScale));
|
||||
|
||||
if (m_pInputHolder)
|
||||
m_pInputHolder->setScreenSize(Minecraft::width, Minecraft::height);
|
||||
@@ -1003,8 +1006,8 @@ float Minecraft::getBestScaleForThisScreenSize(int width, int height)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (height > 1600)
|
||||
return 1.0f / 4.0f;
|
||||
if (height > 1600)
|
||||
return 1.0f / 4.0f;
|
||||
|
||||
if (height > 800)
|
||||
return 1.0f / 3.0f;
|
||||
@@ -1237,4 +1240,4 @@ void Minecraft::locateMultiplayer()
|
||||
m_pRakNetInstance->pingForHosts(C_DEFAULT_PORT);
|
||||
m_pNetEventCallback = new ClientSideNetworkHandler(this, m_pRakNetInstance);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -83,9 +83,9 @@ public:
|
||||
Options* getOptions() const { return m_options; }
|
||||
|
||||
static void setGuiScaleMultiplier(float f);
|
||||
|
||||
|
||||
private:
|
||||
void _reloadInput();
|
||||
void _reloadInput();
|
||||
void _levelGenerated();
|
||||
|
||||
public:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
@@ -108,9 +108,9 @@ void Gui::renderVignette(float a2, int a3, int a4)
|
||||
|
||||
Tesselator& t = Tesselator::instance;
|
||||
t.begin();
|
||||
t.vertexUV(0.0f, a4, -90.0f, 0.0f, 1.0f);
|
||||
t.vertexUV(a3, a4, -90.0f, 1.0f, 1.0f);
|
||||
t.vertexUV(a3, 0.0f, -90.0f, 1.0f, 0.0f);
|
||||
t.vertexUV(0.0f, a4, -90.0f, 0.0f, 1.0f);
|
||||
t.vertexUV(a3, a4, -90.0f, 1.0f, 1.0f);
|
||||
t.vertexUV(a3, 0.0f, -90.0f, 1.0f, 0.0f);
|
||||
t.vertexUV(0.0f, 0.0f, -90.0f, 0.0f, 0.0f);
|
||||
t.draw();
|
||||
|
||||
@@ -134,7 +134,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
|
||||
if (!m->m_pLevel || !m->m_pLocalPlayer)
|
||||
return;
|
||||
|
||||
bool isTouchscreen = m->isTouchscreen();
|
||||
//bool isTouchscreen = m->isTouchscreen();
|
||||
|
||||
field_4 = -90.0f;
|
||||
|
||||
@@ -150,7 +150,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
|
||||
|
||||
field_4 = -90.0f;
|
||||
|
||||
int width = Minecraft::width * InvGuiScale,
|
||||
int width = Minecraft::width * InvGuiScale,
|
||||
height = Minecraft::height * InvGuiScale;
|
||||
|
||||
#ifdef ENH_TRANSPARENT_HOTBAR
|
||||
@@ -166,7 +166,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
|
||||
blit(cenX - hotbarWidth / 2, height - 22, 0, 0, hotbarWidth, 22, 0, 0);
|
||||
|
||||
// selection mark
|
||||
blit(cenX - 1 - hotbarWidth / 2 + 20 * pInventory->m_SelectedHotbarSlot, height - 23, 0, 22, 24, 22, 0, 0);
|
||||
blit(cenX - 1 - hotbarWidth / 2 + 20 * pInventory->m_selectedHotbarSlot, height - 23, 0, 22, 24, 22, 0, 0);
|
||||
|
||||
m->m_pTextures->loadAndBindTexture("gui/icons.png");
|
||||
|
||||
@@ -187,7 +187,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
|
||||
else
|
||||
{
|
||||
// if needed, draw feedback
|
||||
|
||||
|
||||
// NOTE: real Minecraft PE takes it directly from the gamemode as "current progress" and
|
||||
// "last progress". Well guess what? The game mode in question updates our field_8 with
|
||||
// the pre-interpolated break progress! Isn't that awesome?!
|
||||
@@ -298,8 +298,8 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
|
||||
if (m->m_pLocalPlayer->isUnderLiquid(Material::water))
|
||||
{
|
||||
int breathRaw = m->m_pLocalPlayer->field_BC;
|
||||
int breathFull = int(ceilf((float(breathRaw - 2) * 10.0f) / 300.0f));
|
||||
int breathMeter = int(ceilf((float(breathRaw) * 10.0f) / 300.0f)) - breathFull;
|
||||
int breathFull = int(ceilf((float(breathRaw - 2) * 10.0f) / 300.0f));
|
||||
int breathMeter = int(ceilf((float(breathRaw) * 10.0f) / 300.0f)) - breathFull;
|
||||
|
||||
int bubbleX = cenX - 191;
|
||||
int bubbleY = height - 19;
|
||||
@@ -334,7 +334,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
|
||||
|
||||
slotX += 20;
|
||||
}
|
||||
|
||||
|
||||
slotX = cenX - hotbarWidth / 2 + 3;
|
||||
for (int i = 0; i < nSlots - diff; i++)
|
||||
{
|
||||
@@ -460,7 +460,7 @@ void Gui::handleKeyPressed(int keyCode)
|
||||
|
||||
if (m_pMinecraft->getOptions()->isKey(KM_SLOT_R, keyCode))
|
||||
{
|
||||
int* slot = &m_pMinecraft->m_pLocalPlayer->m_pInventory->m_SelectedHotbarSlot;
|
||||
int* slot = &m_pMinecraft->m_pLocalPlayer->m_pInventory->m_selectedHotbarSlot;
|
||||
|
||||
if (*slot <= maxItems)
|
||||
(*slot)++;
|
||||
@@ -469,7 +469,7 @@ void Gui::handleKeyPressed(int keyCode)
|
||||
}
|
||||
if (m_pMinecraft->getOptions()->isKey(KM_SLOT_L, keyCode))
|
||||
{
|
||||
int* slot = &m_pMinecraft->m_pLocalPlayer->m_pInventory->m_SelectedHotbarSlot;
|
||||
int* slot = &m_pMinecraft->m_pLocalPlayer->m_pInventory->m_selectedHotbarSlot;
|
||||
|
||||
if (*slot > 0)
|
||||
(*slot)--;
|
||||
@@ -490,10 +490,10 @@ void Gui::handleKeyPressed(int keyCode)
|
||||
void Gui::renderMessages(bool bShowAll)
|
||||
{
|
||||
//int width = Minecraft::width * InvGuiScale,
|
||||
int height = Minecraft::height * InvGuiScale;
|
||||
int height = Minecraft::height * InvGuiScale;
|
||||
|
||||
int topEdge = height - 49;
|
||||
|
||||
|
||||
for (int i = 0; i < int(m_guiMessages.size()); i++)
|
||||
{
|
||||
GuiMessage& msg = m_guiMessages[i];
|
||||
@@ -503,7 +503,7 @@ void Gui::renderMessages(bool bShowAll)
|
||||
int bkgdColor = 0x7F000000, textColor = 0xFFFFFFFF;
|
||||
|
||||
float fade = 1.0f;
|
||||
|
||||
|
||||
if (!bShowAll)
|
||||
{
|
||||
fade = 10.0f * (1.0f - (float(msg.field_18) / 200.0f));
|
||||
@@ -553,4 +553,4 @@ RectangleArea Gui::getRectangleArea(bool b)
|
||||
Minecraft::height - 24.0f / InvGuiScale,
|
||||
centerX + hotbarWidthHalf,
|
||||
Minecraft::height);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ float WorldSelectionList::getPos(float f)
|
||||
if (field_D8 != 1)
|
||||
return RolledSelectionList::getPos(f);
|
||||
|
||||
return Lerp(WorldSelectionList_Static1(field_54, field_58, field_5C, field_60),
|
||||
return Mth::Lerp(WorldSelectionList_Static1(field_54, field_58, field_5C, field_60),
|
||||
WorldSelectionList_Static1(field_54 + 1.0f, field_58, field_5C, field_60),
|
||||
f);
|
||||
}
|
||||
|
||||
@@ -7,12 +7,14 @@
|
||||
********************************************************************/
|
||||
|
||||
#include "IngameBlockSelectionScreen.hpp"
|
||||
#include "PauseScreen.hpp"
|
||||
#include "client/app/Minecraft.hpp"
|
||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||
|
||||
std::string g_sNotAvailableInDemoVersion = "Not available in the demo version";
|
||||
|
||||
IngameBlockSelectionScreen::IngameBlockSelectionScreen()
|
||||
IngameBlockSelectionScreen::IngameBlockSelectionScreen() :
|
||||
m_btnPause(0, "Pause")
|
||||
{
|
||||
m_selectedSlot = 0;
|
||||
}
|
||||
@@ -69,6 +71,14 @@ bool IngameBlockSelectionScreen::isAllowed(int slot)
|
||||
|
||||
void IngameBlockSelectionScreen::init()
|
||||
{
|
||||
m_btnPause.m_width = 40;
|
||||
m_btnPause.m_xPos = 0;
|
||||
m_btnPause.m_yPos = 0;
|
||||
#if TARGET_OS_IPHONE != 0
|
||||
if (m_pMinecraft->isTouchscreen())
|
||||
m_buttons.push_back(&m_btnPause);
|
||||
#endif
|
||||
|
||||
Inventory* pInv = getInventory();
|
||||
|
||||
int nItems = pInv->getNumItems();
|
||||
@@ -148,8 +158,16 @@ void IngameBlockSelectionScreen::render(int x, int y, float f)
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void IngameBlockSelectionScreen::buttonClicked(Button* pButton)
|
||||
{
|
||||
if (pButton->m_buttonId == m_btnPause.m_buttonId)
|
||||
m_pMinecraft->setScreen(new PauseScreen);
|
||||
}
|
||||
|
||||
void IngameBlockSelectionScreen::mouseClicked(int x, int y, int type)
|
||||
{
|
||||
Screen::mouseClicked(x, y, type);
|
||||
|
||||
// not a left click
|
||||
if (type != 1)
|
||||
return;
|
||||
@@ -161,6 +179,8 @@ void IngameBlockSelectionScreen::mouseClicked(int x, int y, int type)
|
||||
|
||||
void IngameBlockSelectionScreen::mouseReleased(int x, int y, int type)
|
||||
{
|
||||
Screen::mouseReleased(x, y, type);
|
||||
|
||||
// not a left click
|
||||
if (type != 1)
|
||||
return;
|
||||
|
||||
@@ -31,11 +31,13 @@ public:
|
||||
|
||||
virtual void init() override;
|
||||
virtual void render(int x, int y, float f) override;
|
||||
virtual void buttonClicked(Button*) override;
|
||||
virtual void mouseClicked(int x, int y, int type) override;
|
||||
virtual void mouseReleased(int x, int y, int type) override;
|
||||
virtual void removed() override;
|
||||
|
||||
private:
|
||||
int m_selectedSlot;
|
||||
Button m_btnPause;
|
||||
};
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ bool JoinGameScreen::handleBackEvent(bool b)
|
||||
|
||||
void JoinGameScreen::init()
|
||||
{
|
||||
const int BUTTON_WIDTH = 100;
|
||||
const int BUTTON_WIDTH = 84;
|
||||
|
||||
m_btnBack.m_yPos = m_btnJoin.m_yPos = m_btnDirectConnect.m_yPos = m_height - 27;
|
||||
m_btnBack.m_width = m_btnJoin.m_width = BUTTON_WIDTH;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "SelectWorldScreen.hpp"
|
||||
#include "JoinGameScreen.hpp"
|
||||
|
||||
#if defined(_WIN32) || defined(TARGET_OS_MAC)
|
||||
#if defined(_WIN32) || (defined(TARGET_OS_MAC) && TARGET_OS_IPHONE == 0)
|
||||
#define CAN_QUIT
|
||||
#endif
|
||||
|
||||
@@ -75,7 +75,7 @@ const char* gSplashes[] =
|
||||
"Minecraft!",
|
||||
"Yaaay!",
|
||||
"Multiplayer!",
|
||||
"Not yet touch compatible!",// "Touch compatible!",
|
||||
"Touch compatible!",
|
||||
"Undocumented!",
|
||||
"Ingots!",
|
||||
"Exploding creepers!",
|
||||
@@ -600,27 +600,27 @@ void StartMenuScreen::draw3dTitle(float f)
|
||||
{
|
||||
glPushMatrix();
|
||||
glTranslatef(0.4f, 0.6f, -12.0f);
|
||||
if (i == 0)
|
||||
switch (i)
|
||||
{
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glTranslatef(0.0f, -0.5f, -0.5f);
|
||||
glEnable(GL_BLEND);
|
||||
//force set alpha
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
case 0:
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glTranslatef(0.0f, -0.5f, -0.5f);
|
||||
glEnable(GL_BLEND);
|
||||
//force set alpha
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
break;
|
||||
|
||||
if (i == 1)
|
||||
{
|
||||
glDisable(GL_BLEND);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
//revert
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
if (i == 2)
|
||||
{
|
||||
glEnable(GL_BLEND);
|
||||
//glBlendFunc(GL_SRC_COLOR, GL_ONE);
|
||||
case 1:
|
||||
glDisable(GL_BLEND);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
//revert
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
glEnable(GL_BLEND);
|
||||
//glBlendFunc(GL_SRC_COLOR, GL_ONE);
|
||||
break;
|
||||
}
|
||||
|
||||
glScalef(1.0f, -1.0f, 1.0f);
|
||||
@@ -646,8 +646,7 @@ void StartMenuScreen::draw3dTitle(float f)
|
||||
glPushMatrix();
|
||||
|
||||
TitleTile* pTTile = m_pTiles[y * Width + x];
|
||||
// @TODO: After merging the iOS port, change to Mth::Lerp
|
||||
float z = Lerp(pTTile->lastHeight, pTTile->height, f);
|
||||
float z = Mth::Lerp(pTTile->lastHeight, pTTile->height, f);
|
||||
float scale = 1.0f;
|
||||
float bright = 1.0f;
|
||||
float rotation = 180.0f;
|
||||
|
||||
@@ -18,7 +18,9 @@ HumanoidModel::HumanoidModel(float a, float b):
|
||||
m_leg1(0, 16),
|
||||
m_leg2(0, 16)
|
||||
{
|
||||
field_20 = false;
|
||||
field_234 = 0;
|
||||
field_20 = false;
|
||||
|
||||
m_head.setModel(this);
|
||||
m_body.setModel(this);
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
void setBrightness(float) override;
|
||||
|
||||
public:
|
||||
bool field_20 = false;
|
||||
bool field_20;
|
||||
ModelPart m_head, m_body, m_arm1, m_arm2, m_leg1, m_leg2;
|
||||
bool field_234;
|
||||
bool field_235;
|
||||
|
||||
@@ -202,7 +202,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, PlaceBl
|
||||
Tile::tiles[tile]->setPlacedBy(m_pLevel, x, y, z, pPlayer);
|
||||
|
||||
const Tile::SoundType* pSound = pTile->m_pSound;
|
||||
m_pLevel->playSound(float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, "step." + pSound->m_name, 0.5f * (1.0f + pSound->field_18), 0.8f * pSound->field_1C);
|
||||
m_pLevel->playSound(float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, "step." + pSound->m_name, 0.5f * (1.0f + pSound->volume), 0.8f * pSound->pitch);
|
||||
}
|
||||
|
||||
void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, RemoveBlockPacket* pRemoveBlockPkt)
|
||||
@@ -233,7 +233,7 @@ void ClientSideNetworkHandler::handle(const RakNet::RakNetGUID& rakGuid, RemoveB
|
||||
if (pTile && setTileResult)
|
||||
{
|
||||
const Tile::SoundType* pSound = pTile->m_pSound;
|
||||
m_pLevel->playSound(float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, "step." + pSound->m_name, 0.5f * (1.0f + pSound->field_18), 0.8f * pSound->field_1C);
|
||||
m_pLevel->playSound(float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, "step." + pSound->m_name, 0.5f * (1.0f + pSound->volume), 0.8f * pSound->pitch);
|
||||
|
||||
pTile->destroy(m_pLevel, x, y, z, data);
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ std::vector<std::string> Options::getOptionStrings()
|
||||
SO("gfx_biomecolors", saveBool(m_bBiomeColors));
|
||||
SO("gfx_dynamichand", saveBool(m_bDynamicHand));
|
||||
SO("misc_oldtitle", saveBool(m_bOldTitleLogo));
|
||||
SO("info_debugtext", saveBool(m_bAutoJump));
|
||||
SO("info_debugtext", saveBool(m_bDebugText));
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "compat/LegacyCPPCompatibility.hpp"
|
||||
|
||||
class IArea
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "compat/LegacyCPPCompatibility.hpp"
|
||||
|
||||
class Player;
|
||||
|
||||
enum
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "compat/LegacyCPPCompatibility.hpp"
|
||||
|
||||
struct TurnDelta
|
||||
{
|
||||
float x, y;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "MouseHandler.hpp"
|
||||
|
||||
#include "common/Utils.hpp"
|
||||
|
||||
MouseHandler::MouseHandler() :
|
||||
m_pTurnInput(nullptr)
|
||||
{
|
||||
|
||||
@@ -50,14 +50,14 @@ void Multitouch::feed(MouseButtonType a1, bool a2, int a3, int a4, int fingerId)
|
||||
MouseDevice* pDevice = g(fingerId);
|
||||
pDevice->feed(a1, a2, a3, a4);
|
||||
|
||||
if (a1)
|
||||
if (a1 != BUTTON_NONE)
|
||||
{
|
||||
if (a2)
|
||||
{
|
||||
_wasPressed[fingerId] = true;
|
||||
_wasPressedThisUpdate[fingerId] = true;
|
||||
}
|
||||
else if (a2 == 0)
|
||||
else
|
||||
{
|
||||
_wasReleased[fingerId] = true;
|
||||
_wasReleasedThisUpdate[fingerId] = true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "client/renderer/Texture.hpp"
|
||||
|
||||
|
||||
@@ -129,9 +129,9 @@ void GameRenderer::moveCameraToPlayer(float f)
|
||||
|
||||
float headHeightDiff = pMob->field_84 - 1.62f;
|
||||
|
||||
float posX = Lerp(pMob->field_3C.x, pMob->m_pos.x, f);
|
||||
float posY = Lerp(pMob->field_3C.y, pMob->m_pos.y, f);
|
||||
float posZ = Lerp(pMob->field_3C.z, pMob->m_pos.z, f);
|
||||
float posX = Mth::Lerp(pMob->field_3C.x, pMob->m_pos.x, f);
|
||||
float posY = Mth::Lerp(pMob->field_3C.y, pMob->m_pos.y, f);
|
||||
float posZ = Mth::Lerp(pMob->field_3C.z, pMob->m_pos.z, f);
|
||||
|
||||
glRotatef(field_5C + f * (field_58 - field_5C), 0.0f, 0.0f, 1.0f);
|
||||
|
||||
@@ -241,8 +241,8 @@ void GameRenderer::bobView(float f)
|
||||
return;
|
||||
|
||||
Player* player = (Player*)m_pMinecraft->m_pMobPersp;
|
||||
float f1 = Lerp(player->field_B9C, player->field_BA0, f);
|
||||
float f2 = Lerp(player->field_118, player->field_11C, f);
|
||||
float f1 = Mth::Lerp(player->field_B9C, player->field_BA0, f);
|
||||
float f2 = Mth::Lerp(player->field_118, player->field_11C, f);
|
||||
// @NOTE: Multiplying by M_PI inside of the paren makes it stuttery for some reason? Anyways it works now :)
|
||||
float f3 = -(player->field_94 + (player->field_94 - player->field_90) * f) * float(M_PI);
|
||||
float f4 = Mth::sin(f3);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "client/renderer/Texture.hpp"
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "ItemInHandRenderer.hpp"
|
||||
#include "client/app/Minecraft.hpp"
|
||||
#include "common/Mth.hpp"
|
||||
|
||||
ItemInHandRenderer::ItemInHandRenderer(Minecraft* pMC) :
|
||||
m_ItemInstance(0, 1, 0),
|
||||
@@ -124,33 +125,33 @@ void ItemInHandRenderer::renderItem(ItemInstance* inst)
|
||||
SHADE_IF_NEEDED(0.8f);
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
t.vertexUV(i * C_ONE_PIXEL, 0.0f, -C_ONE_PIXEL, Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2);
|
||||
t.vertexUV(i * C_ONE_PIXEL, 0.0f, 0.0f, Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2);
|
||||
t.vertexUV(i * C_ONE_PIXEL, 1.0f, 0.0f, Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1);
|
||||
t.vertexUV(i * C_ONE_PIXEL, 1.0f, -C_ONE_PIXEL, Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1);
|
||||
t.vertexUV(i * C_ONE_PIXEL, 0.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2);
|
||||
t.vertexUV(i * C_ONE_PIXEL, 0.0f, 0.0f, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2);
|
||||
t.vertexUV(i * C_ONE_PIXEL, 1.0f, 0.0f, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1);
|
||||
t.vertexUV(i * C_ONE_PIXEL, 1.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1);
|
||||
}
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
t.vertexUV((i + 1) * C_ONE_PIXEL, 1.0f, -C_ONE_PIXEL, Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1);
|
||||
t.vertexUV((i + 1) * C_ONE_PIXEL, 1.0f, 0.0f, Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1);
|
||||
t.vertexUV((i + 1) * C_ONE_PIXEL, 0.0f, 0.0f, Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2);
|
||||
t.vertexUV((i + 1) * C_ONE_PIXEL, 0.0f, -C_ONE_PIXEL, Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2);
|
||||
t.vertexUV((i + 1) * C_ONE_PIXEL, 1.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1);
|
||||
t.vertexUV((i + 1) * C_ONE_PIXEL, 1.0f, 0.0f, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_1);
|
||||
t.vertexUV((i + 1) * C_ONE_PIXEL, 0.0f, 0.0f, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2);
|
||||
t.vertexUV((i + 1) * C_ONE_PIXEL, 0.0f, -C_ONE_PIXEL, Mth::Lerp(texU_2, texU_1, i * C_ONE_PIXEL) - C_RATIO_2, texV_2);
|
||||
}
|
||||
|
||||
SHADE_IF_NEEDED(0.6f);
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
t.vertexUV(0.0f, (i + 1) * C_ONE_PIXEL, 0.0f, texU_2, Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(1.0f, (i + 1) * C_ONE_PIXEL, 0.0f, texU_1, Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(1.0f, (i + 1) * C_ONE_PIXEL, -C_ONE_PIXEL, texU_1, Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(0.0f, (i + 1) * C_ONE_PIXEL, -C_ONE_PIXEL, texU_2, Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(0.0f, (i + 1) * C_ONE_PIXEL, 0.0f, texU_2, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(1.0f, (i + 1) * C_ONE_PIXEL, 0.0f, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(1.0f, (i + 1) * C_ONE_PIXEL, -C_ONE_PIXEL, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(0.0f, (i + 1) * C_ONE_PIXEL, -C_ONE_PIXEL, texU_2, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
}
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
t.vertexUV(1.0f, i * C_ONE_PIXEL, 0.0f, texU_1, Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(0.0f, i * C_ONE_PIXEL, 0.0f, texU_2, Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(0.0f, i * C_ONE_PIXEL, -C_ONE_PIXEL, texU_2, Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(1.0f, i * C_ONE_PIXEL, -C_ONE_PIXEL, texU_1, Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(1.0f, i * C_ONE_PIXEL, 0.0f, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(0.0f, i * C_ONE_PIXEL, 0.0f, texU_2, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(0.0f, i * C_ONE_PIXEL, -C_ONE_PIXEL, texU_2, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
t.vertexUV(1.0f, i * C_ONE_PIXEL, -C_ONE_PIXEL, texU_1, Mth::Lerp(texV_2, texV_1, i * C_ONE_PIXEL));
|
||||
}
|
||||
|
||||
t.draw();
|
||||
@@ -169,9 +170,8 @@ void ItemInHandRenderer::render(float f)
|
||||
|
||||
if (m_pMinecraft->getOptions()->m_bDynamicHand && m_pMinecraft->m_pMobPersp == pLP)
|
||||
{
|
||||
// @TODO: Change to Mth::Lerp when iOS port is pulled!
|
||||
float rYaw = Lerp(pLP->m_lastRenderArmYaw, pLP->m_renderArmYaw, f);
|
||||
float rPitch = Lerp(pLP->m_lastRenderArmPitch, pLP->m_renderArmPitch, f);
|
||||
float rYaw = Mth::Lerp(pLP->m_lastRenderArmYaw, pLP->m_renderArmYaw, f);
|
||||
float rPitch = Mth::Lerp(pLP->m_lastRenderArmPitch, pLP->m_renderArmPitch, f);
|
||||
glRotatef((pLP->m_pitch - rPitch) * 0.1f, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef((pLP->m_yaw - rYaw ) * 0.1f, 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "LevelRenderer.hpp"
|
||||
#include "client/app/Minecraft.hpp"
|
||||
#include "renderer/GL/GL.hpp"
|
||||
#include "common/Mth.hpp"
|
||||
|
||||
#include "world/tile/LeafTile.hpp"
|
||||
#include "world/tile/GrassTile.hpp"
|
||||
@@ -1249,28 +1250,28 @@ void LevelRenderer::addParticle(const std::string& name, float x, float y, float
|
||||
LOG_W("Unknown particle type: %s", name.c_str());
|
||||
}
|
||||
|
||||
void LevelRenderer::playSound(const std::string& name, float x, float y, float z, float a, float b)
|
||||
void LevelRenderer::playSound(const std::string& name, float x, float y, float z, float volume, float pitch)
|
||||
{
|
||||
// TODO: Who's the genius who decided it'd be better to check a name string rather than an enum?
|
||||
float mult = 1.0f, maxDist = 16.0f;
|
||||
float playerDist = m_pMinecraft->m_pMobPersp->distanceToSqr(x, y, z);
|
||||
|
||||
if (a > 1.0f)
|
||||
if (volume > 1.0f)
|
||||
{
|
||||
mult = 16.0f;
|
||||
maxDist = a * mult;
|
||||
maxDist = volume * mult;
|
||||
}
|
||||
|
||||
if (name == "random.explode")
|
||||
{
|
||||
a *= 1.0f - playerDist / 65536.0f;
|
||||
if (a < 0)
|
||||
volume *= 1.0f - playerDist / 65536.0f;
|
||||
if (volume < 0)
|
||||
return;
|
||||
maxDist = 256.0f;
|
||||
}
|
||||
|
||||
if (maxDist * maxDist > playerDist)
|
||||
m_pMinecraft->m_pSoundEngine->play(name, x, y, z, a, b);
|
||||
m_pMinecraft->m_pSoundEngine->play(name, x, y, z, volume, pitch);
|
||||
}
|
||||
|
||||
void LevelRenderer::renderSky(float f)
|
||||
@@ -1307,7 +1308,7 @@ void LevelRenderer::renderClouds(float f)
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
float yPos = Lerp(m_pMinecraft->m_pMobPersp->field_98.y, m_pMinecraft->m_pMobPersp->m_pos.y, f); // not certain if this old pos Y is used
|
||||
float yPos = Mth::Lerp(m_pMinecraft->m_pMobPersp->field_98.y, m_pMinecraft->m_pMobPersp->m_pos.y, f); // not certain if this old pos Y is used
|
||||
m_pTextures->loadAndBindTexture("environment/clouds.png");
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
@@ -1315,8 +1316,8 @@ void LevelRenderer::renderClouds(float f)
|
||||
|
||||
Vec3 cloudColor = m_pLevel->getCloudColor(f);
|
||||
|
||||
float offX = Lerp(m_pMinecraft->m_pMobPersp->field_3C.x, m_pMinecraft->m_pMobPersp->m_pos.x, f) + (float(m_ticksSinceStart) + f) * 0.3f;
|
||||
float offZ = Lerp(m_pMinecraft->m_pMobPersp->field_3C.z, m_pMinecraft->m_pMobPersp->m_pos.z, f);
|
||||
float offX = Mth::Lerp(m_pMinecraft->m_pMobPersp->field_3C.x, m_pMinecraft->m_pMobPersp->m_pos.x, f) + (float(m_ticksSinceStart) + f) * 0.3f;
|
||||
float offZ = Mth::Lerp(m_pMinecraft->m_pMobPersp->field_3C.z, m_pMinecraft->m_pMobPersp->m_pos.z, f);
|
||||
|
||||
int dx2048 = Mth::floor(offX / 2048.0f);
|
||||
int dz2048 = Mth::floor(offZ / 2048.0f);
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
void setTilesDirty(int, int, int, int, int, int) override;
|
||||
void takePicture(TripodCamera*, Entity*) override;
|
||||
void addParticle(const std::string&, float, float, float, float, float, float) override;
|
||||
void playSound(const std::string& a, float b, float c, float d, float e, float f) override;
|
||||
void playSound(const std::string& name, float x, float y, float z, float volume, float pitch) override;
|
||||
void skyColorChanged() override;
|
||||
void generateSky();
|
||||
void cull(Culler*, float);
|
||||
|
||||
@@ -31,6 +31,13 @@ void PatchManager::LoadPatchData(const std::string& patchData)
|
||||
while (std::getline(patchDataStream, currLine))
|
||||
{
|
||||
if (currLine.empty()) continue;
|
||||
if (currLine.at(currLine.size() - 1) == '\r')
|
||||
{
|
||||
// Ignore Windows line-endings when processing file on Unix systems
|
||||
// How would we possibly standardize this if the game isn't the thing writing the file?
|
||||
currLine = currLine.substr(0, currLine.size() - 1);
|
||||
}
|
||||
if (currLine.empty()) continue;
|
||||
if (currLine[0] == '#') continue;
|
||||
|
||||
std::string command;
|
||||
@@ -38,6 +45,13 @@ void PatchManager::LoadPatchData(const std::string& patchData)
|
||||
// read command type
|
||||
if (!std::getline(lineStream, command, PM_SEPARATOR))
|
||||
continue;
|
||||
|
||||
/*if (command[0] == '\n')
|
||||
{
|
||||
// We'll end up here if we're on a platform that doesn't use Windows line-endings
|
||||
// So let's just ignore them
|
||||
command = command.erase(0, 1);
|
||||
}*/
|
||||
|
||||
if (command == "stop_now")
|
||||
{
|
||||
|
||||
@@ -44,3 +44,19 @@ void SoundSystem::stop(const std::string& sound)
|
||||
void SoundSystem::playAt(const SoundDesc& sound, float x, float y, float z, float a, float b)
|
||||
{
|
||||
}
|
||||
|
||||
void SoundSystem::startEngine()
|
||||
{
|
||||
}
|
||||
|
||||
void SoundSystem::stopEngine()
|
||||
{
|
||||
}
|
||||
|
||||
void SoundSystem::muteAudio()
|
||||
{
|
||||
}
|
||||
|
||||
void SoundSystem::unMuteAudio()
|
||||
{
|
||||
}
|
||||
@@ -24,5 +24,12 @@ public:
|
||||
virtual void pause(const std::string& sound);
|
||||
virtual void stop(const std::string& sound);
|
||||
virtual void playAt(const SoundDesc& sound, float x, float y, float z, float a, float b);
|
||||
|
||||
// Be prepared for these to be called regardless of engine state
|
||||
virtual void startEngine();
|
||||
virtual void stopEngine();
|
||||
|
||||
virtual void muteAudio();
|
||||
virtual void unMuteAudio();
|
||||
};
|
||||
|
||||
|
||||
@@ -168,4 +168,3 @@ float Mth::random()
|
||||
{
|
||||
return g_Random.nextFloat();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,5 +37,11 @@ public:
|
||||
static float sin(float);
|
||||
static float sqrt(float);
|
||||
static unsigned fastRandom();
|
||||
|
||||
// @NOTE: This is inlined.
|
||||
static constexpr float Lerp(float a, float b, float progress)
|
||||
{
|
||||
return a + progress * (b - a);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
// note: not an official file name
|
||||
|
||||
#include "common/Utils.hpp"
|
||||
#include "compat/PlatformDefinitions.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
|
||||
@@ -36,7 +37,7 @@
|
||||
|
||||
int g_TimeSecondsOnInit = 0;
|
||||
|
||||
#if (!defined(USE_SDL) || defined(_WIN32)) && !defined(ANDROID)
|
||||
#if (!defined(USE_SDL) || defined(_WIN32)) && !defined(ANDROID) && !MC_TARGET_OS_MAC
|
||||
|
||||
DIR* opendir(const char* name)
|
||||
{
|
||||
|
||||
@@ -26,17 +26,7 @@
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#ifdef USE_OLD_CPP
|
||||
#ifndef constexpr
|
||||
#define constexpr const
|
||||
#endif
|
||||
#ifndef nullptr
|
||||
#define nullptr NULL
|
||||
#endif
|
||||
#ifndef override
|
||||
#define override
|
||||
#endif
|
||||
#endif
|
||||
#include "../../compat/LegacyCPPCompatibility.hpp"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable : 4068)
|
||||
@@ -44,6 +34,7 @@
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
// Do we even need all this WinSock stuff anymore?
|
||||
#ifndef _XBOX // assume we're on a normal Windows device
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <WinSock2.h>
|
||||
@@ -186,7 +177,7 @@ enum eTileID
|
||||
TILE_NOTE_BLOCK,
|
||||
TILE_BED,
|
||||
TILE_RAIL_POWERED,
|
||||
TYPE_RAIL_ACTIVATOR,
|
||||
TILE_RAIL_ACTIVATOR,
|
||||
TILE_PISTON_STICKY,
|
||||
TILE_COBWEB,
|
||||
TILE_TALLGRASS,
|
||||
@@ -635,12 +626,6 @@ float Max(float a, float b);
|
||||
|
||||
void sleepMs(int ms);
|
||||
|
||||
// @NOTE: This is inlined.
|
||||
static constexpr float Lerp(float a, float b, float progress)
|
||||
{
|
||||
return a + progress * (b - a);
|
||||
}
|
||||
|
||||
bool createFolderIfNotExists(const char* pDir);
|
||||
bool DeleteDirectory(const std::string& name, bool unused);
|
||||
|
||||
|
||||
@@ -258,5 +258,5 @@ public:
|
||||
void read(RakNet::BitStream*) override;
|
||||
public:
|
||||
int m_playerID;
|
||||
uint8_t m_itemID;
|
||||
uint16_t m_itemID;
|
||||
};
|
||||
|
||||
@@ -233,7 +233,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, PlaceBlock
|
||||
Tile::tiles[tile]->setPlacedBy(m_pLevel, x, y, z, pMob);
|
||||
|
||||
const Tile::SoundType* pSound = Tile::tiles[tile]->m_pSound;
|
||||
m_pLevel->playSound(float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, "step." + pSound->m_name, 0.5f * (pSound->field_18 + 1.0f), pSound->field_1C * 0.8f);
|
||||
m_pLevel->playSound(float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, "step." + pSound->m_name, 0.5f * (pSound->volume + 1.0f), pSound->pitch * 0.8f);
|
||||
}
|
||||
|
||||
redistributePacket(packet, guid);
|
||||
@@ -257,7 +257,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& guid, RemoveBloc
|
||||
if (pTile && setTileResult)
|
||||
{
|
||||
const Tile::SoundType* pSound = pTile->m_pSound;
|
||||
m_pMinecraft->m_pSoundEngine->play("step." + pSound->m_name, float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, 0.5f * (pSound->field_18 + 1.0f), pSound->field_1C * 0.8f);
|
||||
m_pMinecraft->m_pSoundEngine->play("step." + pSound->m_name, float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f, 0.5f * (pSound->volume + 1.0f), pSound->pitch * 0.8f);
|
||||
|
||||
// redistribute the packet only if needed
|
||||
redistributePacket(packet, guid);
|
||||
@@ -479,44 +479,44 @@ void ServerSideNetworkHandler::commandTP(OnlinePlayer* player, const std::vector
|
||||
{
|
||||
if (!m_pLevel)
|
||||
return;
|
||||
|
||||
|
||||
if (parms.size() != 3)
|
||||
{
|
||||
sendMessage(player, "Usage: /tp <x> <y> <z>");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (player->m_pPlayer != this->m_pMinecraft->m_pLocalPlayer)
|
||||
{
|
||||
sendMessage(player, "Sorry, only the host can use this command at the moment");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Vec3 pos = player->m_pPlayer->getPos(1.0f);
|
||||
|
||||
|
||||
float x = pos.x, y = pos.y, z = pos.z;
|
||||
|
||||
|
||||
std::stringstream ss;
|
||||
if (parms[0] != "~")
|
||||
{
|
||||
ss = std::stringstream(parms[0]);
|
||||
ss.str(parms[0]);
|
||||
ss >> x;
|
||||
}
|
||||
if (parms[1] != "~")
|
||||
{
|
||||
ss = std::stringstream(parms[1]);
|
||||
ss.str(parms[1]);
|
||||
ss >> y;
|
||||
}
|
||||
if (parms[2] != "~")
|
||||
{
|
||||
ss = std::stringstream(parms[2]);
|
||||
ss.str(parms[2]);
|
||||
ss >> z;
|
||||
}
|
||||
|
||||
ss = std::stringstream();
|
||||
|
||||
ss.str(std::string());
|
||||
ss << "Teleported to " << x << ", " << y << ", " << z;
|
||||
|
||||
|
||||
player->m_pPlayer->setPos(x, y, z);
|
||||
|
||||
|
||||
sendMessage(player, ss.str());
|
||||
}
|
||||
|
||||
@@ -446,7 +446,7 @@ label_45:
|
||||
bPlaySound = false;
|
||||
|
||||
if (bPlaySound)
|
||||
m_pLevel->playSound(this, "step." + sound->m_name, sound->field_18 * 0.15f, sound->field_1C);
|
||||
m_pLevel->playSound(this, "step." + sound->m_name, sound->volume * 0.15f, sound->pitch);
|
||||
|
||||
Tile::tiles[tileID]->stepOn(m_pLevel, tileX, tileY, tileZ, this);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ void ItemEntity::_init(ItemInstance* itemInstance)
|
||||
field_E8 = 2 * float(M_PI) * Mth::random();
|
||||
setSize(0.25f, 0.25f);
|
||||
field_84 = field_8C * 0.5f;
|
||||
m__itemInstance = itemInstance ? *itemInstance : ItemInstance(0, 0, 0);
|
||||
m__itemInstance = itemInstance ? *itemInstance : ItemInstance();
|
||||
m_pItemInstance = &m__itemInstance;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,9 +60,8 @@ void LocalPlayer::aiStep()
|
||||
|
||||
m_lastRenderArmYaw = m_renderArmYaw;
|
||||
m_lastRenderArmPitch = m_renderArmPitch;
|
||||
// @TODO: Change to Mth::Lerp when iOS port is pulled!
|
||||
m_renderArmYaw = Lerp(m_renderArmYaw, m_yaw, 0.5f);
|
||||
m_renderArmPitch = Lerp(m_renderArmPitch, m_pitch, 0.5f);
|
||||
m_renderArmYaw = Mth::Lerp(m_renderArmYaw, m_yaw, 0.5f);
|
||||
m_renderArmPitch = Mth::Lerp(m_renderArmPitch, m_pitch, 0.5f);
|
||||
|
||||
Mob::aiStep();
|
||||
Player::aiStep();
|
||||
|
||||
@@ -707,9 +707,9 @@ Vec3 Mob::getPos(float f)
|
||||
return m_pos;
|
||||
|
||||
return Vec3(
|
||||
Lerp(field_3C.x, m_pos.x, f),
|
||||
Lerp(field_3C.y, m_pos.y, f),
|
||||
Lerp(field_3C.z, m_pos.z, f)
|
||||
Mth::Lerp(field_3C.x, m_pos.x, f),
|
||||
Mth::Lerp(field_3C.y, m_pos.y, f),
|
||||
Mth::Lerp(field_3C.z, m_pos.z, f)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ void CreativeMode::continueDestroyBlock(int x, int y, int z, int i)
|
||||
{
|
||||
m_pMinecraft->m_pSoundEngine->play("step." + pTile->m_pSound->m_name,
|
||||
float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f,
|
||||
0.5f * (1.0f + pTile->m_pSound->field_18), 0.8f * pTile->m_pSound->field_1C);
|
||||
0.5f * (1.0f + pTile->m_pSound->volume), 0.8f * pTile->m_pSound->pitch);
|
||||
}
|
||||
|
||||
if (m_destroyProgress >= 1.0f)
|
||||
|
||||
@@ -40,7 +40,7 @@ bool GameMode::destroyBlock(int x, int y, int z, int i)
|
||||
{
|
||||
m_pMinecraft->m_pSoundEngine->play("step." + pTile->m_pSound->m_name,
|
||||
float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f,
|
||||
0.5f * (1.0f + pTile->m_pSound->field_18), 0.8f * pTile->m_pSound->field_1C);
|
||||
0.5f * (1.0f + pTile->m_pSound->volume), 0.8f * pTile->m_pSound->pitch);
|
||||
|
||||
pTile->destroy(pLevel, x, y, z, tileData);
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ void SurvivalMode::continueDestroyBlock(int x, int y, int z, int i)
|
||||
{
|
||||
m_pMinecraft->m_pSoundEngine->play("step." + pTile->m_pSound->m_name,
|
||||
float(x) + 0.5f, float(y) + 0.5f, float(z) + 0.5f,
|
||||
0.5f * (1.0f + pTile->m_pSound->field_18), 0.8f * pTile->m_pSound->field_1C);
|
||||
0.5f * (1.0f + pTile->m_pSound->volume), 0.8f * pTile->m_pSound->pitch);
|
||||
}
|
||||
|
||||
if (m_destroyProgress >= 1.0f)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Inventory::Inventory(Player* pPlayer)
|
||||
{
|
||||
m_pPlayer = pPlayer;
|
||||
m_SelectedHotbarSlot = 0;
|
||||
m_selectedHotbarSlot = 0;
|
||||
m_bIsSurvival = false;
|
||||
|
||||
for (int i = 0; i < C_MAX_HOTBAR_ITEMS; i++)
|
||||
@@ -233,12 +233,12 @@ ItemInstance* Inventory::getQuickSlotItem(int slotNo)
|
||||
|
||||
ItemInstance* Inventory::getSelectedItem()
|
||||
{
|
||||
return getQuickSlotItem(m_SelectedHotbarSlot);
|
||||
return getQuickSlotItem(m_selectedHotbarSlot);
|
||||
}
|
||||
|
||||
int Inventory::getSelectedItemId()
|
||||
{
|
||||
return getQuickSlotItemId(m_SelectedHotbarSlot);
|
||||
return getQuickSlotItemId(m_selectedHotbarSlot);
|
||||
}
|
||||
|
||||
void Inventory::selectItem(int slotNo, int maxHotBarSlot)
|
||||
@@ -251,7 +251,7 @@ void Inventory::selectItem(int slotNo, int maxHotBarSlot)
|
||||
{
|
||||
if (m_hotbar[i] == slotNo)
|
||||
{
|
||||
m_SelectedHotbarSlot = i;
|
||||
m_selectedHotbarSlot = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -260,7 +260,7 @@ void Inventory::selectItem(int slotNo, int maxHotBarSlot)
|
||||
m_hotbar[i + 1] = m_hotbar[i];
|
||||
|
||||
m_hotbar[0] = slotNo;
|
||||
m_SelectedHotbarSlot = 0;
|
||||
m_selectedHotbarSlot = 0;
|
||||
}
|
||||
|
||||
void Inventory::selectSlot(int slotNo)
|
||||
@@ -268,7 +268,7 @@ void Inventory::selectSlot(int slotNo)
|
||||
if (slotNo < 0 || slotNo >= C_MAX_HOTBAR_ITEMS)
|
||||
return;
|
||||
|
||||
m_SelectedHotbarSlot = slotNo;
|
||||
m_selectedHotbarSlot = slotNo;
|
||||
}
|
||||
|
||||
void Inventory::setQuickSlotIndexByItemId(int slotNo, int itemID)
|
||||
@@ -312,4 +312,4 @@ int Inventory::getAttackDamage(Entity* pEnt)
|
||||
return 1;
|
||||
|
||||
return pInst->getAttackDamage(pEnt);
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
int getSelectedSlotNo() const
|
||||
{
|
||||
return m_SelectedHotbarSlot;
|
||||
return m_selectedHotbarSlot;
|
||||
}
|
||||
|
||||
// v0.2.0 name alias
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
int m_SelectedHotbarSlot;
|
||||
int m_selectedHotbarSlot;
|
||||
private:
|
||||
Player* m_pPlayer;
|
||||
bool m_bIsSurvival;
|
||||
@@ -59,4 +59,3 @@ private:
|
||||
int m_hotbar[C_MAX_HOTBAR_ITEMS];
|
||||
std::vector<ItemInstance> m_items;
|
||||
};
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ bool TileItem::useOn(ItemInstance* instance, Player* player, Level* level, int x
|
||||
float(y) + 0.5f,
|
||||
float(z) + 0.5f,
|
||||
"step." + pTile->m_pSound->m_name,
|
||||
(pTile->m_pSound->field_18 + 1.0f) * 0.5f,
|
||||
pTile->m_pSound->field_1C * 0.8f
|
||||
(pTile->m_pSound->volume + 1.0f) * 0.5f,
|
||||
pTile->m_pSound->pitch * 0.8f
|
||||
);
|
||||
|
||||
instance->m_amount--;
|
||||
|
||||
@@ -1666,12 +1666,12 @@ void Level::addParticle(const std::string& name, float a, float b, float c, floa
|
||||
}
|
||||
}
|
||||
|
||||
void Level::playSound(Entity* entity, const std::string& name, float a, float b)
|
||||
void Level::playSound(Entity* entity, const std::string& name, float volume, float pitch)
|
||||
{
|
||||
for (std::vector<LevelListener*>::iterator it = m_levelListeners.begin(); it != m_levelListeners.end(); it++)
|
||||
{
|
||||
LevelListener* pListener = *it;
|
||||
pListener->playSound(name, entity->m_pos.x, entity->m_pos.y - entity->field_84, entity->m_pos.z, a, b);
|
||||
pListener->playSound(name, entity->m_pos.x, entity->m_pos.y - entity->field_84, entity->m_pos.z, volume, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,8 +129,8 @@ public:
|
||||
void addToTickNextTick(int, int, int, int, int);
|
||||
void takePicture(TripodCamera* pCamera, Entity* pOwner);
|
||||
void addParticle(const std::string& name, float, float, float, float, float, float);
|
||||
void playSound(Entity*, const std::string& name, float, float);
|
||||
void playSound(float x, float y, float z, const std::string& name, float, float);
|
||||
void playSound(Entity*, const std::string& name, float volume, float pitch);
|
||||
void playSound(float x, float y, float z, const std::string& name, float volume, float pitch);
|
||||
void animateTick(int x, int y, int z);
|
||||
float getSeenPercent(Vec3, AABB);
|
||||
void explode(Entity*, float x, float y, float z, float power);
|
||||
|
||||
@@ -28,7 +28,7 @@ void LevelListener::allChanged()
|
||||
|
||||
}
|
||||
|
||||
void LevelListener::playSound(const std::string& a, float b, float c, float d, float e, float f)
|
||||
void LevelListener::playSound(const std::string& name, float x, float y, float z, float volume, float pitch)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void BinaryHeap::downHeap(int num)
|
||||
float var9;
|
||||
if (var5 >= m_count) {
|
||||
var8 = nullptr;
|
||||
var9 = INFINITY;
|
||||
var9 = std::numeric_limits<float>::infinity();
|
||||
}
|
||||
else {
|
||||
var8 = m_items[var5];
|
||||
|
||||