Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8d4dd1a1d0 |
@@ -1,62 +1,36 @@
|
||||
FROM ubuntu:24.04 as clang
|
||||
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ARG LLVM_VERSION=20
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y \
|
||||
wget \
|
||||
lsb-release \
|
||||
software-properties-common \
|
||||
gnupg
|
||||
|
||||
RUN wget https://apt.llvm.org/llvm.sh \
|
||||
&& chmod +x llvm.sh \
|
||||
&& ./llvm.sh ${LLVM_VERSION} \
|
||||
&& rm llvm.sh
|
||||
|
||||
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 100 \
|
||||
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION}
|
||||
|
||||
RUN update-alternatives --install /usr/bin/lld lld /usr/bin/lld-${LLVM_VERSION} 100
|
||||
|
||||
RUN apt-get install -y \
|
||||
libc++-${LLVM_VERSION}-dev \
|
||||
libc++abi-${LLVM_VERSION}-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV CC="clang" \
|
||||
CXX="clang++" \
|
||||
CC_LD="lld" \
|
||||
CXX_LD="lld"
|
||||
|
||||
FROM clang AS ivjcraft
|
||||
|
||||
ARG MESON_VERSION=1.10.2
|
||||
|
||||
# Dependencies
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y software-properties-common \
|
||||
&& add-apt-repository ppa:ubuntu-toolchain-r/test \
|
||||
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y \
|
||||
build-essential \
|
||||
gcc-14 g++-14 \
|
||||
python3 \
|
||||
ninja-build \
|
||||
libsdl2-dev \
|
||||
libgl-dev \
|
||||
libglm-dev \
|
||||
libglu1-mesa-dev \
|
||||
libpthread-stubs0-dev \
|
||||
libssl-dev \
|
||||
gcc-15 g++-15 \
|
||||
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-15 100 \
|
||||
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-15 100 \
|
||||
# Set GCC 14 as the default compiler
|
||||
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 \
|
||||
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100 \
|
||||
# Clean up lol
|
||||
&& apt-get autoremove -y \
|
||||
&& apt-get clean -y \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN wget -qO meson.tar.gz https://github.com/mesonbuild/meson/releases/latest/download/meson-${MESON_VERSION}.tar.gz \
|
||||
# Use the latest version of Meson -> $(curl -s "https://api.github.com/repos/mesonbuild/meson/releases/latest" | grep -Po '"tag_name": "\K[0-9.]+')
|
||||
RUN MESON_VERSION=1.10.2 \
|
||||
&& wget -qO meson.tar.gz https://github.com/mesonbuild/meson/releases/latest/download/meson-${MESON_VERSION}.tar.gz \
|
||||
&& mkdir /opt/meson \
|
||||
&& tar xf meson.tar.gz --strip-components=1 -C /opt/meson \
|
||||
&& mv /opt/meson/meson.py /opt/meson/meson \
|
||||
&& ln -s /opt/meson/meson /usr/bin/meson \
|
||||
&& rm -rf meson.tar.gz
|
||||
|
||||
ENV DEBIAN_FRONTEND=dialog
|
||||
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 438 B |
|
After Width: | Height: | Size: 477 B |
@@ -1,5 +1,7 @@
|
||||
# <img src=".github-assets/logo.jpg" alt="Logo" width="50" height="50" style="vertical-align: middle;"> 4JCraft
|
||||
|
||||
     
|
||||
   
|
||||
---
|
||||
|
||||
4JCraft is a modified version of the Minecraft Console Legacy Edition, aimed at porting old Minecraft to different platforms (such as Linux, Android, Emscripten, etc.) and refactoring the codebase to improve organization and use modern C++ features.
|
||||
|
||||
@@ -1,55 +1,58 @@
|
||||
# MARK: build configuration
|
||||
|
||||
project(
|
||||
'4jcraft',
|
||||
['cpp', 'c'],
|
||||
version: '0.1.0',
|
||||
meson_version: '>= 1.3',
|
||||
default_options: [
|
||||
'cpp_std=c++20',
|
||||
'warning_level=0',
|
||||
'unity=on', # merge source files per target
|
||||
'unity_size=8', # TODO: mess around with this
|
||||
'buildtype=debug',
|
||||
'b_pch=true', # precompiled headers
|
||||
'default_library=static', # static linkage to subprojects
|
||||
# 'b_lto=true', # link-time optimisation (ThinLTO under clang+lld)
|
||||
# 'b_ndebug=if-release', # drop assert() in --buildtype=release
|
||||
],
|
||||
'4jcraft',
|
||||
['cpp', 'c'],
|
||||
version: '0.1.0',
|
||||
meson_version: '>= 1.3',
|
||||
default_options: [
|
||||
'cpp_std=c++23',
|
||||
'warning_level=0',
|
||||
'buildtype=debugoptimized', # for now
|
||||
'unity=on', # merge source files per target
|
||||
'unity_size=8', # TODO: mess around with this
|
||||
'b_pch=true', # precompiled headers
|
||||
],
|
||||
)
|
||||
|
||||
pymod = import('python')
|
||||
python = pymod.find_installation('python3', required: true)
|
||||
|
||||
cc = meson.get_compiler('cpp')
|
||||
lib_dir = meson.current_source_dir() / 'thirdparty/lib' / host_machine.system() / host_machine.cpu()
|
||||
inc_dir = 'thirdparty/include' / host_machine.system()
|
||||
|
||||
global_cpp_args = []
|
||||
global_cpp_defs = [
|
||||
'-DSPLIT_SAVES',
|
||||
'-D_LARGE_WORLDS',
|
||||
'-D_EXTENDED_ACHIEVEMENTS',
|
||||
'-DMULTITHREAD_ENABLE', # always-on threading flag (formerly in App_Defines.h)
|
||||
'-DSPLIT_SAVES',
|
||||
'-D_LARGE_WORLDS',
|
||||
'-D_EXTENDED_ACHIEVEMENTS',
|
||||
'-D_DEBUG_MENUS_ENABLED',
|
||||
'-D_DEBUG',
|
||||
'-D_FORTIFY_SOURCE=2',
|
||||
'-DDEBUG',
|
||||
]
|
||||
|
||||
# Debug-only defines: keep for debug + debugoptimized so iteration is unchanged.
|
||||
# --buildtype=release strips them so shipping builds don't carry debug logging,
|
||||
# debug menu UI, or assert-driven sanity checks.
|
||||
if get_option('buildtype') in ['debug', 'debugoptimized']
|
||||
global_cpp_defs += [
|
||||
'-D_DEBUG',
|
||||
'-DDEBUG',
|
||||
'-D_DEBUG_MENUS_ENABLED',
|
||||
]
|
||||
if host_machine.system() == 'linux' or host_machine.system() == 'android'
|
||||
global_cpp_defs += ['-Dlinux', '-D__linux', '-D__linux__']
|
||||
endif
|
||||
|
||||
if get_option('buildtype') == 'debugoptimized'
|
||||
global_cpp_defs += ['-D_FORTIFY_SOURCE=2']
|
||||
if host_machine.system() == 'android'
|
||||
global_cpp_defs += ['-D__android__']
|
||||
endif
|
||||
|
||||
# MARK: meson options
|
||||
if get_option('renderer') == 'gles'
|
||||
global_cpp_defs += ['-DGLES']
|
||||
if host_machine.system() == 'android'
|
||||
gl_dep = cc.find_library('GLESv3', required: true )
|
||||
else
|
||||
gl_dep = dependency('glesv2', required: true)
|
||||
endif
|
||||
glu_dep = dependency('', required: false)
|
||||
else
|
||||
gl_dep = dependency('gl', required: true)
|
||||
glu_dep = dependency('glu', required: true)
|
||||
endif
|
||||
|
||||
if get_option('enable_vsync')
|
||||
global_cpp_defs += ['-DENABLE_VSYNC']
|
||||
global_cpp_defs += ['-DENABLE_VSYNC']
|
||||
endif
|
||||
|
||||
if get_option('classic_panorama')
|
||||
@@ -57,52 +60,51 @@ if get_option('classic_panorama')
|
||||
endif
|
||||
|
||||
if get_option('enable_frame_profiler')
|
||||
global_cpp_defs += ['-DENABLE_FRAME_PROFILER']
|
||||
global_cpp_defs += ['-DENABLE_FRAME_PROFILER']
|
||||
endif
|
||||
|
||||
if get_option('ui_backend') == 'shiggy'
|
||||
global_cpp_defs += ['-D_ENABLEIGGY']
|
||||
global_cpp_defs += ['-D_ENABLEIGGY']
|
||||
endif
|
||||
|
||||
if get_option('ui_backend') == 'java'
|
||||
global_cpp_defs += '-DENABLE_JAVA_GUIS'
|
||||
endif
|
||||
|
||||
if get_option('occlusion_culling') == 'off'
|
||||
global_cpp_defs += ['-DOCCLUSION_MODE_NONE']
|
||||
elif get_option('occlusion_culling') == 'frustum'
|
||||
global_cpp_defs += ['-DOCCLUSION_MODE_FRUSTUM']
|
||||
elif get_option('occlusion_culling') == 'bfs'
|
||||
global_cpp_defs += ['-DOCCLUSION_MODE_BFS', '-DUSE_OCCLUSION_CULLING']
|
||||
elif get_option('occlusion_culling') == 'hardware'
|
||||
global_cpp_defs += ['-DOCCLUSION_MODE_HARDWARE', '-DUSE_OCCLUSION_CULLING']
|
||||
global_cpp_defs += '-DENABLE_JAVA_GUIS'
|
||||
endif
|
||||
|
||||
add_project_arguments(global_cpp_defs, language: ['cpp', 'c'])
|
||||
|
||||
global_cpp_args = [
|
||||
'-Wshift-count-overflow',
|
||||
'-pipe',
|
||||
]
|
||||
add_project_arguments(global_cpp_args, language: 'cpp')
|
||||
|
||||
if host_machine.system() == 'android'
|
||||
sdl2_dep = declare_dependency(
|
||||
dependencies: cc.find_library('SDL2', dirs: lib_dir, required: true ),
|
||||
include_directories: inc_dir)
|
||||
else
|
||||
sdl2_dep = dependency('sdl2')
|
||||
endif
|
||||
thread_dep = dependency('threads')
|
||||
dl_dep = cc.find_library('dl', required: true)
|
||||
|
||||
if host_machine.system() == 'android'
|
||||
glm_dep = declare_dependency(include_directories: inc_dir)
|
||||
else
|
||||
glm_dep = dependency('glm')
|
||||
endif
|
||||
|
||||
stb = subproject('stb').get_variable('stb_inc')
|
||||
stb_dep = declare_dependency(include_directories: stb)
|
||||
|
||||
miniaudio_dep = dependency('miniaudio')
|
||||
|
||||
subdir('targets/util')
|
||||
subdir('targets/java')
|
||||
subdir('targets/nbt')
|
||||
subdir('targets/platform')
|
||||
|
||||
# MARK: platform configuration
|
||||
|
||||
if host_machine.system() in ['linux', 'windows']
|
||||
platform_fs_dep = platform_fs_std_dep
|
||||
platform_game_dep = platform_game_stub_dep
|
||||
platform_input_dep = platform_input_sdl2_dep
|
||||
platform_leaderboard_dep = platform_leaderboard_stub_dep
|
||||
platform_network_dep = platform_network_stub_dep
|
||||
platform_profile_dep = platform_profile_stub_dep
|
||||
platform_renderer_dep = platform_renderer_gl_dep
|
||||
platform_sound_dep = platform_sound_miniaudio_dep
|
||||
platform_storage_dep = platform_storage_stub_dep
|
||||
platform_thread_dep = platform_thread_dep # standardized backend (for now)
|
||||
|
||||
app_platform_sources = files('targets/app/desktop/main.cpp')
|
||||
endif
|
||||
|
||||
subdir('targets/resources')
|
||||
subdir('targets/minecraft')
|
||||
subdir('targets/app')
|
||||
|
||||
@@ -40,10 +40,3 @@ option(
|
||||
value: 'frustum',
|
||||
description: 'Occlusion culling mode. Off disables ALL CULLING (debug only!), Frustum disables offscreen rendering (default), BFS is experimental connectivity culling, hardware uses GPU queries.',
|
||||
)
|
||||
|
||||
option(
|
||||
'enable_mimalloc',
|
||||
type: 'feature',
|
||||
value: 'auto',
|
||||
description: 'Link mimalloc as the malloc implementation. Requires libmimalloc-dev.',
|
||||
)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
[constants]
|
||||
ndk_home = 'set_path_to_you_ndk'
|
||||
ndk_api = 'set_api_ndk'
|
||||
|
||||
[properties]
|
||||
skip_sanity_check = true
|
||||
|
||||
[binaries]
|
||||
c = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android' + ndk_api + '-clang'
|
||||
cpp = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android' + ndk_api + '-clang++'
|
||||
ar = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
|
||||
strip = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip'
|
||||
sys_root = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/sysroot'
|
||||
as = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as'
|
||||
ranlib = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib'
|
||||
ld = ndk_home / 'toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ld'
|
||||
pkg_config = 'false'
|
||||
|
||||
[host_machine]
|
||||
system = 'android'
|
||||
cpu_family = 'arm'
|
||||
cpu = 'aarch64'
|
||||
endian = 'little'
|
||||
@@ -1,183 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from pathlib import Path
|
||||
|
||||
DEFAULT_EXTENSIONS = {
|
||||
".c",
|
||||
".cc",
|
||||
".cpp",
|
||||
".cxx",
|
||||
".h",
|
||||
".hh",
|
||||
".hpp",
|
||||
".hxx",
|
||||
".inl",
|
||||
".ipp",
|
||||
}
|
||||
DEFAULT_JOBS = os.cpu_count() or 4
|
||||
DEFAULT_TIMEOUT = 10
|
||||
|
||||
# ansi escapes
|
||||
RESET = "\033[0m" if sys.stdout.isatty() else ""
|
||||
GREEN = "\033[32m" if sys.stdout.isatty() else ""
|
||||
YELLOW = "\033[33m" if sys.stdout.isatty() else ""
|
||||
RED = "\033[31m" if sys.stdout.isatty() else ""
|
||||
BOLD = "\033[1m" if sys.stdout.isatty() else ""
|
||||
|
||||
def format_file(path, clang_format, extra_args, timeout):
|
||||
cmd = [clang_format, "-i"]
|
||||
cmd += extra_args
|
||||
cmd.append(str(path))
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=timeout,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
msg = (result.stderr or result.stdout or "non-zero exit code").strip()
|
||||
return ("error", str(path), msg)
|
||||
return ("ok", str(path), None)
|
||||
|
||||
except subprocess.TimeoutExpired:
|
||||
return ("timeout", str(path), f"exceeded {timeout}s timeout")
|
||||
|
||||
except FileNotFoundError:
|
||||
return ("error", str(path), f"'{clang_format}' not found — is it installed?")
|
||||
|
||||
except Exception as exc:
|
||||
return ("error", str(path), str(exc))
|
||||
|
||||
def find_files(root, extensions, exclude_dirs):
|
||||
found = []
|
||||
for dirpath, dirnames, filenames in os.walk(root):
|
||||
dirnames[:] = [d for d in dirnames if d not in exclude_dirs]
|
||||
for fname in filenames:
|
||||
if Path(fname).suffix.lower() in extensions:
|
||||
found.append(Path(dirpath) / fname)
|
||||
return sorted(found)
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser(
|
||||
description="Recursively runs clang-format on C/C++ files.",
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
)
|
||||
p.add_argument("directory", nargs="?", default=".", type=Path)
|
||||
p.add_argument(
|
||||
"--clang-format",
|
||||
default="clang-format",
|
||||
metavar="BIN",
|
||||
help="Path to the clang-format executable. (default: clang-format)",
|
||||
)
|
||||
p.add_argument(
|
||||
"-j",
|
||||
"--jobs",
|
||||
type=int,
|
||||
default=DEFAULT_JOBS,
|
||||
metavar="N",
|
||||
help=f"Number of parallel workers. (default: {DEFAULT_JOBS})",
|
||||
)
|
||||
p.add_argument(
|
||||
"--timeout",
|
||||
type=int,
|
||||
default=DEFAULT_TIMEOUT,
|
||||
metavar="SECS",
|
||||
help=f"Per-file timeout in seconds. (default: {DEFAULT_TIMEOUT})",
|
||||
)
|
||||
p.add_argument(
|
||||
"--extensions",
|
||||
nargs="+",
|
||||
metavar="EXT",
|
||||
help="File extensions to process (including the dot)."
|
||||
f"(default: {' '.join(sorted(DEFAULT_EXTENSIONS))})",
|
||||
)
|
||||
p.add_argument(
|
||||
"--exclude",
|
||||
nargs="*",
|
||||
default=[],
|
||||
metavar="DIR",
|
||||
help="Directory names to skip during traversal (e.g. build third_party).",
|
||||
)
|
||||
p.add_argument(
|
||||
"--clang-format-args",
|
||||
nargs=argparse.REMAINDER,
|
||||
default=[],
|
||||
metavar="...",
|
||||
)
|
||||
args = p.parse_args()
|
||||
|
||||
root = args.directory.resolve()
|
||||
if not root.is_dir():
|
||||
print(f"{RED}Error:{RESET} '{root}' is not a directory.", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
extensions = (
|
||||
{e if e.startswith(".") else f".{e}" for e in args.extensions}
|
||||
if args.extensions
|
||||
else DEFAULT_EXTENSIONS
|
||||
)
|
||||
|
||||
exclude_dirs = set(args.exclude)
|
||||
|
||||
files = find_files(root, extensions, exclude_dirs)
|
||||
if not files:
|
||||
print(f"{YELLOW}No source files found.{RESET}")
|
||||
return 0
|
||||
|
||||
total = len(files)
|
||||
print(f"Found {BOLD}{total}{RESET} file(s).")
|
||||
|
||||
counters = {"ok": 0, "timeout": 0, "error": 0}
|
||||
completed = 0
|
||||
|
||||
with ThreadPoolExecutor(max_workers=args.jobs) as pool:
|
||||
futures = {
|
||||
pool.submit(
|
||||
format_file,
|
||||
f,
|
||||
args.clang_format,
|
||||
args.clang_format_args,
|
||||
args.timeout,
|
||||
): f
|
||||
for f in files
|
||||
}
|
||||
|
||||
for future in as_completed(futures):
|
||||
status, path_str, error = future.result()
|
||||
counters[status] += 1
|
||||
completed += 1
|
||||
rel = os.path.relpath(path_str, root)
|
||||
|
||||
if status == "ok":
|
||||
tag = f"{GREEN}[ OK ]{RESET}"
|
||||
elif status == "timeout":
|
||||
tag = f"{YELLOW}[ TIMEOUT ]{RESET}"
|
||||
else:
|
||||
tag = f"{RED}[ ERROR ]{RESET}"
|
||||
|
||||
progress = f"[{completed:>{len(str(total))}}/{total}]"
|
||||
line = f"{progress} {tag} {rel}"
|
||||
if error:
|
||||
line += f"\n {RED}{error}{RESET}"
|
||||
print(line)
|
||||
|
||||
print()
|
||||
print(f"{BOLD}Summary{RESET}")
|
||||
print(f"Total: {total}")
|
||||
print(f"{GREEN}OK: {counters['ok']}{RESET}")
|
||||
|
||||
if counters["timeout"]:
|
||||
print(f"{YELLOW}Timeout: {counters['timeout']}{RESET}")
|
||||
if counters["error"]:
|
||||
print(f"{RED}Error: {counters['error']}{RESET}")
|
||||
|
||||
return 1 if (counters["timeout"] or counters["error"]) else 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -1,97 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Enumerate C/C++ source files for a meson target.
|
||||
|
||||
Replaces the run_command('sh', '-c', 'find ...') hack in
|
||||
targets/{minecraft,app}/meson.build. Run this whenever source files are
|
||||
added or removed and commit the regenerated *_sources.txt files.
|
||||
|
||||
Usage:
|
||||
python3 scripts/list_sources.py
|
||||
|
||||
Each module's sources.txt is generated relative to its meson source dir.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
# Module configuration: (output_path, scan_root, [exclude_basenames]).
|
||||
# Paths in the output file are relative to the directory containing the
|
||||
# meson.build that reads it.
|
||||
MODULES = [
|
||||
{
|
||||
"name": "minecraft",
|
||||
"output": REPO_ROOT / "targets" / "minecraft" / "sources.txt",
|
||||
"scan_root": REPO_ROOT / "targets" / "minecraft",
|
||||
"rel_to": REPO_ROOT / "targets" / "minecraft",
|
||||
"exclude": {
|
||||
"DurangoStats.cpp", # Durango-specific
|
||||
# Incomplete / unused
|
||||
"SkyIslandDimension.cpp",
|
||||
"MemoryChunkStorage.cpp",
|
||||
"MemoryLevelStorage.cpp",
|
||||
"MemoryLevelStorageSource.cpp",
|
||||
"NbtSlotFile.cpp",
|
||||
"ZonedChunkStorage.cpp",
|
||||
"ZoneFile.cpp",
|
||||
"ZoneIo.cpp",
|
||||
"LevelConflictException.cpp",
|
||||
"SurvivalMode.cpp",
|
||||
"CreativeMode.cpp",
|
||||
"GameMode.cpp",
|
||||
"DemoMode.cpp",
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "app_common",
|
||||
"output": REPO_ROOT / "targets" / "app" / "common_sources.txt",
|
||||
"scan_root": REPO_ROOT / "targets" / "app" / "common",
|
||||
"rel_to": REPO_ROOT / "targets" / "app",
|
||||
"exclude": {
|
||||
"UIScene_InGameSaveManagementMenu.cpp",
|
||||
},
|
||||
},
|
||||
{
|
||||
"name": "app_linux",
|
||||
"output": REPO_ROOT / "targets" / "app" / "linux_sources.txt",
|
||||
"scan_root": REPO_ROOT / "targets" / "app" / "linux",
|
||||
"rel_to": REPO_ROOT / "targets" / "app",
|
||||
"exclude": set(),
|
||||
},
|
||||
]
|
||||
|
||||
EXTENSIONS = (".cpp", ".c")
|
||||
|
||||
|
||||
def collect(scan_root: Path, rel_to: Path, exclude: set[str]) -> list[str]:
|
||||
out: list[str] = []
|
||||
for dirpath, _dirnames, filenames in os.walk(scan_root):
|
||||
for name in filenames:
|
||||
if not name.endswith(EXTENSIONS):
|
||||
continue
|
||||
if name in exclude:
|
||||
continue
|
||||
full = Path(dirpath) / name
|
||||
out.append(str(full.relative_to(rel_to)))
|
||||
out.sort()
|
||||
return out
|
||||
|
||||
|
||||
def main() -> int:
|
||||
for mod in MODULES:
|
||||
sources = collect(mod["scan_root"], mod["rel_to"], mod["exclude"])
|
||||
body = "\n".join(sources) + "\n"
|
||||
out_path: Path = mod["output"]
|
||||
previous = out_path.read_text() if out_path.exists() else ""
|
||||
if previous == body:
|
||||
print(f"{mod['name']}: {len(sources)} files (unchanged)")
|
||||
else:
|
||||
out_path.write_text(body)
|
||||
print(f"{mod['name']}: {len(sources)} files (regenerated {out_path.relative_to(REPO_ROOT)})")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -3,3 +3,7 @@ c = 'clang'
|
||||
cpp = 'clang++'
|
||||
c_ld = 'lld'
|
||||
cpp_ld = 'lld'
|
||||
|
||||
[built-in options]
|
||||
cpp_args = ['-stdlib=libc++']
|
||||
cpp_link_args = ['-stdlib=libc++']
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
[wrap-file]
|
||||
directory = glew-2.2.0
|
||||
source_url = http://downloads.sourceforge.net/glew/glew-2.2.0.tgz
|
||||
source_filename = glew-2.2.0.tgz
|
||||
source_hash = d4fc82893cfb00109578d0a1a2337fb8ca335b3ceccf97b97e5cc7f08e4353e1
|
||||
patch_filename = glew_2.2.0-2_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/glew_2.2.0-2/get_patch
|
||||
patch_hash = df7bc80456da53f83e93e89ca5035d04cdff19a836c956887a684b2bee16eb9b
|
||||
wrapdb_version = 2.2.0-2
|
||||
|
||||
[provide]
|
||||
glew = glew_dep
|
||||
@@ -1,13 +0,0 @@
|
||||
[wrap-file]
|
||||
directory = glm-1.0.1
|
||||
source_url = https://github.com/g-truc/glm/archive/refs/tags/1.0.1.tar.gz
|
||||
source_filename = glm-1.0.1.tar.gz
|
||||
source_hash = 9f3174561fd26904b23f0db5e560971cbf9b3cbda0b280f04d5c379d03bf234c
|
||||
patch_filename = glm_1.0.1-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/glm_1.0.1-1/get_patch
|
||||
patch_hash = 25679275e26bc4c36bb617d1b4a52197039402af828d2a4bf67b3c0260a5df6a
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/glm_1.0.1-1/glm-1.0.1.tar.gz
|
||||
wrapdb_version = 1.0.1-1
|
||||
|
||||
[provide]
|
||||
glm = glm_dep
|
||||
@@ -1,6 +1,6 @@
|
||||
project('simdutf',
|
||||
'cpp',
|
||||
default_options: ['cpp_std=c++20'],
|
||||
default_options: ['cpp_std=c++23'],
|
||||
version: '8.2.0',
|
||||
meson_version: '>= 1.1',
|
||||
license: ['MIT'],
|
||||
@@ -55,7 +55,7 @@ simdutf_lib = static_library(
|
||||
)
|
||||
|
||||
simdutf_dep = declare_dependency(
|
||||
include_directories: include_directories('.'),
|
||||
sources: simdutf_amalgamate,
|
||||
link_with: simdutf_lib,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
project('stb', 'c')
|
||||
|
||||
stb_dep = declare_dependency(
|
||||
include_directories: include_directories('.'),
|
||||
)
|
||||
|
||||
meson.override_dependency('stb', stb_dep)
|
||||
stb_inc = include_directories('.')
|
||||
@@ -1,15 +0,0 @@
|
||||
[wrap-file]
|
||||
directory = SDL2-2.32.8
|
||||
source_url = https://github.com/libsdl-org/SDL/releases/download/release-2.32.8/SDL2-2.32.8.tar.gz
|
||||
source_filename = SDL2-2.32.8.tar.gz
|
||||
source_hash = 0ca83e9c9b31e18288c7ec811108e58bac1f1bb5ec6577ad386830eac51c787e
|
||||
patch_filename = sdl2_2.32.8-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/sdl2_2.32.8-1/get_patch
|
||||
patch_hash = 5df17ea39ca418826db20e96bd821fa52b5718dac64b6225119fb6588c2744f0
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/sdl2_2.32.8-1/SDL2-2.32.8.tar.gz
|
||||
wrapdb_version = 2.32.8-1
|
||||
|
||||
[provide]
|
||||
sdl2 = sdl2_dep
|
||||
sdl2main = sdl2main_dep
|
||||
sdl2_test = sdl2_test_dep
|
||||
@@ -1,7 +1,7 @@
|
||||
[wrap-git]
|
||||
url = https://github.com/simdutf/simdutf.git
|
||||
depth = 1
|
||||
revision = fd476229424b40ae71a58dd5a205795c3d76b5f1
|
||||
revision = v8.2.0
|
||||
patch_directory = simdutf
|
||||
|
||||
[provide]
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
[wrap-file]
|
||||
directory = zlib-1.3.2
|
||||
source_url = https://zlib.net/zlib-1.3.2.tar.xz
|
||||
source_fallback_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.2-1/get_source/zlib-1.3.2.tar.xz
|
||||
source_filename = zlib-1.3.2.tar.xz
|
||||
source_hash = d7a0654783a4da529d1bb793b7ad9c3318020af77667bcae35f95d0e42a792f3
|
||||
patch_filename = zlib_1.3.2-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.2-1/get_patch
|
||||
patch_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/zlib_1.3.2-1/zlib_1.3.2-1_patch.zip
|
||||
patch_hash = 5ae7a2e92f823df118cfb8c1b23d94e3117864392b3446581d669049b2fba6dd
|
||||
wrapdb_version = 1.3.2-1
|
||||
|
||||
[provide]
|
||||
dependency_names = zlib
|
||||
@@ -0,0 +1,48 @@
|
||||
# Network Code Implementation Notes
|
||||
|
||||
## Overview
|
||||
|
||||
The networking classes are organized as follows:
|
||||
|
||||
```
|
||||
Game \
|
||||
^ |
|
||||
| |
|
||||
+-----------------------------+-----------------------------+ |
|
||||
| | |
|
||||
v v |
|
||||
Game Network Manager <--------------------------------> Network Player Interface |- platform independent layers
|
||||
^ ^ |
|
||||
| | |
|
||||
v | |
|
||||
Platform Network Manager Interface | |
|
||||
^ | /
|
||||
| |
|
||||
v v \
|
||||
Platform Network Manager Implementation(1) <------> Network Player Implementation (3) |
|
||||
^ ^ |_ platform specific layers
|
||||
| | |
|
||||
v v |
|
||||
Platform specific network code(2) Platform specific player code (4) /
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
- In general the game should **only communicate with the `GameNetworkManager` and `NetworkPlayerInterface` APIs**, which provide a platform independent interface for networking functionality. The `GameNetworkManager` may in general have code which is aware of the game itself, but it *shouldn't have any platform-specific networking code*. It communicates with a platform specific implementation of a `PlatformNetworkManagerInterface` to achieve this.
|
||||
|
||||
- The platform specific layers shouldn't contain any general game code, as this is much better placed in the platform independent layers to avoid duplicating effort.
|
||||
|
||||
- Platform specific files for each platform for the numbered classes in the previous diagram are currently:
|
||||
|
||||
|
||||
## Platform-Specific Files
|
||||
|
||||
The platform-specific implementations for each numbered class in the diagram:
|
||||
|
||||
| Class | Xbox 360 | Sony | Other |
|
||||
|-------|---------------------------------|----------------------------|-----------------------|
|
||||
| (1) | PlatformNetworkManagerXbox | PlatformNetworkManagerSony | PlatformNetworkManagerStub |
|
||||
| (2) | Provided by QNET | SQRNetworkManager | Qnet stub* |
|
||||
| (3) | NetworkPlayerXbox | NetworkPlayerSony | NetworkPlayerXbox |
|
||||
| (4) | Provided by QNET | SQRNetworkPlayer | Qnet stub* |
|
||||
\*Temporarily provided by `extra64.h`
|
||||
@@ -0,0 +1,27 @@
|
||||
========================================================================
|
||||
Xbox 360 APPLICATION : Minecraft.Client Project Overview
|
||||
========================================================================
|
||||
|
||||
AppWizard has created this Minecraft.Client application for you.
|
||||
|
||||
This file contains a summary of what you will find in each of the files that
|
||||
make up your Minecraft.Client application.
|
||||
|
||||
Minecraft.Client.vcxproj
|
||||
This is the main project file for VC++ projects generated using an Application Wizard.
|
||||
It contains information about the version of Visual C++ that generated the file, and
|
||||
information about the platforms, configurations, and project features selected with the
|
||||
Application Wizard.
|
||||
|
||||
Minecraft.Client.cpp
|
||||
This is the main application source file.
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Other notes:
|
||||
|
||||
AppWizard uses "TODO:" comments to indicate parts of the source code you
|
||||
should add to or customize.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1,438 +0,0 @@
|
||||
#include "app/common/AppGameServices.h"
|
||||
|
||||
#include "app/common/DLC/DLCSkinFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "java/Class.h" // eINSTANCEOF
|
||||
#include "platform/game/game.h"
|
||||
|
||||
AppGameServices::AppGameServices(Game& game, IMenuService& menus)
|
||||
: game_(game), menus_(menus) {}
|
||||
|
||||
// -- Strings --
|
||||
|
||||
const char* AppGameServices::getString(int id) { return Game::GetString(id); }
|
||||
|
||||
// -- Debug settings --
|
||||
|
||||
bool AppGameServices::debugSettingsOn() { return game_.DebugSettingsOn(); }
|
||||
|
||||
bool AppGameServices::debugArtToolsOn() { return game_.DebugArtToolsOn(); }
|
||||
|
||||
unsigned int AppGameServices::debugGetMask(int iPad, bool overridePlayer) {
|
||||
return game_.GetGameSettingsDebugMask(iPad, overridePlayer);
|
||||
}
|
||||
|
||||
bool AppGameServices::debugMobsDontAttack() {
|
||||
return game_.GetMobsDontAttackEnabled();
|
||||
}
|
||||
|
||||
bool AppGameServices::debugMobsDontTick() {
|
||||
return game_.GetMobsDontTickEnabled();
|
||||
}
|
||||
|
||||
bool AppGameServices::debugFreezePlayers() { return game_.GetFreezePlayers(); }
|
||||
|
||||
// -- Game host options --
|
||||
|
||||
unsigned int AppGameServices::getGameHostOption(eGameHostOption option) {
|
||||
return game_.GetGameHostOption(option);
|
||||
}
|
||||
|
||||
void AppGameServices::setGameHostOption(eGameHostOption option,
|
||||
unsigned int value) {
|
||||
game_.SetGameHostOption(option, value);
|
||||
}
|
||||
|
||||
// -- Level generation --
|
||||
|
||||
LevelGenerationOptions* AppGameServices::getLevelGenerationOptions() {
|
||||
return game_.getLevelGenerationOptions();
|
||||
}
|
||||
|
||||
LevelRuleset* AppGameServices::getGameRuleDefinitions() {
|
||||
return game_.getGameRuleDefinitions();
|
||||
}
|
||||
|
||||
// -- Texture cache --
|
||||
|
||||
void AppGameServices::addMemoryTextureFile(const std::string& name,
|
||||
std::uint8_t* data,
|
||||
unsigned int size) {
|
||||
game_.AddMemoryTextureFile(name, data, size);
|
||||
}
|
||||
|
||||
void AppGameServices::removeMemoryTextureFile(const std::string& name) {
|
||||
game_.RemoveMemoryTextureFile(name);
|
||||
}
|
||||
|
||||
void AppGameServices::getMemFileDetails(const std::string& name,
|
||||
std::uint8_t** data,
|
||||
unsigned int* size) {
|
||||
game_.GetMemFileDetails(name, data, size);
|
||||
}
|
||||
|
||||
bool AppGameServices::isFileInMemoryTextures(const std::string& name) {
|
||||
return game_.IsFileInMemoryTextures(name);
|
||||
}
|
||||
|
||||
// -- Player settings --
|
||||
|
||||
unsigned char AppGameServices::getGameSettings(int iPad, int setting) {
|
||||
return game_.GetGameSettings(iPad, static_cast<eGameSetting>(setting));
|
||||
}
|
||||
|
||||
unsigned char AppGameServices::getGameSettings(int setting) {
|
||||
return game_.GetGameSettings(static_cast<eGameSetting>(setting));
|
||||
}
|
||||
|
||||
// -- App time --
|
||||
|
||||
float AppGameServices::getAppTime() { return game_.getAppTime(); }
|
||||
|
||||
// -- Game state --
|
||||
|
||||
bool AppGameServices::getGameStarted() { return game_.GetGameStarted(); }
|
||||
void AppGameServices::setGameStarted(bool val) { game_.SetGameStarted(val); }
|
||||
bool AppGameServices::getTutorialMode() { return game_.GetTutorialMode(); }
|
||||
void AppGameServices::setTutorialMode(bool val) { game_.SetTutorialMode(val); }
|
||||
bool AppGameServices::isAppPaused() { return game_.IsAppPaused(); }
|
||||
int AppGameServices::getLocalPlayerCount() {
|
||||
return game_.GetLocalPlayerCount();
|
||||
}
|
||||
bool AppGameServices::autosaveDue() { return game_.AutosaveDue(); }
|
||||
void AppGameServices::setAutosaveTimerTime() { game_.SetAutosaveTimerTime(); }
|
||||
int64_t AppGameServices::secondsToAutosave() {
|
||||
return game_.SecondsToAutosave();
|
||||
}
|
||||
|
||||
void AppGameServices::setDisconnectReason(
|
||||
DisconnectPacket::eDisconnectReason reason) {
|
||||
game_.SetDisconnectReason(reason);
|
||||
}
|
||||
|
||||
void AppGameServices::lockSaveNotification() { game_.lockSaveNotification(); }
|
||||
void AppGameServices::unlockSaveNotification() {
|
||||
game_.unlockSaveNotification();
|
||||
}
|
||||
bool AppGameServices::getResetNether() { return game_.GetResetNether(); }
|
||||
bool AppGameServices::getUseDPadForDebug() {
|
||||
return game_.GetUseDPadForDebug();
|
||||
}
|
||||
|
||||
bool AppGameServices::getWriteSavesToFolderEnabled() {
|
||||
return game_.GetWriteSavesToFolderEnabled();
|
||||
}
|
||||
|
||||
bool AppGameServices::isLocalMultiplayerAvailable() {
|
||||
return game_.IsLocalMultiplayerAvailable();
|
||||
}
|
||||
|
||||
bool AppGameServices::dlcInstallPending() { return game_.DLCInstallPending(); }
|
||||
|
||||
bool AppGameServices::dlcInstallProcessCompleted() {
|
||||
return game_.DLCInstallProcessCompleted();
|
||||
}
|
||||
|
||||
bool AppGameServices::canRecordStatsAndAchievements() {
|
||||
return game_.CanRecordStatsAndAchievements();
|
||||
}
|
||||
|
||||
bool AppGameServices::getTMSGlobalFileListRead() {
|
||||
return game_.GetTMSGlobalFileListRead();
|
||||
}
|
||||
|
||||
void AppGameServices::setRequiredTexturePackID(std::uint32_t id) {
|
||||
game_.SetRequiredTexturePackID(id);
|
||||
}
|
||||
|
||||
void AppGameServices::setSpecialTutorialCompletionFlag(int iPad, int index) {
|
||||
game_.SetSpecialTutorialCompletionFlag(iPad, index);
|
||||
}
|
||||
|
||||
void AppGameServices::setBanListCheck(int iPad, bool val) {
|
||||
game_.SetBanListCheck(iPad, val);
|
||||
}
|
||||
|
||||
bool AppGameServices::getBanListCheck(int iPad) {
|
||||
return game_.GetBanListCheck(iPad);
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::getGameNewWorldSize() {
|
||||
return game_.GetGameNewWorldSize();
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::getGameNewWorldSizeUseMoat() {
|
||||
return game_.GetGameNewWorldSizeUseMoat();
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::getGameNewHellScale() {
|
||||
return game_.GetGameNewHellScale();
|
||||
}
|
||||
|
||||
// -- UI dispatch --
|
||||
|
||||
void AppGameServices::setAction(int iPad, eXuiAction action, void* param) {
|
||||
game_.SetAction(iPad, action, param);
|
||||
}
|
||||
|
||||
eXuiAction AppGameServices::getXuiAction(int iPad) {
|
||||
return game_.GetXuiAction(iPad);
|
||||
}
|
||||
|
||||
void AppGameServices::setGlobalXuiAction(eXuiAction action) {
|
||||
game_.SetGlobalXuiAction(action);
|
||||
}
|
||||
|
||||
void AppGameServices::handleButtonPresses() { game_.HandleButtonPresses(); }
|
||||
|
||||
void AppGameServices::setTMSAction(int iPad, eTMSAction action) {
|
||||
game_.SetTMSAction(iPad, action);
|
||||
}
|
||||
|
||||
// -- Skin / cape / animation --
|
||||
|
||||
std::string AppGameServices::getPlayerSkinName(int iPad) {
|
||||
return game_.GetPlayerSkinName(iPad);
|
||||
}
|
||||
|
||||
std::uint32_t AppGameServices::getPlayerSkinId(int iPad) {
|
||||
return game_.GetPlayerSkinId(iPad);
|
||||
}
|
||||
|
||||
std::string AppGameServices::getPlayerCapeName(int iPad) {
|
||||
return game_.GetPlayerCapeName(iPad);
|
||||
}
|
||||
|
||||
std::uint32_t AppGameServices::getPlayerCapeId(int iPad) {
|
||||
return game_.GetPlayerCapeId(iPad);
|
||||
}
|
||||
|
||||
std::uint32_t AppGameServices::getAdditionalModelPartsForPad(int iPad) {
|
||||
return game_.GetAdditionalModelParts(iPad);
|
||||
}
|
||||
|
||||
void AppGameServices::setAdditionalSkinBoxes(std::uint32_t dwSkinID,
|
||||
SKIN_BOX* boxA,
|
||||
unsigned int boxC) {
|
||||
game_.SetAdditionalSkinBoxes(dwSkinID, boxA, boxC);
|
||||
}
|
||||
|
||||
std::vector<SKIN_BOX*>* AppGameServices::getAdditionalSkinBoxes(
|
||||
std::uint32_t dwSkinID) {
|
||||
return game_.GetAdditionalSkinBoxes(dwSkinID);
|
||||
}
|
||||
|
||||
std::vector<ModelPart*>* AppGameServices::getAdditionalModelParts(
|
||||
std::uint32_t dwSkinID) {
|
||||
return game_.GetAdditionalModelParts(dwSkinID);
|
||||
}
|
||||
|
||||
std::vector<ModelPart*>* AppGameServices::setAdditionalSkinBoxesFromVec(
|
||||
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* pvSkinBoxA) {
|
||||
return game_.SetAdditionalSkinBoxes(dwSkinID, pvSkinBoxA);
|
||||
}
|
||||
|
||||
void AppGameServices::setAnimOverrideBitmask(std::uint32_t dwSkinID,
|
||||
unsigned int bitmask) {
|
||||
game_.SetAnimOverrideBitmask(dwSkinID, bitmask);
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::getAnimOverrideBitmask(std::uint32_t dwSkinID) {
|
||||
return game_.GetAnimOverrideBitmask(dwSkinID);
|
||||
}
|
||||
|
||||
std::uint32_t AppGameServices::getSkinIdFromPath(const std::string& skin) {
|
||||
return Game::getSkinIdFromPath(skin);
|
||||
}
|
||||
|
||||
std::string AppGameServices::getSkinPathFromId(std::uint32_t skinId) {
|
||||
return Game::getSkinPathFromId(skinId);
|
||||
}
|
||||
|
||||
bool AppGameServices::defaultCapeExists() { return game_.DefaultCapeExists(); }
|
||||
|
||||
bool AppGameServices::isXuidNotch(PlayerUID xuid) {
|
||||
return game_.isXuidNotch(xuid);
|
||||
}
|
||||
|
||||
bool AppGameServices::isXuidDeadmau5(PlayerUID xuid) {
|
||||
return game_.isXuidDeadmau5(xuid);
|
||||
}
|
||||
|
||||
// -- Platform features --
|
||||
|
||||
void AppGameServices::fatalLoadError() { game_.FatalLoadError(); }
|
||||
|
||||
void AppGameServices::setRichPresenceContext(int iPad, int contextId) {
|
||||
PlatformGame.SetRichPresenceContext(iPad, contextId);
|
||||
}
|
||||
|
||||
void AppGameServices::captureSaveThumbnail() {
|
||||
PlatformGame.CaptureSaveThumbnail();
|
||||
}
|
||||
|
||||
void AppGameServices::getSaveThumbnail(std::uint8_t** data,
|
||||
unsigned int* size) {
|
||||
PlatformGame.GetSaveThumbnail(data, size);
|
||||
}
|
||||
|
||||
void AppGameServices::readBannedList(int iPad, eTMSAction action,
|
||||
bool bCallback) {
|
||||
PlatformGame.ReadBannedList(iPad, action, bCallback);
|
||||
}
|
||||
|
||||
void AppGameServices::updatePlayerInfo(std::uint8_t networkSmallId,
|
||||
int16_t playerColourIndex,
|
||||
unsigned int playerPrivileges) {
|
||||
game_.UpdatePlayerInfo(networkSmallId, playerColourIndex, playerPrivileges);
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::getPlayerPrivileges(std::uint8_t networkSmallId) {
|
||||
return game_.GetPlayerPrivileges(networkSmallId);
|
||||
}
|
||||
|
||||
void AppGameServices::setGameSettingsDebugMask(int iPad, unsigned int uiVal) {
|
||||
game_.SetGameSettingsDebugMask(iPad, uiVal);
|
||||
}
|
||||
|
||||
// -- Schematics / terrain --
|
||||
|
||||
void AppGameServices::processSchematics(LevelChunk* chunk) {
|
||||
game_.processSchematics(chunk);
|
||||
}
|
||||
|
||||
void AppGameServices::processSchematicsLighting(LevelChunk* chunk) {
|
||||
game_.processSchematicsLighting(chunk);
|
||||
}
|
||||
|
||||
void AppGameServices::addTerrainFeaturePosition(_eTerrainFeatureType type,
|
||||
int x, int z) {
|
||||
game_.AddTerrainFeaturePosition(type, x, z);
|
||||
}
|
||||
|
||||
bool AppGameServices::getTerrainFeaturePosition(_eTerrainFeatureType type,
|
||||
int* pX, int* pZ) {
|
||||
return game_.GetTerrainFeaturePosition(type, pX, pZ);
|
||||
}
|
||||
|
||||
void AppGameServices::loadDefaultGameRules() { game_.loadDefaultGameRules(); }
|
||||
|
||||
// -- Archive / resources --
|
||||
|
||||
bool AppGameServices::hasArchiveFile(const std::string& filename) {
|
||||
return game_.hasArchiveFile(filename);
|
||||
}
|
||||
|
||||
std::vector<std::uint8_t> AppGameServices::getArchiveFile(
|
||||
const std::string& filename) {
|
||||
return game_.getArchiveFile(filename);
|
||||
}
|
||||
|
||||
// -- Strings / formatting / misc queries --
|
||||
|
||||
int AppGameServices::getHTMLColour(eMinecraftColour colour) {
|
||||
return game_.GetHTMLColour(colour);
|
||||
}
|
||||
|
||||
std::string AppGameServices::getEntityName(EntityTypeId type) {
|
||||
return game_.getEntityName(static_cast<eINSTANCEOF>(type));
|
||||
}
|
||||
|
||||
const char* AppGameServices::getGameRulesString(const std::string& key) {
|
||||
return game_.GetGameRulesString(key);
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::createImageTextData(
|
||||
std::uint8_t* textMetadata, int64_t seed, bool hasSeed,
|
||||
unsigned int uiHostOptions, unsigned int uiTexturePackId) {
|
||||
return game_.CreateImageTextData(textMetadata, seed, hasSeed, uiHostOptions,
|
||||
uiTexturePackId);
|
||||
}
|
||||
|
||||
std::string AppGameServices::getFilePath(std::uint32_t packId,
|
||||
std::string filename,
|
||||
bool bAddDataFolder,
|
||||
std::string mountPoint) {
|
||||
return game_.getFilePath(packId, filename, bAddDataFolder, mountPoint);
|
||||
}
|
||||
|
||||
char* AppGameServices::getUniqueMapName() { return game_.GetUniqueMapName(); }
|
||||
|
||||
void AppGameServices::setUniqueMapName(char* name) {
|
||||
game_.SetUniqueMapName(name);
|
||||
}
|
||||
|
||||
unsigned int AppGameServices::getOpacityTimer(int iPad) {
|
||||
return game_.GetOpacityTimer(iPad);
|
||||
}
|
||||
|
||||
void AppGameServices::setOpacityTimer(int iPad) { game_.SetOpacityTimer(iPad); }
|
||||
|
||||
void AppGameServices::tickOpacityTimer(int iPad) {
|
||||
game_.TickOpacityTimer(iPad);
|
||||
}
|
||||
|
||||
bool AppGameServices::isInBannedLevelList(int iPad, PlayerUID xuid,
|
||||
char* levelName) {
|
||||
return game_.IsInBannedLevelList(iPad, xuid, levelName);
|
||||
}
|
||||
|
||||
MOJANG_DATA* AppGameServices::getMojangDataForXuid(PlayerUID xuid) {
|
||||
return game_.GetMojangDataForXuid(xuid);
|
||||
}
|
||||
|
||||
void AppGameServices::debugPrintf(const char* msg) {
|
||||
game_.DebugPrintf("%s", msg);
|
||||
}
|
||||
|
||||
// -- DLC --
|
||||
|
||||
ISkinAssetData* AppGameServices::getSkinAssetData(const std::string& name) {
|
||||
return game_.m_dlcManager.getSkinFile(name);
|
||||
}
|
||||
bool AppGameServices::dlcNeedsCorruptCheck() {
|
||||
return game_.m_dlcManager.NeedsCorruptCheck();
|
||||
}
|
||||
unsigned int AppGameServices::dlcCheckForCorrupt(bool showMessage) {
|
||||
return game_.m_dlcManager.checkForCorruptDLCAndAlert(showMessage);
|
||||
}
|
||||
bool AppGameServices::dlcReadDataFile(unsigned int& filesProcessed,
|
||||
const std::string& path, DLCPack* pack,
|
||||
bool fromArchive) {
|
||||
return game_.m_dlcManager.readDLCDataFile(filesProcessed, path, pack,
|
||||
fromArchive);
|
||||
}
|
||||
void AppGameServices::dlcRemovePack(DLCPack* pack) {
|
||||
game_.m_dlcManager.removePack(pack);
|
||||
}
|
||||
|
||||
// -- Game rules --
|
||||
|
||||
LevelGenerationOptions* AppGameServices::loadGameRules(std::uint8_t* data,
|
||||
unsigned int size) {
|
||||
return game_.m_gameRules.loadGameRules(data, size);
|
||||
}
|
||||
void AppGameServices::saveGameRules(std::uint8_t** data, unsigned int* size) {
|
||||
game_.m_gameRules.saveGameRules(data, size);
|
||||
}
|
||||
void AppGameServices::unloadCurrentGameRules() {
|
||||
game_.m_gameRules.unloadCurrentGameRules();
|
||||
}
|
||||
void AppGameServices::setLevelGenerationOptions(
|
||||
LevelGenerationOptions* levelGen) {
|
||||
game_.m_gameRules.setLevelGenerationOptions(levelGen);
|
||||
}
|
||||
|
||||
// -- Shared data --
|
||||
|
||||
std::vector<std::string>& AppGameServices::getSkinNames() {
|
||||
return game_.vSkinNames;
|
||||
}
|
||||
|
||||
std::vector<FEATURE_DATA*>& AppGameServices::getTerrainFeatures() {
|
||||
return *game_.m_terrainFeatureManager.features();
|
||||
}
|
||||
|
||||
// -- Menu service --
|
||||
|
||||
IMenuService& AppGameServices::menus() { return menus_; }
|
||||
@@ -1,178 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "minecraft/IGameServices.h"
|
||||
|
||||
class Game;
|
||||
class IMenuService;
|
||||
class ISkinAssetData;
|
||||
|
||||
class AppGameServices : public IGameServices {
|
||||
public:
|
||||
AppGameServices(Game& game, IMenuService& menus);
|
||||
|
||||
// -- Strings --
|
||||
const char* getString(int id) override;
|
||||
|
||||
// -- Debug settings --
|
||||
bool debugSettingsOn() override;
|
||||
bool debugArtToolsOn() override;
|
||||
unsigned int debugGetMask(int iPad, bool overridePlayer) override;
|
||||
bool debugMobsDontAttack() override;
|
||||
bool debugMobsDontTick() override;
|
||||
bool debugFreezePlayers() override;
|
||||
|
||||
// -- Game host options --
|
||||
unsigned int getGameHostOption(eGameHostOption option) override;
|
||||
void setGameHostOption(eGameHostOption option, unsigned int value) override;
|
||||
|
||||
// -- Level generation --
|
||||
LevelGenerationOptions* getLevelGenerationOptions() override;
|
||||
LevelRuleset* getGameRuleDefinitions() override;
|
||||
|
||||
// -- Texture cache --
|
||||
void addMemoryTextureFile(const std::string& name, std::uint8_t* data,
|
||||
unsigned int size) override;
|
||||
void removeMemoryTextureFile(const std::string& name) override;
|
||||
void getMemFileDetails(const std::string& name, std::uint8_t** data,
|
||||
unsigned int* size) override;
|
||||
bool isFileInMemoryTextures(const std::string& name) override;
|
||||
|
||||
// -- Player settings --
|
||||
unsigned char getGameSettings(int iPad, int setting) override;
|
||||
unsigned char getGameSettings(int setting) override;
|
||||
|
||||
// -- App time --
|
||||
float getAppTime() override;
|
||||
|
||||
// -- Game state --
|
||||
bool getGameStarted() override;
|
||||
void setGameStarted(bool val) override;
|
||||
bool getTutorialMode() override;
|
||||
void setTutorialMode(bool val) override;
|
||||
bool isAppPaused() override;
|
||||
int getLocalPlayerCount() override;
|
||||
bool autosaveDue() override;
|
||||
void setAutosaveTimerTime() override;
|
||||
int64_t secondsToAutosave() override;
|
||||
void setDisconnectReason(
|
||||
DisconnectPacket::eDisconnectReason reason) override;
|
||||
void lockSaveNotification() override;
|
||||
void unlockSaveNotification() override;
|
||||
bool getResetNether() override;
|
||||
bool getUseDPadForDebug() override;
|
||||
bool getWriteSavesToFolderEnabled() override;
|
||||
bool isLocalMultiplayerAvailable() override;
|
||||
bool dlcInstallPending() override;
|
||||
bool dlcInstallProcessCompleted() override;
|
||||
bool canRecordStatsAndAchievements() override;
|
||||
bool getTMSGlobalFileListRead() override;
|
||||
void setRequiredTexturePackID(std::uint32_t id) override;
|
||||
void setSpecialTutorialCompletionFlag(int iPad, int index) override;
|
||||
void setBanListCheck(int iPad, bool val) override;
|
||||
bool getBanListCheck(int iPad) override;
|
||||
unsigned int getGameNewWorldSize() override;
|
||||
unsigned int getGameNewWorldSizeUseMoat() override;
|
||||
unsigned int getGameNewHellScale() override;
|
||||
|
||||
// -- UI dispatch --
|
||||
void setAction(int iPad, eXuiAction action, void* param) override;
|
||||
eXuiAction getXuiAction(int iPad) override;
|
||||
void setGlobalXuiAction(eXuiAction action) override;
|
||||
void handleButtonPresses() override;
|
||||
void setTMSAction(int iPad, eTMSAction action) override;
|
||||
|
||||
// -- Skin / cape / animation --
|
||||
std::string getPlayerSkinName(int iPad) override;
|
||||
std::uint32_t getPlayerSkinId(int iPad) override;
|
||||
std::string getPlayerCapeName(int iPad) override;
|
||||
std::uint32_t getPlayerCapeId(int iPad) override;
|
||||
std::uint32_t getAdditionalModelPartsForPad(int iPad) override;
|
||||
void setAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX* boxA,
|
||||
unsigned int boxC) override;
|
||||
std::vector<SKIN_BOX*>* getAdditionalSkinBoxes(
|
||||
std::uint32_t dwSkinID) override;
|
||||
std::vector<ModelPart*>* getAdditionalModelParts(
|
||||
std::uint32_t dwSkinID) override;
|
||||
std::vector<ModelPart*>* setAdditionalSkinBoxesFromVec(
|
||||
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* pvSkinBoxA) override;
|
||||
void setAnimOverrideBitmask(std::uint32_t dwSkinID,
|
||||
unsigned int bitmask) override;
|
||||
unsigned int getAnimOverrideBitmask(std::uint32_t dwSkinID) override;
|
||||
std::uint32_t getSkinIdFromPath(const std::string& skin) override;
|
||||
std::string getSkinPathFromId(std::uint32_t skinId) override;
|
||||
bool defaultCapeExists() override;
|
||||
bool isXuidNotch(PlayerUID xuid) override;
|
||||
bool isXuidDeadmau5(PlayerUID xuid) override;
|
||||
|
||||
// -- Platform features --
|
||||
void fatalLoadError() override;
|
||||
void setRichPresenceContext(int iPad, int contextId) override;
|
||||
void captureSaveThumbnail() override;
|
||||
void getSaveThumbnail(std::uint8_t** data, unsigned int* size) override;
|
||||
void readBannedList(int iPad, eTMSAction action, bool bCallback) override;
|
||||
void updatePlayerInfo(std::uint8_t networkSmallId,
|
||||
int16_t playerColourIndex,
|
||||
unsigned int playerPrivileges) override;
|
||||
unsigned int getPlayerPrivileges(std::uint8_t networkSmallId) override;
|
||||
void setGameSettingsDebugMask(int iPad, unsigned int uiVal) override;
|
||||
|
||||
// -- Schematics / terrain --
|
||||
void processSchematics(LevelChunk* chunk) override;
|
||||
void processSchematicsLighting(LevelChunk* chunk) override;
|
||||
void addTerrainFeaturePosition(_eTerrainFeatureType type, int x,
|
||||
int z) override;
|
||||
bool getTerrainFeaturePosition(_eTerrainFeatureType type, int* pX,
|
||||
int* pZ) override;
|
||||
void loadDefaultGameRules() override;
|
||||
|
||||
// -- Archive / resources --
|
||||
bool hasArchiveFile(const std::string& filename) override;
|
||||
std::vector<std::uint8_t> getArchiveFile(
|
||||
const std::string& filename) override;
|
||||
|
||||
// -- Strings / formatting / misc queries --
|
||||
int getHTMLColour(eMinecraftColour colour) override;
|
||||
std::string getEntityName(EntityTypeId type) override;
|
||||
const char* getGameRulesString(const std::string& key) override;
|
||||
unsigned int createImageTextData(std::uint8_t* textMetadata, int64_t seed,
|
||||
bool hasSeed, unsigned int uiHostOptions,
|
||||
unsigned int uiTexturePackId) override;
|
||||
std::string getFilePath(std::uint32_t packId, std::string filename,
|
||||
bool bAddDataFolder,
|
||||
std::string mountPoint) override;
|
||||
char* getUniqueMapName() override;
|
||||
void setUniqueMapName(char* name) override;
|
||||
unsigned int getOpacityTimer(int iPad) override;
|
||||
void setOpacityTimer(int iPad) override;
|
||||
void tickOpacityTimer(int iPad) override;
|
||||
bool isInBannedLevelList(int iPad, PlayerUID xuid,
|
||||
char* levelName) override;
|
||||
MOJANG_DATA* getMojangDataForXuid(PlayerUID xuid) override;
|
||||
void debugPrintf(const char* msg) override;
|
||||
|
||||
// -- DLC --
|
||||
ISkinAssetData* getSkinAssetData(const std::string& name) override;
|
||||
bool dlcNeedsCorruptCheck() override;
|
||||
unsigned int dlcCheckForCorrupt(bool showMessage) override;
|
||||
bool dlcReadDataFile(unsigned int& filesProcessed, const std::string& path,
|
||||
DLCPack* pack, bool fromArchive) override;
|
||||
void dlcRemovePack(DLCPack* pack) override;
|
||||
|
||||
// -- Game rules --
|
||||
LevelGenerationOptions* loadGameRules(std::uint8_t* data,
|
||||
unsigned int size) override;
|
||||
void saveGameRules(std::uint8_t** data, unsigned int* size) override;
|
||||
void unloadCurrentGameRules() override;
|
||||
void setLevelGenerationOptions(LevelGenerationOptions* levelGen) override;
|
||||
|
||||
// -- Shared data --
|
||||
std::vector<std::string>& getSkinNames() override;
|
||||
std::vector<FEATURE_DATA*>& getTerrainFeatures() override;
|
||||
|
||||
// -- Menu service --
|
||||
IMenuService& menus() override;
|
||||
|
||||
private:
|
||||
Game& game_;
|
||||
IMenuService& menus_;
|
||||
};
|
||||
@@ -0,0 +1,135 @@
|
||||
#pragma once
|
||||
|
||||
// 4J Stu - For non-splitscreen menus, default to this screen
|
||||
#define DEFAULT_XUI_MENU_USER 0
|
||||
#define MULTITHREAD_ENABLE
|
||||
#define MAX_CAPENAME_SIZE 32
|
||||
#define MAX_BANNERNAME_SIZE 32
|
||||
#define MAX_TMSFILENAME_SIZE 40
|
||||
#define MAX_TYPE_SIZE 32
|
||||
#define MAX_EXTENSION_TYPES 3
|
||||
|
||||
#define MAX_LOCAL_PLAYERS 4
|
||||
|
||||
// 4J Stu - Required for sentient reporting of whether the volume level has been
|
||||
// changed or not
|
||||
#define DEFAULT_VOLUME_LEVEL 100
|
||||
|
||||
#define GAME_HOST_OPTION_BITMASK_DIFFICULTY 0x00000003 // 0 - 3
|
||||
#define GAME_HOST_OPTION_BITMASK_FRIENDSOFFRIENDS 0x00000004
|
||||
#define GAME_HOST_OPTION_BITMASK_GAMERTAGS 0x00000008
|
||||
#define GAME_HOST_OPTION_BITMASK_GAMETYPE 0x00000030
|
||||
#define GAME_HOST_OPTION_BITMASK_LEVELTYPE 0x00000040
|
||||
#define GAME_HOST_OPTION_BITMASK_STRUCTURES 0x00000080
|
||||
#define GAME_HOST_OPTION_BITMASK_BONUSCHEST 0x00000100
|
||||
#define GAME_HOST_OPTION_BITMASK_BEENINCREATIVE 0x00000200
|
||||
#define GAME_HOST_OPTION_BITMASK_PVP 0x00000400
|
||||
#define GAME_HOST_OPTION_BITMASK_TRUSTPLAYERS 0x00000800
|
||||
#define GAME_HOST_OPTION_BITMASK_TNT 0x00001000
|
||||
#define GAME_HOST_OPTION_BITMASK_FIRESPREADS 0x00002000
|
||||
#define GAME_HOST_OPTION_BITMASK_HOSTFLY 0x00004000
|
||||
#define GAME_HOST_OPTION_BITMASK_HOSTHUNGER 0x00008000
|
||||
#define GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE 0x00010000
|
||||
#define GAME_HOST_OPTION_BITMASK_BEDROCKFOG 0x00020000
|
||||
#define GAME_HOST_OPTION_BITMASK_DISABLESAVE 0x00040000
|
||||
#define GAME_HOST_OPTION_BITMASK_NOTOWNER 0x00080000
|
||||
#define GAME_HOST_OPTION_BITMASK_WORLDSIZE \
|
||||
0x00700000 // 3 bits, 5 values (unset(0), classic(1), small(2), medium(3),
|
||||
// large(4))
|
||||
#define GAME_HOST_OPTION_BITMASK_MOBGRIEFING 0x00800000
|
||||
#define GAME_HOST_OPTION_BITMASK_KEEPINVENTORY 0x01000000
|
||||
#define GAME_HOST_OPTION_BITMASK_DOMOBSPAWNING 0x02000000
|
||||
#define GAME_HOST_OPTION_BITMASK_DOMOBLOOT 0x04000000
|
||||
#define GAME_HOST_OPTION_BITMASK_DOTILEDROPS 0x08000000
|
||||
#define GAME_HOST_OPTION_BITMASK_NATURALREGEN 0x10000000
|
||||
#define GAME_HOST_OPTION_BITMASK_DODAYLIGHTCYCLE 0x20000000
|
||||
#define GAME_HOST_OPTION_BITMASK_ALL 0xFFFFFFFF
|
||||
|
||||
#define GAME_HOST_OPTION_BITMASK_WORLDSIZE_BITSHIFT 20
|
||||
|
||||
enum EGameHostOptionWorldSize {
|
||||
e_worldSize_Unknown = 0,
|
||||
e_worldSize_Classic,
|
||||
e_worldSize_Small,
|
||||
e_worldSize_Medium,
|
||||
e_worldSize_Large
|
||||
};
|
||||
|
||||
#define PROFILE_VERSION_8 10
|
||||
#define PROFILE_VERSION_9 11
|
||||
|
||||
#define PROFILE_VERSION_10 12
|
||||
|
||||
// 4J-JEV: New Statistics and Achievements for 'NexGen' platforms.
|
||||
#define PROFILE_VERSION_11 13
|
||||
|
||||
// Java 1.6.4
|
||||
#define PROFILE_VERSION_12 14
|
||||
|
||||
#define PROFILE_VERSION_CURRENT PROFILE_VERSION_12
|
||||
|
||||
#define MAX_FAVORITE_SKINS \
|
||||
10 // these are stored in the profile data so keep it small
|
||||
|
||||
// defines for game settings - uiBitmaskValues
|
||||
|
||||
#define GAMESETTING_CLOUDS 0x00000001
|
||||
#define GAMESETTING_ONLINE 0x00000002
|
||||
#define GAMESETTING_INVITEONLY 0x00000004
|
||||
#define GAMESETTING_FRIENDSOFFRIENDS 0x00000008
|
||||
#define GAMESETTING_DISPLAYUPDATEMSG 0x00000030
|
||||
#define GAMESETTING_BEDROCKFOG 0x00000040
|
||||
#define GAMESETTING_DISPLAYHUD 0x00000080
|
||||
#define GAMESETTING_DISPLAYHAND 0x00000100
|
||||
#define GAMESETTING_CUSTOMSKINANIM 0x00000200
|
||||
#define GAMESETTING_DEATHMESSAGES 0x00000400
|
||||
#define GAMESETTING_UISIZE 0x00001800
|
||||
#define GAMESETTING_UISIZE_SPLITSCREEN 0x00006000
|
||||
#define GAMESETTING_ANIMATEDCHARACTER 0x00008000
|
||||
#define GAMESETTING_PS3EULAREAD 0x00010000
|
||||
#define GAMESETTING_PSVITANETWORKMODEADHOC 0x00020000
|
||||
|
||||
// defines for languages
|
||||
|
||||
#define MINECRAFT_LANGUAGE_DEFAULT 0x00
|
||||
#define MINECRAFT_LANGUAGE_ENGLISH 0x01
|
||||
#define MINECRAFT_LANGUAGE_JAPANESE 0x02
|
||||
#define MINECRAFT_LANGUAGE_GERMAN 0x03
|
||||
#define MINECRAFT_LANGUAGE_FRENCH 0x04
|
||||
#define MINECRAFT_LANGUAGE_SPANISH 0x05
|
||||
#define MINECRAFT_LANGUAGE_ITALIAN 0x06
|
||||
#define MINECRAFT_LANGUAGE_KOREAN 0x07
|
||||
#define MINECRAFT_LANGUAGE_TCHINESE 0x08
|
||||
#define MINECRAFT_LANGUAGE_PORTUGUESE 0x09
|
||||
#define MINECRAFT_LANGUAGE_BRAZILIAN 0x0A
|
||||
#define MINECRAFT_LANGUAGE_RUSSIAN 0x0B
|
||||
#define MINECRAFT_LANGUAGE_DUTCH 0x0C
|
||||
#define MINECRAFT_LANGUAGE_FINISH 0x0D
|
||||
#define MINECRAFT_LANGUAGE_SWEDISH 0x0E
|
||||
#define MINECRAFT_LANGUAGE_DANISH 0x0F
|
||||
#define MINECRAFT_LANGUAGE_NORWEGIAN 0x10
|
||||
#define MINECRAFT_LANGUAGE_POLISH 0x11
|
||||
#define MINECRAFT_LANGUAGE_TURKISH 0x12
|
||||
#define MINECRAFT_LANGUAGE_LATINAMERICANSPANISH 0x13
|
||||
#define MINECRAFT_LANGUAGE_GREEK 0x14
|
||||
|
||||
/* Match these
|
||||
|
||||
const int XC_LANGUAGE_ENGLISH =1; const int XC_LANGUAGE_JAPANESE
|
||||
=2; const int XC_LANGUAGE_GERMAN
|
||||
=3; const int XC_LANGUAGE_FRENCH
|
||||
=4; const int XC_LANGUAGE_SPANISH
|
||||
=5; const int XC_LANGUAGE_ITALIAN
|
||||
=6; const int XC_LANGUAGE_KOREAN
|
||||
=7; const int XC_LANGUAGE_TCHINESE
|
||||
=8; const int XC_LANGUAGE_PORTUGUESE =9; const int XC_LANGUAGE_BRAZILIAN
|
||||
=10; const int XC_LANGUAGE_RUSSIAN
|
||||
=11; const int XC_LANGUAGE_DUTCH
|
||||
=12; const int XC_LANGUAGE_FINISH
|
||||
=13; const int XC_LANGUAGE_SWEDISH
|
||||
=14; const int XC_LANGUAGE_DANISH
|
||||
=15; const int XC_LANGUAGE_NORWEGIAN =16; const int XC_LANGUAGE_POLISH
|
||||
=17; const int XC_LANGUAGE_TURKISH
|
||||
=18; const int XC_LANGUAGE_LATINAMERICANSPANISH =19;
|
||||
const int XC_LANGUAGE_GREEK =20;
|
||||
*/
|
||||
@@ -100,6 +100,25 @@ enum eTMSAction {
|
||||
eTMSAction_TMSPP_RetrieveUserFilelist_DLCFileOnly,
|
||||
};
|
||||
|
||||
// The server runs on its own thread, so we need to call its actions there
|
||||
// rather than where all other Xui actions are performed In general these are
|
||||
// debugging options
|
||||
enum eXuiServerAction {
|
||||
eXuiServerAction_Idle = 0,
|
||||
eXuiServerAction_DropItem, // Debug
|
||||
eXuiServerAction_SaveGame,
|
||||
eXuiServerAction_AutoSaveGame,
|
||||
eXuiServerAction_SpawnMob, // Debug
|
||||
eXuiServerAction_PauseServer,
|
||||
eXuiServerAction_ToggleRain, // Debug
|
||||
eXuiServerAction_ToggleThunder, // Debug
|
||||
eXuiServerAction_ServerSettingChanged_Gamertags,
|
||||
eXuiServerAction_ServerSettingChanged_Difficulty,
|
||||
eXuiServerAction_ExportSchematic, // Debug
|
||||
eXuiServerAction_ServerSettingChanged_BedrockFog,
|
||||
eXuiServerAction_SetCameraLocation, // Debug
|
||||
};
|
||||
|
||||
enum eGameSetting {
|
||||
eGameSetting_MusicVolume = 0,
|
||||
eGameSetting_SoundFXVolume,
|
||||
@@ -2,18 +2,17 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "app/common/UI/All Platforms/UIEnums.h"
|
||||
#include "minecraft/GameEnums.h"
|
||||
#include "minecraft/GameTypes.h"
|
||||
#include "minecraft/client/model/SkinBox.h"
|
||||
#include "minecraft/world/tutorial/TutorialEnum.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/network/NetTypes.h"
|
||||
#include "platform/profile/ProfileConstants.h"
|
||||
#include "platform/storage/storage.h"
|
||||
#include "platform/sdl2/Storage.h"
|
||||
#include "app/common/App_Defines.h"
|
||||
#include "app/common/App_enums.h"
|
||||
#include "app/common/src/Tutorial/TutorialEnum.h"
|
||||
#include "app/common/src/UI/All Platforms/UIEnums.h"
|
||||
#include "app/include/NetTypes.h"
|
||||
#include "app/include/SkinBox.h"
|
||||
#include "app/include/XboxStubs.h"
|
||||
|
||||
typedef struct {
|
||||
char* wchFilename;
|
||||
wchar_t* wchFilename;
|
||||
eFileExtensionType eEXT;
|
||||
eTMSFileType eTMSType;
|
||||
std::uint8_t* pbData;
|
||||
@@ -145,18 +144,29 @@ typedef struct {
|
||||
int uiStringID;
|
||||
} TIPSTRUCT;
|
||||
|
||||
typedef struct {
|
||||
eXUID eXuid;
|
||||
wchar_t wchCape[MAX_CAPENAME_SIZE];
|
||||
wchar_t wchSkin[MAX_CAPENAME_SIZE];
|
||||
} MOJANG_DATA;
|
||||
|
||||
typedef struct {
|
||||
eDLCContentType eDLCType;
|
||||
|
||||
uint64_t ullOfferID_Full;
|
||||
uint64_t ullOfferID_Trial;
|
||||
char wchBanner[MAX_BANNERNAME_SIZE];
|
||||
char wchDataFile[MAX_BANNERNAME_SIZE];
|
||||
wchar_t wchBanner[MAX_BANNERNAME_SIZE];
|
||||
wchar_t wchDataFile[MAX_BANNERNAME_SIZE];
|
||||
int iGender;
|
||||
int iConfig;
|
||||
unsigned int uiSortIndex;
|
||||
} DLC_INFO;
|
||||
|
||||
typedef struct {
|
||||
int x, z;
|
||||
_eTerrainFeatureType eTerrainFeature;
|
||||
} FEATURE_DATA;
|
||||
|
||||
// banned list
|
||||
typedef struct {
|
||||
std::uint8_t* pBannedList;
|
||||
@@ -171,12 +181,12 @@ typedef struct _DLCRequest {
|
||||
typedef struct _TMSPPRequest {
|
||||
eTMSContentState eState;
|
||||
eDLCContentType eType;
|
||||
IPlatformStorage::eGlobalStorage eStorageFacility;
|
||||
IPlatformStorage::eTMS_FILETYPEVAL eFileTypeVal;
|
||||
C4JStorage::eGlobalStorage eStorageFacility;
|
||||
C4JStorage::eTMS_FILETYPEVAL eFileTypeVal;
|
||||
// char szFilename[MAX_TMSFILENAME_SIZE];
|
||||
int (*CallbackFunc)(void*, int, int, IPlatformStorage::PTMSPP_FILEDATA,
|
||||
int (*CallbackFunc)(void*, int, int, C4JStorage::PTMSPP_FILEDATA,
|
||||
const char* szFilename);
|
||||
char wchFilename[MAX_TMSFILENAME_SIZE];
|
||||
wchar_t wchFilename[MAX_TMSFILENAME_SIZE];
|
||||
|
||||
void* lpCallbackParam;
|
||||
} TMSPPRequest;
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
#include "app/common/ArchiveManager.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/UI/All Platforms/ArchiveFile.h"
|
||||
#include "java/File.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/skins/TexturePack.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
#include "platform/PlatformTypes.h"
|
||||
#include "platform/fs/fs.h"
|
||||
|
||||
ArchiveManager::ArchiveManager()
|
||||
: m_mediaArchive(nullptr), m_dwRequiredTexturePackID(0) {}
|
||||
|
||||
void ArchiveManager::loadMediaArchive() {
|
||||
std::string mediapath = "";
|
||||
|
||||
mediapath = "Common\\Media\\MediaWindows64.arc";
|
||||
|
||||
if (!mediapath.empty()) {
|
||||
std::string exeDirW = PlatformFilesystem.getBasePath().string();
|
||||
std::string candidate = exeDirW + File::pathSeparator + mediapath;
|
||||
if (File(candidate).exists()) {
|
||||
m_mediaArchive = new ArchiveFile(File(candidate));
|
||||
} else {
|
||||
m_mediaArchive = new ArchiveFile(File(mediapath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ArchiveManager::getArchiveFileSize(const std::string& filename) {
|
||||
TexturePack* tPack = nullptr;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft && pMinecraft->skins)
|
||||
tPack = pMinecraft->skins->getSelected();
|
||||
if (tPack && tPack->hasData() && tPack->getArchiveFile() &&
|
||||
tPack->getArchiveFile()->hasFile(filename)) {
|
||||
return tPack->getArchiveFile()->getFileSize(filename);
|
||||
} else
|
||||
return m_mediaArchive->getFileSize(filename);
|
||||
}
|
||||
|
||||
bool ArchiveManager::hasArchiveFile(const std::string& filename) {
|
||||
TexturePack* tPack = nullptr;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft && pMinecraft->skins)
|
||||
tPack = pMinecraft->skins->getSelected();
|
||||
if (tPack && tPack->hasData() && tPack->getArchiveFile() &&
|
||||
tPack->getArchiveFile()->hasFile(filename))
|
||||
return true;
|
||||
else
|
||||
return m_mediaArchive->hasFile(filename);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> ArchiveManager::getArchiveFile(
|
||||
const std::string& filename) {
|
||||
TexturePack* tPack = nullptr;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
if (pMinecraft && pMinecraft->skins)
|
||||
tPack = pMinecraft->skins->getSelected();
|
||||
if (tPack && tPack->hasData() && tPack->getArchiveFile() &&
|
||||
tPack->getArchiveFile()->hasFile(filename)) {
|
||||
return tPack->getArchiveFile()->getFile(filename);
|
||||
} else
|
||||
return m_mediaArchive->getFile(filename);
|
||||
}
|
||||
|
||||
void ArchiveManager::addMemoryTPDFile(int iConfig, std::uint8_t* pbData,
|
||||
unsigned int byteCount) {
|
||||
std::lock_guard<std::mutex> lock(csMemTPDLock);
|
||||
PMEMDATA pData = nullptr;
|
||||
auto it = m_MEM_TPD.find(iConfig);
|
||||
if (it == m_MEM_TPD.end()) {
|
||||
pData = new MEMDATA();
|
||||
pData->pbData = pbData;
|
||||
pData->byteCount = byteCount;
|
||||
pData->ucRefCount = 1;
|
||||
|
||||
m_MEM_TPD[iConfig] = pData;
|
||||
}
|
||||
}
|
||||
|
||||
void ArchiveManager::removeMemoryTPDFile(int iConfig) {
|
||||
std::lock_guard<std::mutex> lock(csMemTPDLock);
|
||||
PMEMDATA pData = nullptr;
|
||||
auto it = m_MEM_TPD.find(iConfig);
|
||||
if (it != m_MEM_TPD.end()) {
|
||||
pData = m_MEM_TPD[iConfig];
|
||||
delete pData;
|
||||
m_MEM_TPD.erase(iConfig);
|
||||
}
|
||||
}
|
||||
|
||||
int ArchiveManager::getTPConfigVal(char* pwchDataFile) { return -1; }
|
||||
|
||||
bool ArchiveManager::isFileInTPD(int iConfig) {
|
||||
bool val = false;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csMemTPDLock);
|
||||
auto it = m_MEM_TPD.find(iConfig);
|
||||
if (it != m_MEM_TPD.end()) val = true;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void ArchiveManager::getTPD(int iConfig, std::uint8_t** ppbData,
|
||||
unsigned int* pByteCount) {
|
||||
std::lock_guard<std::mutex> lock(csMemTPDLock);
|
||||
auto it = m_MEM_TPD.find(iConfig);
|
||||
if (it != m_MEM_TPD.end()) {
|
||||
PMEMDATA pData = (*it).second;
|
||||
*ppbData = pData->pbData;
|
||||
*pByteCount = pData->byteCount;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
|
||||
class ArchiveFile;
|
||||
|
||||
class ArchiveManager {
|
||||
public:
|
||||
ArchiveManager();
|
||||
|
||||
void loadMediaArchive();
|
||||
ArchiveFile* getMediaArchive() const { return m_mediaArchive; }
|
||||
|
||||
int getArchiveFileSize(const std::string& filename);
|
||||
bool hasArchiveFile(const std::string& filename);
|
||||
std::vector<uint8_t> getArchiveFile(const std::string& filename);
|
||||
|
||||
// Texture Pack Data files (icon, banner, comparison shot & text)
|
||||
void addMemoryTPDFile(int iConfig, std::uint8_t* pbData,
|
||||
unsigned int byteCount);
|
||||
void removeMemoryTPDFile(int iConfig);
|
||||
bool isFileInTPD(int iConfig);
|
||||
void getTPD(int iConfig, std::uint8_t** ppbData, unsigned int* pByteCount);
|
||||
int getTPDSize() { return m_MEM_TPD.size(); }
|
||||
int getTPConfigVal(char* pwchDataFile);
|
||||
|
||||
void setRequiredTexturePackID(std::uint32_t texturePackId) {
|
||||
m_dwRequiredTexturePackID = texturePackId;
|
||||
}
|
||||
std::uint32_t getRequiredTexturePackID() const {
|
||||
return m_dwRequiredTexturePackID;
|
||||
}
|
||||
|
||||
virtual void getFileFromTPD(eTPDFileType eType, std::uint8_t* pbData,
|
||||
unsigned int byteCount, std::uint8_t** ppbData,
|
||||
unsigned int* pByteCount) {
|
||||
*ppbData = nullptr;
|
||||
*pByteCount = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
ArchiveFile* m_mediaArchive;
|
||||
|
||||
private:
|
||||
std::unordered_map<int, PMEMDATA> m_MEM_TPD;
|
||||
std::mutex csMemTPDLock;
|
||||
std::uint32_t m_dwRequiredTexturePackID;
|
||||
};
|
||||
@@ -1,62 +0,0 @@
|
||||
#include "app/common/Audio/ConsoleSoundEngine.h"
|
||||
|
||||
bool ConsoleSoundEngine::GetIsPlayingStreamingCDMusic() {
|
||||
return m_bIsPlayingStreamingCDMusic;
|
||||
}
|
||||
bool ConsoleSoundEngine::GetIsPlayingStreamingGameMusic() {
|
||||
return m_bIsPlayingStreamingGameMusic;
|
||||
}
|
||||
void ConsoleSoundEngine::SetIsPlayingStreamingCDMusic(bool bVal) {
|
||||
m_bIsPlayingStreamingCDMusic = bVal;
|
||||
}
|
||||
void ConsoleSoundEngine::SetIsPlayingStreamingGameMusic(bool bVal) {
|
||||
m_bIsPlayingStreamingGameMusic = bVal;
|
||||
}
|
||||
bool ConsoleSoundEngine::GetIsPlayingEndMusic() { return m_bIsPlayingEndMusic; }
|
||||
bool ConsoleSoundEngine::GetIsPlayingNetherMusic() {
|
||||
return m_bIsPlayingNetherMusic;
|
||||
}
|
||||
void ConsoleSoundEngine::SetIsPlayingEndMusic(bool bVal) {
|
||||
m_bIsPlayingEndMusic = bVal;
|
||||
}
|
||||
void ConsoleSoundEngine::SetIsPlayingNetherMusic(bool bVal) {
|
||||
m_bIsPlayingNetherMusic = bVal;
|
||||
}
|
||||
|
||||
void ConsoleSoundEngine::tick() {
|
||||
if (scheduledSounds.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto it = scheduledSounds.begin(); it != scheduledSounds.end();) {
|
||||
ConsoleSoundEngine::ScheduledSound* next = *it;
|
||||
next->delay--;
|
||||
|
||||
if (next->delay <= 0) {
|
||||
play(next->iSound, next->x, next->y, next->z, next->volume,
|
||||
next->pitch);
|
||||
it = scheduledSounds.erase(it);
|
||||
delete next;
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleSoundEngine::schedule(int iSound, float x, float y, float z,
|
||||
float volume, float pitch, int delayTicks) {
|
||||
scheduledSounds.push_back(new ConsoleSoundEngine::ScheduledSound(
|
||||
iSound, x, y, z, volume, pitch, delayTicks));
|
||||
}
|
||||
|
||||
ConsoleSoundEngine::ScheduledSound::ScheduledSound(int iSound, float x, float y,
|
||||
float z, float volume,
|
||||
float pitch, int delay) {
|
||||
this->iSound = iSound;
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->z = z;
|
||||
this->volume = volume;
|
||||
this->pitch = pitch;
|
||||
this->delay = delay;
|
||||
}
|
||||
@@ -1,882 +0,0 @@
|
||||
#include "SoundEngine.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/Audio/ConsoleSoundEngine.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/Iggy/include/rrCore.h"
|
||||
#include "java/Random.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
#include "minecraft/util/Mth.h"
|
||||
#include "minecraft/world/entity/Mob.h"
|
||||
#include "minecraft/world/level/storage/LevelData.h"
|
||||
#include "platform/PlatformTypes.h"
|
||||
#include "platform/fs/fs.h"
|
||||
#include "platform/thread/C4JThread.h"
|
||||
|
||||
#define STB_VORBIS_HEADER_ONLY
|
||||
#include "stb_vorbis.c"
|
||||
|
||||
// Fixes strcasecmp in miniaudio
|
||||
// https://stackoverflow.com/questions/31127260/strcasecmp-a-non-standard-function
|
||||
int strcasecmp(const char* a, const char* b) {
|
||||
int ca, cb;
|
||||
do {
|
||||
ca = *(unsigned char*)a;
|
||||
cb = *(unsigned char*)b;
|
||||
ca = tolower(toupper(ca));
|
||||
cb = tolower(toupper(cb));
|
||||
a++;
|
||||
b++;
|
||||
} while (ca == cb && ca != '\0');
|
||||
return ca - cb;
|
||||
}
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "miniaudio.h"
|
||||
|
||||
#undef STB_VORBIS_HEADER_ONLY
|
||||
#include "stb_vorbis.c"
|
||||
|
||||
// stb_vorbis leaks single-letter macros (C, L, R, etc.) that collide with
|
||||
// identifiers in other translation units during unity builds.
|
||||
#undef C
|
||||
#undef L
|
||||
#undef R
|
||||
#undef TRUE
|
||||
#undef FALSE
|
||||
|
||||
// ASSETS
|
||||
const char* SoundEngine::m_szStreamFileA[eStream_Max] = {"calm1",
|
||||
"calm2",
|
||||
"calm3",
|
||||
"hal1",
|
||||
"hal2",
|
||||
"hal3",
|
||||
"hal4",
|
||||
"nuance1",
|
||||
"nuance2",
|
||||
"creative1",
|
||||
"creative2",
|
||||
"creative3",
|
||||
"creative4",
|
||||
"creative5",
|
||||
"creative6",
|
||||
"menu1",
|
||||
"menu2",
|
||||
"menu3",
|
||||
"menu4",
|
||||
"piano1",
|
||||
"piano2",
|
||||
"piano3",
|
||||
"nether1",
|
||||
"nether2",
|
||||
"nether3",
|
||||
"nether4",
|
||||
"the_end_dragon_alive",
|
||||
"the_end_end",
|
||||
"11",
|
||||
"13",
|
||||
"blocks",
|
||||
"cat",
|
||||
"chirp",
|
||||
"far",
|
||||
"mall",
|
||||
"mellohi",
|
||||
"stal",
|
||||
"strad",
|
||||
"ward",
|
||||
"where_are_we_now"};
|
||||
char SoundEngine::m_szSoundPath[] = {"app/common/Sound/"};
|
||||
char SoundEngine::m_szMusicPath[] = {"app/common/"};
|
||||
char SoundEngine::m_szRedistName[] = {"redist64"};
|
||||
|
||||
// END ASSETS
|
||||
|
||||
// Linux specific functions
|
||||
|
||||
// PIMPL'd state for the miniaudio backend. Defined here so SoundEngine.h
|
||||
// stays free of miniaudio.h.
|
||||
struct SoundEngineMiniAudio {
|
||||
ma_engine engine{};
|
||||
ma_engine_config engineConfig{};
|
||||
ma_sound musicStream{};
|
||||
};
|
||||
|
||||
struct MiniAudioSound {
|
||||
ma_sound sound;
|
||||
AUDIO_INFO info;
|
||||
bool active;
|
||||
};
|
||||
|
||||
SoundEngine::SoundEngine()
|
||||
: m_audio(std::make_unique<SoundEngineMiniAudio>()) {}
|
||||
SoundEngine::~SoundEngine() = default;
|
||||
std::vector<MiniAudioSound*> m_activeSounds;
|
||||
void SoundEngine::init(Options* pOptions) {
|
||||
app.DebugPrintf("---SoundEngine::init\n");
|
||||
random = new Random();
|
||||
*m_audio = SoundEngineMiniAudio{};
|
||||
m_musicStreamActive = false;
|
||||
m_StreamState = eMusicStreamState_Idle;
|
||||
m_iMusicDelay = 0;
|
||||
m_validListenerCount = 0;
|
||||
|
||||
m_bHeardTrackA = nullptr;
|
||||
|
||||
// Start the streaming music playing some music from the overworld
|
||||
SetStreamingSounds(eStream_Overworld_Calm1, eStream_Overworld_piano3,
|
||||
eStream_Nether1, eStream_Nether4, eStream_end_dragon,
|
||||
eStream_end_end, eStream_CD_1);
|
||||
|
||||
m_musicID = getMusicID(LevelData::DIMENSION_OVERWORLD);
|
||||
|
||||
m_StreamingAudioInfo.bIs3D = false;
|
||||
m_StreamingAudioInfo.x = 0;
|
||||
m_StreamingAudioInfo.y = 0;
|
||||
m_StreamingAudioInfo.z = 0;
|
||||
m_StreamingAudioInfo.volume = 1;
|
||||
m_StreamingAudioInfo.pitch = 1;
|
||||
|
||||
memset(CurrentSoundsPlaying, 0,
|
||||
sizeof(int) *
|
||||
(static_cast<int>(eSoundType_MAX) + static_cast<int>(eSFX_MAX)));
|
||||
memset(m_ListenerA, 0, sizeof(AUDIO_LISTENER) * XUSER_MAX_COUNT);
|
||||
m_audio->engineConfig = ma_engine_config_init();
|
||||
m_audio->engineConfig.listenerCount = MAX_LOCAL_PLAYERS;
|
||||
|
||||
if (ma_engine_init(&m_audio->engineConfig, &m_audio->engine) !=
|
||||
MA_SUCCESS) {
|
||||
app.DebugPrintf("Failed to initialize miniaudio engine\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ma_engine_set_volume(&m_audio->engine, 1.0f);
|
||||
|
||||
m_MasterMusicVolume = 1.0f;
|
||||
m_MasterEffectsVolume = 1.0f;
|
||||
|
||||
m_validListenerCount = 1;
|
||||
|
||||
m_bSystemMusicPlaying = false;
|
||||
}
|
||||
void SoundEngine::destroy() { ma_engine_uninit(&m_audio->engine); }
|
||||
|
||||
void SoundEngine::play(int iSound, float x, float y, float z, float volume,
|
||||
float pitch) {
|
||||
if (iSound == -1) return;
|
||||
char szId[256];
|
||||
strncpy(szId, wchSoundNames[iSound], 255);
|
||||
for (int i = 0; szId[i]; i++)
|
||||
if (szId[i] == '.') szId[i] = '/';
|
||||
|
||||
std::string base = PlatformFilesystem.getBasePath().string() + "/";
|
||||
const char* roots[] = {"Sound/Minecraft/", "app/common/Sound/Minecraft/",
|
||||
"app/common/res/TitleUpdate/res/Sound/Minecraft/"};
|
||||
char finalPath[512] = {0};
|
||||
bool found = false;
|
||||
|
||||
for (const char* root : roots) {
|
||||
std::string fullRoot = base + root;
|
||||
for (const char* ext : {".ogg", ".wav"}) {
|
||||
int count = 0;
|
||||
for (int i = 1; i <= 16; i++) {
|
||||
char tryP[512];
|
||||
snprintf(tryP, 512, "%s%s%d%s", fullRoot.c_str(), szId, i, ext);
|
||||
if (PlatformFilesystem.exists(tryP))
|
||||
count = i;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (count > 0) {
|
||||
snprintf(finalPath, 512, "%s%s%d%s", fullRoot.c_str(), szId,
|
||||
(rand() % count) + 1, ext);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
char tryP[512];
|
||||
snprintf(tryP, 512, "%s%s%s", fullRoot.c_str(), szId, ext);
|
||||
if (PlatformFilesystem.exists(tryP)) {
|
||||
strncpy(finalPath, tryP, 511);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
}
|
||||
|
||||
if (!found) return;
|
||||
MiniAudioSound* s = new MiniAudioSound();
|
||||
memset(&s->info, 0, sizeof(AUDIO_INFO));
|
||||
s->info.x = x;
|
||||
s->info.y = y;
|
||||
s->info.z = z;
|
||||
s->info.volume = volume;
|
||||
s->info.pitch = pitch;
|
||||
s->info.bIs3D = true;
|
||||
|
||||
if (ma_sound_init_from_file(&m_audio->engine, finalPath,
|
||||
MA_SOUND_FLAG_ASYNC, nullptr, nullptr,
|
||||
&s->sound) == MA_SUCCESS) {
|
||||
ma_sound_set_spatialization_enabled(&s->sound, MA_TRUE);
|
||||
ma_sound_set_min_distance(&s->sound, 2.0f);
|
||||
ma_sound_set_max_distance(&s->sound, 48.0f);
|
||||
ma_sound_set_volume(&s->sound, volume * m_MasterEffectsVolume);
|
||||
ma_sound_set_position(&s->sound, x, y, z);
|
||||
ma_sound_start(&s->sound);
|
||||
m_activeSounds.push_back(s);
|
||||
} else
|
||||
delete s;
|
||||
}
|
||||
|
||||
void SoundEngine::playUI(int iSound, float volume, float pitch) {
|
||||
char szIdentifier[256];
|
||||
if (iSound >= eSFX_MAX)
|
||||
strncpy(szIdentifier, wchSoundNames[iSound], 255);
|
||||
else
|
||||
strncpy(szIdentifier, wchUISoundNames[iSound], 255);
|
||||
for (int i = 0; szIdentifier[i]; i++)
|
||||
if (szIdentifier[i] == '.') szIdentifier[i] = '/';
|
||||
std::string base = PlatformFilesystem.getBasePath().string() + "/";
|
||||
const char* roots[] = {
|
||||
"Sound/Minecraft/UI/",
|
||||
"Sound/Minecraft/",
|
||||
"app/common/Sound/Minecraft/UI/",
|
||||
"app/common/Sound/Minecraft/",
|
||||
};
|
||||
char finalPath[512] = {0};
|
||||
bool found = false;
|
||||
|
||||
for (const char* root : roots) {
|
||||
for (const char* ext : {".ogg", ".wav", ".mp3"}) {
|
||||
char tryP[512];
|
||||
snprintf(tryP, 512, "%s%s%s%s", base.c_str(), root, szIdentifier,
|
||||
ext);
|
||||
if (PlatformFilesystem.exists(tryP)) {
|
||||
strncpy(finalPath, tryP, 511);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
}
|
||||
|
||||
if (!found) return;
|
||||
MiniAudioSound* s = new MiniAudioSound();
|
||||
memset(&s->info, 0, sizeof(AUDIO_INFO));
|
||||
s->info.volume = volume;
|
||||
s->info.pitch = pitch;
|
||||
s->info.bIs3D = false;
|
||||
|
||||
if (ma_sound_init_from_file(&m_audio->engine, finalPath,
|
||||
MA_SOUND_FLAG_ASYNC, nullptr, nullptr,
|
||||
&s->sound) == MA_SUCCESS) {
|
||||
ma_sound_set_spatialization_enabled(&s->sound, MA_FALSE);
|
||||
ma_sound_set_volume(&s->sound, volume * m_MasterEffectsVolume);
|
||||
ma_sound_set_pitch(&s->sound, pitch);
|
||||
ma_sound_start(&s->sound);
|
||||
m_activeSounds.push_back(s);
|
||||
} else
|
||||
delete s;
|
||||
}
|
||||
|
||||
int SoundEngine::getMusicID(int iDomain) {
|
||||
int iRandomVal = 0;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
// Protection from errors
|
||||
if (pMinecraft == nullptr || pMinecraft->skins == nullptr) {
|
||||
// any track from the overworld
|
||||
return GetRandomishTrack(m_iStream_Overworld_Min,
|
||||
m_iStream_Overworld_Max);
|
||||
}
|
||||
|
||||
if (pMinecraft->skins->isUsingDefaultSkin()) {
|
||||
switch (iDomain) {
|
||||
case LevelData::DIMENSION_END:
|
||||
// the end isn't random - it has different music depending
|
||||
// whether the dragon is alive or not, but we've not
|
||||
// added the dead dragon music yet
|
||||
// haha they said wheter
|
||||
return m_iStream_End_Min;
|
||||
case LevelData::DIMENSION_NETHER:
|
||||
return GetRandomishTrack(m_iStream_Nether_Min,
|
||||
m_iStream_Nether_Max);
|
||||
// return m_iStream_Nether_Min +
|
||||
// random->nextInt(m_iStream_Nether_Max-m_iStream_Nether_Min);
|
||||
default: // overworld
|
||||
// return m_iStream_Overworld_Min +
|
||||
// random->nextInt(m_iStream_Overworld_Max-m_iStream_Overworld_Min);
|
||||
return GetRandomishTrack(m_iStream_Overworld_Min,
|
||||
m_iStream_Overworld_Max);
|
||||
}
|
||||
} else {
|
||||
// using a texture pack - may have multiple End music tracks
|
||||
switch (iDomain) {
|
||||
case LevelData::DIMENSION_END:
|
||||
return GetRandomishTrack(m_iStream_End_Min, m_iStream_End_Max);
|
||||
case LevelData::DIMENSION_NETHER:
|
||||
// return m_iStream_Nether_Min +
|
||||
// random->nextInt(m_iStream_Nether_Max-m_iStream_Nether_Min);
|
||||
return GetRandomishTrack(m_iStream_Nether_Min,
|
||||
m_iStream_Nether_Max);
|
||||
default: // overworld
|
||||
// return m_iStream_Overworld_Min +
|
||||
// random->nextInt(m_iStream_Overworld_Max-m_iStream_Overworld_Min);
|
||||
return GetRandomishTrack(m_iStream_Overworld_Min,
|
||||
m_iStream_Overworld_Max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int SoundEngine::getMusicID(const std::string& name) {
|
||||
int iCD = 0;
|
||||
for (size_t i = 0; i < 12; i++) {
|
||||
std::string fileName = m_szStreamFileA[i + eStream_CD_1];
|
||||
|
||||
if (name == fileName) {
|
||||
iCD = static_cast<int>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return iCD + m_iStream_CD_1;
|
||||
}
|
||||
|
||||
void SoundEngine::playStreaming(const std::string& name, float x, float y,
|
||||
float z, float volume, float pitch,
|
||||
bool bMusicDelay) {
|
||||
m_StreamingAudioInfo.x = x;
|
||||
m_StreamingAudioInfo.y = y;
|
||||
m_StreamingAudioInfo.z = z;
|
||||
m_StreamingAudioInfo.volume = volume;
|
||||
m_StreamingAudioInfo.pitch = pitch;
|
||||
|
||||
if (m_StreamState == eMusicStreamState_Playing) {
|
||||
m_StreamState = eMusicStreamState_Stop;
|
||||
} else if (m_StreamState == eMusicStreamState_Opening) {
|
||||
m_StreamState = eMusicStreamState_OpeningCancel;
|
||||
}
|
||||
app.DebugPrintf("playStreaming %S", name.c_str());
|
||||
if (name.empty()) {
|
||||
// music, or stop CD
|
||||
m_StreamingAudioInfo.bIs3D = false;
|
||||
|
||||
// we need a music id
|
||||
// random delay of up to 3 minutes for music
|
||||
m_iMusicDelay = random->nextInt(
|
||||
20 * 60 * 3); // random->nextInt(20 * 60 * 10) + 20 * 60 * 10;
|
||||
|
||||
#if defined(_DEBUG)
|
||||
m_iMusicDelay = 0;
|
||||
#endif
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
bool playerInEnd = false;
|
||||
bool playerInNether = false;
|
||||
|
||||
for (unsigned int i = 0; i < MAX_LOCAL_PLAYERS; i++) {
|
||||
if (pMinecraft->localplayers[i] != nullptr) {
|
||||
if (pMinecraft->localplayers[i]->dimension ==
|
||||
LevelData::DIMENSION_END) {
|
||||
playerInEnd = true;
|
||||
} else if (pMinecraft->localplayers[i]->dimension ==
|
||||
LevelData::DIMENSION_NETHER) {
|
||||
playerInNether = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (playerInEnd) {
|
||||
m_musicID = getMusicID(LevelData::DIMENSION_END);
|
||||
} else if (playerInNether) {
|
||||
m_musicID = getMusicID(LevelData::DIMENSION_NETHER);
|
||||
} else {
|
||||
m_musicID = getMusicID(LevelData::DIMENSION_OVERWORLD);
|
||||
}
|
||||
} else {
|
||||
// jukebox
|
||||
m_StreamingAudioInfo.bIs3D = true;
|
||||
m_musicID = getMusicID(name);
|
||||
m_iMusicDelay = 0;
|
||||
}
|
||||
}
|
||||
int SoundEngine::OpenStreamThreadProc(void* lpParameter) {
|
||||
SoundEngine* soundEngine = (SoundEngine*)lpParameter;
|
||||
|
||||
const char* ext = strrchr(soundEngine->m_szStreamName, '.');
|
||||
|
||||
if (soundEngine->m_musicStreamActive) {
|
||||
ma_sound_stop(&soundEngine->m_audio->musicStream);
|
||||
ma_sound_uninit(&soundEngine->m_audio->musicStream);
|
||||
soundEngine->m_musicStreamActive = false;
|
||||
}
|
||||
|
||||
ma_result result = ma_sound_init_from_file(
|
||||
&soundEngine->m_audio->engine, soundEngine->m_szStreamName,
|
||||
MA_SOUND_FLAG_STREAM, nullptr, nullptr,
|
||||
&soundEngine->m_audio->musicStream);
|
||||
|
||||
if (result != MA_SUCCESS) {
|
||||
app.DebugPrintf(
|
||||
"SoundEngine::OpenStreamThreadProc - Failed to open stream: "
|
||||
"%s\n",
|
||||
soundEngine->m_szStreamName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ma_sound_set_spatialization_enabled(&soundEngine->m_audio->musicStream,
|
||||
MA_FALSE);
|
||||
ma_sound_set_looping(&soundEngine->m_audio->musicStream, MA_FALSE);
|
||||
|
||||
soundEngine->m_musicStreamActive = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
void SoundEngine::playMusicTick() {
|
||||
static float fMusicVol = 0.0f;
|
||||
fMusicVol = getMasterMusicVolume();
|
||||
|
||||
switch (m_StreamState) {
|
||||
case eMusicStreamState_Idle:
|
||||
if (m_iMusicDelay > 0) {
|
||||
m_iMusicDelay--;
|
||||
return;
|
||||
}
|
||||
if (m_musicID != -1) {
|
||||
std::string base =
|
||||
PlatformFilesystem.getBasePath().string() + "/";
|
||||
bool isCD = (m_musicID >= m_iStream_CD_1);
|
||||
const char* folder = isCD ? "cds/" : "music/";
|
||||
const char* track = m_szStreamFileA[m_musicID];
|
||||
bool found = false;
|
||||
m_szStreamName[0] = '\0';
|
||||
|
||||
const char* roots[] = {"app/common/music/", "music/", "./"};
|
||||
|
||||
for (const char* r : roots) {
|
||||
for (const char* e : {".ogg", ".mp3", ".wav"}) {
|
||||
// try with folder prefix (music/ or cds/)
|
||||
snprintf(m_szStreamName, sizeof(m_szStreamName),
|
||||
"%s%s%s%s%s", base.c_str(), r, folder, track,
|
||||
e);
|
||||
if (PlatformFilesystem.exists(m_szStreamName)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
// try without folder prefix
|
||||
snprintf(m_szStreamName, sizeof(m_szStreamName),
|
||||
"%s%s%s%s", base.c_str(), r, track, e);
|
||||
if (PlatformFilesystem.exists(m_szStreamName)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
}
|
||||
|
||||
if (found) {
|
||||
SetIsPlayingStreamingGameMusic(!isCD);
|
||||
SetIsPlayingStreamingCDMusic(isCD);
|
||||
m_openStreamThread = new C4JThread(
|
||||
OpenStreamThreadProc, this, "OpenStreamThreadProc");
|
||||
m_openStreamThread->run();
|
||||
m_StreamState = eMusicStreamState_Opening;
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"[SoundEngine] oh noes couldn't find music track '%s', "
|
||||
"retrying "
|
||||
"in 1min\n",
|
||||
track);
|
||||
m_iMusicDelay = 20 * 60;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case eMusicStreamState_Opening:
|
||||
if (!m_openStreamThread->isRunning()) {
|
||||
delete m_openStreamThread;
|
||||
m_openStreamThread = nullptr;
|
||||
|
||||
if (!m_musicStreamActive) {
|
||||
m_StreamState = eMusicStreamState_Idle;
|
||||
break;
|
||||
}
|
||||
|
||||
ma_sound_set_spatialization_enabled(
|
||||
&m_audio->musicStream,
|
||||
m_StreamingAudioInfo.bIs3D ? MA_TRUE : MA_FALSE);
|
||||
if (m_StreamingAudioInfo.bIs3D) {
|
||||
ma_sound_set_position(
|
||||
&m_audio->musicStream, m_StreamingAudioInfo.x,
|
||||
m_StreamingAudioInfo.y, m_StreamingAudioInfo.z);
|
||||
}
|
||||
|
||||
ma_sound_set_pitch(&m_audio->musicStream,
|
||||
m_StreamingAudioInfo.pitch);
|
||||
ma_sound_set_volume(
|
||||
&m_audio->musicStream,
|
||||
m_StreamingAudioInfo.volume * getMasterMusicVolume());
|
||||
ma_sound_start(&m_audio->musicStream);
|
||||
|
||||
m_StreamState = eMusicStreamState_Playing;
|
||||
}
|
||||
break;
|
||||
|
||||
case eMusicStreamState_OpeningCancel:
|
||||
if (!m_openStreamThread->isRunning()) {
|
||||
delete m_openStreamThread;
|
||||
m_openStreamThread = nullptr;
|
||||
m_StreamState = eMusicStreamState_Stop;
|
||||
}
|
||||
break;
|
||||
|
||||
case eMusicStreamState_Stop:
|
||||
if (m_musicStreamActive) {
|
||||
ma_sound_stop(&m_audio->musicStream);
|
||||
ma_sound_uninit(&m_audio->musicStream);
|
||||
m_musicStreamActive = false;
|
||||
}
|
||||
SetIsPlayingStreamingCDMusic(false);
|
||||
SetIsPlayingStreamingGameMusic(false);
|
||||
m_StreamState = eMusicStreamState_Idle;
|
||||
break;
|
||||
|
||||
case eMusicStreamState_Playing:
|
||||
if (GetIsPlayingStreamingGameMusic()) {
|
||||
bool playerInEnd = false, playerInNether = false;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
for (unsigned int i = 0; i < MAX_LOCAL_PLAYERS; ++i) {
|
||||
if (pMinecraft->localplayers[i]) {
|
||||
if (pMinecraft->localplayers[i]->dimension ==
|
||||
LevelData::DIMENSION_END)
|
||||
playerInEnd = true;
|
||||
else if (pMinecraft->localplayers[i]->dimension ==
|
||||
LevelData::DIMENSION_NETHER)
|
||||
playerInNether = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Dimension Switching
|
||||
bool needsStop = false;
|
||||
if (playerInEnd && !GetIsPlayingEndMusic()) {
|
||||
m_musicID = getMusicID(LevelData::DIMENSION_END);
|
||||
SetIsPlayingEndMusic(true);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
needsStop = true;
|
||||
} else if (!playerInEnd && GetIsPlayingEndMusic()) {
|
||||
m_musicID =
|
||||
playerInNether
|
||||
? getMusicID(LevelData::DIMENSION_NETHER)
|
||||
: getMusicID(LevelData::DIMENSION_OVERWORLD);
|
||||
SetIsPlayingEndMusic(false);
|
||||
SetIsPlayingNetherMusic(playerInNether);
|
||||
needsStop = true;
|
||||
} else if (playerInNether && !GetIsPlayingNetherMusic()) {
|
||||
m_musicID = getMusicID(LevelData::DIMENSION_NETHER);
|
||||
SetIsPlayingNetherMusic(true);
|
||||
SetIsPlayingEndMusic(false);
|
||||
needsStop = true;
|
||||
} else if (!playerInNether && GetIsPlayingNetherMusic()) {
|
||||
m_musicID =
|
||||
playerInEnd
|
||||
? getMusicID(LevelData::DIMENSION_END)
|
||||
: getMusicID(LevelData::DIMENSION_OVERWORLD);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
SetIsPlayingEndMusic(playerInEnd);
|
||||
needsStop = true;
|
||||
}
|
||||
|
||||
if (needsStop) m_StreamState = eMusicStreamState_Stop;
|
||||
|
||||
// volume change required?
|
||||
if (m_musicStreamActive)
|
||||
ma_sound_set_volume(
|
||||
&m_audio->musicStream,
|
||||
m_StreamingAudioInfo.volume * fMusicVol);
|
||||
|
||||
} else if (m_StreamingAudioInfo.bIs3D && m_validListenerCount > 1 &&
|
||||
m_musicStreamActive) {
|
||||
float fClosestDist = 1e6f;
|
||||
int iClosest = 0;
|
||||
for (size_t i = 0; i < MAX_LOCAL_PLAYERS; i++) {
|
||||
if (m_ListenerA[i].bValid) {
|
||||
float dist = sqrtf(powf(m_StreamingAudioInfo.x -
|
||||
m_ListenerA[i].vPosition.x,
|
||||
2) +
|
||||
powf(m_StreamingAudioInfo.y -
|
||||
m_ListenerA[i].vPosition.y,
|
||||
2) +
|
||||
powf(m_StreamingAudioInfo.z -
|
||||
m_ListenerA[i].vPosition.z,
|
||||
2));
|
||||
if (dist < fClosestDist) {
|
||||
fClosestDist = dist;
|
||||
iClosest = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
ma_sound_set_position(
|
||||
&m_audio->musicStream,
|
||||
m_StreamingAudioInfo.x - m_ListenerA[iClosest].vPosition.x,
|
||||
m_StreamingAudioInfo.y - m_ListenerA[iClosest].vPosition.y,
|
||||
m_StreamingAudioInfo.z - m_ListenerA[iClosest].vPosition.z);
|
||||
}
|
||||
break;
|
||||
|
||||
case eMusicStreamState_Completed:
|
||||
m_iMusicDelay = random->nextInt(20 * 60 * 3);
|
||||
{
|
||||
int dim = LevelData::DIMENSION_OVERWORLD;
|
||||
Minecraft* pMc = Minecraft::GetInstance();
|
||||
for (int i = 0; i < MAX_LOCAL_PLAYERS; i++) {
|
||||
if (pMc->localplayers[i]) {
|
||||
dim = pMc->localplayers[i]->dimension;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_musicID = getMusicID(dim);
|
||||
SetIsPlayingEndMusic(dim == LevelData::DIMENSION_END);
|
||||
SetIsPlayingNetherMusic(dim == LevelData::DIMENSION_NETHER);
|
||||
}
|
||||
m_StreamState = eMusicStreamState_Idle;
|
||||
break;
|
||||
}
|
||||
|
||||
// check the status of the stream - this is for when a track completes
|
||||
// rather than is stopped by the user action
|
||||
|
||||
if (m_musicStreamActive && !ma_sound_is_playing(&m_audio->musicStream) &&
|
||||
ma_sound_at_end(&m_audio->musicStream)) {
|
||||
ma_sound_uninit(&m_audio->musicStream);
|
||||
m_musicStreamActive = false;
|
||||
SetIsPlayingStreamingCDMusic(false);
|
||||
SetIsPlayingStreamingGameMusic(false);
|
||||
m_StreamState = eMusicStreamState_Completed;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundEngine::updateMiniAudio() {
|
||||
if (m_validListenerCount == 1) {
|
||||
for (size_t i = 0; i < MAX_LOCAL_PLAYERS; i++) {
|
||||
if (m_ListenerA[i].bValid) {
|
||||
ma_engine_listener_set_position(
|
||||
&m_audio->engine, 0, m_ListenerA[i].vPosition.x,
|
||||
m_ListenerA[i].vPosition.y, m_ListenerA[i].vPosition.z);
|
||||
|
||||
ma_engine_listener_set_direction(&m_audio->engine, 0,
|
||||
m_ListenerA[i].vOrientFront.x,
|
||||
m_ListenerA[i].vOrientFront.y,
|
||||
m_ListenerA[i].vOrientFront.z);
|
||||
|
||||
ma_engine_listener_set_world_up(&m_audio->engine, 0, 0.0f, 1.0f,
|
||||
0.0f);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ma_engine_listener_set_position(&m_audio->engine, 0, 0.0f, 0.0f, 0.0f);
|
||||
ma_engine_listener_set_direction(&m_audio->engine, 0, 0.0f, 0.0f, 1.0f);
|
||||
ma_engine_listener_set_world_up(&m_audio->engine, 0, 0.0f, 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
for (auto it = m_activeSounds.begin(); it != m_activeSounds.end();) {
|
||||
MiniAudioSound* s = *it;
|
||||
|
||||
if (!ma_sound_is_playing(&s->sound)) {
|
||||
ma_sound_uninit(&s->sound);
|
||||
delete s;
|
||||
it = m_activeSounds.erase(it);
|
||||
continue;
|
||||
}
|
||||
|
||||
float finalVolume =
|
||||
s->info.volume * m_MasterEffectsVolume * SFX_VOLUME_MULTIPLIER;
|
||||
if (finalVolume > SFX_MAX_GAIN) finalVolume = SFX_MAX_GAIN;
|
||||
|
||||
ma_sound_set_volume(&s->sound, finalVolume);
|
||||
ma_sound_set_pitch(&s->sound, s->info.pitch);
|
||||
|
||||
if (s->info.bIs3D) {
|
||||
if (m_validListenerCount > 1) {
|
||||
float fClosest = 10000.0f;
|
||||
int iClosestListener = 0;
|
||||
float fClosestX = 0.0f, fClosestY = 0.0f, fClosestZ = 0.0f,
|
||||
fDist;
|
||||
for (size_t i = 0; i < MAX_LOCAL_PLAYERS; i++) {
|
||||
if (m_ListenerA[i].bValid) {
|
||||
float x, y, z;
|
||||
|
||||
x = fabs(m_ListenerA[i].vPosition.x - s->info.x);
|
||||
y = fabs(m_ListenerA[i].vPosition.y - s->info.y);
|
||||
z = fabs(m_ListenerA[i].vPosition.z - s->info.z);
|
||||
fDist = x + y + z;
|
||||
|
||||
if (fDist < fClosest) {
|
||||
fClosest = fDist;
|
||||
fClosestX = x;
|
||||
fClosestY = y;
|
||||
fClosestZ = z;
|
||||
iClosestListener = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float realDist =
|
||||
sqrtf((fClosestX * fClosestX) + (fClosestY * fClosestY) +
|
||||
(fClosestZ * fClosestZ));
|
||||
ma_sound_set_position(&s->sound, 0, 0, realDist);
|
||||
} else {
|
||||
ma_sound_set_position(&s->sound, s->info.x, s->info.y,
|
||||
s->info.z);
|
||||
}
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundEngine::tick(std::shared_ptr<Mob>* players, float a) {
|
||||
// update the listener positions
|
||||
int listenerCount = 0;
|
||||
if (players) {
|
||||
bool bListenerPostionSet = false;
|
||||
for (size_t i = 0; i < MAX_LOCAL_PLAYERS; i++) {
|
||||
if (players[i] != nullptr) {
|
||||
m_ListenerA[i].bValid = true;
|
||||
F32 x, y, z;
|
||||
x = players[i]->xo + (players[i]->x - players[i]->xo) * a;
|
||||
y = players[i]->yo + (players[i]->y - players[i]->yo) * a;
|
||||
z = players[i]->zo + (players[i]->z - players[i]->zo) * a;
|
||||
|
||||
float yRot = players[i]->yRotO +
|
||||
(players[i]->yRot - players[i]->yRotO) * a;
|
||||
float yCos = (float)cos(yRot * Mth::DEG_TO_RAD);
|
||||
float ySin = (float)sin(yRot * Mth::DEG_TO_RAD);
|
||||
|
||||
// store the listener positions for splitscreen
|
||||
m_ListenerA[i].vPosition.x = x;
|
||||
m_ListenerA[i].vPosition.y = y;
|
||||
m_ListenerA[i].vPosition.z = z;
|
||||
|
||||
m_ListenerA[i].vOrientFront.x = -ySin;
|
||||
m_ListenerA[i].vOrientFront.y = 0;
|
||||
m_ListenerA[i].vOrientFront.z = yCos;
|
||||
|
||||
listenerCount++;
|
||||
} else {
|
||||
m_ListenerA[i].bValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there were no valid players set, make up a default listener
|
||||
if (listenerCount == 0) {
|
||||
m_ListenerA[0].vPosition.x = 0;
|
||||
m_ListenerA[0].vPosition.y = 0;
|
||||
m_ListenerA[0].vPosition.z = 0;
|
||||
m_ListenerA[0].vOrientFront.x = 0;
|
||||
m_ListenerA[0].vOrientFront.y = 0;
|
||||
m_ListenerA[0].vOrientFront.z = 1.0f;
|
||||
listenerCount++;
|
||||
}
|
||||
m_validListenerCount = listenerCount;
|
||||
updateMiniAudio();
|
||||
}
|
||||
|
||||
// Universal, these functions shouldn't need platform specific
|
||||
// implementations
|
||||
void SoundEngine::updateMusicVolume(float fVal) { m_MasterMusicVolume = fVal; }
|
||||
void SoundEngine::updateSystemMusicPlaying(bool isPlaying) {
|
||||
m_bSystemMusicPlaying = isPlaying;
|
||||
}
|
||||
void SoundEngine::updateSoundEffectVolume(float fVal) {
|
||||
m_MasterEffectsVolume = fVal;
|
||||
}
|
||||
void SoundEngine::SetStreamingSounds(int iOverworldMin, int iOverWorldMax,
|
||||
int iNetherMin, int iNetherMax,
|
||||
int iEndMin, int iEndMax, int iCD1) {
|
||||
m_iStream_Overworld_Min = iOverworldMin;
|
||||
m_iStream_Overworld_Max = iOverWorldMax;
|
||||
m_iStream_Nether_Min = iNetherMin;
|
||||
m_iStream_Nether_Max = iNetherMax;
|
||||
m_iStream_End_Min = iEndMin;
|
||||
m_iStream_End_Max = iEndMax;
|
||||
m_iStream_CD_1 = iCD1;
|
||||
|
||||
// array to monitor recently played tracks
|
||||
if (m_bHeardTrackA) {
|
||||
delete[] m_bHeardTrackA;
|
||||
}
|
||||
m_bHeardTrackA = new bool[iEndMax + 1];
|
||||
memset(m_bHeardTrackA, 0, sizeof(bool) * (iEndMax + 1));
|
||||
}
|
||||
int SoundEngine::GetRandomishTrack(int iStart, int iEnd) {
|
||||
// 4J-PB - make it more likely that we'll get a track we've not heard for a
|
||||
// while, although repeating tracks sometimes is fine
|
||||
|
||||
// if all tracks have been heard, clear the flags
|
||||
bool bAllTracksHeard = true;
|
||||
int iVal = iStart;
|
||||
for (size_t i = iStart; i <= iEnd; i++) {
|
||||
if (m_bHeardTrackA[i] == false) {
|
||||
bAllTracksHeard = false;
|
||||
app.DebugPrintf("Not heard all tracks yet\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bAllTracksHeard) {
|
||||
app.DebugPrintf("Heard all tracks - resetting the tracking array\n");
|
||||
|
||||
for (size_t i = iStart; i <= iEnd; i++) {
|
||||
m_bHeardTrackA[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// trying to get a track we haven't heard, but not too hard
|
||||
for (size_t i = 0; i <= ((iEnd - iStart) / 2); i++) {
|
||||
// random->nextInt(1) will always return 0
|
||||
iVal = random->nextInt((iEnd - iStart) + 1) + iStart;
|
||||
if (m_bHeardTrackA[iVal] == false) {
|
||||
// not heard this
|
||||
app.DebugPrintf("(%d) Not heard track %d yet, so playing it now\n",
|
||||
i, iVal);
|
||||
m_bHeardTrackA[iVal] = true;
|
||||
break;
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"(%d) Skipping track %d already heard it recently\n", i, iVal);
|
||||
}
|
||||
}
|
||||
|
||||
app.DebugPrintf("Select track %d\n", iVal);
|
||||
return iVal;
|
||||
}
|
||||
float SoundEngine::getMasterMusicVolume() {
|
||||
if (m_bSystemMusicPlaying) {
|
||||
return 0.0f;
|
||||
} else {
|
||||
return m_MasterMusicVolume;
|
||||
}
|
||||
}
|
||||
void SoundEngine::add(const std::string& name, File* file) {}
|
||||
|
||||
void SoundEngine::addMusic(const std::string& name, File* file) {}
|
||||
void SoundEngine::addStreaming(const std::string& name, File* file) {}
|
||||
|
||||
bool SoundEngine::isStreamingWavebankReady() { return true; }
|
||||
// This is unused by the linux version, it'll need to be changed
|
||||
char* SoundEngine::ConvertSoundPathToName(const std::string& name,
|
||||
bool bConvertSpaces) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1,228 +0,0 @@
|
||||
#include "app/common/Audio/ConsoleSoundEngine.h"
|
||||
#include "app/common/Audio/SoundTypes.h"
|
||||
|
||||
const char* ConsoleSoundEngine::wchSoundNames[eSoundType_MAX] = {
|
||||
"mob/chicken/chicken", // eSoundType_MOB_CHICKEN_AMBIENT
|
||||
"mob/chicken/chickenhurt", // eSoundType_MOB_CHICKEN_HURT
|
||||
"mob/chicken/chickenplop", // eSoundType_MOB_CHICKENPLOP
|
||||
"mob/cow/say", // eSoundType_MOB_COW_AMBIENT
|
||||
"mob/cow/hurt", // eSoundType_MOB_COW_HURT
|
||||
"mob/pig/pig", // eSoundType_MOB_PIG_AMBIENT
|
||||
"mob/pig/pigdeath", // eSoundType_MOB_PIG_DEATH
|
||||
"mob/sheep/sheep", // eSoundType_MOB_SHEEP_AMBIENT
|
||||
"mob/wolf/growl", // eSoundType_MOB_WOLF_GROWL
|
||||
"mob/wolf/whine", // eSoundType_MOB_WOLF_WHINE
|
||||
"mob/wolf/panting", // eSoundType_MOB_WOLF_PANTING
|
||||
"mob/wolf/bark", // eSoundType_MOB_WOLF_BARK
|
||||
"mob/wolf/hurt", // eSoundType_MOB_WOLF_HURT
|
||||
"mob/wolf/death", // eSoundType_MOB_WOLF_DEATH
|
||||
"mob/wolf/shake", // eSoundType_MOB_WOLF_SHAKE
|
||||
"mob/blaze/breathe", // eSoundType_MOB_BLAZE_BREATHE
|
||||
"mob/blaze/hit", // eSoundType_MOB_BLAZE_HURT
|
||||
"mob/blaze/death", // eSoundType_MOB_BLAZE_DEATH
|
||||
"mob/ghast/moan", // eSoundType_MOB_GHAST_MOAN
|
||||
"mob/ghast/scream", // eSoundType_MOB_GHAST_SCREAM
|
||||
"mob/ghast/death", // eSoundType_MOB_GHAST_DEATH
|
||||
"mob/ghast/fireball", // eSoundType_MOB_GHAST_FIREBALL
|
||||
"mob/ghast/charge", // eSoundType_MOB_GHAST_CHARGE
|
||||
"mob/endermen/idle", // eSoundType_MOB_ENDERMEN_IDLE
|
||||
"mob/endermen/hit", // eSoundType_MOB_ENDERMEN_HIT
|
||||
"mob/endermen/death", // eSoundType_MOB_ENDERMEN_DEATH
|
||||
"mob/endermen/portal", // eSoundType_MOB_ENDERMEN_PORTAL
|
||||
"mob/zombiepig/zpig", // eSoundType_MOB_ZOMBIEPIG_AMBIENT
|
||||
"mob/zombiepig/zpighurt", // eSoundType_MOB_ZOMBIEPIG_HURT
|
||||
"mob/zombiepig/zpigdeath", // eSoundType_MOB_ZOMBIEPIG_DEATH
|
||||
"mob/zombiepig/zpigangry", // eSoundType_MOB_ZOMBIEPIG_ZPIGANGRY
|
||||
"mob/silverfish/say", // eSoundType_MOB_SILVERFISH_AMBIENT,
|
||||
"mob/silverfish/hit", // eSoundType_MOB_SILVERFISH_HURT
|
||||
"mob/silverfish/kill", // eSoundType_MOB_SILVERFISH_DEATH,
|
||||
"mob/silverfish/step", // eSoundType_MOB_SILVERFISH_STEP,
|
||||
"mob/skeleton/skeleton", // eSoundType_MOB_SKELETON_AMBIENT,
|
||||
"mob/skeleton/skeletonhurt", // eSoundType_MOB_SKELETON_HURT,
|
||||
"mob/spider/spider", // eSoundType_MOB_SPIDER_AMBIENT,
|
||||
"mob/spider/spiderdeath", // eSoundType_MOB_SPIDER_DEATH,
|
||||
"mob/slime/slime", // eSoundType_MOB_SLIME,
|
||||
"mob/slime/slimeattack", // eSoundType_MOB_SLIME_ATTACK,
|
||||
"mob/creeper/creeper", // eSoundType_MOB_CREEPER_HURT,
|
||||
"mob/creeper/creeperdeath", // eSoundType_MOB_CREEPER_DEATH,
|
||||
"mob/zombie/zombie", // eSoundType_MOB_ZOMBIE_AMBIENT,
|
||||
"mob/zombie/zombiehurt", // eSoundType_MOB_ZOMBIE_HURT,
|
||||
"mob/zombie/zombiedeath", // eSoundType_MOB_ZOMBIE_DEATH,
|
||||
"mob/zombie/wood", // eSoundType_MOB_ZOMBIE_WOOD,
|
||||
"mob/zombie/woodbreak", // eSoundType_MOB_ZOMBIE_WOOD_BREAK,
|
||||
"mob/zombie/metal", // eSoundType_MOB_ZOMBIE_METAL,
|
||||
"mob/magmacube/big", // eSoundType_MOB_MAGMACUBE_BIG,
|
||||
"mob/magmacube/small", // eSoundType_MOB_MAGMACUBE_SMALL,
|
||||
"mob/cat/purr", // eSoundType_MOB_CAT_PURR
|
||||
"mob/cat/purreow", // eSoundType_MOB_CAT_PURREOW
|
||||
"mob/cat/meow", // eSoundType_MOB_CAT_MEOW
|
||||
// 4J-PB - correct the name of the event for hitting ocelots
|
||||
"mob/cat/hitt", // eSoundType_MOB_CAT_HITT
|
||||
// "mob.irongolem.throw", //
|
||||
// eSoundType_MOB_IRONGOLEM_THROW "mob.irongolem.hit",
|
||||
//// eSoundType_MOB_IRONGOLEM_HIT "mob.irongolem.death",
|
||||
//// eSoundType_MOB_IRONGOLEM_DEATH "mob.irongolem.walk",
|
||||
//// eSoundType_MOB_IRONGOLEM_WALK
|
||||
"random/bow", // eSoundType_RANDOM_BOW,
|
||||
"random/bowhit", // eSoundType_RANDOM_BOW_HIT,
|
||||
"random/explode", // eSoundType_RANDOM_EXPLODE,
|
||||
"random/fizz", // eSoundType_RANDOM_FIZZ,
|
||||
"random/pop", // eSoundType_RANDOM_POP,
|
||||
"random/fuse", // eSoundType_RANDOM_FUSE,
|
||||
"random/drink", // eSoundType_RANDOM_DRINK,
|
||||
"random/eat", // eSoundType_RANDOM_EAT,
|
||||
"random/burp", // eSoundType_RANDOM_BURP,
|
||||
"random/splash", // eSoundType_RANDOM_SPLASH,
|
||||
"random/click", // eSoundType_RANDOM_CLICK,
|
||||
"random/glass", // eSoundType_RANDOM_GLASS,
|
||||
"random/orb", // eSoundType_RANDOM_ORB,
|
||||
"random/break", // eSoundType_RANDOM_BREAK,
|
||||
"random/chestopen", // eSoundType_RANDOM_CHEST_OPEN,
|
||||
"random/chestclosed", // eSoundType_RANDOM_CHEST_CLOSE,
|
||||
"random/door_open", // eSoundType_RANDOM_DOOR_OPEN,
|
||||
"random/door_close", // eSoundType_RANDOM_DOOR_CLOSE,
|
||||
"ambient/weather/rain", // eSoundType_AMBIENT_WEATHER_RAIN,
|
||||
"ambient/weather/thunder", // eSoundType_AMBIENT_WEATHER_THUNDER,
|
||||
"ambient/cave/cave", // eSoundType_CAVE_CAVE, DON'T USE FOR XBOX 360!!!
|
||||
"portal/portal", // eSoundType_PORTAL_PORTAL,
|
||||
// 4J-PB - added a couple that were still using std::string
|
||||
"portal/trigger", // eSoundType_PORTAL_TRIGGER
|
||||
"portal/travel", // eSoundType_PORTAL_TRAVEL
|
||||
|
||||
"fire/ignite", // eSoundType_FIRE_IGNITE,
|
||||
"fire/fire", // eSoundType_FIRE_FIRE,
|
||||
"damage/hit", // eSoundType_DAMAGE_HURT,
|
||||
"damage/fallsmall", // eSoundType_DAMAGE_FALL_SMALL,
|
||||
"damage/fallbig", // eSoundType_DAMAGE_FALL_BIG,
|
||||
"note/harp", // eSoundType_NOTE_HARP,
|
||||
"note/bd", // eSoundType_NOTE_BD,
|
||||
"note/snare", // eSoundType_NOTE_SNARE,
|
||||
"note/hat", // eSoundType_NOTE_HAT,
|
||||
"note/bassattack", // eSoundType_NOTE_BASSATTACK,
|
||||
"tile/piston.in", // eSoundType_TILE_PISTON_IN,
|
||||
"tile/piston.out", // eSoundType_TILE_PISTON_OUT,
|
||||
"liquid/water", // eSoundType_LIQUID_WATER,
|
||||
"liquid/lavapop", // eSoundType_LIQUID_LAVA_POP,
|
||||
"liquid/lava", // eSoundType_LIQUID_LAVA,
|
||||
"step/stone", // eSoundType_STEP_STONE,
|
||||
"step/wood", // eSoundType_STEP_WOOD,
|
||||
"step/gravel", // eSoundType_STEP_GRAVEL,
|
||||
"step/grass", // eSoundType_STEP_GRASS,
|
||||
"step/metal", // eSoundType_STEP_METAL,
|
||||
"step/cloth", // eSoundType_STEP_CLOTH,
|
||||
"step/sand", // eSoundType_STEP_SAND,
|
||||
|
||||
// below this are the additional sounds from the second soundbank
|
||||
"mob/enderdragon/end", // eSoundType_MOB_ENDERDRAGON_END
|
||||
"mob/enderdragon/growl", // eSoundType_MOB_ENDERDRAGON_GROWL
|
||||
"mob/enderdragon/hit", // eSoundType_MOB_ENDERDRAGON_HIT
|
||||
"mob/enderdragon/wings", // eSoundType_MOB_ENDERDRAGON_MOVE
|
||||
"mob/irongolem/throw", // eSoundType_MOB_IRONGOLEM_THROW
|
||||
"mob/irongolem/hit", // eSoundType_MOB_IRONGOLEM_HIT
|
||||
"mob/irongolem/death", // eSoundType_MOB_IRONGOLEM_DEATH
|
||||
"mob/irongolem/walk", // eSoundType_MOB_IRONGOLEM_WALK
|
||||
|
||||
// TU14
|
||||
"damage/thorns", // eSoundType_DAMAGE_THORNS
|
||||
"random/anvil_break", // eSoundType_RANDOM_ANVIL_BREAK
|
||||
"random/anvil_land", // eSoundType_RANDOM_ANVIL_LAND
|
||||
"random/anvil_use", // eSoundType_RANDOM_ANVIL_USE
|
||||
"mob/villager/haggle", // eSoundType_MOB_VILLAGER_HAGGLE
|
||||
"mob/villager/idle", // eSoundType_MOB_VILLAGER_IDLE
|
||||
"mob/villager/hit", // eSoundType_MOB_VILLAGER_HIT
|
||||
"mob/villager/death", // eSoundType_MOB_VILLAGER_DEATH
|
||||
"mob/villager/yes", // eSoundType_MOB_VILLAGER_YES
|
||||
"mob/villager/no", // eSoundType_MOB_VILLAGER_NO
|
||||
"mob/zombie/infect", // eSoundType_MOB_ZOMBIE_INFECT
|
||||
"mob/zombie/unfect", // eSoundType_MOB_ZOMBIE_UNFECT
|
||||
"mob/zombie/remedy", // eSoundType_MOB_ZOMBIE_REMEDY
|
||||
"step/snow", // eSoundType_STEP_SNOW
|
||||
"step/ladder", // eSoundType_STEP_LADDER
|
||||
"dig/cloth", // eSoundType_DIG_CLOTH
|
||||
"dig/grass", // eSoundType_DIG_GRASS
|
||||
"dig/gravel", // eSoundType_DIG_GRAVEL
|
||||
"dig/sand", // eSoundType_DIG_SAND
|
||||
"dig/snow", // eSoundType_DIG_SNOW
|
||||
"dig/stone", // eSoundType_DIG_STONE
|
||||
"dig/wood", // eSoundType_DIG_WOOD
|
||||
|
||||
// 1.6.4
|
||||
"fireworks/launch", // eSoundType_FIREWORKS_LAUNCH,
|
||||
"fireworks/blast", // eSoundType_FIREWORKS_BLAST,
|
||||
"fireworks/blast_far", // eSoundType_FIREWORKS_BLAST_FAR,
|
||||
"fireworks/large_blast", // eSoundType_FIREWORKS_LARGE_BLAST,
|
||||
"fireworks/large_blast_far", // eSoundType_FIREWORKS_LARGE_BLAST_FAR,
|
||||
"fireworks/twinkle", // eSoundType_FIREWORKS_TWINKLE,
|
||||
"fireworks/twinkle_far", // eSoundType_FIREWORKS_TWINKLE_FAR,
|
||||
|
||||
"mob/bat/idle", // eSoundType_MOB_BAT_IDLE,
|
||||
"mob/bat/hurt", // eSoundType_MOB_BAT_HURT,
|
||||
"mob/bat/death", // eSoundType_MOB_BAT_DEATH,
|
||||
"mob/bat/takeoff", // eSoundType_MOB_BAT_TAKEOFF,
|
||||
|
||||
"mob/wither/spawn", // eSoundType_MOB_WITHER_SPAWN,
|
||||
"mob/wither/idle", // eSoundType_MOB_WITHER_IDLE,
|
||||
"mob/wither/hurt", // eSoundType_MOB_WITHER_HURT,
|
||||
"mob/wither/death", // eSoundType_MOB_WITHER_DEATH,
|
||||
"mob/wither/shoot", // eSoundType_MOB_WITHER_SHOOT,
|
||||
|
||||
"mob/cow/step", // eSoundType_MOB_COW_STEP,
|
||||
"mob/chicken/step", // eSoundType_MOB_CHICKEN_STEP,
|
||||
"mob/pig/step", // eSoundType_MOB_PIG_STEP,
|
||||
"mob/enderman/stare", // eSoundType_MOB_ENDERMAN_STARE,
|
||||
"mob/enderman/scream", // eSoundType_MOB_ENDERMAN_SCREAM,
|
||||
"mob/sheep/shear", // eSoundType_MOB_SHEEP_SHEAR,
|
||||
"mob/sheep/step", // eSoundType_MOB_SHEEP_STEP,
|
||||
"mob/skeleton.death", // eSoundType_MOB_SKELETON_DEATH,
|
||||
"mob/skeleton/step", // eSoundType_MOB_SKELETON_STEP,
|
||||
"mob/spider/step", // eSoundType_MOB_SPIDER_STEP,
|
||||
"mob/wolf/step", // eSoundType_MOB_WOLF_STEP,
|
||||
"mob/zombie/step", // eSoundType_MOB_ZOMBIE_STEP,
|
||||
|
||||
"liquid/swim", // eSoundType_LIQUID_SWIM,
|
||||
|
||||
"mob/horse/land", // eSoundType_MOB_HORSE_LAND,
|
||||
"mob/horse/armor", // eSoundType_MOB_HORSE_ARMOR,
|
||||
"mob/horse/leather", // eSoundType_MOB_HORSE_LEATHER,
|
||||
"mob/horse/zombie.death", // eSoundType_MOB_HORSE_ZOMBIE_DEATH,
|
||||
"mob/horse/skeleton.death", // eSoundType_MOB_HORSE_SKELETON_DEATH,
|
||||
"mob/horse/donkey.death", // eSoundType_MOB_HORSE_DONKEY_DEATH,
|
||||
"mob/horse/death", // eSoundType_MOB_HORSE_DEATH,
|
||||
"mob/horse/zombie.hit", // eSoundType_MOB_HORSE_ZOMBIE_HIT,
|
||||
"mob/horse/skeleton.hit", // eSoundType_MOB_HORSE_SKELETON_HIT,
|
||||
"mob/horse/donkey.hit", // eSoundType_MOB_HORSE_DONKEY_HIT,
|
||||
"mob/horse/hit", // eSoundType_MOB_HORSE_HIT,
|
||||
"mob/horse/zombie.idle", // eSoundType_MOB_HORSE_ZOMBIE_IDLE,
|
||||
"mob/horse/skeleton.idle", // eSoundType_MOB_HORSE_SKELETON_IDLE,
|
||||
"mob/horse/donkey.idle", // eSoundType_MOB_HORSE_DONKEY_IDLE,
|
||||
"mob/horse/idle", // eSoundType_MOB_HORSE_IDLE,
|
||||
"mob/horse/donkey.angry", // eSoundType_MOB_HORSE_DONKEY_ANGRY,
|
||||
"mob/horse/angry", // eSoundType_MOB_HORSE_ANGRY,
|
||||
"mob/horse/gallop", // eSoundType_MOB_HORSE_GALLOP,
|
||||
"mob/horse/breathe", // eSoundType_MOB_HORSE_BREATHE,
|
||||
"mob/horse/wood", // eSoundType_MOB_HORSE_WOOD,
|
||||
"mob/horse/soft", // eSoundType_MOB_HORSE_SOFT,
|
||||
"mob/horse/jump", // eSoundType_MOB_HORSE_JUMP,
|
||||
|
||||
"mob/witch/idle", // eSoundType_MOB_WITCH_IDLE, <---
|
||||
// missing
|
||||
"mob/witch/hurt", // eSoundType_MOB_WITCH_HURT, <---
|
||||
// missing
|
||||
"mob/witch/death", // eSoundType_MOB_WITCH_DEATH, <---
|
||||
// missing
|
||||
|
||||
"mob/slime/big", // eSoundType_MOB_SLIME_BIG,
|
||||
"mob/slime/small", // eSoundType_MOB_SLIME_SMALL,
|
||||
|
||||
"eating", // eSoundType_EATING <--- missing
|
||||
"random/levelup", // eSoundType_RANDOM_LEVELUP
|
||||
|
||||
// 4J-PB - Some sounds were updated, but we can't do that for the 360 or we
|
||||
// have to do a new sound bank instead, we'll add the sounds as new ones and
|
||||
// change the code to reference them
|
||||
"fire/new_ignite",
|
||||
};
|
||||
|
||||
const char* ConsoleSoundEngine::wchUISoundNames[eSFX_MAX] = {
|
||||
"back", "craft", "craftfail", "focus", "press", "scroll",
|
||||
};
|
||||
@@ -1,128 +0,0 @@
|
||||
#include "app/common/BannedListManager.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "platform/XboxStubs.h"
|
||||
|
||||
BannedListManager::BannedListManager() {
|
||||
m_pBannedListFileBuffer = nullptr;
|
||||
m_dwBannedListFileSize = 0;
|
||||
std::memset(m_pszUniqueMapName, 0, 14);
|
||||
|
||||
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
|
||||
m_bRead_BannedListA[i] = false;
|
||||
m_BanListCheck[i] = false;
|
||||
m_vBannedListA[i] = new std::vector<PBANNEDLISTDATA>;
|
||||
}
|
||||
}
|
||||
|
||||
void BannedListManager::invalidate(int iPad) {
|
||||
if (m_bRead_BannedListA[iPad] == true) {
|
||||
m_bRead_BannedListA[iPad] = false;
|
||||
setBanListCheck(iPad, false);
|
||||
m_vBannedListA[iPad]->clear();
|
||||
|
||||
if (BannedListA[iPad].pBannedList) {
|
||||
delete[] BannedListA[iPad].pBannedList;
|
||||
BannedListA[iPad].pBannedList = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BannedListManager::addLevel(int iPad, PlayerUID xuid, char* pszLevelName,
|
||||
bool bWriteToTMS) {
|
||||
// we will have retrieved the banned level list from TMS, so add this one to
|
||||
// it and write it back to TMS
|
||||
|
||||
BANNEDLISTDATA* pBannedListData = new BANNEDLISTDATA;
|
||||
memset(pBannedListData, 0, sizeof(BANNEDLISTDATA));
|
||||
|
||||
memcpy(&pBannedListData->xuid, &xuid, sizeof(PlayerUID));
|
||||
strcpy(pBannedListData->pszLevelName, pszLevelName);
|
||||
m_vBannedListA[iPad]->push_back(pBannedListData);
|
||||
|
||||
if (bWriteToTMS) {
|
||||
const std::size_t bannedListCount = m_vBannedListA[iPad]->size();
|
||||
const unsigned int dataBytes =
|
||||
static_cast<unsigned int>(sizeof(BANNEDLISTDATA) * bannedListCount);
|
||||
PBANNEDLISTDATA pBannedList = new BANNEDLISTDATA[bannedListCount];
|
||||
int iCount = 0;
|
||||
for (auto it = m_vBannedListA[iPad]->begin();
|
||||
it != m_vBannedListA[iPad]->end(); ++it) {
|
||||
PBANNEDLISTDATA pData = *it;
|
||||
memcpy(&pBannedList[iCount++], pData, sizeof(BANNEDLISTDATA));
|
||||
}
|
||||
|
||||
// 4J-PB - write to TMS++ now
|
||||
|
||||
// bool
|
||||
// bRes=PlatformStorage.WriteTMSFile(iPad,IPlatformStorage::eGlobalStorage_TitleUser,"BannedList",(std::uint8_t*)pBannedList,
|
||||
// dwDataBytes);
|
||||
|
||||
delete[] pBannedList;
|
||||
}
|
||||
// update telemetry too
|
||||
}
|
||||
|
||||
bool BannedListManager::isInList(int iPad, PlayerUID xuid, char* pszLevelName) {
|
||||
for (auto it = m_vBannedListA[iPad]->begin();
|
||||
it != m_vBannedListA[iPad]->end(); ++it) {
|
||||
PBANNEDLISTDATA pData = *it;
|
||||
if (IsEqualXUID(pData->xuid, xuid) &&
|
||||
(strcmp(pData->pszLevelName, pszLevelName) == 0)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void BannedListManager::removeLevel(int iPad, PlayerUID xuid,
|
||||
char* pszLevelName) {
|
||||
// bool bFound=false;
|
||||
// bool bRes;
|
||||
|
||||
// we will have retrieved the banned level list from TMS, so remove this one
|
||||
// from it and write it back to TMS
|
||||
for (auto it = m_vBannedListA[iPad]->begin();
|
||||
it != m_vBannedListA[iPad]->end();) {
|
||||
PBANNEDLISTDATA pBannedListData = *it;
|
||||
|
||||
if (pBannedListData != nullptr) {
|
||||
if (IsEqualXUID(pBannedListData->xuid, xuid) &&
|
||||
(strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) {
|
||||
// match found, so remove this entry
|
||||
it = m_vBannedListA[iPad]->erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
const std::size_t bannedListCount = m_vBannedListA[iPad]->size();
|
||||
const unsigned int dataBytes =
|
||||
static_cast<unsigned int>(sizeof(BANNEDLISTDATA) * bannedListCount);
|
||||
if (dataBytes == 0) {
|
||||
// wipe the file
|
||||
} else {
|
||||
PBANNEDLISTDATA pBannedList =
|
||||
(BANNEDLISTDATA*)(new std::uint8_t[dataBytes]);
|
||||
|
||||
for (std::size_t i = 0; i < bannedListCount; ++i) {
|
||||
PBANNEDLISTDATA pBannedListData = m_vBannedListA[iPad]->at(i);
|
||||
|
||||
memcpy(&pBannedList[i], pBannedListData, sizeof(BANNEDLISTDATA));
|
||||
}
|
||||
delete[] pBannedList;
|
||||
}
|
||||
|
||||
// update telemetry too
|
||||
}
|
||||
|
||||
void BannedListManager::setUniqueMapName(char* pszUniqueMapName) {
|
||||
memcpy(m_pszUniqueMapName, pszUniqueMapName, 14);
|
||||
}
|
||||
|
||||
char* BannedListManager::getUniqueMapName() { return m_pszUniqueMapName; }
|
||||
@@ -1,46 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
|
||||
class BannedListManager {
|
||||
public:
|
||||
BannedListManager();
|
||||
|
||||
void invalidate(int iPad);
|
||||
void addLevel(int iPad, PlayerUID xuid, char* pszLevelName,
|
||||
bool bWriteToTMS);
|
||||
bool isInList(int iPad, PlayerUID xuid, char* pszLevelName);
|
||||
void removeLevel(int iPad, PlayerUID xuid, char* pszLevelName);
|
||||
|
||||
void setUniqueMapName(char* pszUniqueMapName);
|
||||
char* getUniqueMapName();
|
||||
|
||||
void setBanListCheck(int iPad, bool bVal) { m_BanListCheck[iPad] = bVal; }
|
||||
bool getBanListCheck(int iPad) const { return m_BanListCheck[iPad]; }
|
||||
|
||||
bool getBanListRead(int iPad) const { return m_bRead_BannedListA[iPad]; }
|
||||
void setBanListRead(int iPad, bool bVal) {
|
||||
m_bRead_BannedListA[iPad] = bVal;
|
||||
}
|
||||
|
||||
void clearBanList(int iPad) {
|
||||
BannedListA[iPad].pBannedList = nullptr;
|
||||
BannedListA[iPad].byteCount = 0;
|
||||
}
|
||||
|
||||
BANNEDLIST BannedListA[XUSER_MAX_COUNT];
|
||||
|
||||
std::uint8_t* m_pBannedListFileBuffer;
|
||||
unsigned int m_dwBannedListFileSize;
|
||||
|
||||
private:
|
||||
VBANNEDLIST* m_vBannedListA[XUSER_MAX_COUNT];
|
||||
bool m_bRead_BannedListA[XUSER_MAX_COUNT];
|
||||
char m_pszUniqueMapName[14];
|
||||
bool m_BanListCheck[XUSER_MAX_COUNT];
|
||||
};
|
||||
@@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "DLCFile.h"
|
||||
#include "minecraft/world/level/GameRules/LevelGenerationOptions.h"
|
||||
|
||||
class DLCGameRules : public DLCFile {
|
||||
public:
|
||||
DLCGameRules(DLCManager::EDLCType type, const std::string& path)
|
||||
: DLCFile(type, path) {}
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
#include "DLCLocalisationFile.h"
|
||||
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/DLC/DLCFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "minecraft/locale/StringTable.h"
|
||||
|
||||
DLCLocalisationFile::DLCLocalisationFile(const std::string& path)
|
||||
: DLCFile(DLCManager::e_DLCType_LocalisationData, path) {
|
||||
m_strings = nullptr;
|
||||
}
|
||||
|
||||
void DLCLocalisationFile::addData(std::uint8_t* pbData,
|
||||
std::uint32_t dataBytes) {
|
||||
m_strings = new StringTable(
|
||||
std::span<const std::uint8_t>(pbData, dataBytes), app.getLocale());
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "minecraft/world/level/dlc/DLCConstants.h"
|
||||
|
||||
class DLCPack;
|
||||
class DLCSkinFile;
|
||||
|
||||
class DLCManager {
|
||||
public:
|
||||
// Re-export the file-scope enums as nested type aliases so existing
|
||||
// app-side call sites that use DLCManager::EDLCType /
|
||||
// DLCManager::e_DLCType_Texture continue to compile. minecraft/-side
|
||||
// call sites should use the namespaced names from DLCConstants.h
|
||||
// directly.
|
||||
using EDLCType = ::minecraft::dlc::EDLCType;
|
||||
using EDLCParameterType = ::minecraft::dlc::EDLCParameterType;
|
||||
|
||||
static constexpr EDLCType e_DLCType_Skin = ::minecraft::dlc::e_DLCType_Skin;
|
||||
static constexpr EDLCType e_DLCType_Cape = ::minecraft::dlc::e_DLCType_Cape;
|
||||
static constexpr EDLCType e_DLCType_Texture =
|
||||
::minecraft::dlc::e_DLCType_Texture;
|
||||
static constexpr EDLCType e_DLCType_UIData =
|
||||
::minecraft::dlc::e_DLCType_UIData;
|
||||
static constexpr EDLCType e_DLCType_PackConfig =
|
||||
::minecraft::dlc::e_DLCType_PackConfig;
|
||||
static constexpr EDLCType e_DLCType_TexturePack =
|
||||
::minecraft::dlc::e_DLCType_TexturePack;
|
||||
static constexpr EDLCType e_DLCType_LocalisationData =
|
||||
::minecraft::dlc::e_DLCType_LocalisationData;
|
||||
static constexpr EDLCType e_DLCType_GameRules =
|
||||
::minecraft::dlc::e_DLCType_GameRules;
|
||||
static constexpr EDLCType e_DLCType_Audio =
|
||||
::minecraft::dlc::e_DLCType_Audio;
|
||||
static constexpr EDLCType e_DLCType_ColourTable =
|
||||
::minecraft::dlc::e_DLCType_ColourTable;
|
||||
static constexpr EDLCType e_DLCType_GameRulesHeader =
|
||||
::minecraft::dlc::e_DLCType_GameRulesHeader;
|
||||
static constexpr EDLCType e_DLCType_Max = ::minecraft::dlc::e_DLCType_Max;
|
||||
static constexpr EDLCType e_DLCType_All = ::minecraft::dlc::e_DLCType_All;
|
||||
|
||||
static constexpr EDLCParameterType e_DLCParamType_Invalid =
|
||||
::minecraft::dlc::e_DLCParamType_Invalid;
|
||||
static constexpr EDLCParameterType e_DLCParamType_DisplayName =
|
||||
::minecraft::dlc::e_DLCParamType_DisplayName;
|
||||
static constexpr EDLCParameterType e_DLCParamType_ThemeName =
|
||||
::minecraft::dlc::e_DLCParamType_ThemeName;
|
||||
static constexpr EDLCParameterType e_DLCParamType_Free =
|
||||
::minecraft::dlc::e_DLCParamType_Free;
|
||||
static constexpr EDLCParameterType e_DLCParamType_Credit =
|
||||
::minecraft::dlc::e_DLCParamType_Credit;
|
||||
static constexpr EDLCParameterType e_DLCParamType_Cape =
|
||||
::minecraft::dlc::e_DLCParamType_Cape;
|
||||
static constexpr EDLCParameterType e_DLCParamType_Box =
|
||||
::minecraft::dlc::e_DLCParamType_Box;
|
||||
static constexpr EDLCParameterType e_DLCParamType_Anim =
|
||||
::minecraft::dlc::e_DLCParamType_Anim;
|
||||
static constexpr EDLCParameterType e_DLCParamType_PackId =
|
||||
::minecraft::dlc::e_DLCParamType_PackId;
|
||||
static constexpr EDLCParameterType e_DLCParamType_NetherParticleColour =
|
||||
::minecraft::dlc::e_DLCParamType_NetherParticleColour;
|
||||
static constexpr EDLCParameterType e_DLCParamType_EnchantmentTextColour =
|
||||
::minecraft::dlc::e_DLCParamType_EnchantmentTextColour;
|
||||
static constexpr EDLCParameterType
|
||||
e_DLCParamType_EnchantmentTextFocusColour =
|
||||
::minecraft::dlc::e_DLCParamType_EnchantmentTextFocusColour;
|
||||
static constexpr EDLCParameterType e_DLCParamType_DataPath =
|
||||
::minecraft::dlc::e_DLCParamType_DataPath;
|
||||
static constexpr EDLCParameterType e_DLCParamType_PackVersion =
|
||||
::minecraft::dlc::e_DLCParamType_PackVersion;
|
||||
static constexpr EDLCParameterType e_DLCParamType_Max =
|
||||
::minecraft::dlc::e_DLCParamType_Max;
|
||||
|
||||
const static char* wchTypeNamesA[e_DLCParamType_Max];
|
||||
|
||||
private:
|
||||
std::vector<DLCPack*> m_packs;
|
||||
// bool m_bNeedsUpdated;
|
||||
bool m_bNeedsCorruptCheck;
|
||||
unsigned int m_dwUnnamedCorruptDLCCount;
|
||||
|
||||
public:
|
||||
DLCManager();
|
||||
~DLCManager();
|
||||
|
||||
static EDLCParameterType getParameterType(const std::string& paramName);
|
||||
|
||||
unsigned int getPackCount(EDLCType type = e_DLCType_All);
|
||||
|
||||
// bool NeedsUpdated() { return m_bNeedsUpdated; }
|
||||
// void SetNeedsUpdated(bool val) { m_bNeedsUpdated = val; }
|
||||
|
||||
bool NeedsCorruptCheck() { return m_bNeedsCorruptCheck; }
|
||||
void SetNeedsCorruptCheck(bool val) { m_bNeedsCorruptCheck = val; }
|
||||
|
||||
void resetUnnamedCorruptCount() { m_dwUnnamedCorruptDLCCount = 0; }
|
||||
void incrementUnnamedCorruptCount() { ++m_dwUnnamedCorruptDLCCount; }
|
||||
|
||||
void addPack(DLCPack* pack);
|
||||
void removePack(DLCPack* pack);
|
||||
void removeAllPacks(void);
|
||||
void LanguageChanged(void);
|
||||
|
||||
DLCPack* getPack(const std::string& name);
|
||||
DLCPack* getPack(unsigned int index, EDLCType type = e_DLCType_All);
|
||||
unsigned int getPackIndex(DLCPack* pack, bool& found,
|
||||
EDLCType type = e_DLCType_All);
|
||||
DLCSkinFile* getSkinFile(
|
||||
const std::string& path); // Will hunt all packs of type skin to find
|
||||
// the right skinfile
|
||||
|
||||
DLCPack* getPackContainingSkin(const std::string& path);
|
||||
unsigned int getPackIndexContainingSkin(const std::string& path,
|
||||
bool& found);
|
||||
|
||||
unsigned int checkForCorruptDLCAndAlert(bool showMessage = true);
|
||||
|
||||
// bool readDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
// const std::wstring& path, DLCPack* pack,
|
||||
// bool fromArchive = false);
|
||||
bool readDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
const std::string& path, DLCPack* pack,
|
||||
bool fromArchive = false);
|
||||
std::uint32_t retrievePackIDFromDLCDataFile(const std::string& path,
|
||||
DLCPack* pack);
|
||||
|
||||
private:
|
||||
bool processDLCDataFile(unsigned int& dwFilesProcessed,
|
||||
std::uint8_t* pbData, unsigned int dwLength,
|
||||
DLCPack* pack);
|
||||
|
||||
std::uint32_t retrievePackID(std::uint8_t* pbData, unsigned int dwLength,
|
||||
DLCPack* pack);
|
||||
};
|
||||
|
||||
std::string dlc_read_wstring(const void* data);
|
||||
@@ -1,44 +0,0 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <format>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "DLCFile.h"
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "minecraft/client/model/HumanoidModel.h"
|
||||
#include "minecraft/client/model/SkinBox.h"
|
||||
#include "minecraft/client/skins/ISkinAssetData.h"
|
||||
|
||||
class DLCSkinFile : public DLCFile, public ISkinAssetData {
|
||||
private:
|
||||
std::string m_displayName;
|
||||
std::string m_themeName;
|
||||
std::string m_cape;
|
||||
unsigned int m_uiAnimOverrideBitmask;
|
||||
bool m_bIsFree;
|
||||
std::vector<SKIN_BOX*> m_AdditionalBoxes;
|
||||
|
||||
public:
|
||||
DLCSkinFile(const std::string& path);
|
||||
|
||||
void addData(std::uint8_t* pbData, std::uint32_t dataBytes) override;
|
||||
void addParameter(DLCManager::EDLCParameterType type,
|
||||
const std::string& value) override;
|
||||
|
||||
std::string getParameterAsString(
|
||||
DLCManager::EDLCParameterType type) override;
|
||||
bool getParameterAsBool(DLCManager::EDLCParameterType type) override;
|
||||
|
||||
// ISkinAssetData
|
||||
[[nodiscard]] std::uint32_t getSkinID() override {
|
||||
return DLCFile::getSkinID();
|
||||
}
|
||||
[[nodiscard]] unsigned int getAnimOverrideBitmask() override {
|
||||
return m_uiAnimOverrideBitmask;
|
||||
}
|
||||
[[nodiscard]] int getAdditionalBoxesCount() override;
|
||||
[[nodiscard]] std::vector<SKIN_BOX*>* getAdditionalBoxes() override;
|
||||
|
||||
bool isFree() { return m_bIsFree; }
|
||||
};
|
||||
@@ -1,701 +0,0 @@
|
||||
#include "app/common/DLCController.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "app/common/DLC/DLCPack.h"
|
||||
#include "app/common/DLC/DLCSkinFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/UI/ConsoleUIController.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/skins/TexturePack.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/profile/profile.h"
|
||||
#include "platform/storage/storage.h"
|
||||
|
||||
DLCController::DLCController() {
|
||||
m_pDLCFileBuffer = nullptr;
|
||||
m_dwDLCFileSize = 0;
|
||||
m_bDefaultCapeInstallAttempted = false;
|
||||
m_bDLCInstallProcessCompleted = false;
|
||||
m_bDLCInstallPending = false;
|
||||
m_iTotalDLC = 0;
|
||||
m_iTotalDLCInstalled = 0;
|
||||
m_bNewDLCAvailable = false;
|
||||
m_bSeenNewDLCTip = false;
|
||||
m_iDLCOfferC = 0;
|
||||
m_bAllDLCContentRetrieved = true;
|
||||
m_bAllTMSContentRetrieved = true;
|
||||
m_bTickTMSDLCFiles = true;
|
||||
}
|
||||
|
||||
std::unordered_map<PlayerUID, MOJANG_DATA*> DLCController::MojangData;
|
||||
std::unordered_map<int, uint64_t> DLCController::DLCTextures_PackID;
|
||||
std::unordered_map<uint64_t, DLC_INFO*> DLCController::DLCInfo_Trial;
|
||||
std::unordered_map<uint64_t, DLC_INFO*> DLCController::DLCInfo_Full;
|
||||
std::unordered_map<std::string, uint64_t> DLCController::DLCInfo_SkinName;
|
||||
|
||||
std::uint32_t DLCController::m_dwContentTypeA[e_Marketplace_MAX] = {
|
||||
XMARKETPLACE_OFFERING_TYPE_CONTENT,
|
||||
XMARKETPLACE_OFFERING_TYPE_THEME,
|
||||
XMARKETPLACE_OFFERING_TYPE_AVATARITEM,
|
||||
XMARKETPLACE_OFFERING_TYPE_TILE,
|
||||
};
|
||||
|
||||
int DLCController::marketplaceCountsCallback(
|
||||
void* pParam, IPlatformStorage::DLC_TMS_DETAILS* pTMSDetails, int iPad) {
|
||||
app.DebugPrintf("Marketplace Counts= New - %d Total - %d\n",
|
||||
pTMSDetails->dwNewOffers, pTMSDetails->dwTotalOffers);
|
||||
|
||||
if (pTMSDetails->dwNewOffers > 0) {
|
||||
app.m_dlcController.m_bNewDLCAvailable = true;
|
||||
app.m_dlcController.m_bSeenNewDLCTip = false;
|
||||
} else {
|
||||
app.m_dlcController.m_bNewDLCAvailable = false;
|
||||
app.m_dlcController.m_bSeenNewDLCTip = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool DLCController::startInstallDLCProcess(int iPad) {
|
||||
app.DebugPrintf("--- DLCController::startInstallDLCProcess: pad=%i.\n",
|
||||
iPad);
|
||||
|
||||
if ((dlcInstallProcessCompleted() == false) &&
|
||||
(m_bDLCInstallPending == false)) {
|
||||
app.m_dlcManager.resetUnnamedCorruptCount();
|
||||
m_bDLCInstallPending = true;
|
||||
m_iTotalDLC = 0;
|
||||
m_iTotalDLCInstalled = 0;
|
||||
app.DebugPrintf(
|
||||
"--- DLCController::startInstallDLCProcess - "
|
||||
"PlatformStorage.GetInstalledDLC\n");
|
||||
|
||||
PlatformStorage.GetInstalledDLC(iPad, [this](int iInstalledC, int pad) {
|
||||
return dlcInstalledCallback(iInstalledC, pad);
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"--- DLCController::startInstallDLCProcess - nothing to do\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int DLCController::dlcInstalledCallback(int iInstalledC, int iPad) {
|
||||
app.DebugPrintf(
|
||||
"--- DLCController::dlcInstalledCallback: totalDLC=%i, pad=%i.\n",
|
||||
iInstalledC, iPad);
|
||||
m_iTotalDLC = iInstalledC;
|
||||
mountNextDLC(iPad);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DLCController::mountNextDLC(int iPad) {
|
||||
app.DebugPrintf("--- DLCController::mountNextDLC: pad=%i.\n", iPad);
|
||||
if (m_iTotalDLCInstalled < m_iTotalDLC) {
|
||||
if (PlatformStorage.MountInstalledDLC(
|
||||
iPad, m_iTotalDLCInstalled,
|
||||
[this](int pad, std::uint32_t dwErr,
|
||||
std::uint32_t dwLicenceMask) {
|
||||
return dlcMountedCallback(pad, dwErr, dwLicenceMask);
|
||||
}) != 997 /* ERROR_IO_PENDING */) {
|
||||
app.DebugPrintf("Failed to mount DLC %d for pad %d\n",
|
||||
m_iTotalDLCInstalled, iPad);
|
||||
++m_iTotalDLCInstalled;
|
||||
mountNextDLC(iPad);
|
||||
} else {
|
||||
app.DebugPrintf("PlatformStorage.MountInstalledDLC ok\n");
|
||||
}
|
||||
} else {
|
||||
m_bDLCInstallPending = false;
|
||||
m_bDLCInstallProcessCompleted = true;
|
||||
ui.HandleDLCMountingComplete();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_WINDOWS64)
|
||||
#define CONTENT_DATA_DISPLAY_NAME(a) (a.szDisplayName)
|
||||
#else
|
||||
#define CONTENT_DATA_DISPLAY_NAME(a) (a.wszDisplayName)
|
||||
#endif
|
||||
|
||||
int DLCController::dlcMountedCallback(int iPad, std::uint32_t dwErr,
|
||||
std::uint32_t dwLicenceMask) {
|
||||
#if defined(_WINDOWS64)
|
||||
app.DebugPrintf("--- DLCController::dlcMountedCallback\n");
|
||||
|
||||
if (dwErr != 0 /* ERROR_SUCCESS */) {
|
||||
app.DebugPrintf("Failed to mount DLC for pad %d: %u\n", iPad, dwErr);
|
||||
app.m_dlcManager.incrementUnnamedCorruptCount();
|
||||
} else {
|
||||
XCONTENT_DATA ContentData =
|
||||
PlatformStorage.GetDLC(m_iTotalDLCInstalled);
|
||||
|
||||
DLCPack* pack =
|
||||
app.m_dlcManager.getPack(CONTENT_DATA_DISPLAY_NAME(ContentData));
|
||||
|
||||
if (pack != nullptr && pack->IsCorrupt()) {
|
||||
app.DebugPrintf(
|
||||
"Pack '%s' is corrupt, removing it from the DLC Manager.\n",
|
||||
CONTENT_DATA_DISPLAY_NAME(ContentData));
|
||||
app.m_dlcManager.removePack(pack);
|
||||
pack = nullptr;
|
||||
}
|
||||
|
||||
if (pack == nullptr) {
|
||||
app.DebugPrintf("Pack \"%s\" is not installed, so adding it\n",
|
||||
CONTENT_DATA_DISPLAY_NAME(ContentData));
|
||||
|
||||
#if defined(_WINDOWS64)
|
||||
pack = new DLCPack(ContentData.szDisplayName, dwLicenceMask);
|
||||
#else
|
||||
pack = new DLCPack(ContentData.wszDisplayName, dwLicenceMask);
|
||||
#endif
|
||||
pack->SetDLCMountIndex(m_iTotalDLCInstalled);
|
||||
pack->SetDLCDeviceID(ContentData.DeviceID);
|
||||
app.m_dlcManager.addPack(pack);
|
||||
handleDLC(pack);
|
||||
|
||||
if (pack->getDLCItemsCount(DLCManager::e_DLCType_Texture) > 0) {
|
||||
Minecraft::GetInstance()->skins->addTexturePackFromDLC(
|
||||
pack, pack->GetPackId());
|
||||
}
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"Pack \"%s\" is already installed. Updating license to %u\n",
|
||||
CONTENT_DATA_DISPLAY_NAME(ContentData), dwLicenceMask);
|
||||
|
||||
pack->SetDLCMountIndex(m_iTotalDLCInstalled);
|
||||
pack->SetDLCDeviceID(ContentData.DeviceID);
|
||||
pack->updateLicenseMask(dwLicenceMask);
|
||||
}
|
||||
|
||||
PlatformStorage.UnmountInstalledDLC();
|
||||
}
|
||||
++m_iTotalDLCInstalled;
|
||||
mountNextDLC(iPad);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#undef CONTENT_DATA_DISPLAY_NAME
|
||||
|
||||
void DLCController::handleDLC(DLCPack* pack) {
|
||||
unsigned int dwFilesProcessed = 0;
|
||||
std::vector<std::string> dlcFilenames;
|
||||
PlatformStorage.GetMountedDLCFileList("DLCDrive", dlcFilenames);
|
||||
for (int i = 0; i < dlcFilenames.size(); i++) {
|
||||
app.m_dlcManager.readDLCDataFile(dwFilesProcessed, dlcFilenames[i],
|
||||
pack);
|
||||
}
|
||||
if (dwFilesProcessed == 0) app.m_dlcManager.removePack(pack);
|
||||
}
|
||||
|
||||
void DLCController::addCreditText(const char* lpStr) {
|
||||
app.DebugPrintf("ADDING CREDIT - %s\n", lpStr);
|
||||
SCreditTextItemDef* pCreditStruct = new SCreditTextItemDef;
|
||||
pCreditStruct->m_eType = eSmallText;
|
||||
pCreditStruct->m_iStringID[0] = NO_TRANSLATED_STRING;
|
||||
pCreditStruct->m_iStringID[1] = NO_TRANSLATED_STRING;
|
||||
pCreditStruct->m_Text = new char[strlen(lpStr) + 1];
|
||||
strcpy((char*)pCreditStruct->m_Text, lpStr);
|
||||
vDLCCredits.push_back(pCreditStruct);
|
||||
}
|
||||
|
||||
bool DLCController::alreadySeenCreditText(const std::string& wstemp) {
|
||||
for (unsigned int i = 0; i < m_vCreditText.size(); i++) {
|
||||
std::string temp = m_vCreditText.at(i);
|
||||
if (temp.compare(wstemp) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
m_vCreditText.push_back((char*)wstemp.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int DLCController::getDLCCreditsCount() {
|
||||
return (unsigned int)vDLCCredits.size();
|
||||
}
|
||||
|
||||
SCreditTextItemDef* DLCController::getDLCCredits(int iIndex) {
|
||||
return vDLCCredits.at(iIndex);
|
||||
}
|
||||
|
||||
int32_t DLCController::registerDLCData(char* pType, char* pBannerName,
|
||||
int iGender, uint64_t ullOfferID_Full,
|
||||
uint64_t ullOfferID_Trial,
|
||||
char* pFirstSkin,
|
||||
unsigned int uiSortIndex, int iConfig,
|
||||
char* pDataFile) {
|
||||
int32_t hr = 0;
|
||||
DLC_INFO* pDLCData = new DLC_INFO;
|
||||
memset(pDLCData, 0, sizeof(DLC_INFO));
|
||||
pDLCData->ullOfferID_Full = ullOfferID_Full;
|
||||
pDLCData->ullOfferID_Trial = ullOfferID_Trial;
|
||||
pDLCData->eDLCType = e_DLC_NotDefined;
|
||||
pDLCData->iGender = iGender;
|
||||
pDLCData->uiSortIndex = uiSortIndex;
|
||||
pDLCData->iConfig = iConfig;
|
||||
|
||||
if (strcmp(pBannerName, "") != 0) {
|
||||
strncpy(pDLCData->wchBanner, pBannerName, MAX_BANNERNAME_SIZE);
|
||||
}
|
||||
if (pDataFile[0] != 0) {
|
||||
strncpy(pDLCData->wchDataFile, pDataFile, MAX_BANNERNAME_SIZE);
|
||||
}
|
||||
|
||||
if (pType != nullptr) {
|
||||
if (strcmp(pType, "Skin") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_SkinPack;
|
||||
} else if (strcmp(pType, "Gamerpic") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_Gamerpics;
|
||||
} else if (strcmp(pType, "Theme") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_Themes;
|
||||
} else if (strcmp(pType, "Avatar") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_AvatarItems;
|
||||
} else if (strcmp(pType, "MashUpPack") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_MashupPacks;
|
||||
DLCTextures_PackID[pDLCData->iConfig] = ullOfferID_Full;
|
||||
} else if (strcmp(pType, "TexturePack") == 0) {
|
||||
pDLCData->eDLCType = e_DLC_TexturePacks;
|
||||
DLCTextures_PackID[pDLCData->iConfig] = ullOfferID_Full;
|
||||
}
|
||||
}
|
||||
|
||||
if (ullOfferID_Trial != 0ll) DLCInfo_Trial[ullOfferID_Trial] = pDLCData;
|
||||
if (ullOfferID_Full != 0ll) DLCInfo_Full[ullOfferID_Full] = pDLCData;
|
||||
if (pFirstSkin[0] != 0) DLCInfo_SkinName[pFirstSkin] = ullOfferID_Full;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
bool DLCController::getDLCFullOfferIDForSkinID(const std::string& FirstSkin,
|
||||
uint64_t* pullVal) {
|
||||
auto it = DLCInfo_SkinName.find(FirstSkin);
|
||||
if (it == DLCInfo_SkinName.end()) {
|
||||
return false;
|
||||
} else {
|
||||
*pullVal = (uint64_t)it->second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool DLCController::getDLCFullOfferIDForPackID(const int iPackID,
|
||||
uint64_t* pullVal) {
|
||||
auto it = DLCTextures_PackID.find(iPackID);
|
||||
if (it == DLCTextures_PackID.end()) {
|
||||
*pullVal = (uint64_t)0;
|
||||
return false;
|
||||
} else {
|
||||
*pullVal = (uint64_t)it->second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
DLC_INFO* DLCController::getDLCInfoForTrialOfferID(uint64_t ullOfferID_Trial) {
|
||||
if (DLCInfo_Trial.size() > 0) {
|
||||
auto it = DLCInfo_Trial.find(ullOfferID_Trial);
|
||||
if (it == DLCInfo_Trial.end()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return it->second;
|
||||
}
|
||||
} else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DLC_INFO* DLCController::getDLCInfoForFullOfferID(uint64_t ullOfferID_Full) {
|
||||
if (DLCInfo_Full.size() > 0) {
|
||||
auto it = DLCInfo_Full.find(ullOfferID_Full);
|
||||
if (it == DLCInfo_Full.end()) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return it->second;
|
||||
}
|
||||
} else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DLC_INFO* DLCController::getDLCInfoTrialOffer(int iIndex) {
|
||||
std::unordered_map<uint64_t, DLC_INFO*>::iterator it =
|
||||
DLCInfo_Trial.begin();
|
||||
for (int i = 0; i < iIndex; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
DLC_INFO* DLCController::getDLCInfoFullOffer(int iIndex) {
|
||||
std::unordered_map<uint64_t, DLC_INFO*>::iterator it = DLCInfo_Full.begin();
|
||||
for (int i = 0; i < iIndex; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
uint64_t DLCController::getDLCInfoTexturesFullOffer(int iIndex) {
|
||||
std::unordered_map<int, uint64_t>::iterator it = DLCTextures_PackID.begin();
|
||||
for (int i = 0; i < iIndex; i++) {
|
||||
++it;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
||||
int DLCController::getDLCInfoTrialOffersCount() {
|
||||
return (int)DLCInfo_Trial.size();
|
||||
}
|
||||
|
||||
int DLCController::getDLCInfoFullOffersCount() {
|
||||
return (int)DLCInfo_Full.size();
|
||||
}
|
||||
|
||||
int DLCController::getDLCInfoTexturesOffersCount() {
|
||||
return (int)DLCTextures_PackID.size();
|
||||
}
|
||||
|
||||
unsigned int DLCController::addDLCRequest(eDLCMarketplaceType eType,
|
||||
bool bPromote) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csDLCDownloadQueue);
|
||||
|
||||
int iPosition = 0;
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if (pCurrent->dwType == m_dwContentTypeA[eType]) {
|
||||
if (pCurrent->eState == e_DLC_ContentState_Retrieving ||
|
||||
pCurrent->eState == e_DLC_ContentState_Retrieved) {
|
||||
return 0;
|
||||
} else {
|
||||
if (bPromote) {
|
||||
m_DLCDownloadQueue.erase(m_DLCDownloadQueue.begin() +
|
||||
iPosition);
|
||||
m_DLCDownloadQueue.insert(m_DLCDownloadQueue.begin(),
|
||||
pCurrent);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
iPosition++;
|
||||
}
|
||||
|
||||
DLCRequest* pDLCreq = new DLCRequest;
|
||||
pDLCreq->dwType = m_dwContentTypeA[eType];
|
||||
pDLCreq->eState = e_DLC_ContentState_Idle;
|
||||
m_DLCDownloadQueue.push_back(pDLCreq);
|
||||
m_bAllDLCContentRetrieved = false;
|
||||
}
|
||||
|
||||
app.DebugPrintf("[Consoles_App] Added DLC request.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool DLCController::retrieveNextDLCContent() {
|
||||
int primPad = PlatformProfile.GetPrimaryPad();
|
||||
if (primPad == -1 || !PlatformProfile.IsSignedInLive(primPad)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csDLCDownloadQueue);
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if (pCurrent->eState == e_DLC_ContentState_Retrieving) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if (pCurrent->eState == e_DLC_ContentState_Idle) {
|
||||
#if defined(_DEBUG)
|
||||
app.DebugPrintf("RetrieveNextDLCContent - type = %d\n",
|
||||
pCurrent->dwType);
|
||||
#endif
|
||||
IPlatformStorage::EDLCStatus status =
|
||||
PlatformStorage.GetDLCOffers(
|
||||
PlatformProfile.GetPrimaryPad(),
|
||||
[this](int iOfferC, std::uint32_t dwType, int pad) {
|
||||
return dlcOffersReturned(iOfferC, dwType, pad);
|
||||
},
|
||||
pCurrent->dwType);
|
||||
if (status == IPlatformStorage::EDLC_Pending) {
|
||||
pCurrent->eState = e_DLC_ContentState_Retrieving;
|
||||
} else {
|
||||
app.DebugPrintf("RetrieveNextDLCContent - PROBLEM\n");
|
||||
pCurrent->eState = e_DLC_ContentState_Retrieved;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app.DebugPrintf("[Consoles_App] Finished downloading dlc content.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DLCController::checkTMSDLCCanStop() {
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
for (auto it = m_TMSPPDownloadQueue.begin();
|
||||
it != m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
if (pCurrent->eState == e_TMS_ContentState_Retrieving) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int DLCController::dlcOffersReturned(int iOfferC, std::uint32_t dwType,
|
||||
int iPad) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if (pCurrent->dwType == static_cast<std::uint32_t>(dwType)) {
|
||||
m_iDLCOfferC = iOfferC;
|
||||
app.DebugPrintf(
|
||||
"DLCOffersReturned - type %u, count %d - setting to "
|
||||
"retrieved\n",
|
||||
dwType, iOfferC);
|
||||
pCurrent->eState = e_DLC_ContentState_Retrieved;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
eDLCContentType DLCController::find_eDLCContentType(std::uint32_t dwType) {
|
||||
for (int i = 0; i < e_DLC_MAX; i++) {
|
||||
if (m_dwContentTypeA[i] == dwType) {
|
||||
return (eDLCContentType)i;
|
||||
}
|
||||
}
|
||||
return (eDLCContentType)0;
|
||||
}
|
||||
|
||||
bool DLCController::dlcContentRetrieved(eDLCMarketplaceType eType) {
|
||||
std::lock_guard<std::mutex> lock(csDLCDownloadQueue);
|
||||
for (auto it = m_DLCDownloadQueue.begin(); it != m_DLCDownloadQueue.end();
|
||||
++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
if ((pCurrent->dwType == m_dwContentTypeA[eType]) &&
|
||||
(pCurrent->eState == e_DLC_ContentState_Retrieved)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DLCController::tickDLCOffersRetrieved() {
|
||||
if (!m_bAllDLCContentRetrieved) {
|
||||
if (!retrieveNextDLCContent()) {
|
||||
app.DebugPrintf("[Consoles_App] All content retrieved.\n");
|
||||
m_bAllDLCContentRetrieved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DLCController::clearAndResetDLCDownloadQueue() {
|
||||
app.DebugPrintf("[Consoles_App] Clear and reset download queue.\n");
|
||||
|
||||
int iPosition = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
for (auto it = m_DLCDownloadQueue.begin();
|
||||
it != m_DLCDownloadQueue.end(); ++it) {
|
||||
DLCRequest* pCurrent = *it;
|
||||
delete pCurrent;
|
||||
iPosition++;
|
||||
}
|
||||
m_DLCDownloadQueue.clear();
|
||||
m_bAllDLCContentRetrieved = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool DLCController::retrieveNextTMSPPContent() { return false; }
|
||||
|
||||
void DLCController::tickTMSPPFilesRetrieved() {
|
||||
if (m_bTickTMSDLCFiles && !m_bAllTMSContentRetrieved) {
|
||||
if (retrieveNextTMSPPContent() == false) {
|
||||
m_bAllTMSContentRetrieved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DLCController::clearTMSPPFilesRetrieved() {
|
||||
int iPosition = 0;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
for (auto it = m_TMSPPDownloadQueue.begin();
|
||||
it != m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
delete pCurrent;
|
||||
iPosition++;
|
||||
}
|
||||
m_TMSPPDownloadQueue.clear();
|
||||
m_bAllTMSContentRetrieved = true;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int DLCController::addTMSPPFileTypeRequest(eDLCContentType eType,
|
||||
bool bPromote) {
|
||||
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
|
||||
|
||||
if (eType == e_DLC_TexturePackData) {
|
||||
int iCount = getDLCInfoFullOffersCount();
|
||||
|
||||
for (int i = 0; i < iCount; i++) {
|
||||
DLC_INFO* pDLC = getDLCInfoFullOffer(i);
|
||||
|
||||
if ((pDLC->eDLCType == e_DLC_TexturePacks) ||
|
||||
(pDLC->eDLCType == e_DLC_MashupPacks)) {
|
||||
if (pDLC->wchDataFile[0] != 0) {
|
||||
{
|
||||
bool bPresent = app.IsFileInTPD(pDLC->iConfig);
|
||||
|
||||
if (!bPresent) {
|
||||
bool bAlreadyInQueue = false;
|
||||
for (auto it = m_TMSPPDownloadQueue.begin();
|
||||
it != m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
if (strcmp(pDLC->wchDataFile,
|
||||
pCurrent->wchFilename) == 0) {
|
||||
bAlreadyInQueue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bAlreadyInQueue) {
|
||||
TMSPPRequest* pTMSPPreq = new TMSPPRequest;
|
||||
pTMSPPreq->CallbackFunc =
|
||||
&DLCController::tmsPPFileReturned;
|
||||
pTMSPPreq->lpCallbackParam = this;
|
||||
pTMSPPreq->eStorageFacility =
|
||||
IPlatformStorage::eGlobalStorage_Title;
|
||||
pTMSPPreq->eFileTypeVal =
|
||||
IPlatformStorage::TMS_FILETYPE_BINARY;
|
||||
memcpy(pTMSPPreq->wchFilename,
|
||||
pDLC->wchDataFile,
|
||||
sizeof(char) * MAX_BANNERNAME_SIZE);
|
||||
pTMSPPreq->eType = e_DLC_TexturePackData;
|
||||
pTMSPPreq->eState = e_TMS_ContentState_Queued;
|
||||
m_bAllTMSContentRetrieved = false;
|
||||
m_TMSPPDownloadQueue.push_back(pTMSPPreq);
|
||||
}
|
||||
} else {
|
||||
app.DebugPrintf(
|
||||
"Texture data already present in the TPD\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int iCount;
|
||||
iCount = getDLCInfoFullOffersCount();
|
||||
for (int i = 0; i < iCount; i++) {
|
||||
DLC_INFO* pDLC = getDLCInfoFullOffer(i);
|
||||
if (pDLC->eDLCType == eType) {
|
||||
char* cString = pDLC->wchBanner;
|
||||
{
|
||||
bool bPresent = app.IsFileInMemoryTextures(cString);
|
||||
|
||||
if (!bPresent) {
|
||||
bool bAlreadyInQueue = false;
|
||||
for (auto it = m_TMSPPDownloadQueue.begin();
|
||||
it != m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
if (strcmp(pDLC->wchBanner,
|
||||
pCurrent->wchFilename) == 0) {
|
||||
bAlreadyInQueue = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bAlreadyInQueue) {
|
||||
TMSPPRequest* pTMSPPreq = new TMSPPRequest;
|
||||
memset(pTMSPPreq, 0, sizeof(TMSPPRequest));
|
||||
pTMSPPreq->CallbackFunc =
|
||||
&DLCController::tmsPPFileReturned;
|
||||
pTMSPPreq->lpCallbackParam = this;
|
||||
pTMSPPreq->eStorageFacility =
|
||||
IPlatformStorage::eGlobalStorage_Title;
|
||||
pTMSPPreq->eFileTypeVal =
|
||||
IPlatformStorage::TMS_FILETYPE_BINARY;
|
||||
memcpy(pTMSPPreq->wchFilename, pDLC->wchBanner,
|
||||
sizeof(char) * MAX_BANNERNAME_SIZE);
|
||||
pTMSPPreq->eType = eType;
|
||||
pTMSPPreq->eState = e_TMS_ContentState_Queued;
|
||||
m_bAllTMSContentRetrieved = false;
|
||||
m_TMSPPDownloadQueue.push_back(pTMSPPreq);
|
||||
app.DebugPrintf(
|
||||
"===m_TMSPPDownloadQueue Adding %s, q size is "
|
||||
"%d\n",
|
||||
pTMSPPreq->wchFilename,
|
||||
m_TMSPPDownloadQueue.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int DLCController::tmsPPFileReturned(
|
||||
void* pParam, int iPad, int iUserData,
|
||||
IPlatformStorage::PTMSPP_FILEDATA pFileData, const char* szFilename) {
|
||||
DLCController* pClass = (DLCController*)pParam;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(pClass->csTMSPPDownloadQueue);
|
||||
for (auto it = pClass->m_TMSPPDownloadQueue.begin();
|
||||
it != pClass->m_TMSPPDownloadQueue.end(); ++it) {
|
||||
TMSPPRequest* pCurrent = *it;
|
||||
#if defined(_WINDOWS64)
|
||||
char szFile[MAX_TMSFILENAME_SIZE];
|
||||
strncpy(szFile, pCurrent->wchFilename, MAX_TMSFILENAME_SIZE);
|
||||
|
||||
if (strcmp(szFilename, szFile) == 0)
|
||||
#endif
|
||||
{
|
||||
pCurrent->eState = e_TMS_ContentState_Retrieved;
|
||||
|
||||
if (pFileData != nullptr) {
|
||||
switch (pCurrent->eType) {
|
||||
case e_DLC_TexturePackData: {
|
||||
app.DebugPrintf("--- Got texturepack data %s\n",
|
||||
pCurrent->wchFilename);
|
||||
int iConfig =
|
||||
app.GetTPConfigVal(pCurrent->wchFilename);
|
||||
app.AddMemoryTPDFile(iConfig, pFileData->pbData,
|
||||
pFileData->size);
|
||||
} break;
|
||||
default:
|
||||
app.DebugPrintf("--- Got image data - %s\n",
|
||||
pCurrent->wchFilename);
|
||||
app.AddMemoryTextureFile(pCurrent->wchFilename,
|
||||
pFileData->pbData,
|
||||
pFileData->size);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
app.DebugPrintf("TMSImageReturned failed (%s)...\n",
|
||||
szFilename);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/storage/storage.h"
|
||||
|
||||
struct SCreditTextItemDef;
|
||||
|
||||
class DLCPack;
|
||||
|
||||
class DLCController {
|
||||
public:
|
||||
DLCController();
|
||||
|
||||
// Install process
|
||||
bool startInstallDLCProcess(int iPad);
|
||||
int dlcInstalledCallback(int iInstalledC, int iPad);
|
||||
void mountNextDLC(int iPad);
|
||||
int dlcMountedCallback(int iPad, std::uint32_t dwErr,
|
||||
std::uint32_t dwLicenceMask);
|
||||
void handleDLC(DLCPack* pack);
|
||||
|
||||
bool dlcInstallPending() { return m_bDLCInstallPending; }
|
||||
bool dlcInstallProcessCompleted() { return m_bDLCInstallProcessCompleted; }
|
||||
void clearDLCInstalled() { m_bDLCInstallProcessCompleted = false; }
|
||||
|
||||
static int marketplaceCountsCallback(void* pParam,
|
||||
IPlatformStorage::DLC_TMS_DETAILS*,
|
||||
int iPad);
|
||||
|
||||
// DLC info registration
|
||||
static int32_t registerDLCData(char*, char*, int, uint64_t, uint64_t, char*,
|
||||
unsigned int, int, char* pDataFile);
|
||||
bool getDLCFullOfferIDForSkinID(const std::string& FirstSkin,
|
||||
uint64_t* pullVal);
|
||||
bool getDLCFullOfferIDForPackID(const int iPackID, uint64_t* pullVal);
|
||||
DLC_INFO* getDLCInfoForTrialOfferID(uint64_t ullOfferID_Trial);
|
||||
DLC_INFO* getDLCInfoForFullOfferID(uint64_t ullOfferID_Full);
|
||||
DLC_INFO* getDLCInfoTrialOffer(int iIndex);
|
||||
DLC_INFO* getDLCInfoFullOffer(int iIndex);
|
||||
uint64_t getDLCInfoTexturesFullOffer(int iIndex);
|
||||
int getDLCInfoTrialOffersCount();
|
||||
int getDLCInfoFullOffersCount();
|
||||
int getDLCInfoTexturesOffersCount();
|
||||
|
||||
// DLC content/offers
|
||||
unsigned int addDLCRequest(eDLCMarketplaceType eContentType,
|
||||
bool bPromote = false);
|
||||
bool retrieveNextDLCContent();
|
||||
bool checkTMSDLCCanStop();
|
||||
int dlcOffersReturned(int iOfferC, std::uint32_t dwType, int iPad);
|
||||
std::uint32_t getDLCContentType(eDLCContentType eType) {
|
||||
return m_dwContentTypeA[eType];
|
||||
}
|
||||
eDLCContentType find_eDLCContentType(std::uint32_t dwType);
|
||||
int getDLCOffersCount() { return m_iDLCOfferC; }
|
||||
bool dlcContentRetrieved(eDLCMarketplaceType eType);
|
||||
void tickDLCOffersRetrieved();
|
||||
void clearAndResetDLCDownloadQueue();
|
||||
|
||||
// TMS/TMSPP
|
||||
bool retrieveNextTMSPPContent();
|
||||
void tickTMSPPFilesRetrieved();
|
||||
void clearTMSPPFilesRetrieved();
|
||||
unsigned int addTMSPPFileTypeRequest(eDLCContentType eType,
|
||||
bool bPromote = false);
|
||||
static int tmsPPFileReturned(void* pParam, int iPad, int iUserData,
|
||||
IPlatformStorage::PTMSPP_FILEDATA pFileData,
|
||||
const char* szFilename);
|
||||
|
||||
// Credit text
|
||||
void addCreditText(const char* lpStr);
|
||||
bool alreadySeenCreditText(const std::string& wstemp);
|
||||
unsigned int getDLCCreditsCount();
|
||||
SCreditTextItemDef* getDLCCredits(int iIndex);
|
||||
|
||||
// New DLC available
|
||||
void clearNewDLCAvailable() {
|
||||
m_bNewDLCAvailable = false;
|
||||
m_bSeenNewDLCTip = true;
|
||||
}
|
||||
bool getNewDLCAvailable() { return m_bNewDLCAvailable; }
|
||||
void displayNewDLCTipAgain() { m_bSeenNewDLCTip = false; }
|
||||
bool displayNewDLCTip() {
|
||||
if (!m_bSeenNewDLCTip) {
|
||||
m_bSeenNewDLCTip = true;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
void setTickTMSDLCFiles(bool bVal) { m_bTickTMSDLCFiles = bVal; }
|
||||
|
||||
// Public data needed by other parts
|
||||
std::vector<std::string> m_vCreditText;
|
||||
std::uint8_t* m_pDLCFileBuffer;
|
||||
unsigned int m_dwDLCFileSize;
|
||||
|
||||
// DLC install counters (accessed by dlcMountedCallback)
|
||||
int m_iTotalDLC;
|
||||
int m_iTotalDLCInstalled;
|
||||
|
||||
// Static maps
|
||||
static std::unordered_map<PlayerUID, MOJANG_DATA*> MojangData;
|
||||
static std::unordered_map<int, uint64_t> DLCTextures_PackID;
|
||||
static std::unordered_map<uint64_t, DLC_INFO*> DLCInfo_Trial;
|
||||
static std::unordered_map<uint64_t, DLC_INFO*> DLCInfo_Full;
|
||||
static std::unordered_map<std::string, uint64_t> DLCInfo_SkinName;
|
||||
static std::uint32_t m_dwContentTypeA[e_Marketplace_MAX];
|
||||
|
||||
private:
|
||||
std::vector<SCreditTextItemDef*> vDLCCredits;
|
||||
std::vector<DLCRequest*> m_DLCDownloadQueue;
|
||||
std::vector<TMSPPRequest*> m_TMSPPDownloadQueue;
|
||||
|
||||
int m_iDLCOfferC;
|
||||
bool m_bAllDLCContentRetrieved;
|
||||
bool m_bAllTMSContentRetrieved;
|
||||
bool m_bTickTMSDLCFiles;
|
||||
std::mutex csDLCDownloadQueue;
|
||||
std::mutex csTMSPPDownloadQueue;
|
||||
|
||||
bool m_bDLCInstallProcessCompleted;
|
||||
bool m_bDLCInstallPending;
|
||||
bool m_bDefaultCapeInstallAttempted;
|
||||
|
||||
bool m_bNewDLCAvailable;
|
||||
bool m_bSeenNewDLCTip;
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
#include "app/common/DebugOptions.h"
|
||||
|
||||
DebugOptions::DebugOptions() {
|
||||
#if defined(_DEBUG_MENUS_ENABLED)
|
||||
#if defined(_CONTENT_PACKAGE)
|
||||
m_bDebugOptions =
|
||||
false; // make them off by default in a content package build
|
||||
#else
|
||||
m_bDebugOptions = true;
|
||||
#endif
|
||||
#else
|
||||
m_bDebugOptions = false;
|
||||
#endif
|
||||
|
||||
m_bLoadSavesFromFolderEnabled = false;
|
||||
m_bWriteSavesToFolderEnabled = false;
|
||||
m_bMobsDontAttack = false;
|
||||
m_bMobsDontTick = false;
|
||||
m_bFreezePlayers = false;
|
||||
|
||||
#if defined(_CONTENT_PACAKGE)
|
||||
m_bUseDPadForDebug = false;
|
||||
#else
|
||||
m_bUseDPadForDebug = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(_DEBUG_MENUS_ENABLED)
|
||||
bool DebugOptions::debugArtToolsOn(unsigned int debugMask) {
|
||||
return settingsOn() && (debugMask & (1L << eDebugSetting_ArtTools)) != 0;
|
||||
}
|
||||
#endif
|
||||
@@ -1,52 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "minecraft/Console_Debug_enum.h"
|
||||
|
||||
class DebugOptions {
|
||||
public:
|
||||
DebugOptions();
|
||||
|
||||
bool settingsOn() const { return m_bDebugOptions; }
|
||||
void setDebugOptions(bool bVal) { m_bDebugOptions = bVal; }
|
||||
|
||||
bool getLoadSavesFromFolderEnabled() const {
|
||||
return m_bLoadSavesFromFolderEnabled;
|
||||
}
|
||||
void setLoadSavesFromFolderEnabled(bool bVal) {
|
||||
m_bLoadSavesFromFolderEnabled = bVal;
|
||||
}
|
||||
|
||||
bool getWriteSavesToFolderEnabled() const {
|
||||
return m_bWriteSavesToFolderEnabled;
|
||||
}
|
||||
void setWriteSavesToFolderEnabled(bool bVal) {
|
||||
m_bWriteSavesToFolderEnabled = bVal;
|
||||
}
|
||||
|
||||
bool getMobsDontAttack() const { return m_bMobsDontAttack; }
|
||||
void setMobsDontAttack(bool bVal) { m_bMobsDontAttack = bVal; }
|
||||
|
||||
bool getUseDPadForDebug() const { return m_bUseDPadForDebug; }
|
||||
void setUseDPadForDebug(bool bVal) { m_bUseDPadForDebug = bVal; }
|
||||
|
||||
bool getMobsDontTick() const { return m_bMobsDontTick; }
|
||||
void setMobsDontTick(bool bVal) { m_bMobsDontTick = bVal; }
|
||||
|
||||
bool getFreezePlayers() const { return m_bFreezePlayers; }
|
||||
void setFreezePlayers(bool bVal) { m_bFreezePlayers = bVal; }
|
||||
|
||||
#if defined(_DEBUG_MENUS_ENABLED)
|
||||
bool debugArtToolsOn(unsigned int debugMask);
|
||||
#else
|
||||
bool debugArtToolsOn(unsigned int) { return false; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
bool m_bDebugOptions;
|
||||
bool m_bLoadSavesFromFolderEnabled;
|
||||
bool m_bWriteSavesToFolderEnabled;
|
||||
bool m_bMobsDontAttack;
|
||||
bool m_bUseDPadForDebug;
|
||||
bool m_bMobsDontTick;
|
||||
bool m_bFreezePlayers;
|
||||
};
|
||||
@@ -1,89 +0,0 @@
|
||||
#include "app/common/GameMenuService.h"
|
||||
|
||||
#include "app/common/Game.h"
|
||||
|
||||
bool GameMenuService::openInventory(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
bool navigateBack) {
|
||||
return game_.LoadInventoryMenu(iPad, player, navigateBack);
|
||||
}
|
||||
bool GameMenuService::openCreative(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
bool navigateBack) {
|
||||
return game_.LoadCreativeMenu(iPad, player, navigateBack);
|
||||
}
|
||||
bool GameMenuService::openCrafting2x2(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player) {
|
||||
return game_.LoadCrafting2x2Menu(iPad, player);
|
||||
}
|
||||
bool GameMenuService::openCrafting3x3(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
int x, int y, int z) {
|
||||
return game_.LoadCrafting3x3Menu(iPad, player, x, y, z);
|
||||
}
|
||||
bool GameMenuService::openEnchanting(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
int x, int y, int z, Level* level,
|
||||
const std::string& name) {
|
||||
return game_.LoadEnchantingMenu(iPad, inventory, x, y, z, level, name);
|
||||
}
|
||||
bool GameMenuService::openFurnace(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<FurnaceTileEntity> furnace) {
|
||||
return game_.LoadFurnaceMenu(iPad, inventory, furnace);
|
||||
}
|
||||
bool GameMenuService::openBrewingStand(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand) {
|
||||
return game_.LoadBrewingStandMenu(iPad, inventory, brewingStand);
|
||||
}
|
||||
bool GameMenuService::openContainer(int iPad,
|
||||
std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<Container> container) {
|
||||
return game_.LoadContainerMenu(iPad, inventory, container);
|
||||
}
|
||||
bool GameMenuService::openTrap(int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<DispenserTileEntity> trap) {
|
||||
return game_.LoadTrapMenu(iPad, inventory, trap);
|
||||
}
|
||||
bool GameMenuService::openFireworks(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player, int x,
|
||||
int y, int z) {
|
||||
return game_.LoadFireworksMenu(iPad, player, x, y, z);
|
||||
}
|
||||
bool GameMenuService::openSign(int iPad, std::shared_ptr<SignTileEntity> sign) {
|
||||
return game_.LoadSignEntryMenu(iPad, sign);
|
||||
}
|
||||
bool GameMenuService::openRepairing(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
Level* level, int x, int y, int z) {
|
||||
return game_.LoadRepairingMenu(iPad, inventory, level, x, y, z);
|
||||
}
|
||||
bool GameMenuService::openTrading(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Merchant> trader,
|
||||
Level* level, const std::string& name) {
|
||||
return game_.LoadTradingMenu(iPad, inventory, trader, level, name);
|
||||
}
|
||||
bool GameMenuService::openCommandBlock(
|
||||
int iPad, std::shared_ptr<CommandBlockEntity> commandBlock) {
|
||||
return game_.LoadCommandBlockMenu(iPad, commandBlock);
|
||||
}
|
||||
bool GameMenuService::openHopper(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<HopperTileEntity> hopper) {
|
||||
return game_.LoadHopperMenu(iPad, inventory, hopper);
|
||||
}
|
||||
bool GameMenuService::openHopperMinecart(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<MinecartHopper> hopper) {
|
||||
return game_.LoadHopperMenu(iPad, inventory, hopper);
|
||||
}
|
||||
bool GameMenuService::openHorse(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> container,
|
||||
std::shared_ptr<EntityHorse> horse) {
|
||||
return game_.LoadHorseMenu(iPad, inventory, container, horse);
|
||||
}
|
||||
bool GameMenuService::openBeacon(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BeaconTileEntity> beacon) {
|
||||
return game_.LoadBeaconMenu(iPad, inventory, beacon);
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "minecraft/client/IMenuService.h"
|
||||
|
||||
class Game;
|
||||
|
||||
class GameMenuService : public IMenuService {
|
||||
public:
|
||||
explicit GameMenuService(Game& game) : game_(game) {}
|
||||
|
||||
bool openInventory(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
bool navigateBack) override;
|
||||
bool openCreative(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
bool navigateBack) override;
|
||||
bool openCrafting2x2(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player) override;
|
||||
bool openCrafting3x3(int iPad, std::shared_ptr<LocalPlayer> player, int x,
|
||||
int y, int z) override;
|
||||
bool openEnchanting(int iPad, std::shared_ptr<Inventory> inventory, int x,
|
||||
int y, int z, Level* level,
|
||||
const std::string& name) override;
|
||||
bool openFurnace(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<FurnaceTileEntity> furnace) override;
|
||||
bool openBrewingStand(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand) override;
|
||||
bool openContainer(int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<Container> container) override;
|
||||
bool openTrap(int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<DispenserTileEntity> trap) override;
|
||||
bool openFireworks(int iPad, std::shared_ptr<LocalPlayer> player, int x,
|
||||
int y, int z) override;
|
||||
bool openSign(int iPad, std::shared_ptr<SignTileEntity> sign) override;
|
||||
bool openRepairing(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
Level* level, int x, int y, int z) override;
|
||||
bool openTrading(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Merchant> trader, Level* level,
|
||||
const std::string& name) override;
|
||||
bool openCommandBlock(
|
||||
int iPad, std::shared_ptr<CommandBlockEntity> commandBlock) override;
|
||||
bool openHopper(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<HopperTileEntity> hopper) override;
|
||||
bool openHopperMinecart(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<MinecartHopper> hopper) override;
|
||||
bool openHorse(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> container,
|
||||
std::shared_ptr<EntityHorse> horse) override;
|
||||
bool openBeacon(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BeaconTileEntity> beacon) override;
|
||||
|
||||
private:
|
||||
Game& game_;
|
||||
};
|
||||
@@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
#include "ConsoleGameRulesConstants.h"
|
||||
#include "GameRuleManager.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ApplySchematicRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelGeneration/BiomeOverride.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructure.h"
|
||||
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StartFeature.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionGenerateBox.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceContainer.h"
|
||||
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceSpawner.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/AddEnchantmentRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/AddItemRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/CollectItemRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/CompleteAllRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/CompoundGameRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/LevelRuleset.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/NamedAreaRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/UpdatePlayerRuleDefinition.h"
|
||||
#include "app/common/GameRules/LevelRules/RuleDefinitions/UseTileRuleDefinition.h"
|
||||
#include "minecraft/world/level/GameRules/GameRule.h"
|
||||
#include "minecraft/world/level/GameRules/GameRuleDefinition.h"
|
||||
#include "minecraft/world/level/GameRules/GameRulesInstance.h"
|
||||
#include "minecraft/world/level/GameRules/LevelGenerationOptions.h"
|
||||
@@ -1,78 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/profile/profile.h"
|
||||
|
||||
class GameSettingsManager {
|
||||
public:
|
||||
GameSettingsManager();
|
||||
|
||||
void initGameSettings();
|
||||
static int oldProfileVersionCallback(void* pParam, unsigned char* pucData,
|
||||
const unsigned short usVersion,
|
||||
const int iPad);
|
||||
static int defaultOptionsCallback(
|
||||
void* pParam, IPlatformProfile::PROFILESETTINGS* pSettings,
|
||||
const int iPad);
|
||||
int setDefaultOptions(IPlatformProfile::PROFILESETTINGS* pSettings,
|
||||
const int iPad);
|
||||
|
||||
void setGameSettings(int iPad, eGameSetting eVal, unsigned char ucVal);
|
||||
unsigned char getGameSettings(int iPad, eGameSetting eVal);
|
||||
unsigned char getGameSettings(eGameSetting eVal);
|
||||
|
||||
void checkGameSettingsChanged(bool bOverride5MinuteTimer = false,
|
||||
int iPad = XUSER_INDEX_ANY);
|
||||
void applyGameSettingsChanged(int iPad);
|
||||
void clearGameSettingsChangedFlag(int iPad);
|
||||
void actionGameSettings(int iPad, eGameSetting eVal);
|
||||
|
||||
unsigned int getGameSettingsDebugMask(int iPad = -1,
|
||||
bool bOverridePlayer = false);
|
||||
void setGameSettingsDebugMask(int iPad, unsigned int uiVal);
|
||||
void actionDebugMask(int iPad, bool bSetAllClear = false);
|
||||
|
||||
void setSpecialTutorialCompletionFlag(int iPad, int index);
|
||||
|
||||
// Mash-up pack worlds
|
||||
void hideMashupPackWorld(int iPad, unsigned int iMashupPackID);
|
||||
void enableMashupPackWorlds(int iPad);
|
||||
unsigned int getMashupPackWorlds(int iPad);
|
||||
|
||||
// Language/locale
|
||||
void setMinecraftLanguage(int iPad, unsigned char ucLanguage);
|
||||
unsigned char getMinecraftLanguage(int iPad);
|
||||
void setMinecraftLocale(int iPad, unsigned char ucLocale);
|
||||
unsigned char getMinecraftLocale(int iPad);
|
||||
|
||||
// Game host options (bitfield versions)
|
||||
void setGameHostOption(unsigned int& uiHostSettings, eGameHostOption eVal,
|
||||
unsigned int uiVal);
|
||||
unsigned int getGameHostOption(unsigned int uiHostSettings,
|
||||
eGameHostOption eVal);
|
||||
|
||||
bool canRecordStatsAndAchievements();
|
||||
|
||||
// HandleXuiActions and HandleButtonPresses
|
||||
void handleXuiActions();
|
||||
void handleButtonPresses();
|
||||
|
||||
// Action-related
|
||||
static void setActionConfirmed(void* param);
|
||||
|
||||
// Saving message
|
||||
int displaySavingMessage(const IPlatformStorage::ESavingMessage eMsg,
|
||||
int iPad);
|
||||
|
||||
// Game settings array - public, referenced by Game via alias
|
||||
GAME_SETTINGS* GameSettingsA[XUSER_MAX_COUNT];
|
||||
|
||||
// Game host settings bitfield
|
||||
unsigned int m_uiGameHostSettings;
|
||||
|
||||
private:
|
||||
void handleButtonPresses(int iPad);
|
||||
};
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "minecraft/GameEnums.h"
|
||||
#include "app/common/App_enums.h"
|
||||
|
||||
class IPlatformGame {
|
||||
public:
|
||||
@@ -20,10 +20,11 @@ public:
|
||||
virtual void ReadBannedList(int iPad, eTMSAction action = (eTMSAction)0,
|
||||
bool bCallback = false) = 0;
|
||||
|
||||
virtual int LoadLocalTMSFile(char* wchTMSFile) = 0;
|
||||
virtual int LoadLocalTMSFile(char* wchTMSFile, eFileExtensionType eExt) = 0;
|
||||
virtual int LoadLocalTMSFile(wchar_t* wchTMSFile) = 0;
|
||||
virtual int LoadLocalTMSFile(wchar_t* wchTMSFile,
|
||||
eFileExtensionType eExt) = 0;
|
||||
virtual void FreeLocalTMSFiles(eTMSFileType eType) = 0;
|
||||
virtual int GetLocalTMSFileIndex(char* wchTMSFile,
|
||||
virtual int GetLocalTMSFileIndex(wchar_t* wchTMSFile,
|
||||
bool bFilenameIncludesExtension,
|
||||
eFileExtensionType eEXT) = 0;
|
||||
};
|
||||
@@ -1,862 +0,0 @@
|
||||
#include "app/common/LocalizationManager.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/UI/All Platforms/ArchiveFile.h"
|
||||
#include "java/Random.h"
|
||||
#include "minecraft/GameEnums.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/resources/Colours/ColourTable.h"
|
||||
#include "minecraft/client/skins/TexturePack.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
#include "minecraft/locale/StringTable.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/input/input.h"
|
||||
#include "platform/renderer/renderer.h"
|
||||
#include "strings.h"
|
||||
#include "util/StringHelpers.h"
|
||||
#include "app/common/UI/ConsoleUIController.h"
|
||||
|
||||
int LocalizationManager::s_iHTMLFontSizesA[eHTMLSize_COUNT] = {20, 13, 20, 26};
|
||||
|
||||
TIPSTRUCT LocalizationManager::m_GameTipA[MAX_TIPS_GAMETIP] = {
|
||||
{0, IDS_TIPS_GAMETIP_1}, {0, IDS_TIPS_GAMETIP_2},
|
||||
{0, IDS_TIPS_GAMETIP_3}, {0, IDS_TIPS_GAMETIP_4},
|
||||
{0, IDS_TIPS_GAMETIP_5}, {0, IDS_TIPS_GAMETIP_6},
|
||||
{0, IDS_TIPS_GAMETIP_7}, {0, IDS_TIPS_GAMETIP_8},
|
||||
{0, IDS_TIPS_GAMETIP_9}, {0, IDS_TIPS_GAMETIP_10},
|
||||
{0, IDS_TIPS_GAMETIP_11}, {0, IDS_TIPS_GAMETIP_12},
|
||||
{0, IDS_TIPS_GAMETIP_13}, {0, IDS_TIPS_GAMETIP_14},
|
||||
{0, IDS_TIPS_GAMETIP_15}, {0, IDS_TIPS_GAMETIP_16},
|
||||
{0, IDS_TIPS_GAMETIP_17}, {0, IDS_TIPS_GAMETIP_18},
|
||||
{0, IDS_TIPS_GAMETIP_19}, {0, IDS_TIPS_GAMETIP_20},
|
||||
{0, IDS_TIPS_GAMETIP_21}, {0, IDS_TIPS_GAMETIP_22},
|
||||
{0, IDS_TIPS_GAMETIP_23}, {0, IDS_TIPS_GAMETIP_24},
|
||||
{0, IDS_TIPS_GAMETIP_25}, {0, IDS_TIPS_GAMETIP_26},
|
||||
{0, IDS_TIPS_GAMETIP_27}, {0, IDS_TIPS_GAMETIP_28},
|
||||
{0, IDS_TIPS_GAMETIP_29}, {0, IDS_TIPS_GAMETIP_30},
|
||||
{0, IDS_TIPS_GAMETIP_31}, {0, IDS_TIPS_GAMETIP_32},
|
||||
{0, IDS_TIPS_GAMETIP_33}, {0, IDS_TIPS_GAMETIP_34},
|
||||
{0, IDS_TIPS_GAMETIP_35}, {0, IDS_TIPS_GAMETIP_36},
|
||||
{0, IDS_TIPS_GAMETIP_37}, {0, IDS_TIPS_GAMETIP_38},
|
||||
{0, IDS_TIPS_GAMETIP_39}, {0, IDS_TIPS_GAMETIP_40},
|
||||
{0, IDS_TIPS_GAMETIP_41}, {0, IDS_TIPS_GAMETIP_42},
|
||||
{0, IDS_TIPS_GAMETIP_43}, {0, IDS_TIPS_GAMETIP_44},
|
||||
{0, IDS_TIPS_GAMETIP_45}, {0, IDS_TIPS_GAMETIP_46},
|
||||
{0, IDS_TIPS_GAMETIP_47}, {0, IDS_TIPS_GAMETIP_48},
|
||||
{0, IDS_TIPS_GAMETIP_49}, {0, IDS_TIPS_GAMETIP_50},
|
||||
};
|
||||
|
||||
TIPSTRUCT LocalizationManager::m_TriviaTipA[MAX_TIPS_TRIVIATIP] = {
|
||||
{0, IDS_TIPS_TRIVIA_1}, {0, IDS_TIPS_TRIVIA_2}, {0, IDS_TIPS_TRIVIA_3},
|
||||
{0, IDS_TIPS_TRIVIA_4}, {0, IDS_TIPS_TRIVIA_5}, {0, IDS_TIPS_TRIVIA_6},
|
||||
{0, IDS_TIPS_TRIVIA_7}, {0, IDS_TIPS_TRIVIA_8}, {0, IDS_TIPS_TRIVIA_9},
|
||||
{0, IDS_TIPS_TRIVIA_10}, {0, IDS_TIPS_TRIVIA_11}, {0, IDS_TIPS_TRIVIA_12},
|
||||
{0, IDS_TIPS_TRIVIA_13}, {0, IDS_TIPS_TRIVIA_14}, {0, IDS_TIPS_TRIVIA_15},
|
||||
{0, IDS_TIPS_TRIVIA_16}, {0, IDS_TIPS_TRIVIA_17}, {0, IDS_TIPS_TRIVIA_18},
|
||||
{0, IDS_TIPS_TRIVIA_19}, {0, IDS_TIPS_TRIVIA_20},
|
||||
};
|
||||
|
||||
Random* LocalizationManager::TipRandom = new Random();
|
||||
|
||||
LocalizationManager::LocalizationManager()
|
||||
: m_stringTable(nullptr), m_uiCurrentTip(0) {
|
||||
memset(m_TipIDA, 0, sizeof(m_TipIDA));
|
||||
}
|
||||
|
||||
void LocalizationManager::loadStringTable(ArchiveFile* mediaArchive) {
|
||||
if (m_stringTable != nullptr) {
|
||||
// we need to unload the current std::string table, this is a reload
|
||||
delete m_stringTable;
|
||||
}
|
||||
std::string localisationFile = "languages.loc";
|
||||
if (mediaArchive->hasFile(localisationFile)) {
|
||||
std::vector<uint8_t> locFile = mediaArchive->getFile(localisationFile);
|
||||
std::vector<std::string> locales;
|
||||
getLocale(locales);
|
||||
m_stringTable = new StringTable(locFile, locales);
|
||||
} else {
|
||||
m_stringTable = nullptr;
|
||||
assert(false);
|
||||
// AHHHHHHHHH.
|
||||
}
|
||||
}
|
||||
|
||||
const char* LocalizationManager::getString(int iID) const {
|
||||
return m_stringTable->getString(iID);
|
||||
}
|
||||
|
||||
int LocalizationManager::TipsSortFunction(const void* a, const void* b) {
|
||||
int s1 = ((TIPSTRUCT*)a)->iSortValue;
|
||||
int s2 = ((TIPSTRUCT*)b)->iSortValue;
|
||||
|
||||
if (s1 > s2) {
|
||||
return 1;
|
||||
} else if (s1 == s2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void LocalizationManager::initialiseTips() {
|
||||
memset(m_TipIDA, 0, sizeof(m_TipIDA));
|
||||
|
||||
if (!PlatformRenderer.IsHiDef()) {
|
||||
m_GameTipA[0].uiStringID = IDS_TIPS_GAMETIP_0;
|
||||
}
|
||||
|
||||
#if defined(_CONTENT_PACKAGE)
|
||||
for (int i = 1; i < MAX_TIPS_GAMETIP; i++) {
|
||||
m_GameTipA[i].iSortValue = TipRandom->nextInt();
|
||||
}
|
||||
qsort(&m_GameTipA[1], MAX_TIPS_GAMETIP - 1, sizeof(TIPSTRUCT),
|
||||
TipsSortFunction);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < MAX_TIPS_TRIVIATIP; i++) {
|
||||
m_TriviaTipA[i].iSortValue = TipRandom->nextInt();
|
||||
}
|
||||
qsort(m_TriviaTipA, MAX_TIPS_TRIVIATIP, sizeof(TIPSTRUCT),
|
||||
TipsSortFunction);
|
||||
|
||||
int iCurrentGameTip = 0;
|
||||
int iCurrentTriviaTip = 0;
|
||||
|
||||
for (int i = 0; i < MAX_TIPS_GAMETIP + MAX_TIPS_TRIVIATIP; i++) {
|
||||
if ((i % 3 == 2) && (iCurrentTriviaTip < MAX_TIPS_TRIVIATIP)) {
|
||||
m_TipIDA[i] = m_TriviaTipA[iCurrentTriviaTip++].uiStringID;
|
||||
} else {
|
||||
if (iCurrentGameTip < MAX_TIPS_GAMETIP) {
|
||||
m_TipIDA[i] = m_GameTipA[iCurrentGameTip++].uiStringID;
|
||||
} else {
|
||||
m_TipIDA[i] = m_TriviaTipA[iCurrentTriviaTip++].uiStringID;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_TipIDA[i] == 0) {
|
||||
#if !defined(_CONTENT_PACKAGE)
|
||||
assert(0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
m_uiCurrentTip = 0;
|
||||
}
|
||||
|
||||
int LocalizationManager::getNextTip() {
|
||||
static bool bShowSkinDLCTip = true;
|
||||
if (app.GetNewDLCAvailable() && app.DisplayNewDLCTip()) {
|
||||
return IDS_TIPS_GAMETIP_NEWDLC;
|
||||
} else {
|
||||
if (bShowSkinDLCTip) {
|
||||
bShowSkinDLCTip = false;
|
||||
if (app.DLCInstallProcessCompleted()) {
|
||||
if (app.m_dlcManager.getPackCount(DLCManager::e_DLCType_Skin) ==
|
||||
0) {
|
||||
return IDS_TIPS_GAMETIP_SKINPACKS;
|
||||
}
|
||||
} else {
|
||||
return IDS_TIPS_GAMETIP_SKINPACKS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_uiCurrentTip == MAX_TIPS_GAMETIP + MAX_TIPS_TRIVIATIP)
|
||||
m_uiCurrentTip = 0;
|
||||
|
||||
return m_TipIDA[m_uiCurrentTip++];
|
||||
}
|
||||
|
||||
int LocalizationManager::getHTMLColour(eMinecraftColour colour) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
return pMinecraft->skins->getSelected()->getColourTable()->getColour(
|
||||
colour);
|
||||
}
|
||||
|
||||
int LocalizationManager::getHTMLFontSize(EHTMLFontSize size) {
|
||||
return s_iHTMLFontSizesA[size];
|
||||
}
|
||||
|
||||
std::string LocalizationManager::formatHTMLString(
|
||||
int iPad, const std::string& desc, int shadowColour /*= 0xFFFFFFFF*/) {
|
||||
std::string text(desc);
|
||||
|
||||
char replacements[64];
|
||||
text = replaceAll(text, "{*B*}", "<br />");
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_T1));
|
||||
text = replaceAll(text, "{*T1*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_T2));
|
||||
text = replaceAll(text, "{*T2*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_T3));
|
||||
text = replaceAll(text, "{*T3*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_Black));
|
||||
text = replaceAll(text, "{*ETB*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_White));
|
||||
text = replaceAll(text, "{*ETW*}", replacements);
|
||||
text = replaceAll(text, "{*EF*}", "</font>");
|
||||
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_0), shadowColour);
|
||||
text = replaceAll(text, "{*C0*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_1), shadowColour);
|
||||
text = replaceAll(text, "{*C1*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_2), shadowColour);
|
||||
text = replaceAll(text, "{*C2*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_3), shadowColour);
|
||||
text = replaceAll(text, "{*C3*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_4), shadowColour);
|
||||
text = replaceAll(text, "{*C4*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_5), shadowColour);
|
||||
text = replaceAll(text, "{*C5*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_6), shadowColour);
|
||||
text = replaceAll(text, "{*C6*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_7), shadowColour);
|
||||
text = replaceAll(text, "{*C7*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_8), shadowColour);
|
||||
text = replaceAll(text, "{*C8*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_9), shadowColour);
|
||||
text = replaceAll(text, "{*C9*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_a), shadowColour);
|
||||
text = replaceAll(text, "{*CA*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_b), shadowColour);
|
||||
text = replaceAll(text, "{*CB*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_c), shadowColour);
|
||||
text = replaceAll(text, "{*CC*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_d), shadowColour);
|
||||
text = replaceAll(text, "{*CD*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_e), shadowColour);
|
||||
text = replaceAll(text, "{*CE*}", replacements);
|
||||
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
|
||||
getHTMLColour(eHTMLColor_f), shadowColour);
|
||||
text = replaceAll(text, "{*CF*}", replacements);
|
||||
|
||||
// Swap for southpaw.
|
||||
if (app.GetGameSettings(iPad, eGameSetting_ControlSouthPaw)) {
|
||||
text =
|
||||
replaceAll(text, "{*CONTROLLER_ACTION_MOVE*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_LOOK_RIGHT));
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_LOOK*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_RIGHT));
|
||||
|
||||
text = replaceAll(text, "{*CONTROLLER_MENU_NAVIGATE*}",
|
||||
getVKReplacement(VK_PAD_RTHUMB_LEFT));
|
||||
} else {
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_MOVE*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_RIGHT));
|
||||
text =
|
||||
replaceAll(text, "{*CONTROLLER_ACTION_LOOK*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_LOOK_RIGHT));
|
||||
|
||||
text = replaceAll(text, "{*CONTROLLER_MENU_NAVIGATE*}",
|
||||
getVKReplacement(VK_PAD_LTHUMB_LEFT));
|
||||
}
|
||||
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_JUMP*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_JUMP));
|
||||
text =
|
||||
replaceAll(text, "{*CONTROLLER_ACTION_SNEAK*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_SNEAK_TOGGLE));
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_USE*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_USE));
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_ACTION*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_ACTION));
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_LEFT_SCROLL*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_LEFT_SCROLL));
|
||||
text =
|
||||
replaceAll(text, "{*CONTROLLER_ACTION_RIGHT_SCROLL*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_RIGHT_SCROLL));
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_INVENTORY*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_INVENTORY));
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_CRAFTING*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_CRAFTING));
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_DROP*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_DROP));
|
||||
text = replaceAll(
|
||||
text, "{*CONTROLLER_ACTION_CAMERA*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_RENDER_THIRD_PERSON));
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_MENU_PAGEDOWN*}",
|
||||
getActionReplacement(iPad, ACTION_MENU_PAGEDOWN));
|
||||
text =
|
||||
replaceAll(text, "{*CONTROLLER_ACTION_DISMOUNT*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_SNEAK_TOGGLE));
|
||||
text = replaceAll(text, "{*CONTROLLER_VK_A*}", getVKReplacement(VK_PAD_A));
|
||||
text = replaceAll(text, "{*CONTROLLER_VK_B*}", getVKReplacement(VK_PAD_B));
|
||||
text = replaceAll(text, "{*CONTROLLER_VK_X*}", getVKReplacement(VK_PAD_X));
|
||||
text = replaceAll(text, "{*CONTROLLER_VK_Y*}", getVKReplacement(VK_PAD_Y));
|
||||
text = replaceAll(text, "{*CONTROLLER_VK_LB*}",
|
||||
getVKReplacement(VK_PAD_LSHOULDER));
|
||||
text = replaceAll(text, "{*CONTROLLER_VK_RB*}",
|
||||
getVKReplacement(VK_PAD_RSHOULDER));
|
||||
text = replaceAll(text, "{*CONTROLLER_VK_LS*}",
|
||||
getVKReplacement(VK_PAD_LTHUMB_UP));
|
||||
text = replaceAll(text, "{*CONTROLLER_VK_RS*}",
|
||||
getVKReplacement(VK_PAD_RTHUMB_UP));
|
||||
text = replaceAll(text, "{*CONTROLLER_VK_LT*}",
|
||||
getVKReplacement(VK_PAD_LTRIGGER));
|
||||
text = replaceAll(text, "{*CONTROLLER_VK_RT*}",
|
||||
getVKReplacement(VK_PAD_RTRIGGER));
|
||||
text = replaceAll(text, "{*ICON_SHANK_01*}",
|
||||
getIconReplacement(XZP_ICON_SHANK_01));
|
||||
text = replaceAll(text, "{*ICON_SHANK_03*}",
|
||||
getIconReplacement(XZP_ICON_SHANK_03));
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_DPAD_UP*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_DPAD_UP));
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_DPAD_DOWN*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_DPAD_DOWN));
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_DPAD_RIGHT*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_DPAD_RIGHT));
|
||||
text = replaceAll(text, "{*CONTROLLER_ACTION_DPAD_LEFT*}",
|
||||
getActionReplacement(iPad, MINECRAFT_ACTION_DPAD_LEFT));
|
||||
|
||||
std::uint32_t dwLanguage = XGetLanguage();
|
||||
switch (dwLanguage) {
|
||||
case XC_LANGUAGE_KOREAN:
|
||||
case XC_LANGUAGE_JAPANESE:
|
||||
case XC_LANGUAGE_TCHINESE:
|
||||
text = replaceAll(text, " ", "");
|
||||
break;
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
std::string LocalizationManager::getActionReplacement(int iPad,
|
||||
unsigned char ucAction) {
|
||||
unsigned int input = PlatformInput.GetGameJoypadMaps(
|
||||
PlatformInput.GetJoypadMapVal(iPad), ucAction);
|
||||
|
||||
std::string replacement = "";
|
||||
|
||||
if (input & _360_JOY_BUTTON_A)
|
||||
replacement = "ButtonA";
|
||||
else if (input & _360_JOY_BUTTON_B)
|
||||
replacement = "ButtonB";
|
||||
else if (input & _360_JOY_BUTTON_X)
|
||||
replacement = "ButtonX";
|
||||
else if (input & _360_JOY_BUTTON_Y)
|
||||
replacement = "ButtonY";
|
||||
else if ((input & _360_JOY_BUTTON_LSTICK_UP) ||
|
||||
(input & _360_JOY_BUTTON_LSTICK_DOWN) ||
|
||||
(input & _360_JOY_BUTTON_LSTICK_LEFT) ||
|
||||
(input & _360_JOY_BUTTON_LSTICK_RIGHT)) {
|
||||
replacement = "ButtonLeftStick";
|
||||
} else if ((input & _360_JOY_BUTTON_RSTICK_LEFT) ||
|
||||
(input & _360_JOY_BUTTON_RSTICK_RIGHT) ||
|
||||
(input & _360_JOY_BUTTON_RSTICK_UP) ||
|
||||
(input & _360_JOY_BUTTON_RSTICK_DOWN)) {
|
||||
replacement = "ButtonRightStick";
|
||||
} else if (input & _360_JOY_BUTTON_DPAD_LEFT)
|
||||
replacement = "ButtonDpadL";
|
||||
else if (input & _360_JOY_BUTTON_DPAD_RIGHT)
|
||||
replacement = "ButtonDpadR";
|
||||
else if (input & _360_JOY_BUTTON_DPAD_UP)
|
||||
replacement = "ButtonDpadU";
|
||||
else if (input & _360_JOY_BUTTON_DPAD_DOWN)
|
||||
replacement = "ButtonDpadD";
|
||||
else if (input & _360_JOY_BUTTON_LT)
|
||||
replacement = "ButtonLeftTrigger";
|
||||
else if (input & _360_JOY_BUTTON_RT)
|
||||
replacement = "ButtonRightTrigger";
|
||||
else if (input & _360_JOY_BUTTON_RB)
|
||||
replacement = "ButtonRightBumper";
|
||||
else if (input & _360_JOY_BUTTON_LB)
|
||||
replacement = "ButtonLeftBumper";
|
||||
else if (input & _360_JOY_BUTTON_BACK)
|
||||
replacement = "ButtonBack";
|
||||
else if (input & _360_JOY_BUTTON_START)
|
||||
replacement = "ButtonStart";
|
||||
else if (input & _360_JOY_BUTTON_RTHUMB)
|
||||
replacement = "ButtonRS";
|
||||
else if (input & _360_JOY_BUTTON_LTHUMB)
|
||||
replacement = "ButtonLS";
|
||||
|
||||
char string[128];
|
||||
|
||||
#if defined(_WIN64)
|
||||
int size = 45;
|
||||
if (ui.getScreenWidth() < 1920) size = 30;
|
||||
#else
|
||||
int size = 45;
|
||||
#endif
|
||||
|
||||
snprintf(string, 128,
|
||||
"<img src=\"%s\" align=\"middle\" height=\"%d\" width=\"%d\"/>",
|
||||
replacement.c_str(), size, size);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
std::string LocalizationManager::getVKReplacement(unsigned int uiVKey) {
|
||||
std::string replacement = "";
|
||||
switch (uiVKey) {
|
||||
case VK_PAD_A:
|
||||
replacement = "ButtonA";
|
||||
break;
|
||||
case VK_PAD_B:
|
||||
replacement = "ButtonB";
|
||||
break;
|
||||
case VK_PAD_X:
|
||||
replacement = "ButtonX";
|
||||
break;
|
||||
case VK_PAD_Y:
|
||||
replacement = "ButtonY";
|
||||
break;
|
||||
case VK_PAD_LSHOULDER:
|
||||
replacement = "ButtonLeftBumper";
|
||||
break;
|
||||
case VK_PAD_RSHOULDER:
|
||||
replacement = "ButtonRightBumper";
|
||||
break;
|
||||
case VK_PAD_LTRIGGER:
|
||||
replacement = "ButtonLeftTrigger";
|
||||
break;
|
||||
case VK_PAD_RTRIGGER:
|
||||
replacement = "ButtonRightTrigger";
|
||||
break;
|
||||
case VK_PAD_LTHUMB_UP:
|
||||
case VK_PAD_LTHUMB_DOWN:
|
||||
case VK_PAD_LTHUMB_RIGHT:
|
||||
case VK_PAD_LTHUMB_LEFT:
|
||||
case VK_PAD_LTHUMB_UPLEFT:
|
||||
case VK_PAD_LTHUMB_UPRIGHT:
|
||||
case VK_PAD_LTHUMB_DOWNRIGHT:
|
||||
case VK_PAD_LTHUMB_DOWNLEFT:
|
||||
replacement = "ButtonLeftStick";
|
||||
break;
|
||||
case VK_PAD_RTHUMB_UP:
|
||||
case VK_PAD_RTHUMB_DOWN:
|
||||
case VK_PAD_RTHUMB_RIGHT:
|
||||
case VK_PAD_RTHUMB_LEFT:
|
||||
case VK_PAD_RTHUMB_UPLEFT:
|
||||
case VK_PAD_RTHUMB_UPRIGHT:
|
||||
case VK_PAD_RTHUMB_DOWNRIGHT:
|
||||
case VK_PAD_RTHUMB_DOWNLEFT:
|
||||
replacement = "ButtonRightStick";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
char string[128];
|
||||
|
||||
#if defined(_WIN64)
|
||||
int size = 45;
|
||||
if (ui.getScreenWidth() < 1920) size = 30;
|
||||
#else
|
||||
int size = 45;
|
||||
#endif
|
||||
|
||||
snprintf(string, 128,
|
||||
"<img src=\"%s\" align=\"middle\" height=\"%d\" width=\"%d\"/>",
|
||||
replacement.c_str(), size, size);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
std::string LocalizationManager::getIconReplacement(unsigned int uiIcon) {
|
||||
char string[128];
|
||||
|
||||
#if defined(_WIN64)
|
||||
int size = 33;
|
||||
if (ui.getScreenWidth() < 1920) size = 22;
|
||||
#else
|
||||
int size = 33;
|
||||
#endif
|
||||
|
||||
snprintf(string, 128,
|
||||
"<img src=\"Icon_Shank\" align=\"middle\" height=\"%d\" "
|
||||
"width=\"%d\"/>",
|
||||
size, size);
|
||||
std::string result = "";
|
||||
switch (uiIcon) {
|
||||
case XZP_ICON_SHANK_01:
|
||||
result = string;
|
||||
break;
|
||||
case XZP_ICON_SHANK_03:
|
||||
result.append(string).append(string).append(string);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void LocalizationManager::getLocale(std::vector<std::string>& vecWstrLocales) {
|
||||
std::vector<eMCLang> locales;
|
||||
|
||||
const unsigned int systemLanguage = XGetLanguage();
|
||||
|
||||
switch (systemLanguage) {
|
||||
case XC_LANGUAGE_ENGLISH:
|
||||
switch (XGetLocale()) {
|
||||
case XC_LOCALE_AUSTRALIA:
|
||||
case XC_LOCALE_CANADA:
|
||||
case XC_LOCALE_CZECH_REPUBLIC:
|
||||
case XC_LOCALE_GREECE:
|
||||
case XC_LOCALE_HONG_KONG:
|
||||
case XC_LOCALE_HUNGARY:
|
||||
case XC_LOCALE_INDIA:
|
||||
case XC_LOCALE_IRELAND:
|
||||
case XC_LOCALE_ISRAEL:
|
||||
case XC_LOCALE_NEW_ZEALAND:
|
||||
case XC_LOCALE_SAUDI_ARABIA:
|
||||
case XC_LOCALE_SINGAPORE:
|
||||
case XC_LOCALE_SLOVAK_REPUBLIC:
|
||||
case XC_LOCALE_SOUTH_AFRICA:
|
||||
case XC_LOCALE_UNITED_ARAB_EMIRATES:
|
||||
case XC_LOCALE_GREAT_BRITAIN:
|
||||
locales.push_back(eMCLang_enGB);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case XC_LANGUAGE_JAPANESE:
|
||||
locales.push_back(eMCLang_jaJP);
|
||||
break;
|
||||
case XC_LANGUAGE_GERMAN:
|
||||
switch (XGetLocale()) {
|
||||
case XC_LOCALE_AUSTRIA:
|
||||
locales.push_back(eMCLang_deAT);
|
||||
break;
|
||||
case XC_LOCALE_SWITZERLAND:
|
||||
locales.push_back(eMCLang_deCH);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
locales.push_back(eMCLang_deDE);
|
||||
break;
|
||||
case XC_LANGUAGE_FRENCH:
|
||||
switch (XGetLocale()) {
|
||||
case XC_LOCALE_BELGIUM:
|
||||
locales.push_back(eMCLang_frBE);
|
||||
break;
|
||||
case XC_LOCALE_CANADA:
|
||||
locales.push_back(eMCLang_frCA);
|
||||
break;
|
||||
case XC_LOCALE_SWITZERLAND:
|
||||
locales.push_back(eMCLang_frCH);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
locales.push_back(eMCLang_frFR);
|
||||
break;
|
||||
case XC_LANGUAGE_SPANISH:
|
||||
switch (XGetLocale()) {
|
||||
case XC_LOCALE_MEXICO:
|
||||
case XC_LOCALE_ARGENTINA:
|
||||
case XC_LOCALE_CHILE:
|
||||
case XC_LOCALE_COLOMBIA:
|
||||
case XC_LOCALE_UNITED_STATES:
|
||||
case XC_LOCALE_LATIN_AMERICA:
|
||||
locales.push_back(eMCLang_laLAS);
|
||||
locales.push_back(eMCLang_esMX);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
locales.push_back(eMCLang_esES);
|
||||
break;
|
||||
case XC_LANGUAGE_ITALIAN:
|
||||
locales.push_back(eMCLang_itIT);
|
||||
break;
|
||||
case XC_LANGUAGE_KOREAN:
|
||||
locales.push_back(eMCLang_koKR);
|
||||
break;
|
||||
case XC_LANGUAGE_TCHINESE:
|
||||
switch (XGetLocale()) {
|
||||
case XC_LOCALE_HONG_KONG:
|
||||
locales.push_back(eMCLang_zhHK);
|
||||
locales.push_back(eMCLang_zhTW);
|
||||
break;
|
||||
case XC_LOCALE_TAIWAN:
|
||||
locales.push_back(eMCLang_zhTW);
|
||||
locales.push_back(eMCLang_zhHK);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
locales.push_back(eMCLang_hant);
|
||||
locales.push_back(eMCLang_zhCHT);
|
||||
break;
|
||||
case XC_LANGUAGE_PORTUGUESE:
|
||||
if (XGetLocale() == XC_LOCALE_BRAZIL) {
|
||||
locales.push_back(eMCLang_ptBR);
|
||||
}
|
||||
locales.push_back(eMCLang_ptPT);
|
||||
break;
|
||||
case XC_LANGUAGE_POLISH:
|
||||
locales.push_back(eMCLang_plPL);
|
||||
break;
|
||||
case XC_LANGUAGE_RUSSIAN:
|
||||
locales.push_back(eMCLang_ruRU);
|
||||
break;
|
||||
case XC_LANGUAGE_SWEDISH:
|
||||
locales.push_back(eMCLang_svSV);
|
||||
locales.push_back(eMCLang_svSE);
|
||||
break;
|
||||
case XC_LANGUAGE_TURKISH:
|
||||
locales.push_back(eMCLang_trTR);
|
||||
break;
|
||||
case XC_LANGUAGE_BNORWEGIAN:
|
||||
locales.push_back(eMCLang_nbNO);
|
||||
locales.push_back(eMCLang_noNO);
|
||||
locales.push_back(eMCLang_nnNO);
|
||||
break;
|
||||
case XC_LANGUAGE_DUTCH:
|
||||
switch (XGetLocale()) {
|
||||
case XC_LOCALE_BELGIUM:
|
||||
locales.push_back(eMCLang_nlBE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
locales.push_back(eMCLang_nlNL);
|
||||
break;
|
||||
case XC_LANGUAGE_SCHINESE:
|
||||
switch (XGetLocale()) {
|
||||
case XC_LOCALE_SINGAPORE:
|
||||
locales.push_back(eMCLang_zhSG);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
locales.push_back(eMCLang_hans);
|
||||
locales.push_back(eMCLang_csCS);
|
||||
locales.push_back(eMCLang_zhCN);
|
||||
break;
|
||||
}
|
||||
|
||||
locales.push_back(eMCLang_enUS);
|
||||
locales.push_back(eMCLang_null);
|
||||
|
||||
for (int i = 0; i < locales.size(); i++) {
|
||||
eMCLang lang = locales.at(i);
|
||||
vecWstrLocales.push_back(m_localeA[lang]);
|
||||
}
|
||||
}
|
||||
|
||||
int LocalizationManager::get_eMCLang(char* pwchLocale) {
|
||||
return m_eMCLangA[pwchLocale];
|
||||
}
|
||||
|
||||
int LocalizationManager::get_xcLang(char* pwchLocale) {
|
||||
return m_xcLangA[pwchLocale];
|
||||
}
|
||||
|
||||
void LocalizationManager::localeAndLanguageInit() {
|
||||
m_localeA[eMCLang_zhCHT] = "zh-CHT";
|
||||
m_localeA[eMCLang_csCS] = "cs-CS";
|
||||
m_localeA[eMCLang_laLAS] = "la-LAS";
|
||||
m_localeA[eMCLang_null] = "en-EN";
|
||||
m_localeA[eMCLang_enUS] = "en-US";
|
||||
m_localeA[eMCLang_enGB] = "en-GB";
|
||||
m_localeA[eMCLang_enIE] = "en-IE";
|
||||
m_localeA[eMCLang_enAU] = "en-AU";
|
||||
m_localeA[eMCLang_enNZ] = "en-NZ";
|
||||
m_localeA[eMCLang_enCA] = "en-CA";
|
||||
m_localeA[eMCLang_jaJP] = "ja-JP";
|
||||
m_localeA[eMCLang_deDE] = "de-DE";
|
||||
m_localeA[eMCLang_deAT] = "de-AT";
|
||||
m_localeA[eMCLang_frFR] = "fr-FR";
|
||||
m_localeA[eMCLang_frCA] = "fr-CA";
|
||||
m_localeA[eMCLang_esES] = "es-ES";
|
||||
m_localeA[eMCLang_esMX] = "es-MX";
|
||||
m_localeA[eMCLang_itIT] = "it-IT";
|
||||
m_localeA[eMCLang_koKR] = "ko-KR";
|
||||
m_localeA[eMCLang_ptPT] = "pt-PT";
|
||||
m_localeA[eMCLang_ptBR] = "pt-BR";
|
||||
m_localeA[eMCLang_ruRU] = "ru-RU";
|
||||
m_localeA[eMCLang_nlNL] = "nl-NL";
|
||||
m_localeA[eMCLang_fiFI] = "fi-FI";
|
||||
m_localeA[eMCLang_svSV] = "sv-SV";
|
||||
m_localeA[eMCLang_daDA] = "da-DA";
|
||||
m_localeA[eMCLang_noNO] = "no-NO";
|
||||
m_localeA[eMCLang_plPL] = "pl-PL";
|
||||
m_localeA[eMCLang_trTR] = "tr-TR";
|
||||
m_localeA[eMCLang_elEL] = "el-EL";
|
||||
m_localeA[eMCLang_zhSG] = "zh-SG";
|
||||
m_localeA[eMCLang_zhCN] = "zh-CN";
|
||||
m_localeA[eMCLang_zhHK] = "zh-HK";
|
||||
m_localeA[eMCLang_zhTW] = "zh-TW";
|
||||
m_localeA[eMCLang_nlBE] = "nl-BE";
|
||||
m_localeA[eMCLang_daDK] = "da-DK";
|
||||
m_localeA[eMCLang_frBE] = "fr-BE";
|
||||
m_localeA[eMCLang_frCH] = "fr-CH";
|
||||
m_localeA[eMCLang_deCH] = "de-CH";
|
||||
m_localeA[eMCLang_nbNO] = "nb-NO";
|
||||
m_localeA[eMCLang_enGR] = "en-GR";
|
||||
m_localeA[eMCLang_enHK] = "en-HK";
|
||||
m_localeA[eMCLang_enSA] = "en-SA";
|
||||
m_localeA[eMCLang_enHU] = "en-HU";
|
||||
m_localeA[eMCLang_enIN] = "en-IN";
|
||||
m_localeA[eMCLang_enIL] = "en-IL";
|
||||
m_localeA[eMCLang_enSG] = "en-SG";
|
||||
m_localeA[eMCLang_enSK] = "en-SK";
|
||||
m_localeA[eMCLang_enZA] = "en-ZA";
|
||||
m_localeA[eMCLang_enCZ] = "en-CZ";
|
||||
m_localeA[eMCLang_enAE] = "en-AE";
|
||||
m_localeA[eMCLang_esAR] = "es-AR";
|
||||
m_localeA[eMCLang_esCL] = "es-CL";
|
||||
m_localeA[eMCLang_esCO] = "es-CO";
|
||||
m_localeA[eMCLang_esUS] = "es-US";
|
||||
m_localeA[eMCLang_svSE] = "sv-SE";
|
||||
m_localeA[eMCLang_csCZ] = "cs-CZ";
|
||||
m_localeA[eMCLang_elGR] = "el-GR";
|
||||
m_localeA[eMCLang_nnNO] = "nn-NO";
|
||||
m_localeA[eMCLang_skSK] = "sk-SK";
|
||||
m_localeA[eMCLang_hans] = "zh-HANS";
|
||||
m_localeA[eMCLang_hant] = "zh-HANT";
|
||||
|
||||
m_eMCLangA["zh-CHT"] = eMCLang_zhCHT;
|
||||
m_eMCLangA["cs-CS"] = eMCLang_csCS;
|
||||
m_eMCLangA["la-LAS"] = eMCLang_laLAS;
|
||||
m_eMCLangA["en-EN"] = eMCLang_null;
|
||||
m_eMCLangA["en-US"] = eMCLang_enUS;
|
||||
m_eMCLangA["en-GB"] = eMCLang_enGB;
|
||||
m_eMCLangA["en-IE"] = eMCLang_enIE;
|
||||
m_eMCLangA["en-AU"] = eMCLang_enAU;
|
||||
m_eMCLangA["en-NZ"] = eMCLang_enNZ;
|
||||
m_eMCLangA["en-CA"] = eMCLang_enCA;
|
||||
m_eMCLangA["ja-JP"] = eMCLang_jaJP;
|
||||
m_eMCLangA["de-DE"] = eMCLang_deDE;
|
||||
m_eMCLangA["de-AT"] = eMCLang_deAT;
|
||||
m_eMCLangA["fr-FR"] = eMCLang_frFR;
|
||||
m_eMCLangA["fr-CA"] = eMCLang_frCA;
|
||||
m_eMCLangA["es-ES"] = eMCLang_esES;
|
||||
m_eMCLangA["es-MX"] = eMCLang_esMX;
|
||||
m_eMCLangA["it-IT"] = eMCLang_itIT;
|
||||
m_eMCLangA["ko-KR"] = eMCLang_koKR;
|
||||
m_eMCLangA["pt-PT"] = eMCLang_ptPT;
|
||||
m_eMCLangA["pt-BR"] = eMCLang_ptBR;
|
||||
m_eMCLangA["ru-RU"] = eMCLang_ruRU;
|
||||
m_eMCLangA["nl-NL"] = eMCLang_nlNL;
|
||||
m_eMCLangA["fi-FI"] = eMCLang_fiFI;
|
||||
m_eMCLangA["sv-SV"] = eMCLang_svSV;
|
||||
m_eMCLangA["da-DA"] = eMCLang_daDA;
|
||||
m_eMCLangA["no-NO"] = eMCLang_noNO;
|
||||
m_eMCLangA["pl-PL"] = eMCLang_plPL;
|
||||
m_eMCLangA["tr-TR"] = eMCLang_trTR;
|
||||
m_eMCLangA["el-EL"] = eMCLang_elEL;
|
||||
m_eMCLangA["zh-SG"] = eMCLang_zhSG;
|
||||
m_eMCLangA["zh-CN"] = eMCLang_zhCN;
|
||||
m_eMCLangA["zh-HK"] = eMCLang_zhHK;
|
||||
m_eMCLangA["zh-TW"] = eMCLang_zhTW;
|
||||
m_eMCLangA["nl-BE"] = eMCLang_nlBE;
|
||||
m_eMCLangA["da-DK"] = eMCLang_daDK;
|
||||
m_eMCLangA["fr-BE"] = eMCLang_frBE;
|
||||
m_eMCLangA["fr-CH"] = eMCLang_frCH;
|
||||
m_eMCLangA["de-CH"] = eMCLang_deCH;
|
||||
m_eMCLangA["nb-NO"] = eMCLang_nbNO;
|
||||
m_eMCLangA["en-GR"] = eMCLang_enGR;
|
||||
m_eMCLangA["en-HK"] = eMCLang_enHK;
|
||||
m_eMCLangA["en-SA"] = eMCLang_enSA;
|
||||
m_eMCLangA["en-HU"] = eMCLang_enHU;
|
||||
m_eMCLangA["en-IN"] = eMCLang_enIN;
|
||||
m_eMCLangA["en-IL"] = eMCLang_enIL;
|
||||
m_eMCLangA["en-SG"] = eMCLang_enSG;
|
||||
m_eMCLangA["en-SK"] = eMCLang_enSK;
|
||||
m_eMCLangA["en-ZA"] = eMCLang_enZA;
|
||||
m_eMCLangA["en-CZ"] = eMCLang_enCZ;
|
||||
m_eMCLangA["en-AE"] = eMCLang_enAE;
|
||||
m_eMCLangA["es-AR"] = eMCLang_esAR;
|
||||
m_eMCLangA["es-CL"] = eMCLang_esCL;
|
||||
m_eMCLangA["es-CO"] = eMCLang_esCO;
|
||||
m_eMCLangA["es-US"] = eMCLang_esUS;
|
||||
m_eMCLangA["sv-SE"] = eMCLang_svSE;
|
||||
m_eMCLangA["cs-CZ"] = eMCLang_csCZ;
|
||||
m_eMCLangA["el-GR"] = eMCLang_elGR;
|
||||
m_eMCLangA["nn-NO"] = eMCLang_nnNO;
|
||||
m_eMCLangA["sk-SK"] = eMCLang_skSK;
|
||||
m_eMCLangA["zh-HANS"] = eMCLang_hans;
|
||||
m_eMCLangA["zh-HANT"] = eMCLang_hant;
|
||||
|
||||
m_xcLangA["zh-CHT"] = XC_LOCALE_CHINA;
|
||||
m_xcLangA["cs-CS"] = XC_LOCALE_CHINA;
|
||||
m_xcLangA["en-EN"] = XC_LOCALE_UNITED_STATES;
|
||||
m_xcLangA["en-US"] = XC_LOCALE_UNITED_STATES;
|
||||
m_xcLangA["en-GB"] = XC_LOCALE_GREAT_BRITAIN;
|
||||
m_xcLangA["en-IE"] = XC_LOCALE_IRELAND;
|
||||
m_xcLangA["en-AU"] = XC_LOCALE_AUSTRALIA;
|
||||
m_xcLangA["en-NZ"] = XC_LOCALE_NEW_ZEALAND;
|
||||
m_xcLangA["en-CA"] = XC_LOCALE_CANADA;
|
||||
m_xcLangA["ja-JP"] = XC_LOCALE_JAPAN;
|
||||
m_xcLangA["de-DE"] = XC_LOCALE_GERMANY;
|
||||
m_xcLangA["de-AT"] = XC_LOCALE_AUSTRIA;
|
||||
m_xcLangA["fr-FR"] = XC_LOCALE_FRANCE;
|
||||
m_xcLangA["fr-CA"] = XC_LOCALE_CANADA;
|
||||
m_xcLangA["es-ES"] = XC_LOCALE_SPAIN;
|
||||
m_xcLangA["es-MX"] = XC_LOCALE_MEXICO;
|
||||
m_xcLangA["it-IT"] = XC_LOCALE_ITALY;
|
||||
m_xcLangA["ko-KR"] = XC_LOCALE_KOREA;
|
||||
m_xcLangA["pt-PT"] = XC_LOCALE_PORTUGAL;
|
||||
m_xcLangA["pt-BR"] = XC_LOCALE_BRAZIL;
|
||||
m_xcLangA["ru-RU"] = XC_LOCALE_RUSSIAN_FEDERATION;
|
||||
m_xcLangA["nl-NL"] = XC_LOCALE_NETHERLANDS;
|
||||
m_xcLangA["fi-FI"] = XC_LOCALE_FINLAND;
|
||||
m_xcLangA["sv-SV"] = XC_LOCALE_SWEDEN;
|
||||
m_xcLangA["da-DA"] = XC_LOCALE_DENMARK;
|
||||
m_xcLangA["no-NO"] = XC_LOCALE_NORWAY;
|
||||
m_xcLangA["pl-PL"] = XC_LOCALE_POLAND;
|
||||
m_xcLangA["tr-TR"] = XC_LOCALE_TURKEY;
|
||||
m_xcLangA["el-EL"] = XC_LOCALE_GREECE;
|
||||
m_xcLangA["la-LAS"] = XC_LOCALE_LATIN_AMERICA;
|
||||
m_xcLangA["zh-SG"] = XC_LOCALE_SINGAPORE;
|
||||
m_xcLangA["Zh-CN"] = XC_LOCALE_CHINA;
|
||||
m_xcLangA["zh-HK"] = XC_LOCALE_HONG_KONG;
|
||||
m_xcLangA["zh-TW"] = XC_LOCALE_TAIWAN;
|
||||
m_xcLangA["nl-BE"] = XC_LOCALE_BELGIUM;
|
||||
m_xcLangA["da-DK"] = XC_LOCALE_DENMARK;
|
||||
m_xcLangA["fr-BE"] = XC_LOCALE_BELGIUM;
|
||||
m_xcLangA["fr-CH"] = XC_LOCALE_SWITZERLAND;
|
||||
m_xcLangA["de-CH"] = XC_LOCALE_SWITZERLAND;
|
||||
m_xcLangA["nb-NO"] = XC_LOCALE_NORWAY;
|
||||
m_xcLangA["en-GR"] = XC_LOCALE_GREECE;
|
||||
m_xcLangA["en-HK"] = XC_LOCALE_HONG_KONG;
|
||||
m_xcLangA["en-SA"] = XC_LOCALE_SAUDI_ARABIA;
|
||||
m_xcLangA["en-HU"] = XC_LOCALE_HUNGARY;
|
||||
m_xcLangA["en-IN"] = XC_LOCALE_INDIA;
|
||||
m_xcLangA["en-IL"] = XC_LOCALE_ISRAEL;
|
||||
m_xcLangA["en-SG"] = XC_LOCALE_SINGAPORE;
|
||||
m_xcLangA["en-SK"] = XC_LOCALE_SLOVAK_REPUBLIC;
|
||||
m_xcLangA["en-ZA"] = XC_LOCALE_SOUTH_AFRICA;
|
||||
m_xcLangA["en-CZ"] = XC_LOCALE_CZECH_REPUBLIC;
|
||||
m_xcLangA["en-AE"] = XC_LOCALE_UNITED_ARAB_EMIRATES;
|
||||
m_xcLangA["ja-IP"] = XC_LOCALE_JAPAN;
|
||||
m_xcLangA["es-AR"] = XC_LOCALE_ARGENTINA;
|
||||
m_xcLangA["es-CL"] = XC_LOCALE_CHILE;
|
||||
m_xcLangA["es-CO"] = XC_LOCALE_COLOMBIA;
|
||||
m_xcLangA["es-US"] = XC_LOCALE_UNITED_STATES;
|
||||
m_xcLangA["sv-SE"] = XC_LOCALE_SWEDEN;
|
||||
m_xcLangA["cs-CZ"] = XC_LOCALE_CZECH_REPUBLIC;
|
||||
m_xcLangA["el-GR"] = XC_LOCALE_GREECE;
|
||||
m_xcLangA["sk-SK"] = XC_LOCALE_SLOVAK_REPUBLIC;
|
||||
m_xcLangA["zh-HANS"] = XC_LOCALE_CHINA;
|
||||
m_xcLangA["zh-HANT"] = XC_LOCALE_CHINA;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "minecraft/GameEnums.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
|
||||
class ArchiveFile;
|
||||
class Random;
|
||||
class StringTable;
|
||||
|
||||
class LocalizationManager {
|
||||
public:
|
||||
LocalizationManager();
|
||||
|
||||
void localeAndLanguageInit();
|
||||
void loadStringTable(ArchiveFile* mediaArchive);
|
||||
const char* getString(int iID) const;
|
||||
|
||||
std::string formatHTMLString(int iPad, const std::string& desc,
|
||||
int shadowColour = 0xFFFFFFFF);
|
||||
std::string getActionReplacement(int iPad, unsigned char ucAction);
|
||||
std::string getVKReplacement(unsigned int uiVKey);
|
||||
std::string getIconReplacement(unsigned int uiIcon);
|
||||
|
||||
int getHTMLColour(eMinecraftColour colour);
|
||||
int getHTMLColor(eMinecraftColour colour) { return getHTMLColour(colour); }
|
||||
int getHTMLFontSize(EHTMLFontSize size);
|
||||
|
||||
void initialiseTips();
|
||||
int getNextTip();
|
||||
|
||||
void getLocale(std::vector<std::string>& vecWstrLocales);
|
||||
int get_eMCLang(char* pwchLocale);
|
||||
int get_xcLang(char* pwchLocale);
|
||||
|
||||
StringTable* getStringTable() const { return m_stringTable; }
|
||||
|
||||
private:
|
||||
static int s_iHTMLFontSizesA[eHTMLSize_COUNT];
|
||||
|
||||
StringTable* m_stringTable;
|
||||
|
||||
std::unordered_map<int, std::string> m_localeA;
|
||||
std::unordered_map<std::string, int> m_eMCLangA;
|
||||
std::unordered_map<std::string, int> m_xcLangA;
|
||||
|
||||
static const int MAX_TIPS_GAMETIP = 50;
|
||||
static const int MAX_TIPS_TRIVIATIP = 20;
|
||||
static TIPSTRUCT m_GameTipA[MAX_TIPS_GAMETIP];
|
||||
static TIPSTRUCT m_TriviaTipA[MAX_TIPS_TRIVIATIP];
|
||||
static Random* TipRandom;
|
||||
|
||||
int m_TipIDA[MAX_TIPS_GAMETIP + MAX_TIPS_TRIVIATIP];
|
||||
unsigned int m_uiCurrentTip;
|
||||
static int TipsSortFunction(const void* a, const void* b);
|
||||
};
|
||||
@@ -1,665 +0,0 @@
|
||||
#include "app/common/MenuController.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/UI/All Platforms/UIEnums.h"
|
||||
#include "app/common/UI/All Platforms/UIStructs.h"
|
||||
#include "app/common/UI/ConsoleUIController.h"
|
||||
#include "app/common/UI/Scenes/UIScene_FullscreenProgress.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/ProgressRenderer.h"
|
||||
#include "minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
|
||||
#include "minecraft/client/renderer/GameRenderer.h"
|
||||
#include "minecraft/server/MinecraftServer.h"
|
||||
#include "minecraft/world/Container.h"
|
||||
#include "minecraft/world/entity/item/MinecartHopper.h"
|
||||
#include "minecraft/world/entity/player/Player.h"
|
||||
#include "minecraft/world/item/crafting/Recipy.h"
|
||||
#include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h"
|
||||
#include "minecraft/world/level/tile/Tile.h"
|
||||
#include "minecraft/world/level/tile/entity/HopperTileEntity.h"
|
||||
#include "platform/profile/profile.h"
|
||||
#include "platform/storage/storage.h"
|
||||
#include "strings.h"
|
||||
|
||||
unsigned char MenuController::m_szPNG[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
||||
MenuController::MenuController() {
|
||||
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
|
||||
m_eTMSAction[i] = eTMSAction_Idle;
|
||||
m_eXuiAction[i] = eAppAction_Idle;
|
||||
m_eXuiActionParam[i] = nullptr;
|
||||
m_uiOpacityCountDown[i] = 0;
|
||||
}
|
||||
m_eGlobalXuiAction = eAppAction_Idle;
|
||||
}
|
||||
|
||||
void MenuController::setAction(int iPad, eXuiAction action, void* param) {
|
||||
if ((m_eXuiAction[iPad] == eAppAction_ReloadTexturePack) &&
|
||||
(action == eAppAction_EthernetDisconnected)) {
|
||||
app.DebugPrintf(
|
||||
"Invalid change of App action for pad %d from %d to %d, ignoring\n",
|
||||
iPad, m_eXuiAction[iPad], action);
|
||||
} else if ((m_eXuiAction[iPad] == eAppAction_ReloadTexturePack) &&
|
||||
(action == eAppAction_ExitWorld)) {
|
||||
app.DebugPrintf(
|
||||
"Invalid change of App action for pad %d from %d to %d, ignoring\n",
|
||||
iPad, m_eXuiAction[iPad], action);
|
||||
} else if (m_eXuiAction[iPad] == eAppAction_ExitWorldCapturedThumbnail &&
|
||||
action != eAppAction_Idle) {
|
||||
app.DebugPrintf(
|
||||
"Invalid change of App action for pad %d from %d to %d, ignoring\n",
|
||||
iPad, m_eXuiAction[iPad], action);
|
||||
} else {
|
||||
app.DebugPrintf("Changing App action for pad %d from %d to %d\n", iPad,
|
||||
m_eXuiAction[iPad], action);
|
||||
m_eXuiAction[iPad] = action;
|
||||
m_eXuiActionParam[iPad] = param;
|
||||
}
|
||||
}
|
||||
|
||||
bool MenuController::loadInventoryMenu(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
bool bNavigateBack) {
|
||||
bool success = true;
|
||||
|
||||
InventoryScreenInput* initData = new InventoryScreenInput();
|
||||
initData->player = player;
|
||||
initData->bNavigateBack = bNavigateBack;
|
||||
initData->iPad = iPad;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_InventoryMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_InventoryMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadCreativeMenu(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
bool bNavigateBack) {
|
||||
bool success = true;
|
||||
|
||||
InventoryScreenInput* initData = new InventoryScreenInput();
|
||||
initData->player = player;
|
||||
initData->bNavigateBack = bNavigateBack;
|
||||
initData->iPad = iPad;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_CreativeMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_CreativeMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadCrafting2x2Menu(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player) {
|
||||
bool success = true;
|
||||
|
||||
CraftingPanelScreenInput* initData = new CraftingPanelScreenInput();
|
||||
initData->player = player;
|
||||
initData->iContainerType = RECIPE_TYPE_2x2;
|
||||
initData->iPad = iPad;
|
||||
initData->x = 0;
|
||||
initData->y = 0;
|
||||
initData->z = 0;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_Crafting2x2Menu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_Crafting2x2Menu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadCrafting3x3Menu(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
int x, int y, int z) {
|
||||
bool success = true;
|
||||
|
||||
CraftingPanelScreenInput* initData = new CraftingPanelScreenInput();
|
||||
initData->player = player;
|
||||
initData->iContainerType = RECIPE_TYPE_3x3;
|
||||
initData->iPad = iPad;
|
||||
initData->x = x;
|
||||
initData->y = y;
|
||||
initData->z = z;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_Crafting3x3Menu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_Crafting3x3Menu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadFireworksMenu(int iPad,
|
||||
std::shared_ptr<LocalPlayer> player,
|
||||
int x, int y, int z) {
|
||||
bool success = true;
|
||||
|
||||
FireworksScreenInput* initData = new FireworksScreenInput();
|
||||
initData->player = player;
|
||||
initData->iPad = iPad;
|
||||
initData->x = x;
|
||||
initData->y = y;
|
||||
initData->z = z;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_FireworksMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_FireworksMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadEnchantingMenu(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
int x, int y, int z, Level* level,
|
||||
const std::string& name) {
|
||||
bool success = true;
|
||||
|
||||
EnchantingScreenInput* initData = new EnchantingScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->level = level;
|
||||
initData->x = x;
|
||||
initData->y = y;
|
||||
initData->z = z;
|
||||
initData->iPad = iPad;
|
||||
initData->name = name;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_EnchantingMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_EnchantingMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadFurnaceMenu(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<FurnaceTileEntity> furnace) {
|
||||
bool success = true;
|
||||
|
||||
FurnaceScreenInput* initData = new FurnaceScreenInput();
|
||||
initData->furnace = furnace;
|
||||
initData->inventory = inventory;
|
||||
initData->iPad = iPad;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_FurnaceMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_FurnaceMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadBrewingStandMenu(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand) {
|
||||
bool success = true;
|
||||
|
||||
BrewingScreenInput* initData = new BrewingScreenInput();
|
||||
initData->brewingStand = brewingStand;
|
||||
initData->inventory = inventory;
|
||||
initData->iPad = iPad;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_BrewingStandMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_BrewingStandMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadContainerMenu(int iPad,
|
||||
std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<Container> container) {
|
||||
bool success = true;
|
||||
|
||||
ContainerScreenInput* initData = new ContainerScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->container = container;
|
||||
initData->iPad = iPad;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
|
||||
bool bLargeChest =
|
||||
(initData->container->getContainerSize() > 3 * 9) ? true : false;
|
||||
if (bLargeChest) {
|
||||
success =
|
||||
ui.NavigateToScene(iPad, eUIScene_LargeContainerMenu, initData);
|
||||
} else {
|
||||
success =
|
||||
ui.NavigateToScene(iPad, eUIScene_ContainerMenu, initData);
|
||||
}
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_ContainerMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadTrapMenu(int iPad,
|
||||
std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<DispenserTileEntity> trap) {
|
||||
bool success = true;
|
||||
|
||||
TrapScreenInput* initData = new TrapScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->trap = trap;
|
||||
initData->iPad = iPad;
|
||||
|
||||
if (app.GetLocalPlayerCount() > 1) {
|
||||
initData->bSplitscreen = true;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_DispenserMenu, initData);
|
||||
} else {
|
||||
initData->bSplitscreen = false;
|
||||
success = ui.NavigateToScene(iPad, eUIScene_DispenserMenu, initData);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadSignEntryMenu(int iPad,
|
||||
std::shared_ptr<SignTileEntity> sign) {
|
||||
bool success = true;
|
||||
|
||||
SignEntryScreenInput* initData = new SignEntryScreenInput();
|
||||
initData->sign = sign;
|
||||
initData->iPad = iPad;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_SignEntryMenu, initData);
|
||||
|
||||
delete initData;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadRepairingMenu(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
Level* level, int x, int y, int z) {
|
||||
bool success = true;
|
||||
|
||||
AnvilScreenInput* initData = new AnvilScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->level = level;
|
||||
initData->x = x;
|
||||
initData->y = y;
|
||||
initData->z = z;
|
||||
initData->iPad = iPad;
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
initData->bSplitscreen = true;
|
||||
else
|
||||
initData->bSplitscreen = false;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_AnvilMenu, initData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadTradingMenu(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Merchant> trader,
|
||||
Level* level, const std::string& name) {
|
||||
bool success = true;
|
||||
|
||||
TradingScreenInput* initData = new TradingScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->trader = trader;
|
||||
initData->level = level;
|
||||
initData->iPad = iPad;
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
initData->bSplitscreen = true;
|
||||
else
|
||||
initData->bSplitscreen = false;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_TradingMenu, initData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadHopperMenu(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<HopperTileEntity> hopper) {
|
||||
bool success = true;
|
||||
|
||||
HopperScreenInput* initData = new HopperScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->hopper = hopper;
|
||||
initData->iPad = iPad;
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
initData->bSplitscreen = true;
|
||||
else
|
||||
initData->bSplitscreen = false;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_HopperMenu, initData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadHopperMenu(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<MinecartHopper> hopper) {
|
||||
bool success = true;
|
||||
|
||||
HopperScreenInput* initData = new HopperScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->hopper = std::dynamic_pointer_cast<Container>(hopper);
|
||||
initData->iPad = iPad;
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
initData->bSplitscreen = true;
|
||||
else
|
||||
initData->bSplitscreen = false;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_HopperMenu, initData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadHorseMenu(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> container,
|
||||
std::shared_ptr<EntityHorse> horse) {
|
||||
bool success = true;
|
||||
|
||||
HorseScreenInput* initData = new HorseScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->container = container;
|
||||
initData->horse = horse;
|
||||
initData->iPad = iPad;
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
initData->bSplitscreen = true;
|
||||
else
|
||||
initData->bSplitscreen = false;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_HorseMenu, initData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool MenuController::loadBeaconMenu(int iPad,
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BeaconTileEntity> beacon) {
|
||||
bool success = true;
|
||||
|
||||
BeaconScreenInput* initData = new BeaconScreenInput();
|
||||
initData->inventory = inventory;
|
||||
initData->beacon = beacon;
|
||||
initData->iPad = iPad;
|
||||
if (app.GetLocalPlayerCount() > 1)
|
||||
initData->bSplitscreen = true;
|
||||
else
|
||||
initData->bSplitscreen = false;
|
||||
|
||||
success = ui.NavigateToScene(iPad, eUIScene_BeaconMenu, initData);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
int MenuController::texturePackDialogReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MenuController::unlockFullInviteReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
bool bNoPlayer;
|
||||
|
||||
if (pMinecraft->player == nullptr) {
|
||||
bNoPlayer = true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MenuController::unlockFullSaveReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MenuController::unlockFullExitReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
|
||||
Game* pApp = (Game*)pParam;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (result != IPlatformStorage::EMessage_ResultAccept) {
|
||||
pApp->SetAction(pMinecraft->player->GetXboxPad(),
|
||||
eAppAction_ExitWorldTrial);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MenuController::trialOverReturned(void* pParam, int iPad,
|
||||
IPlatformStorage::EMessageResult result) {
|
||||
Game* pApp = (Game*)pParam;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (result != IPlatformStorage::EMessage_ResultAccept) {
|
||||
pApp->SetAction(pMinecraft->player->GetXboxPad(), eAppAction_ExitTrial);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MenuController::remoteSaveThreadProc(void* lpParameter) {
|
||||
Compression::UseDefaultThreadStorage();
|
||||
Tile::CreateNewThreadStorage();
|
||||
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
pMinecraft->progressRenderer->progressStartNoAbort(
|
||||
IDS_PROGRESS_HOST_SAVING);
|
||||
pMinecraft->progressRenderer->progressStage(-1);
|
||||
pMinecraft->progressRenderer->progressStagePercentage(0);
|
||||
|
||||
while (!app.GetGameStarted() &&
|
||||
app.GetXuiAction(PlatformProfile.GetPrimaryPad()) ==
|
||||
eAppAction_WaitRemoteServerSaveComplete) {
|
||||
pMinecraft->tickAllConnections();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
|
||||
if (app.GetXuiAction(PlatformProfile.GetPrimaryPad()) !=
|
||||
eAppAction_WaitRemoteServerSaveComplete) {
|
||||
return 1223; // ERROR_CANCELLED
|
||||
}
|
||||
app.SetAction(PlatformProfile.GetPrimaryPad(), eAppAction_Idle);
|
||||
|
||||
ui.UpdatePlayerBasePositions();
|
||||
|
||||
Tile::ReleaseThreadStorage();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MenuController::exitGameFromRemoteSave(void* lpParameter) {
|
||||
int primaryPad = PlatformProfile.GetPrimaryPad();
|
||||
|
||||
unsigned int uiIDA[3];
|
||||
uiIDA[0] = IDS_CONFIRM_CANCEL;
|
||||
uiIDA[1] = IDS_CONFIRM_OK;
|
||||
|
||||
ui.RequestAlertMessage(
|
||||
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, primaryPad,
|
||||
&MenuController::exitGameFromRemoteSaveDialogReturned, nullptr);
|
||||
}
|
||||
|
||||
int MenuController::exitGameFromRemoteSaveDialogReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
|
||||
if (result == IPlatformStorage::EMessage_ResultDecline) {
|
||||
app.SetAction(iPad, eAppAction_ExitWorld);
|
||||
} else {
|
||||
UIScene_FullscreenProgress* pScene =
|
||||
(UIScene_FullscreenProgress*)ui.FindScene(
|
||||
eUIScene_FullscreenProgress);
|
||||
if (pScene != nullptr) {
|
||||
pScene->SetWasCancelled(false);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define PNG_TAG_tEXt 0x74455874
|
||||
|
||||
unsigned int MenuController::fromBigEndian(unsigned int uiValue) {
|
||||
unsigned int uiReturn =
|
||||
((uiValue >> 24) & 0x000000ff) | ((uiValue >> 8) & 0x0000ff00) |
|
||||
((uiValue << 8) & 0x00ff0000) | ((uiValue << 24) & 0xff000000);
|
||||
return uiReturn;
|
||||
}
|
||||
|
||||
void MenuController::getImageTextData(std::uint8_t* imageData,
|
||||
unsigned int imageBytes,
|
||||
unsigned char* seedText,
|
||||
unsigned int& uiHostOptions,
|
||||
bool& bHostOptionsRead,
|
||||
std::uint32_t& uiTexturePack) {
|
||||
auto readPngUInt32 = [](const std::uint8_t* data) -> unsigned int {
|
||||
unsigned int value = 0;
|
||||
std::memcpy(&value, data, sizeof(value));
|
||||
return value;
|
||||
};
|
||||
|
||||
std::uint8_t* ucPtr = imageData;
|
||||
unsigned int uiCount = 0;
|
||||
unsigned int uiChunkLen;
|
||||
unsigned int uiChunkType;
|
||||
unsigned int uiCRC;
|
||||
char szKeyword[80];
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (m_szPNG[i] != ucPtr[i]) return;
|
||||
}
|
||||
|
||||
uiCount += 8;
|
||||
|
||||
while (uiCount < imageBytes) {
|
||||
uiChunkLen = fromBigEndian(readPngUInt32(&ucPtr[uiCount]));
|
||||
uiCount += sizeof(int);
|
||||
uiChunkType = fromBigEndian(readPngUInt32(&ucPtr[uiCount]));
|
||||
uiCount += sizeof(int);
|
||||
|
||||
if (uiChunkType == PNG_TAG_tEXt) {
|
||||
unsigned char* pszKeyword = &ucPtr[uiCount];
|
||||
while (pszKeyword < ucPtr + uiCount + uiChunkLen) {
|
||||
memset(szKeyword, 0, 80);
|
||||
unsigned int uiKeywordC = 0;
|
||||
while (*pszKeyword != 0) {
|
||||
szKeyword[uiKeywordC++] = *pszKeyword;
|
||||
pszKeyword++;
|
||||
}
|
||||
pszKeyword++;
|
||||
if (strcmp(szKeyword, "4J_SEED") == 0) {
|
||||
unsigned int uiValueC = 0;
|
||||
while (*pszKeyword != 0 &&
|
||||
(pszKeyword < ucPtr + uiCount + uiChunkLen)) {
|
||||
seedText[uiValueC++] = *pszKeyword;
|
||||
pszKeyword++;
|
||||
}
|
||||
} else if (strcmp(szKeyword, "4J_HOSTOPTIONS") == 0) {
|
||||
bHostOptionsRead = true;
|
||||
unsigned int uiValueC = 0;
|
||||
unsigned char pszHostOptions[9];
|
||||
memset(&pszHostOptions, 0, 9);
|
||||
while (*pszKeyword != 0 &&
|
||||
(pszKeyword < ucPtr + uiCount + uiChunkLen) &&
|
||||
uiValueC < 8) {
|
||||
pszHostOptions[uiValueC++] = *pszKeyword;
|
||||
pszKeyword++;
|
||||
}
|
||||
|
||||
uiHostOptions = 0;
|
||||
std::stringstream ss;
|
||||
ss << pszHostOptions;
|
||||
ss >> std::hex >> uiHostOptions;
|
||||
} else if (strcmp(szKeyword, "4J_TEXTUREPACK") == 0) {
|
||||
unsigned int uiValueC = 0;
|
||||
unsigned char pszTexturePack[9];
|
||||
memset(&pszTexturePack, 0, 9);
|
||||
while (*pszKeyword != 0 &&
|
||||
(pszKeyword < ucPtr + uiCount + uiChunkLen) &&
|
||||
uiValueC < 8) {
|
||||
pszTexturePack[uiValueC++] = *pszKeyword;
|
||||
pszKeyword++;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << pszTexturePack;
|
||||
ss >> std::hex >> uiTexturePack;
|
||||
}
|
||||
}
|
||||
}
|
||||
uiCount += uiChunkLen;
|
||||
uiCRC = fromBigEndian(readPngUInt32(&ucPtr[uiCount]));
|
||||
uiCount += sizeof(int);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int MenuController::createImageTextData(std::uint8_t* textMetadata,
|
||||
int64_t seed, bool hasSeed,
|
||||
unsigned int uiHostOptions,
|
||||
unsigned int uiTexturePackId) {
|
||||
int iTextMetadataBytes = 0;
|
||||
if (hasSeed) {
|
||||
strcpy((char*)textMetadata, "4J_SEED");
|
||||
snprintf((char*)&textMetadata[8], 42, "%lld", (long long)seed);
|
||||
|
||||
iTextMetadataBytes += 8;
|
||||
while (textMetadata[iTextMetadataBytes] != 0) iTextMetadataBytes++;
|
||||
++iTextMetadataBytes;
|
||||
}
|
||||
|
||||
strcpy((char*)&textMetadata[iTextMetadataBytes], "4J_HOSTOPTIONS");
|
||||
snprintf((char*)&textMetadata[iTextMetadataBytes + 15], 9, "%X",
|
||||
uiHostOptions);
|
||||
|
||||
iTextMetadataBytes += 15;
|
||||
while (textMetadata[iTextMetadataBytes] != 0) iTextMetadataBytes++;
|
||||
++iTextMetadataBytes;
|
||||
|
||||
strcpy((char*)&textMetadata[iTextMetadataBytes], "4J_TEXTUREPACK");
|
||||
snprintf((char*)&textMetadata[iTextMetadataBytes + 15], 9, "%X",
|
||||
uiHostOptions);
|
||||
|
||||
iTextMetadataBytes += 15;
|
||||
while (textMetadata[iTextMetadataBytes] != 0) iTextMetadataBytes++;
|
||||
|
||||
return iTextMetadataBytes;
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/storage/storage.h"
|
||||
|
||||
class Player;
|
||||
class Inventory;
|
||||
class Level;
|
||||
class FurnaceTileEntity;
|
||||
class Container;
|
||||
class DispenserTileEntity;
|
||||
class SignTileEntity;
|
||||
class BrewingStandTileEntity;
|
||||
class HopperTileEntity;
|
||||
class MinecartHopper;
|
||||
class EntityHorse;
|
||||
class BeaconTileEntity;
|
||||
class LocalPlayer;
|
||||
class Merchant;
|
||||
class CommandBlockEntity;
|
||||
|
||||
class MenuController {
|
||||
public:
|
||||
MenuController();
|
||||
|
||||
// Load menu methods
|
||||
bool loadInventoryMenu(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
bool bNavigateBack = false);
|
||||
bool loadCreativeMenu(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
bool bNavigateBack = false);
|
||||
bool loadEnchantingMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
int x, int y, int z, Level* level,
|
||||
const std::string& name);
|
||||
bool loadFurnaceMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<FurnaceTileEntity> furnace);
|
||||
bool loadBrewingStandMenu(
|
||||
int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand);
|
||||
bool loadContainerMenu(int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<Container> container);
|
||||
bool loadTrapMenu(int iPad, std::shared_ptr<Container> inventory,
|
||||
std::shared_ptr<DispenserTileEntity> trap);
|
||||
bool loadCrafting2x2Menu(int iPad, std::shared_ptr<LocalPlayer> player);
|
||||
bool loadCrafting3x3Menu(int iPad, std::shared_ptr<LocalPlayer> player,
|
||||
int x, int y, int z);
|
||||
bool loadFireworksMenu(int iPad, std::shared_ptr<LocalPlayer> player, int x,
|
||||
int y, int z);
|
||||
bool loadSignEntryMenu(int iPad, std::shared_ptr<SignTileEntity> sign);
|
||||
bool loadRepairingMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
Level* level, int x, int y, int z);
|
||||
bool loadTradingMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Merchant> trader, Level* level,
|
||||
const std::string& name);
|
||||
bool loadHopperMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<HopperTileEntity> hopper);
|
||||
bool loadHopperMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<MinecartHopper> hopper);
|
||||
bool loadHorseMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> container,
|
||||
std::shared_ptr<EntityHorse> horse);
|
||||
bool loadBeaconMenu(int iPad, std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BeaconTileEntity> beacon);
|
||||
|
||||
// Action management
|
||||
void setAction(int iPad, eXuiAction action, void* param = nullptr);
|
||||
eXuiAction getXuiAction(int iPad) { return m_eXuiAction[iPad]; }
|
||||
eXuiAction getGlobalXuiAction() { return m_eGlobalXuiAction; }
|
||||
void setGlobalXuiAction(eXuiAction action) { m_eGlobalXuiAction = action; }
|
||||
|
||||
// TMS action
|
||||
void setTMSAction(int iPad, eTMSAction action) {
|
||||
m_eTMSAction[iPad] = action;
|
||||
}
|
||||
eTMSAction getTMSAction(int iPad) { return m_eTMSAction[iPad]; }
|
||||
|
||||
// Dialog callbacks
|
||||
static int texturePackDialogReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
static int fatalErrorDialogReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
static int trialOverReturned(void* pParam, int iPad,
|
||||
IPlatformStorage::EMessageResult result);
|
||||
static int unlockFullExitReturned(void* pParam, int iPad,
|
||||
IPlatformStorage::EMessageResult result);
|
||||
static int unlockFullSaveReturned(void* pParam, int iPad,
|
||||
IPlatformStorage::EMessageResult result);
|
||||
static int unlockFullInviteReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
|
||||
// Remote save
|
||||
static int remoteSaveThreadProc(void* lpParameter);
|
||||
static void exitGameFromRemoteSave(void* lpParameter);
|
||||
static int exitGameFromRemoteSaveDialogReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
|
||||
// Image text data
|
||||
void getImageTextData(std::uint8_t* imageData, unsigned int imageBytes,
|
||||
unsigned char* seedText, unsigned int& uiHostOptions,
|
||||
bool& bHostOptionsRead, std::uint32_t& uiTexturePack);
|
||||
unsigned int createImageTextData(std::uint8_t* textMetadata, int64_t seed,
|
||||
bool hasSeed, unsigned int uiHostOptions,
|
||||
unsigned int uiTexturePackId);
|
||||
|
||||
// Opacity timer
|
||||
unsigned int getOpacityTimer(int iPad) {
|
||||
return m_uiOpacityCountDown[iPad];
|
||||
}
|
||||
void setOpacityTimer(int iPad) { m_uiOpacityCountDown[iPad] = 120; }
|
||||
void tickOpacityTimer(int iPad) {
|
||||
if (m_uiOpacityCountDown[iPad] > 0) m_uiOpacityCountDown[iPad]--;
|
||||
}
|
||||
|
||||
// Action param accessor (needed by HandleXuiActions)
|
||||
void* getXuiActionParam(int iPad) { return m_eXuiActionParam[iPad]; }
|
||||
|
||||
private:
|
||||
eXuiAction m_eXuiAction[XUSER_MAX_COUNT];
|
||||
eTMSAction m_eTMSAction[XUSER_MAX_COUNT];
|
||||
void* m_eXuiActionParam[XUSER_MAX_COUNT];
|
||||
eXuiAction m_eGlobalXuiAction;
|
||||
|
||||
unsigned int m_uiOpacityCountDown[XUSER_MAX_COUNT];
|
||||
|
||||
static unsigned char m_szPNG[8];
|
||||
unsigned int fromBigEndian(unsigned int uiValue);
|
||||
};
|
||||
@@ -1,513 +0,0 @@
|
||||
#include "app/common/NetworkController.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <cstring>
|
||||
#include <thread>
|
||||
|
||||
#include "app/common/DLC/DLCPack.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/Network/GameNetworkManager.h"
|
||||
#include "app/common/UI/ConsoleUIController.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/ProgressRenderer.h"
|
||||
#include "minecraft/client/multiplayer/MultiPlayerLevel.h"
|
||||
#include "minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
|
||||
#include "minecraft/client/renderer/GameRenderer.h"
|
||||
#include "minecraft/client/skins/DLCTexturePack.h"
|
||||
#include "minecraft/client/skins/TexturePack.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
#include "minecraft/server/MinecraftServer.h"
|
||||
#include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h"
|
||||
#include "platform/input/input.h"
|
||||
#include "platform/profile/profile.h"
|
||||
#include "platform/storage/storage.h"
|
||||
#include "strings.h"
|
||||
|
||||
unsigned int NetworkController::m_uiLastSignInData = 0;
|
||||
|
||||
NetworkController::NetworkController() {
|
||||
m_disconnectReason = DisconnectPacket::eDisconnect_None;
|
||||
m_bLiveLinkRequired = false;
|
||||
m_bChangingSessionType = false;
|
||||
m_bReallyChangingSessionType = false;
|
||||
|
||||
memset(&m_InviteData, 0, sizeof(JoinFromInviteData));
|
||||
memset(m_playerColours, 0, MINECRAFT_NET_MAX_PLAYERS);
|
||||
memset(m_playerGamePrivileges, 0, sizeof(m_playerGamePrivileges));
|
||||
|
||||
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
|
||||
if (XUserGetSigninInfo(i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY,
|
||||
&m_currentSigninInfo[i]) < 0) {
|
||||
m_currentSigninInfo[i].xuid = INVALID_XUID;
|
||||
m_currentSigninInfo[i].dwGuestNumber = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkController::updatePlayerInfo(std::uint8_t networkSmallId,
|
||||
int16_t playerColourIndex,
|
||||
unsigned int playerGamePrivileges) {
|
||||
for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) {
|
||||
if (m_playerColours[i] == networkSmallId) {
|
||||
m_playerColours[i] = 0;
|
||||
m_playerGamePrivileges[i] = 0;
|
||||
}
|
||||
}
|
||||
if (playerColourIndex >= 0 &&
|
||||
playerColourIndex < MINECRAFT_NET_MAX_PLAYERS) {
|
||||
m_playerColours[playerColourIndex] = networkSmallId;
|
||||
m_playerGamePrivileges[playerColourIndex] = playerGamePrivileges;
|
||||
}
|
||||
}
|
||||
|
||||
short NetworkController::getPlayerColour(std::uint8_t networkSmallId) {
|
||||
short index = -1;
|
||||
for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) {
|
||||
if (m_playerColours[i] == networkSmallId) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
unsigned int NetworkController::getPlayerPrivileges(
|
||||
std::uint8_t networkSmallId) {
|
||||
unsigned int privileges = 0;
|
||||
for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) {
|
||||
if (m_playerColours[i] == networkSmallId) {
|
||||
privileges = m_playerGamePrivileges[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return privileges;
|
||||
}
|
||||
|
||||
void NetworkController::processInvite(std::uint32_t dwUserIndex,
|
||||
std::uint32_t dwLocalUsersMask,
|
||||
const INVITE_INFO* pInviteInfo) {
|
||||
m_InviteData.dwUserIndex = dwUserIndex;
|
||||
m_InviteData.dwLocalUsersMask = dwLocalUsersMask;
|
||||
m_InviteData.pInviteInfo = pInviteInfo;
|
||||
app.SetAction(dwUserIndex, eAppAction_ExitAndJoinFromInvite);
|
||||
}
|
||||
|
||||
int NetworkController::primaryPlayerSignedOutReturned(
|
||||
void* pParam, int iPad, const IPlatformStorage::EMessageResult) {
|
||||
if (g_NetworkManager.IsInSession()) {
|
||||
app.SetAction(iPad, eAppAction_PrimaryPlayerSignedOutReturned);
|
||||
} else {
|
||||
app.SetAction(iPad, eAppAction_PrimaryPlayerSignedOutReturned_Menus);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NetworkController::ethernetDisconnectReturned(
|
||||
void* pParam, int iPad, const IPlatformStorage::EMessageResult) {
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (Minecraft::GetInstance()->player != nullptr) {
|
||||
app.SetAction(pMinecraft->player->GetXboxPad(),
|
||||
eAppAction_EthernetDisconnectedReturned);
|
||||
} else {
|
||||
app.SetAction(iPad, eAppAction_EthernetDisconnectedReturned_Menus);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NetworkController::profileReadErrorCallback(void* pParam) {
|
||||
Game* pApp = (Game*)pParam;
|
||||
int iPrimaryPlayer = PlatformProfile.GetPrimaryPad();
|
||||
pApp->SetAction(iPrimaryPlayer, eAppAction_ProfileReadError);
|
||||
}
|
||||
|
||||
int NetworkController::signoutExitWorldThreadProc(void* lpParameter) {
|
||||
Compression::UseDefaultThreadStorage();
|
||||
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
int exitReasonStringId = -1;
|
||||
|
||||
bool saveStats = false;
|
||||
if (pMinecraft->isClientSide() || g_NetworkManager.IsInSession()) {
|
||||
if (lpParameter != nullptr) {
|
||||
switch (app.GetDisconnectReason()) {
|
||||
case DisconnectPacket::eDisconnect_Kicked:
|
||||
exitReasonStringId = IDS_DISCONNECTED_KICKED;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_NoUGC_AllLocal:
|
||||
exitReasonStringId =
|
||||
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_NoUGC_Single_Local:
|
||||
exitReasonStringId =
|
||||
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_NoFlying:
|
||||
exitReasonStringId = IDS_DISCONNECTED_FLYING;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_OutdatedServer:
|
||||
exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_OutdatedClient:
|
||||
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
|
||||
break;
|
||||
default:
|
||||
exitReasonStringId = IDS_DISCONNECTED;
|
||||
}
|
||||
pMinecraft->progressRenderer->progressStartNoAbort(
|
||||
exitReasonStringId);
|
||||
if (pMinecraft->levels[0] != nullptr)
|
||||
pMinecraft->levels[0]->disconnect(false);
|
||||
if (pMinecraft->levels[1] != nullptr)
|
||||
pMinecraft->levels[1]->disconnect(false);
|
||||
} else {
|
||||
exitReasonStringId = IDS_EXITING_GAME;
|
||||
pMinecraft->progressRenderer->progressStartNoAbort(
|
||||
IDS_EXITING_GAME);
|
||||
|
||||
if (pMinecraft->levels[0] != nullptr)
|
||||
pMinecraft->levels[0]->disconnect();
|
||||
if (pMinecraft->levels[1] != nullptr)
|
||||
pMinecraft->levels[1]->disconnect();
|
||||
}
|
||||
|
||||
MinecraftServer::HaltServer(true);
|
||||
saveStats = false;
|
||||
g_NetworkManager.LeaveGame(false);
|
||||
} else {
|
||||
if (lpParameter != nullptr) {
|
||||
switch (app.GetDisconnectReason()) {
|
||||
case DisconnectPacket::eDisconnect_Kicked:
|
||||
exitReasonStringId = IDS_DISCONNECTED_KICKED;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_NoUGC_AllLocal:
|
||||
exitReasonStringId =
|
||||
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_NoUGC_Single_Local:
|
||||
exitReasonStringId =
|
||||
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_OutdatedServer:
|
||||
exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD;
|
||||
break;
|
||||
case DisconnectPacket::eDisconnect_OutdatedClient:
|
||||
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
|
||||
default:
|
||||
exitReasonStringId = IDS_DISCONNECTED;
|
||||
}
|
||||
pMinecraft->progressRenderer->progressStartNoAbort(
|
||||
exitReasonStringId);
|
||||
}
|
||||
}
|
||||
pMinecraft->setLevel(nullptr, exitReasonStringId, nullptr, saveStats, true);
|
||||
|
||||
app.m_gameRules.unloadCurrentGameRules();
|
||||
|
||||
MinecraftServer::resetFlags();
|
||||
|
||||
while (g_NetworkManager.IsInSession()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NetworkController::clearSignInChangeUsersMask() {
|
||||
int iPrimaryPlayer = PlatformProfile.GetPrimaryPad();
|
||||
|
||||
if (m_uiLastSignInData != 0) {
|
||||
if (iPrimaryPlayer >= 0) {
|
||||
m_uiLastSignInData = 1 << iPrimaryPlayer;
|
||||
} else {
|
||||
m_uiLastSignInData = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkController::signInChangeCallback(void* pParam,
|
||||
bool bPrimaryPlayerChanged,
|
||||
unsigned int uiSignInData) {
|
||||
Game* pApp = (Game*)pParam;
|
||||
int iPrimaryPlayer = PlatformProfile.GetPrimaryPad();
|
||||
|
||||
if ((PlatformProfile.GetLockedProfile() != -1) && iPrimaryPlayer != -1) {
|
||||
if (((uiSignInData & (1 << iPrimaryPlayer)) == 0) ||
|
||||
bPrimaryPlayerChanged) {
|
||||
pApp->SetAction(iPrimaryPlayer, eAppAction_PrimaryPlayerSignedOut);
|
||||
pApp->InvalidateBannedList(iPrimaryPlayer);
|
||||
PlatformStorage.ClearDLCOffers();
|
||||
pApp->ClearAndResetDLCDownloadQueue();
|
||||
pApp->ClearDLCInstalled();
|
||||
} else {
|
||||
unsigned int uiChangedPlayers = uiSignInData ^ m_uiLastSignInData;
|
||||
|
||||
if (g_NetworkManager.IsInSession()) {
|
||||
bool hasGuestIdChanged = false;
|
||||
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
|
||||
unsigned int guestNumber = 0;
|
||||
if (PlatformProfile.IsSignedIn(i)) {
|
||||
XUSER_SIGNIN_INFO info;
|
||||
XUserGetSigninInfo(
|
||||
i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY, &info);
|
||||
pApp->DebugPrintf(
|
||||
"Player at index %d has guest number %d\n", i,
|
||||
info.dwGuestNumber);
|
||||
guestNumber = info.dwGuestNumber;
|
||||
}
|
||||
if (pApp->m_networkController.m_currentSigninInfo[i]
|
||||
.dwGuestNumber != 0 &&
|
||||
guestNumber != 0 &&
|
||||
pApp->m_networkController.m_currentSigninInfo[i]
|
||||
.dwGuestNumber != guestNumber) {
|
||||
hasGuestIdChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasGuestIdChanged) {
|
||||
unsigned int uiIDA[1];
|
||||
uiIDA[0] = IDS_CONFIRM_OK;
|
||||
ui.RequestErrorMessage(IDS_GUEST_ORDER_CHANGED_TITLE,
|
||||
IDS_GUEST_ORDER_CHANGED_TEXT, uiIDA,
|
||||
1, PlatformProfile.GetPrimaryPad());
|
||||
}
|
||||
|
||||
bool switchToOffline = false;
|
||||
if (!PlatformProfile.IsSignedInLive(
|
||||
PlatformProfile.GetLockedProfile()) &&
|
||||
!g_NetworkManager.IsLocalGame()) {
|
||||
switchToOffline = true;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
|
||||
if (i == iPrimaryPlayer) continue;
|
||||
|
||||
if (hasGuestIdChanged &&
|
||||
pApp->m_networkController.m_currentSigninInfo[i]
|
||||
.dwGuestNumber != 0 &&
|
||||
g_NetworkManager.GetLocalPlayerByUserIndex(i) !=
|
||||
nullptr) {
|
||||
pApp->DebugPrintf(
|
||||
"Recommending removal of player at index %d "
|
||||
"because their guest id changed\n",
|
||||
i);
|
||||
pApp->SetAction(i, eAppAction_ExitPlayer);
|
||||
} else {
|
||||
XUSER_SIGNIN_INFO info;
|
||||
XUserGetSigninInfo(
|
||||
i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY, &info);
|
||||
|
||||
bool bPlayerChanged =
|
||||
(uiChangedPlayers & (1 << i)) == (1 << i);
|
||||
bool bPlayerSignedIn = ((uiSignInData & (1 << i)) != 0);
|
||||
|
||||
if (bPlayerChanged &&
|
||||
(!bPlayerSignedIn ||
|
||||
(bPlayerSignedIn && !PlatformProfile.AreXUIDSEqual(
|
||||
pApp->m_networkController
|
||||
.m_currentSigninInfo[i]
|
||||
.xuid,
|
||||
info.xuid)))) {
|
||||
pApp->DebugPrintf(
|
||||
"Player at index %d Left - invalidating their "
|
||||
"banned list\n",
|
||||
i);
|
||||
pApp->InvalidateBannedList(i);
|
||||
|
||||
if (g_NetworkManager.GetLocalPlayerByUserIndex(i) !=
|
||||
nullptr ||
|
||||
Minecraft::GetInstance()->localplayers[i] !=
|
||||
nullptr) {
|
||||
pApp->DebugPrintf("Player %d signed out\n", i);
|
||||
pApp->SetAction(i, eAppAction_ExitPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (switchToOffline) {
|
||||
pApp->SetAction(iPrimaryPlayer,
|
||||
eAppAction_EthernetDisconnected);
|
||||
}
|
||||
|
||||
g_NetworkManager.HandleSignInChange();
|
||||
} else if (pApp->GetLiveLinkRequired() &&
|
||||
!PlatformProfile.IsSignedInLive(
|
||||
PlatformProfile.GetLockedProfile())) {
|
||||
{
|
||||
pApp->SetAction(iPrimaryPlayer,
|
||||
eAppAction_EthernetDisconnected);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_uiLastSignInData = uiSignInData;
|
||||
} else if (iPrimaryPlayer != -1) {
|
||||
pApp->InvalidateBannedList(iPrimaryPlayer);
|
||||
PlatformStorage.ClearDLCOffers();
|
||||
pApp->ClearAndResetDLCDownloadQueue();
|
||||
pApp->ClearDLCInstalled();
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
|
||||
if (XUserGetSigninInfo(
|
||||
i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY,
|
||||
&pApp->m_networkController.m_currentSigninInfo[i]) < 0) {
|
||||
pApp->m_networkController.m_currentSigninInfo[i].xuid =
|
||||
INVALID_XUID;
|
||||
pApp->m_networkController.m_currentSigninInfo[i].dwGuestNumber = 0;
|
||||
}
|
||||
app.DebugPrintf(
|
||||
"Player at index %d has guest number %d\n", i,
|
||||
pApp->m_networkController.m_currentSigninInfo[i].dwGuestNumber);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkController::notificationsCallback(void* pParam,
|
||||
std::uint32_t dwNotification,
|
||||
unsigned int uiParam) {
|
||||
Game* pClass = (Game*)pParam;
|
||||
|
||||
PNOTIFICATION pNotification = new NOTIFICATION;
|
||||
pNotification->dwNotification = dwNotification;
|
||||
pNotification->uiParam = uiParam;
|
||||
|
||||
switch (dwNotification) {
|
||||
case XN_SYS_SIGNINCHANGED: {
|
||||
pClass->DebugPrintf("Signing changed - %d\n", uiParam);
|
||||
} break;
|
||||
case XN_SYS_INPUTDEVICESCHANGED:
|
||||
if (app.GetGameStarted() && g_NetworkManager.IsInSession()) {
|
||||
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
|
||||
if (!PlatformInput.IsPadConnected(i) &&
|
||||
Minecraft::GetInstance()->localplayers[i] != nullptr &&
|
||||
!ui.IsPauseMenuDisplayed(i) &&
|
||||
!ui.IsSceneInStack(i, eUIScene_EndPoem)) {
|
||||
ui.CloseUIScenes(i);
|
||||
ui.NavigateToScene(i, eUIScene_PauseMenu);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XN_LIVE_CONTENT_INSTALLED: {
|
||||
app.ClearDLCInstalled();
|
||||
ui.HandleDLCInstalled(PlatformProfile.GetPrimaryPad());
|
||||
} break;
|
||||
case XN_SYS_STORAGEDEVICESCHANGED: {
|
||||
} break;
|
||||
}
|
||||
|
||||
pClass->m_networkController.m_vNotifications.push_back(pNotification);
|
||||
}
|
||||
|
||||
void NetworkController::liveLinkChangeCallback(void* pParam, bool bConnected) {
|
||||
// Implementation is platform-specific, stub here
|
||||
}
|
||||
|
||||
int NetworkController::exitAndJoinFromInvite(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
|
||||
Game* pApp = (Game*)pParam;
|
||||
|
||||
if (result == IPlatformStorage::EMessage_ResultDecline) {
|
||||
pApp->SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NetworkController::exitAndJoinFromInviteSaveDialogReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
|
||||
Game* pClass = (Game*)pParam;
|
||||
if (result == IPlatformStorage::EMessage_ResultDecline ||
|
||||
result == IPlatformStorage::EMessage_ResultThirdOption) {
|
||||
if (result == IPlatformStorage::EMessage_ResultDecline) {
|
||||
if (!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) {
|
||||
TexturePack* tPack =
|
||||
Minecraft::GetInstance()->skins->getSelected();
|
||||
DLCPack* pDLCPack = tPack->getDLCPack();
|
||||
if (!pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Texture,
|
||||
"")) {
|
||||
unsigned int uiIDA[2];
|
||||
uiIDA[0] = IDS_CONFIRM_OK;
|
||||
uiIDA[1] = IDS_CONFIRM_CANCEL;
|
||||
|
||||
ui.RequestErrorMessage(
|
||||
IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE,
|
||||
IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,
|
||||
&NetworkController::warningTrialTexturePackReturned,
|
||||
pClass);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
bool bSaveExists;
|
||||
PlatformStorage.DoesSaveExist(&bSaveExists);
|
||||
if (bSaveExists) {
|
||||
unsigned int uiIDA[2];
|
||||
uiIDA[0] = IDS_CONFIRM_CANCEL;
|
||||
uiIDA[1] = IDS_CONFIRM_OK;
|
||||
ui.RequestErrorMessage(
|
||||
IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2,
|
||||
PlatformProfile.GetPrimaryPad(),
|
||||
&NetworkController::exitAndJoinFromInviteAndSaveReturned,
|
||||
pClass);
|
||||
return 0;
|
||||
} else {
|
||||
MinecraftServer::getInstance()->setSaveOnExit(true);
|
||||
}
|
||||
} else {
|
||||
unsigned int uiIDA[2];
|
||||
uiIDA[0] = IDS_CONFIRM_CANCEL;
|
||||
uiIDA[1] = IDS_CONFIRM_OK;
|
||||
ui.RequestErrorMessage(
|
||||
IDS_TITLE_DECLINE_SAVE_GAME, IDS_CONFIRM_DECLINE_SAVE_GAME,
|
||||
uiIDA, 2, PlatformProfile.GetPrimaryPad(),
|
||||
&NetworkController::exitAndJoinFromInviteDeclineSaveReturned,
|
||||
pClass);
|
||||
return 0;
|
||||
}
|
||||
|
||||
app.SetAction(PlatformProfile.GetPrimaryPad(),
|
||||
eAppAction_ExitAndJoinFromInviteConfirmed);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NetworkController::warningTrialTexturePackReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NetworkController::exitAndJoinFromInviteAndSaveReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
|
||||
if (result == IPlatformStorage::EMessage_ResultDecline) {
|
||||
if (!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) {
|
||||
TexturePack* tPack = Minecraft::GetInstance()->skins->getSelected();
|
||||
DLCPack* pDLCPack = tPack->getDLCPack();
|
||||
if (!pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Texture,
|
||||
"")) {
|
||||
unsigned int uiIDA[2];
|
||||
uiIDA[0] = IDS_CONFIRM_OK;
|
||||
uiIDA[1] = IDS_CONFIRM_CANCEL;
|
||||
ui.RequestErrorMessage(
|
||||
IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE,
|
||||
IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,
|
||||
&NetworkController::warningTrialTexturePackReturned,
|
||||
nullptr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
MinecraftServer::getInstance()->setSaveOnExit(true);
|
||||
app.SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NetworkController::exitAndJoinFromInviteDeclineSaveReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
|
||||
if (result == IPlatformStorage::EMessage_ResultDecline) {
|
||||
MinecraftServer::getInstance()->setSaveOnExit(false);
|
||||
app.SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "minecraft/network/packet/DisconnectPacket.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/network/NetTypes.h"
|
||||
#include "platform/storage/storage.h"
|
||||
|
||||
struct INVITE_INFO;
|
||||
|
||||
typedef struct _JoinFromInviteData {
|
||||
std::uint32_t dwUserIndex;
|
||||
std::uint32_t dwLocalUsersMask;
|
||||
const INVITE_INFO* pInviteInfo;
|
||||
} JoinFromInviteData;
|
||||
|
||||
class NetworkController {
|
||||
public:
|
||||
NetworkController();
|
||||
|
||||
// Player info
|
||||
void updatePlayerInfo(std::uint8_t networkSmallId,
|
||||
int16_t playerColourIndex,
|
||||
unsigned int playerGamePrivileges);
|
||||
short getPlayerColour(std::uint8_t networkSmallId);
|
||||
unsigned int getPlayerPrivileges(std::uint8_t networkSmallId);
|
||||
|
||||
// Sign-in change
|
||||
static void signInChangeCallback(void* pParam, bool bVal,
|
||||
unsigned int uiSignInData);
|
||||
static void clearSignInChangeUsersMask();
|
||||
static int signoutExitWorldThreadProc(void* lpParameter);
|
||||
static int primaryPlayerSignedOutReturned(
|
||||
void* pParam, int iPad, const IPlatformStorage::EMessageResult);
|
||||
static int ethernetDisconnectReturned(
|
||||
void* pParam, int iPad, const IPlatformStorage::EMessageResult);
|
||||
static void profileReadErrorCallback(void* pParam);
|
||||
|
||||
// Notifications
|
||||
static void notificationsCallback(void* pParam,
|
||||
std::uint32_t dwNotification,
|
||||
unsigned int uiParam);
|
||||
|
||||
// Ethernet/Live link
|
||||
static void liveLinkChangeCallback(void* pParam, bool bConnected);
|
||||
|
||||
// Invites
|
||||
void processInvite(std::uint32_t dwUserIndex,
|
||||
std::uint32_t dwLocalUsersMask,
|
||||
const INVITE_INFO* pInviteInfo);
|
||||
static int exitAndJoinFromInvite(void* pParam, int iPad,
|
||||
IPlatformStorage::EMessageResult result);
|
||||
static int exitAndJoinFromInviteSaveDialogReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
static int exitAndJoinFromInviteAndSaveReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
static int exitAndJoinFromInviteDeclineSaveReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
static int warningTrialTexturePackReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
|
||||
// Disconnect
|
||||
DisconnectPacket::eDisconnectReason getDisconnectReason() {
|
||||
return m_disconnectReason;
|
||||
}
|
||||
void setDisconnectReason(DisconnectPacket::eDisconnectReason bVal) {
|
||||
m_disconnectReason = bVal;
|
||||
}
|
||||
|
||||
// Session type flags
|
||||
bool getChangingSessionType() { return m_bChangingSessionType; }
|
||||
void setChangingSessionType(bool bVal) { m_bChangingSessionType = bVal; }
|
||||
bool getReallyChangingSessionType() { return m_bReallyChangingSessionType; }
|
||||
void setReallyChangingSessionType(bool bVal) {
|
||||
m_bReallyChangingSessionType = bVal;
|
||||
}
|
||||
|
||||
// Live link
|
||||
bool getLiveLinkRequired() { return m_bLiveLinkRequired; }
|
||||
void setLiveLinkRequired(bool required) { m_bLiveLinkRequired = required; }
|
||||
|
||||
// Sign-in info
|
||||
XUSER_SIGNIN_INFO m_currentSigninInfo[XUSER_MAX_COUNT];
|
||||
|
||||
// Invite data
|
||||
JoinFromInviteData m_InviteData;
|
||||
|
||||
// Notifications
|
||||
typedef std::vector<PNOTIFICATION> VNOTIFICATIONS;
|
||||
VNOTIFICATIONS m_vNotifications;
|
||||
VNOTIFICATIONS* getNotifications() { return &m_vNotifications; }
|
||||
|
||||
// Static sign-in data
|
||||
static unsigned int m_uiLastSignInData;
|
||||
|
||||
private:
|
||||
std::uint8_t m_playerColours[MINECRAFT_NET_MAX_PLAYERS];
|
||||
unsigned int m_playerGamePrivileges[MINECRAFT_NET_MAX_PLAYERS];
|
||||
|
||||
DisconnectPacket::eDisconnectReason m_disconnectReason;
|
||||
bool m_bChangingSessionType;
|
||||
bool m_bReallyChangingSessionType;
|
||||
bool m_bLiveLinkRequired;
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
#include "app/common/SaveManager.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/Network/GameNetworkManager.h"
|
||||
#include "minecraft/server/MinecraftServer.h"
|
||||
#include "minecraft/server/ServerAction.h"
|
||||
#include "platform/profile/profile.h"
|
||||
|
||||
void SaveManager::setAutosaveTimerTime(int settingValue) {
|
||||
m_uiAutosaveTimer =
|
||||
time_util::clock::now() + std::chrono::minutes(settingValue * 15);
|
||||
}
|
||||
|
||||
bool SaveManager::autosaveDue() const {
|
||||
return (time_util::clock::now() > m_uiAutosaveTimer);
|
||||
}
|
||||
|
||||
int64_t SaveManager::secondsToAutosave() const {
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(
|
||||
m_uiAutosaveTimer - time_util::clock::now())
|
||||
.count();
|
||||
}
|
||||
|
||||
void SaveManager::lock() {
|
||||
std::lock_guard<std::mutex> lock(m_saveNotificationMutex);
|
||||
if (m_saveNotificationDepth++ == 0) {
|
||||
if (g_NetworkManager
|
||||
.IsInSession()) // this can be triggered from the front end if
|
||||
// we're downloading a save
|
||||
{
|
||||
MinecraftServer::getInstance()->broadcastStartSavingPacket();
|
||||
|
||||
if (g_NetworkManager.IsLocalGame() &&
|
||||
g_NetworkManager.GetPlayerCount() == 1) {
|
||||
MinecraftServer::getInstance()->queueServerAction(
|
||||
minecraft::server::PauseServer{true});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SaveManager::unlock() {
|
||||
std::lock_guard<std::mutex> lock(m_saveNotificationMutex);
|
||||
if (--m_saveNotificationDepth == 0) {
|
||||
if (g_NetworkManager
|
||||
.IsInSession()) // this can be triggered from the front end if
|
||||
// we're downloading a save
|
||||
{
|
||||
MinecraftServer::getInstance()->broadcastStopSavingPacket();
|
||||
|
||||
if (g_NetworkManager.IsLocalGame() &&
|
||||
g_NetworkManager.GetPlayerCount() == 1) {
|
||||
MinecraftServer::getInstance()->queueServerAction(
|
||||
minecraft::server::PauseServer{false});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
|
||||
#include "util/Timer.h"
|
||||
|
||||
class SaveManager {
|
||||
public:
|
||||
SaveManager() : m_uiAutosaveTimer{}, m_saveNotificationDepth(0) {}
|
||||
|
||||
void setAutosaveTimerTime(int settingValue);
|
||||
bool autosaveDue() const;
|
||||
int64_t secondsToAutosave() const;
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
private:
|
||||
time_util::time_point m_uiAutosaveTimer;
|
||||
std::mutex m_saveNotificationMutex;
|
||||
int m_saveNotificationDepth;
|
||||
};
|
||||
@@ -1,451 +0,0 @@
|
||||
#include "app/common/SkinManager.h"
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "app/common/DLC/DLCPack.h"
|
||||
#include "app/common/DLC/DLCSkinFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "minecraft/Minecraft_Macros.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/model/geom/Model.h"
|
||||
#include "minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
|
||||
#include "minecraft/client/renderer/entity/EntityRenderDispatcher.h"
|
||||
#include "minecraft/client/renderer/entity/EntityRenderer.h"
|
||||
#include "minecraft/world/entity/player/Player.h"
|
||||
#include "platform/profile/profile.h"
|
||||
|
||||
SkinManager::SkinManager() : m_xuidNotch(INVALID_XUID) {
|
||||
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
|
||||
m_dwAdditionalModelParts[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void SkinManager::setPlayerSkin(int iPad, const std::string& name,
|
||||
GAME_SETTINGS** gameSettingsA) {
|
||||
std::uint32_t skinId = getSkinIdFromPath(name);
|
||||
setPlayerSkin(iPad, skinId, gameSettingsA);
|
||||
}
|
||||
|
||||
void SkinManager::setPlayerSkin(int iPad, std::uint32_t dwSkinId,
|
||||
GAME_SETTINGS** gameSettingsA) {
|
||||
app.DebugPrintf("Setting skin for %d to %08X\n", iPad, dwSkinId);
|
||||
|
||||
gameSettingsA[iPad]->dwSelectedSkin = dwSkinId;
|
||||
gameSettingsA[iPad]->bSettingsChanged = true;
|
||||
|
||||
if (Minecraft::GetInstance()->localplayers[iPad] != nullptr)
|
||||
Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomSkin(
|
||||
dwSkinId);
|
||||
}
|
||||
|
||||
std::string SkinManager::getPlayerSkinName(int iPad,
|
||||
GAME_SETTINGS** gameSettingsA) {
|
||||
return getSkinPathFromId(gameSettingsA[iPad]->dwSelectedSkin);
|
||||
}
|
||||
|
||||
std::uint32_t SkinManager::getPlayerSkinId(int iPad,
|
||||
GAME_SETTINGS** gameSettingsA,
|
||||
DLCManager& dlcManager) {
|
||||
DLCPack* Pack = nullptr;
|
||||
DLCSkinFile* skinFile = nullptr;
|
||||
std::uint32_t dwSkin = gameSettingsA[iPad]->dwSelectedSkin;
|
||||
char chars[256];
|
||||
|
||||
if (GET_IS_DLC_SKIN_FROM_BITMASK(dwSkin)) {
|
||||
snprintf(chars, 256, "dlcskin%08d.png",
|
||||
GET_DLC_SKIN_ID_FROM_BITMASK(dwSkin));
|
||||
|
||||
Pack = dlcManager.getPackContainingSkin(chars);
|
||||
|
||||
if (Pack) {
|
||||
skinFile = Pack->getSkinFile(chars);
|
||||
|
||||
bool bSkinIsFree =
|
||||
skinFile->getParameterAsBool(DLCManager::e_DLCParamType_Free);
|
||||
bool bLicensed = Pack->hasPurchasedFile(DLCManager::e_DLCType_Skin,
|
||||
skinFile->getPath());
|
||||
|
||||
if (bSkinIsFree || bLicensed) {
|
||||
return dwSkin;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dwSkin;
|
||||
}
|
||||
|
||||
std::uint32_t SkinManager::getAdditionalModelParts(int iPad) {
|
||||
return m_dwAdditionalModelParts[iPad];
|
||||
}
|
||||
|
||||
void SkinManager::setPlayerCape(int iPad, const std::string& name,
|
||||
GAME_SETTINGS** gameSettingsA) {
|
||||
std::uint32_t capeId = Player::getCapeIdFromPath(name);
|
||||
setPlayerCape(iPad, capeId, gameSettingsA);
|
||||
}
|
||||
|
||||
void SkinManager::setPlayerCape(int iPad, std::uint32_t dwCapeId,
|
||||
GAME_SETTINGS** gameSettingsA) {
|
||||
app.DebugPrintf("Setting cape for %d to %08X\n", iPad, dwCapeId);
|
||||
|
||||
gameSettingsA[iPad]->dwSelectedCape = dwCapeId;
|
||||
gameSettingsA[iPad]->bSettingsChanged = true;
|
||||
|
||||
if (Minecraft::GetInstance()->localplayers[iPad] != nullptr)
|
||||
Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomCape(
|
||||
dwCapeId);
|
||||
}
|
||||
|
||||
std::string SkinManager::getPlayerCapeName(int iPad,
|
||||
GAME_SETTINGS** gameSettingsA) {
|
||||
return Player::getCapePathFromId(gameSettingsA[iPad]->dwSelectedCape);
|
||||
}
|
||||
|
||||
std::uint32_t SkinManager::getPlayerCapeId(int iPad,
|
||||
GAME_SETTINGS** gameSettingsA) {
|
||||
return gameSettingsA[iPad]->dwSelectedCape;
|
||||
}
|
||||
|
||||
void SkinManager::setPlayerFavoriteSkin(int iPad, int iIndex,
|
||||
unsigned int uiSkinID,
|
||||
GAME_SETTINGS** gameSettingsA) {
|
||||
app.DebugPrintf("Setting favorite skin for %d to %08X\n", iPad, uiSkinID);
|
||||
|
||||
gameSettingsA[iPad]->uiFavoriteSkinA[iIndex] = uiSkinID;
|
||||
gameSettingsA[iPad]->bSettingsChanged = true;
|
||||
}
|
||||
|
||||
unsigned int SkinManager::getPlayerFavoriteSkin(int iPad, int iIndex,
|
||||
GAME_SETTINGS** gameSettingsA) {
|
||||
return gameSettingsA[iPad]->uiFavoriteSkinA[iIndex];
|
||||
}
|
||||
|
||||
unsigned char SkinManager::getPlayerFavoriteSkinsPos(
|
||||
int iPad, GAME_SETTINGS** gameSettingsA) {
|
||||
return gameSettingsA[iPad]->ucCurrentFavoriteSkinPos;
|
||||
}
|
||||
|
||||
void SkinManager::setPlayerFavoriteSkinsPos(int iPad, int iPos,
|
||||
GAME_SETTINGS** gameSettingsA) {
|
||||
gameSettingsA[iPad]->ucCurrentFavoriteSkinPos = (unsigned char)iPos;
|
||||
gameSettingsA[iPad]->bSettingsChanged = true;
|
||||
}
|
||||
|
||||
unsigned int SkinManager::getPlayerFavoriteSkinsCount(
|
||||
int iPad, GAME_SETTINGS** gameSettingsA) {
|
||||
unsigned int uiCount = 0;
|
||||
for (int i = 0; i < MAX_FAVORITE_SKINS; i++) {
|
||||
if (gameSettingsA[iPad]->uiFavoriteSkinA[i] != 0xFFFFFFFF) {
|
||||
uiCount++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return uiCount;
|
||||
}
|
||||
|
||||
void SkinManager::validateFavoriteSkins(int iPad, GAME_SETTINGS** gameSettingsA,
|
||||
DLCManager& dlcManager) {
|
||||
unsigned int uiCount = getPlayerFavoriteSkinsCount(iPad, gameSettingsA);
|
||||
|
||||
unsigned int uiValidSkin = 0;
|
||||
char chars[256];
|
||||
|
||||
for (unsigned int i = 0; i < uiCount; i++) {
|
||||
snprintf(chars, 256, "dlcskin%08d.png",
|
||||
getPlayerFavoriteSkin(iPad, i, gameSettingsA));
|
||||
|
||||
DLCPack* pDLCPack = dlcManager.getPackContainingSkin(chars);
|
||||
|
||||
if (pDLCPack != nullptr) {
|
||||
DLCSkinFile* pSkinFile = pDLCPack->getSkinFile(chars);
|
||||
|
||||
if (pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Skin, "") ||
|
||||
(pSkinFile && pSkinFile->isFree())) {
|
||||
gameSettingsA[iPad]->uiFavoriteSkinA[uiValidSkin++] =
|
||||
gameSettingsA[iPad]->uiFavoriteSkinA[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = uiValidSkin; i < MAX_FAVORITE_SKINS; i++) {
|
||||
gameSettingsA[iPad]->uiFavoriteSkinA[i] = 0xFFFFFFFF;
|
||||
}
|
||||
}
|
||||
|
||||
bool SkinManager::isXuidNotch(PlayerUID xuid) {
|
||||
if (m_xuidNotch != INVALID_XUID && xuid != INVALID_XUID) {
|
||||
return PlatformProfile.AreXUIDSEqual(xuid, m_xuidNotch);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SkinManager::isXuidDeadmau5(PlayerUID xuid) {
|
||||
// Delegates back to static MojangData on Game - this is a simple forwarding
|
||||
// wrapper for now; the actual MojangData map stays on Game.
|
||||
return app.isXuidDeadmau5(xuid);
|
||||
}
|
||||
|
||||
void SkinManager::addMemoryTextureFile(const std::string& wName,
|
||||
std::uint8_t* pbData,
|
||||
unsigned int byteCount) {
|
||||
std::lock_guard<std::mutex> lock(csMemFilesLock);
|
||||
PMEMDATA pData = nullptr;
|
||||
auto it = m_MEM_Files.find(wName);
|
||||
if (it != m_MEM_Files.end()) {
|
||||
#if !defined(_CONTENT_PACKAGE)
|
||||
printf("Incrementing the memory texture file count for %s\n",
|
||||
wName.c_str());
|
||||
#endif
|
||||
pData = (*it).second;
|
||||
|
||||
if (pData->byteCount == 0 && byteCount != 0) {
|
||||
if (pData->pbData != nullptr) delete[] pData->pbData;
|
||||
|
||||
pData->pbData = pbData;
|
||||
pData->byteCount = byteCount;
|
||||
}
|
||||
|
||||
++pData->ucRefCount;
|
||||
return;
|
||||
}
|
||||
|
||||
pData = new MEMDATA();
|
||||
pData->pbData = pbData;
|
||||
pData->byteCount = byteCount;
|
||||
pData->ucRefCount = 1;
|
||||
|
||||
m_MEM_Files[wName] = pData;
|
||||
}
|
||||
|
||||
void SkinManager::removeMemoryTextureFile(const std::string& wName) {
|
||||
std::lock_guard<std::mutex> lock(csMemFilesLock);
|
||||
|
||||
auto it = m_MEM_Files.find(wName);
|
||||
if (it != m_MEM_Files.end()) {
|
||||
#if !defined(_CONTENT_PACKAGE)
|
||||
printf("Decrementing the memory texture file count for %s\n",
|
||||
wName.c_str());
|
||||
#endif
|
||||
PMEMDATA pData = (*it).second;
|
||||
--pData->ucRefCount;
|
||||
if (pData->ucRefCount <= 0) {
|
||||
#if !defined(_CONTENT_PACKAGE)
|
||||
printf("Erasing the memory texture file data for %s\n",
|
||||
wName.c_str());
|
||||
#endif
|
||||
delete pData;
|
||||
m_MEM_Files.erase(wName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool SkinManager::defaultCapeExists() {
|
||||
std::string wTex = "Special_Cape.png";
|
||||
bool val = false;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csMemFilesLock);
|
||||
auto it = m_MEM_Files.find(wTex);
|
||||
if (it != m_MEM_Files.end()) val = true;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
bool SkinManager::isFileInMemoryTextures(const std::string& wName) {
|
||||
bool val = false;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(csMemFilesLock);
|
||||
auto it = m_MEM_Files.find(wName);
|
||||
if (it != m_MEM_Files.end()) val = true;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void SkinManager::getMemFileDetails(const std::string& wName,
|
||||
std::uint8_t** ppbData,
|
||||
unsigned int* pByteCount) {
|
||||
std::lock_guard<std::mutex> lock(csMemFilesLock);
|
||||
auto it = m_MEM_Files.find(wName);
|
||||
if (it != m_MEM_Files.end()) {
|
||||
PMEMDATA pData = (*it).second;
|
||||
*ppbData = pData->pbData;
|
||||
*pByteCount = pData->byteCount;
|
||||
}
|
||||
}
|
||||
|
||||
void SkinManager::setAdditionalSkinBoxes(std::uint32_t dwSkinID,
|
||||
SKIN_BOX* SkinBoxA,
|
||||
unsigned int dwSkinBoxC) {
|
||||
EntityRenderer* renderer =
|
||||
EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER);
|
||||
Model* pModel = renderer->getModel();
|
||||
std::vector<ModelPart*>* pvModelPart = new std::vector<ModelPart*>;
|
||||
std::vector<SKIN_BOX*>* pvSkinBoxes = new std::vector<SKIN_BOX*>;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock_mp(csAdditionalModelParts);
|
||||
std::lock_guard<std::mutex> lock_sb(csAdditionalSkinBoxes);
|
||||
|
||||
app.DebugPrintf(
|
||||
"*** SetAdditionalSkinBoxes - Inserting model parts for skin %d "
|
||||
"from "
|
||||
"array of Skin Boxes\n",
|
||||
dwSkinID & 0x0FFFFFFF);
|
||||
|
||||
for (unsigned int i = 0; i < dwSkinBoxC; i++) {
|
||||
if (pModel) {
|
||||
ModelPart* pModelPart = pModel->AddOrRetrievePart(&SkinBoxA[i]);
|
||||
pvModelPart->push_back(pModelPart);
|
||||
pvSkinBoxes->push_back(&SkinBoxA[i]);
|
||||
}
|
||||
}
|
||||
|
||||
m_AdditionalModelParts.insert(
|
||||
std::pair<std::uint32_t, std::vector<ModelPart*>*>(dwSkinID,
|
||||
pvModelPart));
|
||||
m_AdditionalSkinBoxes.insert(
|
||||
std::pair<std::uint32_t, std::vector<SKIN_BOX*>*>(dwSkinID,
|
||||
pvSkinBoxes));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ModelPart*>* SkinManager::setAdditionalSkinBoxes(
|
||||
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* pvSkinBoxA) {
|
||||
EntityRenderer* renderer =
|
||||
EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER);
|
||||
Model* pModel = renderer->getModel();
|
||||
std::vector<ModelPart*>* pvModelPart = new std::vector<ModelPart*>;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock_mp(csAdditionalModelParts);
|
||||
std::lock_guard<std::mutex> lock_sb(csAdditionalSkinBoxes);
|
||||
app.DebugPrintf(
|
||||
"*** SetAdditionalSkinBoxes - Inserting model parts for skin %d "
|
||||
"from "
|
||||
"array of Skin Boxes\n",
|
||||
dwSkinID & 0x0FFFFFFF);
|
||||
|
||||
for (auto it = pvSkinBoxA->begin(); it != pvSkinBoxA->end(); ++it) {
|
||||
if (pModel) {
|
||||
ModelPart* pModelPart = pModel->AddOrRetrievePart(*it);
|
||||
pvModelPart->push_back(pModelPart);
|
||||
}
|
||||
}
|
||||
|
||||
m_AdditionalModelParts.insert(
|
||||
std::pair<std::uint32_t, std::vector<ModelPart*>*>(dwSkinID,
|
||||
pvModelPart));
|
||||
m_AdditionalSkinBoxes.insert(
|
||||
std::pair<std::uint32_t, std::vector<SKIN_BOX*>*>(dwSkinID,
|
||||
pvSkinBoxA));
|
||||
}
|
||||
return pvModelPart;
|
||||
}
|
||||
|
||||
std::vector<ModelPart*>* SkinManager::getAdditionalModelParts(
|
||||
std::uint32_t dwSkinID) {
|
||||
std::lock_guard<std::mutex> lock(csAdditionalModelParts);
|
||||
std::vector<ModelPart*>* pvModelParts = nullptr;
|
||||
if (m_AdditionalModelParts.size() > 0) {
|
||||
auto it = m_AdditionalModelParts.find(dwSkinID);
|
||||
if (it != m_AdditionalModelParts.end()) {
|
||||
pvModelParts = (*it).second;
|
||||
}
|
||||
}
|
||||
|
||||
return pvModelParts;
|
||||
}
|
||||
|
||||
std::vector<SKIN_BOX*>* SkinManager::getAdditionalSkinBoxes(
|
||||
std::uint32_t dwSkinID) {
|
||||
std::lock_guard<std::mutex> lock(csAdditionalSkinBoxes);
|
||||
std::vector<SKIN_BOX*>* pvSkinBoxes = nullptr;
|
||||
if (m_AdditionalSkinBoxes.size() > 0) {
|
||||
auto it = m_AdditionalSkinBoxes.find(dwSkinID);
|
||||
if (it != m_AdditionalSkinBoxes.end()) {
|
||||
pvSkinBoxes = (*it).second;
|
||||
}
|
||||
}
|
||||
|
||||
return pvSkinBoxes;
|
||||
}
|
||||
|
||||
unsigned int SkinManager::getAnimOverrideBitmask(std::uint32_t dwSkinID) {
|
||||
std::lock_guard<std::mutex> lock(csAnimOverrideBitmask);
|
||||
unsigned int uiAnimOverrideBitmask = 0L;
|
||||
|
||||
if (m_AnimOverrides.size() > 0) {
|
||||
auto it = m_AnimOverrides.find(dwSkinID);
|
||||
if (it != m_AnimOverrides.end()) {
|
||||
uiAnimOverrideBitmask = (*it).second;
|
||||
}
|
||||
}
|
||||
|
||||
return uiAnimOverrideBitmask;
|
||||
}
|
||||
|
||||
void SkinManager::setAnimOverrideBitmask(std::uint32_t dwSkinID,
|
||||
unsigned int uiAnimOverrideBitmask) {
|
||||
std::lock_guard<std::mutex> lock(csAnimOverrideBitmask);
|
||||
|
||||
if (m_AnimOverrides.size() > 0) {
|
||||
auto it = m_AnimOverrides.find(dwSkinID);
|
||||
if (it != m_AnimOverrides.end()) {
|
||||
return; // already in here
|
||||
}
|
||||
}
|
||||
m_AnimOverrides.insert(std::pair<std::uint32_t, unsigned int>(
|
||||
dwSkinID, uiAnimOverrideBitmask));
|
||||
}
|
||||
|
||||
std::uint32_t SkinManager::getSkinIdFromPath(const std::string& skin) {
|
||||
bool dlcSkin = false;
|
||||
unsigned int skinId = 0;
|
||||
|
||||
if (skin.size() >= 14) {
|
||||
dlcSkin = skin.substr(0, 3).compare("dlc") == 0;
|
||||
|
||||
std::string skinValue = skin.substr(7, skin.size());
|
||||
skinValue = skinValue.substr(0, skinValue.find_first_of('.'));
|
||||
|
||||
std::stringstream ss;
|
||||
if (dlcSkin)
|
||||
ss << std::dec << skinValue.c_str();
|
||||
else
|
||||
ss << std::hex << skinValue.c_str();
|
||||
ss >> skinId;
|
||||
|
||||
skinId = MAKE_SKIN_BITMASK(dlcSkin, skinId);
|
||||
}
|
||||
return skinId;
|
||||
}
|
||||
|
||||
std::string SkinManager::getSkinPathFromId(std::uint32_t skinId) {
|
||||
char chars[256];
|
||||
if (GET_IS_DLC_SKIN_FROM_BITMASK(skinId)) {
|
||||
snprintf(chars, 256, "dlcskin%08d.png",
|
||||
GET_DLC_SKIN_ID_FROM_BITMASK(skinId));
|
||||
} else {
|
||||
std::uint32_t ugcSkinIndex = GET_UGC_SKIN_ID_FROM_BITMASK(skinId);
|
||||
std::uint32_t defaultSkinIndex =
|
||||
GET_DEFAULT_SKIN_ID_FROM_BITMASK(skinId);
|
||||
if (ugcSkinIndex == 0) {
|
||||
snprintf(chars, 256, "defskin%08X.png", defaultSkinIndex);
|
||||
} else {
|
||||
snprintf(chars, 256, "ugcskin%08X.png", ugcSkinIndex);
|
||||
}
|
||||
}
|
||||
return chars;
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "minecraft/client/model/SkinBox.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
|
||||
class ModelPart;
|
||||
class DLCManager;
|
||||
|
||||
class SkinManager {
|
||||
public:
|
||||
SkinManager();
|
||||
|
||||
// Skin get/set (require GameSettingsA pointer from Game)
|
||||
void setPlayerSkin(int iPad, const std::string& name,
|
||||
GAME_SETTINGS** gameSettingsA);
|
||||
void setPlayerSkin(int iPad, std::uint32_t dwSkinId,
|
||||
GAME_SETTINGS** gameSettingsA);
|
||||
std::string getPlayerSkinName(int iPad, GAME_SETTINGS** gameSettingsA);
|
||||
std::uint32_t getPlayerSkinId(int iPad, GAME_SETTINGS** gameSettingsA,
|
||||
DLCManager& dlcManager);
|
||||
|
||||
// Cape get/set
|
||||
void setPlayerCape(int iPad, const std::string& name,
|
||||
GAME_SETTINGS** gameSettingsA);
|
||||
void setPlayerCape(int iPad, std::uint32_t dwCapeId,
|
||||
GAME_SETTINGS** gameSettingsA);
|
||||
std::string getPlayerCapeName(int iPad, GAME_SETTINGS** gameSettingsA);
|
||||
std::uint32_t getPlayerCapeId(int iPad, GAME_SETTINGS** gameSettingsA);
|
||||
|
||||
// Favorite skins
|
||||
void setPlayerFavoriteSkin(int iPad, int iIndex, unsigned int uiSkinID,
|
||||
GAME_SETTINGS** gameSettingsA);
|
||||
unsigned int getPlayerFavoriteSkin(int iPad, int iIndex,
|
||||
GAME_SETTINGS** gameSettingsA);
|
||||
unsigned char getPlayerFavoriteSkinsPos(int iPad,
|
||||
GAME_SETTINGS** gameSettingsA);
|
||||
void setPlayerFavoriteSkinsPos(int iPad, int iPos,
|
||||
GAME_SETTINGS** gameSettingsA);
|
||||
unsigned int getPlayerFavoriteSkinsCount(int iPad,
|
||||
GAME_SETTINGS** gameSettingsA);
|
||||
void validateFavoriteSkins(int iPad, GAME_SETTINGS** gameSettingsA,
|
||||
DLCManager& dlcManager);
|
||||
|
||||
// Additional model parts per player
|
||||
std::uint32_t getAdditionalModelParts(int iPad);
|
||||
|
||||
// Additional model parts per skin texture
|
||||
void setAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX* SkinBoxA,
|
||||
unsigned int dwSkinBoxC);
|
||||
std::vector<ModelPart*>* setAdditionalSkinBoxes(
|
||||
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* pvSkinBoxA);
|
||||
std::vector<ModelPart*>* getAdditionalModelParts(std::uint32_t dwSkinID);
|
||||
std::vector<SKIN_BOX*>* getAdditionalSkinBoxes(std::uint32_t dwSkinID);
|
||||
|
||||
// Anim overrides
|
||||
void setAnimOverrideBitmask(std::uint32_t dwSkinID,
|
||||
unsigned int uiAnimOverrideBitmask);
|
||||
unsigned int getAnimOverrideBitmask(std::uint32_t dwSkinID);
|
||||
|
||||
// Skin path <-> id conversion (static)
|
||||
static std::uint32_t getSkinIdFromPath(const std::string& skin);
|
||||
static std::string getSkinPathFromId(std::uint32_t skinId);
|
||||
|
||||
// Default cape
|
||||
bool defaultCapeExists();
|
||||
|
||||
// Notch/Deadmau5 xuid checks
|
||||
bool isXuidNotch(PlayerUID xuid);
|
||||
bool isXuidDeadmau5(PlayerUID xuid);
|
||||
|
||||
// Memory texture files for player skins
|
||||
void addMemoryTextureFile(const std::string& wName, std::uint8_t* pbData,
|
||||
unsigned int byteCount);
|
||||
void removeMemoryTextureFile(const std::string& wName);
|
||||
void getMemFileDetails(const std::string& wName, std::uint8_t** ppbData,
|
||||
unsigned int* pByteCount);
|
||||
bool isFileInMemoryTextures(const std::string& wName);
|
||||
|
||||
// storing skin files
|
||||
std::vector<std::string> vSkinNames;
|
||||
|
||||
// per-player additional model parts
|
||||
std::uint32_t m_dwAdditionalModelParts[XUSER_MAX_COUNT];
|
||||
|
||||
private:
|
||||
PlayerUID m_xuidNotch;
|
||||
|
||||
// Memory texture files
|
||||
std::unordered_map<std::string, PMEMDATA> m_MEM_Files;
|
||||
std::mutex csMemFilesLock;
|
||||
|
||||
// Additional model parts/skin boxes per skin id
|
||||
std::unordered_map<std::uint32_t, std::vector<ModelPart*>*>
|
||||
m_AdditionalModelParts;
|
||||
std::unordered_map<std::uint32_t, std::vector<SKIN_BOX*>*>
|
||||
m_AdditionalSkinBoxes;
|
||||
std::unordered_map<std::uint32_t, unsigned int> m_AnimOverrides;
|
||||
std::mutex csAdditionalModelParts;
|
||||
std::mutex csAdditionalSkinBoxes;
|
||||
std::mutex csAnimOverrideBitmask;
|
||||
};
|
||||
@@ -1,58 +0,0 @@
|
||||
#include "app/common/TerrainFeatureManager.h"
|
||||
|
||||
void TerrainFeatureManager::add(_eTerrainFeatureType eFeatureType, int x,
|
||||
int z) {
|
||||
// check we don't already have this in
|
||||
for (auto it = m_vTerrainFeatures.begin(); it < m_vTerrainFeatures.end();
|
||||
++it) {
|
||||
FEATURE_DATA* pFeatureData = *it;
|
||||
|
||||
if ((pFeatureData->eTerrainFeature == eFeatureType) &&
|
||||
(pFeatureData->x == x) && (pFeatureData->z == z))
|
||||
return;
|
||||
}
|
||||
|
||||
FEATURE_DATA* pFeatureData = new FEATURE_DATA;
|
||||
pFeatureData->eTerrainFeature = eFeatureType;
|
||||
pFeatureData->x = x;
|
||||
pFeatureData->z = z;
|
||||
|
||||
m_vTerrainFeatures.push_back(pFeatureData);
|
||||
}
|
||||
|
||||
_eTerrainFeatureType TerrainFeatureManager::isFeature(int x, int z) const {
|
||||
for (auto it = m_vTerrainFeatures.begin(); it < m_vTerrainFeatures.end();
|
||||
++it) {
|
||||
FEATURE_DATA* pFeatureData = *it;
|
||||
|
||||
if ((pFeatureData->x == x) && (pFeatureData->z == z))
|
||||
return pFeatureData->eTerrainFeature;
|
||||
}
|
||||
|
||||
return eTerrainFeature_None;
|
||||
}
|
||||
|
||||
bool TerrainFeatureManager::getPosition(_eTerrainFeatureType eType, int* pX,
|
||||
int* pZ) const {
|
||||
for (auto it = m_vTerrainFeatures.begin(); it < m_vTerrainFeatures.end();
|
||||
++it) {
|
||||
FEATURE_DATA* pFeatureData = *it;
|
||||
|
||||
if (pFeatureData->eTerrainFeature == eType) {
|
||||
*pX = pFeatureData->x;
|
||||
*pZ = pFeatureData->z;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void TerrainFeatureManager::clear() {
|
||||
FEATURE_DATA* pFeatureData;
|
||||
while (m_vTerrainFeatures.size() > 0) {
|
||||
pFeatureData = m_vTerrainFeatures.back();
|
||||
m_vTerrainFeatures.pop_back();
|
||||
delete pFeatureData;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/App_structs.h"
|
||||
#include "minecraft/GameEnums.h"
|
||||
|
||||
class TerrainFeatureManager {
|
||||
public:
|
||||
void add(_eTerrainFeatureType eFeatureType, int x, int z);
|
||||
void clear();
|
||||
_eTerrainFeatureType isFeature(int x, int z) const;
|
||||
bool getPosition(_eTerrainFeatureType eType, int* pX, int* pZ) const;
|
||||
|
||||
std::vector<FEATURE_DATA*>* features() { return &m_vTerrainFeatures; }
|
||||
|
||||
private:
|
||||
std::vector<FEATURE_DATA*> m_vTerrainFeatures;
|
||||
};
|
||||
@@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
// using namespace std;
|
||||
|
||||
#include "Tutorial.h"
|
||||
#include "minecraft/client/multiplayer/MultiPlayerGameMode.h"
|
||||
|
||||
class ClientConnection;
|
||||
class Minecraft;
|
||||
class Tutorial;
|
||||
|
||||
class TutorialMode : public MultiPlayerGameMode {
|
||||
protected:
|
||||
Tutorial* tutorial;
|
||||
int m_iPad;
|
||||
|
||||
// Function to make this an abstract class
|
||||
virtual bool isImplemented() = 0;
|
||||
|
||||
public:
|
||||
TutorialMode(int iPad, Minecraft* minecraft, ClientConnection* connection);
|
||||
virtual ~TutorialMode();
|
||||
|
||||
void startDestroyBlock(int x, int y, int z, int face) override;
|
||||
bool destroyBlock(int x, int y, int z, int face) override;
|
||||
void tick() override;
|
||||
bool useItemOn(std::shared_ptr<Player> player, Level* level,
|
||||
std::shared_ptr<ItemInstance> item, int x, int y, int z,
|
||||
int face, Vec3* hit, bool bTestUseOnly = false,
|
||||
bool* pbUsedItem = nullptr) override;
|
||||
void attack(std::shared_ptr<Player> player,
|
||||
std::shared_ptr<Entity> entity) override;
|
||||
|
||||
bool isInputAllowed(int mapping) override;
|
||||
|
||||
Tutorial* getTutorial() override { return tutorial; }
|
||||
};
|
||||
@@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/common/DLC/DLCPack.h"
|
||||
#include "platform/profile/profile.h"
|
||||
#include "platform/storage/storage.h"
|
||||
|
||||
class DLCPack;
|
||||
|
||||
class IUIScene_PauseMenu {
|
||||
protected:
|
||||
DLCPack* m_pDLCPack;
|
||||
|
||||
public:
|
||||
static int ExitGameDialogReturned(void* pParam, int iPad,
|
||||
IPlatformStorage::EMessageResult result);
|
||||
static int ExitGameSaveDialogReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
static int ExitGameAndSaveReturned(void* pParam, int iPad,
|
||||
IPlatformStorage::EMessageResult result);
|
||||
static int ExitGameDeclineSaveReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
static int WarningTrialTexturePackReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
static int SaveGameDialogReturned(void* pParam, int iPad,
|
||||
IPlatformStorage::EMessageResult result);
|
||||
static int EnableAutosaveDialogReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
static int DisableAutosaveDialogReturned(
|
||||
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
|
||||
|
||||
static int SaveWorldThreadProc(void* lpParameter);
|
||||
static int ExitWorldThreadProc(void* lpParameter);
|
||||
static void _ExitWorld(void* lpParameter); // Call only from a thread
|
||||
|
||||
protected:
|
||||
virtual void ShowScene(bool show) = 0;
|
||||
virtual void SetIgnoreInput(bool ignoreInput) = 0;
|
||||
};
|
||||
@@ -1,31 +0,0 @@
|
||||
#include "UIComponent_Logo.h"
|
||||
|
||||
#include "app/common/UI/UILayer.h"
|
||||
#include "app/common/UI/UIScene.h"
|
||||
#include "platform/renderer/renderer.h"
|
||||
|
||||
UIComponent_Logo::UIComponent_Logo(int iPad, void* initData,
|
||||
UILayer* parentLayer)
|
||||
: UIScene(iPad, parentLayer) {
|
||||
// Setup all the Iggy references we need for this scene
|
||||
initialiseMovie();
|
||||
}
|
||||
|
||||
std::string UIComponent_Logo::getMoviePath() {
|
||||
switch (m_parentLayer->getViewport()) {
|
||||
case IPlatformRenderer::VIEWPORT_TYPE_SPLIT_TOP:
|
||||
case IPlatformRenderer::VIEWPORT_TYPE_SPLIT_BOTTOM:
|
||||
case IPlatformRenderer::VIEWPORT_TYPE_SPLIT_LEFT:
|
||||
case IPlatformRenderer::VIEWPORT_TYPE_SPLIT_RIGHT:
|
||||
case IPlatformRenderer::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
|
||||
case IPlatformRenderer::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
|
||||
case IPlatformRenderer::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
|
||||
case IPlatformRenderer::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
|
||||
return "ComponentLogoSplit";
|
||||
break;
|
||||
case IPlatformRenderer::VIEWPORT_TYPE_FULLSCREEN:
|
||||
default:
|
||||
return "ComponentLogo";
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
#include "UIControl_SaveList.h"
|
||||
|
||||
#include "app/common/Iggy/include/iggy.h"
|
||||
#include "app/common/UI/Controls/UIControl.h"
|
||||
#include "app/common/UI/Controls/UIControl_ButtonList.h"
|
||||
#include "app/common/UI/UIScene.h"
|
||||
#ifndef _ENABLEIGGY
|
||||
#include "app/common/Iggy/iggy_stubs.h"
|
||||
#endif
|
||||
#include "app/common/Iggy/include/rrCore.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
bool UIControl_SaveList::setupControl(UIScene* scene, IggyValuePath* parent,
|
||||
const std::string& controlName) {
|
||||
UIControl::setControlType(UIControl::eSaveList);
|
||||
bool success =
|
||||
UIControl_ButtonList::setupControl(scene, parent, controlName);
|
||||
|
||||
// SlotList specific initialisers
|
||||
m_funcSetTextureName = registerFastName("SetTextureName");
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void UIControl_SaveList::addItem(const std::string& label) {
|
||||
addItem(label, "");
|
||||
}
|
||||
|
||||
void UIControl_SaveList::addItem(const std::string& label, int data) {
|
||||
addItem(label, "", data);
|
||||
}
|
||||
|
||||
void UIControl_SaveList::addItem(const std::string& label,
|
||||
const std::string& iconName) {
|
||||
addItem(label, iconName, m_itemCount);
|
||||
++m_itemCount;
|
||||
}
|
||||
|
||||
void UIControl_SaveList::addItem(const std::string& label,
|
||||
const std::string& iconName, int data) {
|
||||
IggyDataValue result;
|
||||
IggyDataValue value[3];
|
||||
|
||||
IggyStringUTF8 stringVal;
|
||||
stringVal.string = const_cast<char*>((char*)label.c_str());
|
||||
stringVal.length = (S32)label.length();
|
||||
value[0].type = IGGY_DATATYPE_string_UTF8;
|
||||
value[0].string8 = stringVal;
|
||||
|
||||
value[1].type = IGGY_DATATYPE_number;
|
||||
value[1].number = m_itemCount;
|
||||
|
||||
IggyStringUTF8 stringVal2;
|
||||
stringVal2.string = const_cast<char*>(iconName.c_str());
|
||||
stringVal2.length = iconName.length();
|
||||
value[2].type = IGGY_DATATYPE_string_UTF8;
|
||||
value[2].string8 = stringVal2;
|
||||
IggyResult out =
|
||||
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
|
||||
getIggyValuePath(), m_addNewItemFunc, 3, value);
|
||||
}
|
||||
|
||||
void UIControl_SaveList::setTextureName(int iId, const std::string& iconName) {
|
||||
IggyDataValue result;
|
||||
IggyDataValue value[2];
|
||||
|
||||
value[0].type = IGGY_DATATYPE_number;
|
||||
value[0].number = iId;
|
||||
|
||||
IggyStringUTF8 stringVal;
|
||||
stringVal.string = const_cast<char*>(iconName.c_str());
|
||||
stringVal.length = iconName.length();
|
||||
value[1].type = IGGY_DATATYPE_string_UTF8;
|
||||
value[1].string8 = stringVal;
|
||||
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
|
||||
getIggyValuePath(),
|
||||
m_funcSetTextureName, 2, value);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "app/common/Iggy/include/iggy.h"
|
||||
#include "app/common/UI/Controls/UIControl_SaveList.h"
|
||||
#include "app/common/UI/UIScene.h"
|
||||
#ifndef _ENABLEIGGY
|
||||
#include "app/common/Iggy/iggy_stubs.h"
|
||||
#endif
|
||||
#include "UIControl_ButtonList.h"
|
||||
|
||||
class UIControl_SaveList : public UIControl_ButtonList {
|
||||
private:
|
||||
IggyName m_funcSetTextureName;
|
||||
|
||||
public:
|
||||
virtual bool setupControl(UIScene* scene, IggyValuePath* parent,
|
||||
const std::string& controlName);
|
||||
|
||||
using UIControl_ButtonList::addItem;
|
||||
|
||||
void addItem(const std::string& label);
|
||||
// void addItem(const std::wstring& label);
|
||||
|
||||
void addItem(const std::string& label, int data);
|
||||
// void addItem(const std::wstring& label, int data);
|
||||
|
||||
void addItem(const std::string& label, const std::string& iconName);
|
||||
// void addItem(const std::string& label, const std::wstring& iconName);
|
||||
void setTextureName(int iId, const std::string& iconName);
|
||||
|
||||
private:
|
||||
void addItem(const std::string& label, const std::string& iconName,
|
||||
int data);
|
||||
// void addItem(const std::string& label, const std::string& iconName,
|
||||
// int data);
|
||||
};
|
||||
@@ -1,322 +0,0 @@
|
||||
|
||||
#include "UIScene_Credits.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/UI/ConsoleUIController.h"
|
||||
#include "app/common/UI/UILayer.h"
|
||||
#include "app/common/UI/UIScene.h"
|
||||
#include "strings.h"
|
||||
#include "util/StringHelpers.h"
|
||||
|
||||
#define CREDIT_ICON -2
|
||||
|
||||
SCreditTextItemDef UIScene_Credits::gs_aCreditDefs[MAX_CREDIT_STRINGS] = {
|
||||
{"MOJANG", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eExtraLargeText},
|
||||
{"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText}, // extra blank line
|
||||
{"%s", IDS_CREDITS_ORIGINALDESIGN, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Markus Persson", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText}, // extra blank line
|
||||
{"%s", IDS_CREDITS_PMPROD, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Daniel Kaplan", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText}, // extra blank line
|
||||
{"%s", IDS_CREDITS_RESTOFMOJANG, NO_TRANSLATED_STRING, eMediumText},
|
||||
{"%s", IDS_CREDITS_LEADPC, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Jens Bergensten", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"%s", IDS_CREDITS_JON_KAGSTROM, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"%s", IDS_CREDITS_CEO, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Carl Manneh", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"%s", IDS_CREDITS_DOF, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Lydia Winters", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"%s", IDS_CREDITS_WCW, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Karin Severinsson", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText},
|
||||
{"%s", IDS_CREDITS_CUSTOMERSUPPORT, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Marc Watson", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText}, // extra blank line
|
||||
{"%s", IDS_CREDITS_DESPROG, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Aron Nieminen", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText}, // extra blank line
|
||||
{"%s", IDS_CREDITS_CHIEFARCHITECT, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Daniel Frisk", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"%s", IDS_CREDITS_CODENINJA, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"%s", IDS_CREDITS_TOBIAS_MOLLSTAM, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"%s", IDS_CREDITS_OFFICEDJ, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Kristoffer Jelbring", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText},
|
||||
{"%s", IDS_CREDITS_DEVELOPER, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Leonard Axelsson", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText},
|
||||
{"%s", IDS_CREDITS_BULLYCOORD, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Jakob Porser", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"%s", IDS_CREDITS_ARTDEVELOPER, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Junkboy", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"%s", IDS_CREDITS_EXPLODANIM, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Mattis Grahm", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"%s", IDS_CREDITS_CONCEPTART, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Henrik Petterson", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText},
|
||||
{"%s", IDS_CREDITS_CRUNCHER, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Patrick Geuder", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"%s", IDS_CREDITS_MUSICANDSOUNDS, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Daniel Rosenfeld (C418)", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText},
|
||||
{"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText}, // extra blank line
|
||||
|
||||
// Added credit for horses
|
||||
{"Developers of Mo' Creatures:", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eExtraLargeText},
|
||||
{"John Olarte (DrZhark)", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText},
|
||||
{"Kent Christian Jensen", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText},
|
||||
{"Dan Roque", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText}, // extra blank line
|
||||
|
||||
{"4J Studios", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eExtraLargeText},
|
||||
{"%s", IDS_CREDITS_PROGRAMMING, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Paddy Burns", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Richard Reavy", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Stuart Ross", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"James Vaughan", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Mark Hughes", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Harry Gordon", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Thomas Kronberg", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
|
||||
{"%s", IDS_CREDITS_ART, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"David Keningale", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Alan Redmond", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Chris Reeves", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Kate Wright", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Michael Hansen", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Donald Robertson", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText},
|
||||
{"Jamie Keddie", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Thomas Naylor", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Brian Lindsay", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Hannah Watts", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Rebecca O'Neil", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
|
||||
{"%s", IDS_CREDITS_QA, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Steven Gary Woodward", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText},
|
||||
{"George Vaughan", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText}, // extra blank line
|
||||
{"%s", IDS_CREDITS_SPECIALTHANKS, NO_TRANSLATED_STRING, eLargeText},
|
||||
{"Chris van der Kuyl", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText},
|
||||
{"Roni Percy", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Anne Clarke", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
{"Anthony Kent", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING, eSmallText},
|
||||
|
||||
// Miles & Iggy credits
|
||||
{"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText}, // extra blank line
|
||||
{"", CREDIT_ICON, eCreditIcon_Iggy, eSmallText}, // extra blank line
|
||||
{"Uses Iggy.", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText}, // extra blank line
|
||||
{"Copyright (C) 2009-2014 by RAD Game Tools, Inc.", NO_TRANSLATED_STRING,
|
||||
NO_TRANSLATED_STRING, eSmallText}, // extra blank line
|
||||
{"", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText}, // extra blank line
|
||||
{"", CREDIT_ICON, eCreditIcon_Miles, eSmallText}, // extra blank line
|
||||
{"Uses Miles Sound System.", NO_TRANSLATED_STRING, NO_TRANSLATED_STRING,
|
||||
eSmallText}, // extra blank line
|
||||
{"Copyright (C) 1991-2014 by RAD Game Tools, Inc.", NO_TRANSLATED_STRING,
|
||||
NO_TRANSLATED_STRING, eSmallText}, // extra blank line
|
||||
};
|
||||
|
||||
UIScene_Credits::UIScene_Credits(int iPad, void* initData, UILayer* parentLayer)
|
||||
: UIScene(iPad, parentLayer) {
|
||||
// Setup all the Iggy references we need for this scene
|
||||
initialiseMovie();
|
||||
|
||||
m_bAddNextLabel = false;
|
||||
|
||||
// How many lines of text are in the credits?
|
||||
m_iNumTextDefs = MAX_CREDIT_STRINGS;
|
||||
|
||||
// Are there any additional lines needed for the DLC credits?
|
||||
m_iNumTextDefs += app.GetDLCCreditsCount();
|
||||
|
||||
m_iCurrDefIndex = -1;
|
||||
|
||||
// Add the first 20 Flash can cope with
|
||||
for (unsigned int i = 0; i < 20; ++i) {
|
||||
++m_iCurrDefIndex;
|
||||
|
||||
// Set up the new text element.
|
||||
if (gs_aCreditDefs[i].m_iStringID[0] == NO_TRANSLATED_STRING) {
|
||||
setNextLabel(gs_aCreditDefs[i].m_Text, gs_aCreditDefs[i].m_eType);
|
||||
} else // using additional translated string.
|
||||
{
|
||||
char* creditsString = new char[128];
|
||||
if (gs_aCreditDefs[i].m_iStringID[1] != NO_TRANSLATED_STRING) {
|
||||
snprintf(creditsString, 128, gs_aCreditDefs[i].m_Text,
|
||||
app.GetString(gs_aCreditDefs[i].m_iStringID[0]),
|
||||
app.GetString(gs_aCreditDefs[i].m_iStringID[1]));
|
||||
} else {
|
||||
snprintf(creditsString, 128, gs_aCreditDefs[i].m_Text,
|
||||
app.GetString(gs_aCreditDefs[i].m_iStringID[0]));
|
||||
}
|
||||
setNextLabel(creditsString, gs_aCreditDefs[i].m_eType);
|
||||
delete[] creditsString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string UIScene_Credits::getMoviePath() { return "Credits"; }
|
||||
|
||||
void UIScene_Credits::updateTooltips() {
|
||||
ui.SetTooltips(m_iPad, -1, IDS_TOOLTIPS_BACK);
|
||||
}
|
||||
|
||||
void UIScene_Credits::updateComponents() {
|
||||
m_parentLayer->showComponent(m_iPad, eUIComponent_Logo, true);
|
||||
}
|
||||
|
||||
void UIScene_Credits::handleReload() {
|
||||
// We don't allow this in splitscreen, so just go back
|
||||
navigateBack();
|
||||
}
|
||||
|
||||
void UIScene_Credits::tick() {
|
||||
UIScene::tick();
|
||||
|
||||
if (m_bAddNextLabel) {
|
||||
m_bAddNextLabel = false;
|
||||
|
||||
const SCreditTextItemDef* pDef;
|
||||
|
||||
// Time to create next text item.
|
||||
++m_iCurrDefIndex;
|
||||
|
||||
// Wrap back to start.
|
||||
if (m_iCurrDefIndex >= m_iNumTextDefs) {
|
||||
m_iCurrDefIndex = 0;
|
||||
}
|
||||
|
||||
if (m_iCurrDefIndex >= MAX_CREDIT_STRINGS) {
|
||||
app.DebugPrintf("DLC credit %d\n",
|
||||
m_iCurrDefIndex - MAX_CREDIT_STRINGS);
|
||||
// DLC credit
|
||||
pDef = app.GetDLCCredits(m_iCurrDefIndex - MAX_CREDIT_STRINGS);
|
||||
} else {
|
||||
// Get text def for this item.
|
||||
pDef = &(gs_aCreditDefs[m_iCurrDefIndex]);
|
||||
}
|
||||
|
||||
// Set up the new text element.
|
||||
if (pDef->m_Text != nullptr) // 4J-PB - think the RAD logo ones aren't
|
||||
// set up yet and are coming is as null
|
||||
{
|
||||
if (pDef->m_iStringID[0] == CREDIT_ICON) {
|
||||
addImage((ECreditIcons)pDef->m_iStringID[1]);
|
||||
} else // using additional translated string.
|
||||
{
|
||||
std::string sanitisedString = std::string(pDef->m_Text);
|
||||
|
||||
// 4J-JEV: Some DLC credits contain copyright or registered
|
||||
// symbols that are not rendered in some fonts.
|
||||
if (!ui.UsingBitmapFont()) {
|
||||
sanitisedString =
|
||||
replaceAll(sanitisedString, "\u00A9", "(C)");
|
||||
sanitisedString =
|
||||
replaceAll(sanitisedString, "\u00AE", "(R)");
|
||||
sanitisedString =
|
||||
replaceAll(sanitisedString, "\u2013", "-");
|
||||
}
|
||||
|
||||
char* creditsString = new char[128];
|
||||
if (pDef->m_iStringID[0] == NO_TRANSLATED_STRING) {
|
||||
memset(creditsString, 0, 128);
|
||||
memcpy(creditsString, sanitisedString.c_str(),
|
||||
sizeof(char) * sanitisedString.length());
|
||||
} else if (pDef->m_iStringID[1] != NO_TRANSLATED_STRING) {
|
||||
snprintf(creditsString, 128, sanitisedString.c_str(),
|
||||
app.GetString(pDef->m_iStringID[0]),
|
||||
app.GetString(pDef->m_iStringID[1]));
|
||||
} else {
|
||||
snprintf(creditsString, 128, sanitisedString.c_str(),
|
||||
app.GetString(pDef->m_iStringID[0]));
|
||||
}
|
||||
|
||||
setNextLabel(creditsString, pDef->m_eType);
|
||||
delete[] creditsString;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_Credits::handleInput(int iPad, int key, bool repeat, bool pressed,
|
||||
bool released, bool& handled) {
|
||||
// app.DebugPrintf("UIScene_DebugOverlay handling input for pad %d, key %d,
|
||||
// down- %s, pressed- %s, released- %s\n", iPad, key,
|
||||
// down?"true":"false", pressed?"true":"false", released?"true":"false");
|
||||
|
||||
ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released);
|
||||
|
||||
switch (key) {
|
||||
case ACTION_MENU_CANCEL:
|
||||
if (pressed && !repeat) {
|
||||
navigateBack();
|
||||
}
|
||||
break;
|
||||
case ACTION_MENU_OK:
|
||||
case ACTION_MENU_UP:
|
||||
case ACTION_MENU_DOWN:
|
||||
sendInputToMovie(key, repeat, pressed, released);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UIScene_Credits::setNextLabel(const std::string& label,
|
||||
ECreditTextTypes size) {
|
||||
IggyDataValue result;
|
||||
IggyDataValue value[3];
|
||||
|
||||
IggyStringUTF8 stringVal;
|
||||
stringVal.string = const_cast<char*>(label.c_str());
|
||||
stringVal.length = label.length();
|
||||
value[0].type = IGGY_DATATYPE_string_UTF8;
|
||||
value[0].string8 = stringVal;
|
||||
|
||||
value[1].type = IGGY_DATATYPE_number;
|
||||
value[1].number = (int)size;
|
||||
|
||||
value[2].type = IGGY_DATATYPE_boolean;
|
||||
value[2].boolval = (m_iCurrDefIndex == (m_iNumTextDefs - 1));
|
||||
|
||||
IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result,
|
||||
IggyPlayerRootPath(getMovie()),
|
||||
m_funcSetNextLabel, 3, value);
|
||||
}
|
||||
|
||||
void UIScene_Credits::addImage(ECreditIcons icon) {
|
||||
IggyDataValue result;
|
||||
IggyDataValue value[2];
|
||||
|
||||
value[0].type = IGGY_DATATYPE_number;
|
||||
value[0].number = (int)icon;
|
||||
|
||||
value[1].type = IGGY_DATATYPE_boolean;
|
||||
value[1].boolval = (m_iCurrDefIndex == (m_iNumTextDefs - 1));
|
||||
|
||||
IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result,
|
||||
IggyPlayerRootPath(getMovie()),
|
||||
m_funcAddImage, 2, value);
|
||||
}
|
||||
|
||||
void UIScene_Credits::handleRequestMoreData(F64 startIndex, bool up) {
|
||||
m_bAddNextLabel = true;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
#include "platform/XboxStubs.h"
|
||||
|
||||
#include "platform/PlatformTypes.h"
|
||||
|
||||
bool IsEqualXUID(PlayerUID a, PlayerUID b) { return a == b; }
|
||||
|
||||
uint32_t XUserGetSigninInfo(uint32_t dwUserIndex, uint32_t dwFlags,
|
||||
PXUSER_SIGNIN_INFO pSigninInfo) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* CXuiStringTable::Lookup(const char* szId) { return szId; }
|
||||
const char* CXuiStringTable::Lookup(uint32_t nIndex) { return "String"; }
|
||||
void CXuiStringTable::Clear() {}
|
||||
int32_t CXuiStringTable::Load(const char* szId) { return 0; }
|
||||
|
||||
uint32_t XGetLanguage() { return 1; }
|
||||
uint32_t XGetLocale() { return 0; }
|
||||
uint32_t XEnableGuestSignin(bool fEnable) { return 0; }
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "Consoles_SoundEngine.h"
|
||||
|
||||
bool ConsoleSoundEngine::GetIsPlayingStreamingCDMusic() {
|
||||
return m_bIsPlayingStreamingCDMusic;
|
||||
}
|
||||
bool ConsoleSoundEngine::GetIsPlayingStreamingGameMusic() {
|
||||
return m_bIsPlayingStreamingGameMusic;
|
||||
}
|
||||
void ConsoleSoundEngine::SetIsPlayingStreamingCDMusic(bool bVal) {
|
||||
m_bIsPlayingStreamingCDMusic = bVal;
|
||||
}
|
||||
void ConsoleSoundEngine::SetIsPlayingStreamingGameMusic(bool bVal) {
|
||||
m_bIsPlayingStreamingGameMusic = bVal;
|
||||
}
|
||||
bool ConsoleSoundEngine::GetIsPlayingEndMusic() { return m_bIsPlayingEndMusic; }
|
||||
bool ConsoleSoundEngine::GetIsPlayingNetherMusic() {
|
||||
return m_bIsPlayingNetherMusic;
|
||||
}
|
||||
void ConsoleSoundEngine::SetIsPlayingEndMusic(bool bVal) {
|
||||
m_bIsPlayingEndMusic = bVal;
|
||||
}
|
||||
void ConsoleSoundEngine::SetIsPlayingNetherMusic(bool bVal) {
|
||||
m_bIsPlayingNetherMusic = bVal;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "SoundTypes.h"
|
||||
#include "minecraft/sounds/SoundTypes.h"
|
||||
|
||||
class File;
|
||||
|
||||
@@ -21,11 +21,6 @@ typedef struct {
|
||||
class Options;
|
||||
class Mob;
|
||||
|
||||
// Game-side sound engine interface. The concrete backend
|
||||
// (app/common/Audio/SoundEngine) inherits from this and forwards into
|
||||
// IPlatformSound. minecraft/ consumers see only the abstract base, so
|
||||
// they don't have to drag the concrete backend (and its miniaudio
|
||||
// pimpl) into their compilation units.
|
||||
class ConsoleSoundEngine {
|
||||
public:
|
||||
ConsoleSoundEngine()
|
||||
@@ -34,13 +29,11 @@ public:
|
||||
m_bIsPlayingEndMusic(false),
|
||||
m_bIsPlayingNetherMusic(false) {}
|
||||
|
||||
virtual ~ConsoleSoundEngine() = default;
|
||||
|
||||
virtual void tick(std::shared_ptr<Mob>* players, float a) = 0;
|
||||
virtual void destroy() = 0;
|
||||
virtual void play(int iSound, float x, float y, float z, float volume,
|
||||
float pitch) = 0;
|
||||
virtual void playStreaming(const std::string& name, float x, float y,
|
||||
virtual void playStreaming(const std::wstring& name, float x, float y,
|
||||
float z, float volume, float pitch,
|
||||
bool bMusicDelay = true) = 0;
|
||||
virtual void playUI(int iSound, float volume, float pitch) = 0;
|
||||
@@ -48,10 +41,10 @@ public:
|
||||
virtual void updateSystemMusicPlaying(bool isPlaying) = 0;
|
||||
virtual void updateSoundEffectVolume(float fVal) = 0;
|
||||
virtual void init(Options*) = 0;
|
||||
virtual void add(const std::string& name, File* file) = 0;
|
||||
virtual void addMusic(const std::string& name, File* file) = 0;
|
||||
virtual void addStreaming(const std::string& name, File* file) = 0;
|
||||
virtual char* ConvertSoundPathToName(const std::string& name,
|
||||
virtual void add(const std::wstring& name, File* file) = 0;
|
||||
virtual void addMusic(const std::wstring& name, File* file) = 0;
|
||||
virtual void addStreaming(const std::wstring& name, File* file) = 0;
|
||||
virtual char* ConvertSoundPathToName(const std::wstring& name,
|
||||
bool bConvertSpaces) = 0;
|
||||
virtual void playMusicTick() = 0;
|
||||
|
||||
@@ -64,8 +57,8 @@ public:
|
||||
virtual void SetIsPlayingEndMusic(bool bVal);
|
||||
virtual void SetIsPlayingNetherMusic(bool bVal);
|
||||
|
||||
static const char* wchSoundNames[eSoundType_MAX];
|
||||
static const char* wchUISoundNames[eSFX_MAX];
|
||||
static const wchar_t* wchSoundNames[eSoundType_MAX];
|
||||
static const wchar_t* wchUISoundNames[eSFX_MAX];
|
||||
|
||||
public:
|
||||
void tick();
|
||||
@@ -4,19 +4,13 @@ class Options;
|
||||
class C4JThread;
|
||||
class Random;
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "app/common/Audio/ConsoleSoundEngine.h"
|
||||
#include "app/common/Audio/SoundTypes.h"
|
||||
#include "app/common/Iggy/include/rrCore.h"
|
||||
#include "platform/PlatformTypes.h"
|
||||
|
||||
// Forward-declare the miniaudio backing state. The full struct lives in
|
||||
// SoundEngine.cpp where miniaudio.h is actually included. This keeps
|
||||
// miniaudio.h out of the 9 minecraft files that include SoundEngine.h
|
||||
// via the 4j include chain.
|
||||
struct SoundEngineMiniAudio;
|
||||
#include "app/common/App_Defines.h"
|
||||
#include "app/common/src/Audio/Consoles_SoundEngine.h"
|
||||
#include "app/linux/Iggy/include/rrCore.h"
|
||||
#include "minecraft/sounds/SoundTypes.h"
|
||||
#include "miniaudio.h"
|
||||
|
||||
constexpr float SFX_3D_MIN_DISTANCE = 1.0f;
|
||||
constexpr float SFX_3D_MAX_DISTANCE = 16.0f;
|
||||
@@ -96,22 +90,22 @@ typedef struct {
|
||||
char chName[64];
|
||||
#endif
|
||||
} AUDIO_INFO;
|
||||
|
||||
// MiniAudioSound's definition lives in SoundEngine.cpp alongside the
|
||||
// miniaudio backend; consumers of this header don't need to see it.
|
||||
|
||||
struct MiniAudioSound {
|
||||
ma_sound sound;
|
||||
AUDIO_INFO info;
|
||||
bool active;
|
||||
};
|
||||
class SoundEngine : public ConsoleSoundEngine {
|
||||
static const int MAX_SAME_SOUNDS_PLAYING = 8; // 4J added
|
||||
public:
|
||||
SoundEngine();
|
||||
~SoundEngine();
|
||||
virtual void destroy();
|
||||
#if defined(_DEBUG)
|
||||
void GetSoundName(char* szSoundName, int iSound);
|
||||
#endif
|
||||
virtual void play(int iSound, float x, float y, float z, float volume,
|
||||
float pitch);
|
||||
virtual void playStreaming(const std::string& name, float x, float y,
|
||||
virtual void playStreaming(const std::wstring& name, float x, float y,
|
||||
float z, float volume, float pitch,
|
||||
bool bMusicDelay = true);
|
||||
virtual void playUI(int iSound, float volume, float pitch);
|
||||
@@ -123,14 +117,14 @@ public:
|
||||
virtual void tick(std::shared_ptr<Mob>* players,
|
||||
float a); // 4J - updated to take array of local players
|
||||
// rather than single one
|
||||
virtual void add(const std::string& name, File* file);
|
||||
virtual void addMusic(const std::string& name, File* file);
|
||||
virtual void addStreaming(const std::string& name, File* file);
|
||||
virtual char* ConvertSoundPathToName(const std::string& name,
|
||||
virtual void add(const std::wstring& name, File* file);
|
||||
virtual void addMusic(const std::wstring& name, File* file);
|
||||
virtual void addStreaming(const std::wstring& name, File* file);
|
||||
virtual char* ConvertSoundPathToName(const std::wstring& name,
|
||||
bool bConvertSpaces = false);
|
||||
bool isStreamingWavebankReady(); // 4J Added
|
||||
int getMusicID(int iDomain);
|
||||
int getMusicID(const std::string& name);
|
||||
int getMusicID(const std::wstring& name);
|
||||
void SetStreamingSounds(int iOverworldMin, int iOverWorldMax,
|
||||
int iNetherMin, int iNetherMax, int iEndMin,
|
||||
int iEndMax, int iCD1);
|
||||
@@ -142,15 +136,15 @@ private:
|
||||
float getMasterMusicVolume();
|
||||
// platform specific functions
|
||||
int initAudioHardware(int iMinSpeakers) { return iMinSpeakers; }
|
||||
#if defined(__linux__)
|
||||
void updateMiniAudio();
|
||||
#endif
|
||||
|
||||
int GetRandomishTrack(int iStart, int iEnd);
|
||||
|
||||
// Miniaudio engine + music stream PIMPL'd into SoundEngineMiniAudio,
|
||||
// defined in SoundEngine.cpp. Owned via unique_ptr; the destructor
|
||||
// is out-of-line so the unique_ptr instantiation can see the full
|
||||
// type.
|
||||
std::unique_ptr<SoundEngineMiniAudio> m_audio;
|
||||
ma_engine m_engine;
|
||||
ma_engine_config m_engineConfig;
|
||||
ma_sound m_musicStream;
|
||||
bool m_musicStreamActive;
|
||||
|
||||
static char m_szSoundPath[];
|
||||
@@ -167,7 +161,7 @@ private:
|
||||
int m_StreamState;
|
||||
int m_MusicType;
|
||||
AUDIO_INFO m_StreamingAudioInfo;
|
||||
std::string m_CDMusic;
|
||||
std::wstring m_CDMusic;
|
||||
bool m_bSystemMusicPlaying;
|
||||
float m_MasterMusicVolume;
|
||||
float m_MasterEffectsVolume;
|
||||
@@ -0,0 +1,228 @@
|
||||
#include "Consoles_SoundEngine.h"
|
||||
#include "minecraft/sounds/SoundTypes.h"
|
||||
|
||||
const wchar_t* ConsoleSoundEngine::wchSoundNames[eSoundType_MAX] = {
|
||||
L"mob/chicken/chicken", // eSoundType_MOB_CHICKEN_AMBIENT
|
||||
L"mob/chicken/chickenhurt", // eSoundType_MOB_CHICKEN_HURT
|
||||
L"mob/chicken/chickenplop", // eSoundType_MOB_CHICKENPLOP
|
||||
L"mob/cow/say", // eSoundType_MOB_COW_AMBIENT
|
||||
L"mob/cow/hurt", // eSoundType_MOB_COW_HURT
|
||||
L"mob/pig/pig", // eSoundType_MOB_PIG_AMBIENT
|
||||
L"mob/pig/pigdeath", // eSoundType_MOB_PIG_DEATH
|
||||
L"mob/sheep/sheep", // eSoundType_MOB_SHEEP_AMBIENT
|
||||
L"mob/wolf/growl", // eSoundType_MOB_WOLF_GROWL
|
||||
L"mob/wolf/whine", // eSoundType_MOB_WOLF_WHINE
|
||||
L"mob/wolf/panting", // eSoundType_MOB_WOLF_PANTING
|
||||
L"mob/wolf/bark", // eSoundType_MOB_WOLF_BARK
|
||||
L"mob/wolf/hurt", // eSoundType_MOB_WOLF_HURT
|
||||
L"mob/wolf/death", // eSoundType_MOB_WOLF_DEATH
|
||||
L"mob/wolf/shake", // eSoundType_MOB_WOLF_SHAKE
|
||||
L"mob/blaze/breathe", // eSoundType_MOB_BLAZE_BREATHE
|
||||
L"mob/blaze/hit", // eSoundType_MOB_BLAZE_HURT
|
||||
L"mob/blaze/death", // eSoundType_MOB_BLAZE_DEATH
|
||||
L"mob/ghast/moan", // eSoundType_MOB_GHAST_MOAN
|
||||
L"mob/ghast/scream", // eSoundType_MOB_GHAST_SCREAM
|
||||
L"mob/ghast/death", // eSoundType_MOB_GHAST_DEATH
|
||||
L"mob/ghast/fireball", // eSoundType_MOB_GHAST_FIREBALL
|
||||
L"mob/ghast/charge", // eSoundType_MOB_GHAST_CHARGE
|
||||
L"mob/endermen/idle", // eSoundType_MOB_ENDERMEN_IDLE
|
||||
L"mob/endermen/hit", // eSoundType_MOB_ENDERMEN_HIT
|
||||
L"mob/endermen/death", // eSoundType_MOB_ENDERMEN_DEATH
|
||||
L"mob/endermen/portal", // eSoundType_MOB_ENDERMEN_PORTAL
|
||||
L"mob/zombiepig/zpig", // eSoundType_MOB_ZOMBIEPIG_AMBIENT
|
||||
L"mob/zombiepig/zpighurt", // eSoundType_MOB_ZOMBIEPIG_HURT
|
||||
L"mob/zombiepig/zpigdeath", // eSoundType_MOB_ZOMBIEPIG_DEATH
|
||||
L"mob/zombiepig/zpigangry", // eSoundType_MOB_ZOMBIEPIG_ZPIGANGRY
|
||||
L"mob/silverfish/say", // eSoundType_MOB_SILVERFISH_AMBIENT,
|
||||
L"mob/silverfish/hit", // eSoundType_MOB_SILVERFISH_HURT
|
||||
L"mob/silverfish/kill", // eSoundType_MOB_SILVERFISH_DEATH,
|
||||
L"mob/silverfish/step", // eSoundType_MOB_SILVERFISH_STEP,
|
||||
L"mob/skeleton/skeleton", // eSoundType_MOB_SKELETON_AMBIENT,
|
||||
L"mob/skeleton/skeletonhurt", // eSoundType_MOB_SKELETON_HURT,
|
||||
L"mob/spider/spider", // eSoundType_MOB_SPIDER_AMBIENT,
|
||||
L"mob/spider/spiderdeath", // eSoundType_MOB_SPIDER_DEATH,
|
||||
L"mob/slime/slime", // eSoundType_MOB_SLIME,
|
||||
L"mob/slime/slimeattack", // eSoundType_MOB_SLIME_ATTACK,
|
||||
L"mob/creeper/creeper", // eSoundType_MOB_CREEPER_HURT,
|
||||
L"mob/creeper/creeperdeath", // eSoundType_MOB_CREEPER_DEATH,
|
||||
L"mob/zombie/zombie", // eSoundType_MOB_ZOMBIE_AMBIENT,
|
||||
L"mob/zombie/zombiehurt", // eSoundType_MOB_ZOMBIE_HURT,
|
||||
L"mob/zombie/zombiedeath", // eSoundType_MOB_ZOMBIE_DEATH,
|
||||
L"mob/zombie/wood", // eSoundType_MOB_ZOMBIE_WOOD,
|
||||
L"mob/zombie/woodbreak", // eSoundType_MOB_ZOMBIE_WOOD_BREAK,
|
||||
L"mob/zombie/metal", // eSoundType_MOB_ZOMBIE_METAL,
|
||||
L"mob/magmacube/big", // eSoundType_MOB_MAGMACUBE_BIG,
|
||||
L"mob/magmacube/small", // eSoundType_MOB_MAGMACUBE_SMALL,
|
||||
L"mob/cat/purr", // eSoundType_MOB_CAT_PURR
|
||||
L"mob/cat/purreow", // eSoundType_MOB_CAT_PURREOW
|
||||
L"mob/cat/meow", // eSoundType_MOB_CAT_MEOW
|
||||
// 4J-PB - correct the name of the event for hitting ocelots
|
||||
L"mob/cat/hitt", // eSoundType_MOB_CAT_HITT
|
||||
// L"mob.irongolem.throw", //
|
||||
// eSoundType_MOB_IRONGOLEM_THROW L"mob.irongolem.hit",
|
||||
//// eSoundType_MOB_IRONGOLEM_HIT L"mob.irongolem.death",
|
||||
//// eSoundType_MOB_IRONGOLEM_DEATH L"mob.irongolem.walk",
|
||||
//// eSoundType_MOB_IRONGOLEM_WALK
|
||||
L"random/bow", // eSoundType_RANDOM_BOW,
|
||||
L"random/bowhit", // eSoundType_RANDOM_BOW_HIT,
|
||||
L"random/explode", // eSoundType_RANDOM_EXPLODE,
|
||||
L"random/fizz", // eSoundType_RANDOM_FIZZ,
|
||||
L"random/pop", // eSoundType_RANDOM_POP,
|
||||
L"random/fuse", // eSoundType_RANDOM_FUSE,
|
||||
L"random/drink", // eSoundType_RANDOM_DRINK,
|
||||
L"random/eat", // eSoundType_RANDOM_EAT,
|
||||
L"random/burp", // eSoundType_RANDOM_BURP,
|
||||
L"random/splash", // eSoundType_RANDOM_SPLASH,
|
||||
L"random/click", // eSoundType_RANDOM_CLICK,
|
||||
L"random/glass", // eSoundType_RANDOM_GLASS,
|
||||
L"random/orb", // eSoundType_RANDOM_ORB,
|
||||
L"random/break", // eSoundType_RANDOM_BREAK,
|
||||
L"random/chestopen", // eSoundType_RANDOM_CHEST_OPEN,
|
||||
L"random/chestclosed", // eSoundType_RANDOM_CHEST_CLOSE,
|
||||
L"random/door_open", // eSoundType_RANDOM_DOOR_OPEN,
|
||||
L"random/door_close", // eSoundType_RANDOM_DOOR_CLOSE,
|
||||
L"ambient/weather/rain", // eSoundType_AMBIENT_WEATHER_RAIN,
|
||||
L"ambient/weather/thunder", // eSoundType_AMBIENT_WEATHER_THUNDER,
|
||||
L"ambient/cave/cave", // eSoundType_CAVE_CAVE, DON'T USE FOR XBOX 360!!!
|
||||
L"portal/portal", // eSoundType_PORTAL_PORTAL,
|
||||
// 4J-PB - added a couple that were still using std::wstring
|
||||
L"portal/trigger", // eSoundType_PORTAL_TRIGGER
|
||||
L"portal/travel", // eSoundType_PORTAL_TRAVEL
|
||||
|
||||
L"fire/ignite", // eSoundType_FIRE_IGNITE,
|
||||
L"fire/fire", // eSoundType_FIRE_FIRE,
|
||||
L"damage/hit", // eSoundType_DAMAGE_HURT,
|
||||
L"damage/fallsmall", // eSoundType_DAMAGE_FALL_SMALL,
|
||||
L"damage/fallbig", // eSoundType_DAMAGE_FALL_BIG,
|
||||
L"note/harp", // eSoundType_NOTE_HARP,
|
||||
L"note/bd", // eSoundType_NOTE_BD,
|
||||
L"note/snare", // eSoundType_NOTE_SNARE,
|
||||
L"note/hat", // eSoundType_NOTE_HAT,
|
||||
L"note/bassattack", // eSoundType_NOTE_BASSATTACK,
|
||||
L"tile/piston.in", // eSoundType_TILE_PISTON_IN,
|
||||
L"tile/piston.out", // eSoundType_TILE_PISTON_OUT,
|
||||
L"liquid/water", // eSoundType_LIQUID_WATER,
|
||||
L"liquid/lavapop", // eSoundType_LIQUID_LAVA_POP,
|
||||
L"liquid/lava", // eSoundType_LIQUID_LAVA,
|
||||
L"step/stone", // eSoundType_STEP_STONE,
|
||||
L"step/wood", // eSoundType_STEP_WOOD,
|
||||
L"step/gravel", // eSoundType_STEP_GRAVEL,
|
||||
L"step/grass", // eSoundType_STEP_GRASS,
|
||||
L"step/metal", // eSoundType_STEP_METAL,
|
||||
L"step/cloth", // eSoundType_STEP_CLOTH,
|
||||
L"step/sand", // eSoundType_STEP_SAND,
|
||||
|
||||
// below this are the additional sounds from the second soundbank
|
||||
L"mob/enderdragon/end", // eSoundType_MOB_ENDERDRAGON_END
|
||||
L"mob/enderdragon/growl", // eSoundType_MOB_ENDERDRAGON_GROWL
|
||||
L"mob/enderdragon/hit", // eSoundType_MOB_ENDERDRAGON_HIT
|
||||
L"mob/enderdragon/wings", // eSoundType_MOB_ENDERDRAGON_MOVE
|
||||
L"mob/irongolem/throw", // eSoundType_MOB_IRONGOLEM_THROW
|
||||
L"mob/irongolem/hit", // eSoundType_MOB_IRONGOLEM_HIT
|
||||
L"mob/irongolem/death", // eSoundType_MOB_IRONGOLEM_DEATH
|
||||
L"mob/irongolem/walk", // eSoundType_MOB_IRONGOLEM_WALK
|
||||
|
||||
// TU14
|
||||
L"damage/thorns", // eSoundType_DAMAGE_THORNS
|
||||
L"random/anvil_break", // eSoundType_RANDOM_ANVIL_BREAK
|
||||
L"random/anvil_land", // eSoundType_RANDOM_ANVIL_LAND
|
||||
L"random/anvil_use", // eSoundType_RANDOM_ANVIL_USE
|
||||
L"mob/villager/haggle", // eSoundType_MOB_VILLAGER_HAGGLE
|
||||
L"mob/villager/idle", // eSoundType_MOB_VILLAGER_IDLE
|
||||
L"mob/villager/hit", // eSoundType_MOB_VILLAGER_HIT
|
||||
L"mob/villager/death", // eSoundType_MOB_VILLAGER_DEATH
|
||||
L"mob/villager/yes", // eSoundType_MOB_VILLAGER_YES
|
||||
L"mob/villager/no", // eSoundType_MOB_VILLAGER_NO
|
||||
L"mob/zombie/infect", // eSoundType_MOB_ZOMBIE_INFECT
|
||||
L"mob/zombie/unfect", // eSoundType_MOB_ZOMBIE_UNFECT
|
||||
L"mob/zombie/remedy", // eSoundType_MOB_ZOMBIE_REMEDY
|
||||
L"step/snow", // eSoundType_STEP_SNOW
|
||||
L"step/ladder", // eSoundType_STEP_LADDER
|
||||
L"dig/cloth", // eSoundType_DIG_CLOTH
|
||||
L"dig/grass", // eSoundType_DIG_GRASS
|
||||
L"dig/gravel", // eSoundType_DIG_GRAVEL
|
||||
L"dig/sand", // eSoundType_DIG_SAND
|
||||
L"dig/snow", // eSoundType_DIG_SNOW
|
||||
L"dig/stone", // eSoundType_DIG_STONE
|
||||
L"dig/wood", // eSoundType_DIG_WOOD
|
||||
|
||||
// 1.6.4
|
||||
L"fireworks/launch", // eSoundType_FIREWORKS_LAUNCH,
|
||||
L"fireworks/blast", // eSoundType_FIREWORKS_BLAST,
|
||||
L"fireworks/blast_far", // eSoundType_FIREWORKS_BLAST_FAR,
|
||||
L"fireworks/large_blast", // eSoundType_FIREWORKS_LARGE_BLAST,
|
||||
L"fireworks/large_blast_far", // eSoundType_FIREWORKS_LARGE_BLAST_FAR,
|
||||
L"fireworks/twinkle", // eSoundType_FIREWORKS_TWINKLE,
|
||||
L"fireworks/twinkle_far", // eSoundType_FIREWORKS_TWINKLE_FAR,
|
||||
|
||||
L"mob/bat/idle", // eSoundType_MOB_BAT_IDLE,
|
||||
L"mob/bat/hurt", // eSoundType_MOB_BAT_HURT,
|
||||
L"mob/bat/death", // eSoundType_MOB_BAT_DEATH,
|
||||
L"mob/bat/takeoff", // eSoundType_MOB_BAT_TAKEOFF,
|
||||
|
||||
L"mob/wither/spawn", // eSoundType_MOB_WITHER_SPAWN,
|
||||
L"mob/wither/idle", // eSoundType_MOB_WITHER_IDLE,
|
||||
L"mob/wither/hurt", // eSoundType_MOB_WITHER_HURT,
|
||||
L"mob/wither/death", // eSoundType_MOB_WITHER_DEATH,
|
||||
L"mob/wither/shoot", // eSoundType_MOB_WITHER_SHOOT,
|
||||
|
||||
L"mob/cow/step", // eSoundType_MOB_COW_STEP,
|
||||
L"mob/chicken/step", // eSoundType_MOB_CHICKEN_STEP,
|
||||
L"mob/pig/step", // eSoundType_MOB_PIG_STEP,
|
||||
L"mob/enderman/stare", // eSoundType_MOB_ENDERMAN_STARE,
|
||||
L"mob/enderman/scream", // eSoundType_MOB_ENDERMAN_SCREAM,
|
||||
L"mob/sheep/shear", // eSoundType_MOB_SHEEP_SHEAR,
|
||||
L"mob/sheep/step", // eSoundType_MOB_SHEEP_STEP,
|
||||
L"mob/skeleton.death", // eSoundType_MOB_SKELETON_DEATH,
|
||||
L"mob/skeleton/step", // eSoundType_MOB_SKELETON_STEP,
|
||||
L"mob/spider/step", // eSoundType_MOB_SPIDER_STEP,
|
||||
L"mob/wolf/step", // eSoundType_MOB_WOLF_STEP,
|
||||
L"mob/zombie/step", // eSoundType_MOB_ZOMBIE_STEP,
|
||||
|
||||
L"liquid/swim", // eSoundType_LIQUID_SWIM,
|
||||
|
||||
L"mob/horse/land", // eSoundType_MOB_HORSE_LAND,
|
||||
L"mob/horse/armor", // eSoundType_MOB_HORSE_ARMOR,
|
||||
L"mob/horse/leather", // eSoundType_MOB_HORSE_LEATHER,
|
||||
L"mob/horse/zombie.death", // eSoundType_MOB_HORSE_ZOMBIE_DEATH,
|
||||
L"mob/horse/skeleton.death", // eSoundType_MOB_HORSE_SKELETON_DEATH,
|
||||
L"mob/horse/donkey.death", // eSoundType_MOB_HORSE_DONKEY_DEATH,
|
||||
L"mob/horse/death", // eSoundType_MOB_HORSE_DEATH,
|
||||
L"mob/horse/zombie.hit", // eSoundType_MOB_HORSE_ZOMBIE_HIT,
|
||||
L"mob/horse/skeleton.hit", // eSoundType_MOB_HORSE_SKELETON_HIT,
|
||||
L"mob/horse/donkey.hit", // eSoundType_MOB_HORSE_DONKEY_HIT,
|
||||
L"mob/horse/hit", // eSoundType_MOB_HORSE_HIT,
|
||||
L"mob/horse/zombie.idle", // eSoundType_MOB_HORSE_ZOMBIE_IDLE,
|
||||
L"mob/horse/skeleton.idle", // eSoundType_MOB_HORSE_SKELETON_IDLE,
|
||||
L"mob/horse/donkey.idle", // eSoundType_MOB_HORSE_DONKEY_IDLE,
|
||||
L"mob/horse/idle", // eSoundType_MOB_HORSE_IDLE,
|
||||
L"mob/horse/donkey.angry", // eSoundType_MOB_HORSE_DONKEY_ANGRY,
|
||||
L"mob/horse/angry", // eSoundType_MOB_HORSE_ANGRY,
|
||||
L"mob/horse/gallop", // eSoundType_MOB_HORSE_GALLOP,
|
||||
L"mob/horse/breathe", // eSoundType_MOB_HORSE_BREATHE,
|
||||
L"mob/horse/wood", // eSoundType_MOB_HORSE_WOOD,
|
||||
L"mob/horse/soft", // eSoundType_MOB_HORSE_SOFT,
|
||||
L"mob/horse/jump", // eSoundType_MOB_HORSE_JUMP,
|
||||
|
||||
L"mob/witch/idle", // eSoundType_MOB_WITCH_IDLE, <---
|
||||
// missing
|
||||
L"mob/witch/hurt", // eSoundType_MOB_WITCH_HURT, <---
|
||||
// missing
|
||||
L"mob/witch/death", // eSoundType_MOB_WITCH_DEATH, <---
|
||||
// missing
|
||||
|
||||
L"mob/slime/big", // eSoundType_MOB_SLIME_BIG,
|
||||
L"mob/slime/small", // eSoundType_MOB_SLIME_SMALL,
|
||||
|
||||
L"eating", // eSoundType_EATING <--- missing
|
||||
L"random/levelup", // eSoundType_RANDOM_LEVELUP
|
||||
|
||||
// 4J-PB - Some sounds were updated, but we can't do that for the 360 or we
|
||||
// have to do a new sound bank instead, we'll add the sounds as new ones and
|
||||
// change the code to reference them
|
||||
L"fire/new_ignite",
|
||||
};
|
||||
|
||||
const wchar_t* ConsoleSoundEngine::wchUISoundNames[eSFX_MAX] = {
|
||||
L"back", L"craft", L"craftfail", L"focus", L"press", L"scroll",
|
||||
};
|
||||
@@ -10,16 +10,11 @@
|
||||
#define VER_PRODUCTBUILD 560
|
||||
// This goes up if there is any change to network traffic or code in a build
|
||||
#define VER_NETWORK 560
|
||||
|
||||
// Network protocol version. Sent in the pre-login packet so client and
|
||||
// server can detect mismatched builds.
|
||||
#define MINECRAFT_NET_VERSION VER_NETWORK
|
||||
|
||||
#define VER_PRODUCTBUILD_QFE 0
|
||||
|
||||
#define VER_FILEVERSION_STRING "1.6"
|
||||
#define VER_PRODUCTVERSION_STRING VER_FILEVERSION_STRING
|
||||
#define VER_FILEVERSION_STRING_W "1.6"
|
||||
#define VER_FILEVERSION_STRING_W L"1.6"
|
||||
#define VER_PRODUCTVERSION_STRING_W VER_FILEVERSION_STRING_W
|
||||
#define VER_FILEBETA_STR ""
|
||||
#undef VER_FILEVERSION
|
||||
@@ -32,25 +27,25 @@
|
||||
|
||||
#if (VER_PRODUCTBUILD < 10)
|
||||
#define VER_FILEBPAD "000"
|
||||
#define VER_FILEBPAD_W "000"
|
||||
#define VER_FILEBPAD_W L"000"
|
||||
#elif (VER_PRODUCTBUILD < 100)
|
||||
#define VER_FILEBPAD "00"
|
||||
#define VER_FILEBPAD_W "00"
|
||||
#define VER_FILEBPAD_W L"00"
|
||||
#elif (VER_PRODUCTBUILD < 1000)
|
||||
#define VER_FILEBPAD "0"
|
||||
#define VER_FILEBPAD_W "0"
|
||||
#define VER_FILEBPAD_W L"0"
|
||||
#else
|
||||
#define VER_FILEBPAD
|
||||
#define VER_FILEBPAD_W
|
||||
#endif
|
||||
|
||||
#define VER_WIDE_PREFIX(x) x
|
||||
#define VER_WIDE_PREFIX(x) L##x
|
||||
|
||||
#define VER_FILEVERSION_STR2(x, y) \
|
||||
VER_FILEVERSION_STRING "." VER_FILEBPAD #x "." #y
|
||||
#define VER_FILEVERSION_STR2_W(x, y) \
|
||||
VER_FILEVERSION_STRING_W \
|
||||
"." VER_FILEBPAD_W VER_WIDE_PREFIX(#x) "." VER_WIDE_PREFIX(#y)
|
||||
#define VER_FILEVERSION_STR2_W(x, y) \
|
||||
VER_FILEVERSION_STRING_W L"." VER_FILEBPAD_W VER_WIDE_PREFIX( \
|
||||
#x) L"." VER_WIDE_PREFIX(#y)
|
||||
#define VER_FILEVERSION_STR1(x, y) VER_FILEVERSION_STR2(x, y)
|
||||
#define VER_FILEVERSION_STR1_W(x, y) VER_FILEVERSION_STR2_W(x, y)
|
||||
|
||||
@@ -0,0 +1,385 @@
|
||||
#include "ColourTable.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "app/common/App_enums.h"
|
||||
#include "util/StringHelpers.h"
|
||||
#include "java/InputOutputStream/ByteArrayInputStream.h"
|
||||
#include "java/InputOutputStream/DataInputStream.h"
|
||||
|
||||
std::unordered_map<std::wstring, eMinecraftColour>
|
||||
ColourTable::s_colourNamesMap;
|
||||
|
||||
const wchar_t* ColourTable::ColourTableElements[eMinecraftColour_COUNT] = {
|
||||
L"NOTSET",
|
||||
|
||||
L"Foliage_Evergreen",
|
||||
L"Foliage_Birch",
|
||||
L"Foliage_Default",
|
||||
L"Foliage_Common",
|
||||
L"Foliage_Ocean",
|
||||
L"Foliage_Plains",
|
||||
L"Foliage_Desert",
|
||||
L"Foliage_ExtremeHills",
|
||||
L"Foliage_Forest",
|
||||
L"Foliage_Taiga",
|
||||
L"Foliage_Swampland",
|
||||
L"Foliage_River",
|
||||
L"Foliage_Hell",
|
||||
L"Foliage_Sky",
|
||||
L"Foliage_FrozenOcean",
|
||||
L"Foliage_FrozenRiver",
|
||||
L"Foliage_IcePlains",
|
||||
L"Foliage_IceMountains",
|
||||
L"Foliage_MushroomIsland",
|
||||
L"Foliage_MushroomIslandShore",
|
||||
L"Foliage_Beach",
|
||||
L"Foliage_DesertHills",
|
||||
L"Foliage_ForestHills",
|
||||
L"Foliage_TaigaHills",
|
||||
L"Foliage_ExtremeHillsEdge",
|
||||
L"Foliage_Jungle",
|
||||
L"Foliage_JungleHills",
|
||||
|
||||
L"Grass_Common",
|
||||
L"Grass_Ocean",
|
||||
L"Grass_Plains",
|
||||
L"Grass_Desert",
|
||||
L"Grass_ExtremeHills",
|
||||
L"Grass_Forest",
|
||||
L"Grass_Taiga",
|
||||
L"Grass_Swampland",
|
||||
L"Grass_River",
|
||||
L"Grass_Hell",
|
||||
L"Grass_Sky",
|
||||
L"Grass_FrozenOcean",
|
||||
L"Grass_FrozenRiver",
|
||||
L"Grass_IcePlains",
|
||||
L"Grass_IceMountains",
|
||||
L"Grass_MushroomIsland",
|
||||
L"Grass_MushroomIslandShore",
|
||||
L"Grass_Beach",
|
||||
L"Grass_DesertHills",
|
||||
L"Grass_ForestHills",
|
||||
L"Grass_TaigaHills",
|
||||
L"Grass_ExtremeHillsEdge",
|
||||
L"Grass_Jungle",
|
||||
L"Grass_JungleHills",
|
||||
|
||||
L"Water_Ocean",
|
||||
L"Water_Plains",
|
||||
L"Water_Desert",
|
||||
L"Water_ExtremeHills",
|
||||
L"Water_Forest",
|
||||
L"Water_Taiga",
|
||||
L"Water_Swampland",
|
||||
L"Water_River",
|
||||
L"Water_Hell",
|
||||
L"Water_Sky",
|
||||
L"Water_FrozenOcean",
|
||||
L"Water_FrozenRiver",
|
||||
L"Water_IcePlains",
|
||||
L"Water_IceMountains",
|
||||
L"Water_MushroomIsland",
|
||||
L"Water_MushroomIslandShore",
|
||||
L"Water_Beach",
|
||||
L"Water_DesertHills",
|
||||
L"Water_ForestHills",
|
||||
L"Water_TaigaHills",
|
||||
L"Water_ExtremeHillsEdge",
|
||||
L"Water_Jungle",
|
||||
L"Water_JungleHills",
|
||||
|
||||
L"Sky_Ocean",
|
||||
L"Sky_Plains",
|
||||
L"Sky_Desert",
|
||||
L"Sky_ExtremeHills",
|
||||
L"Sky_Forest",
|
||||
L"Sky_Taiga",
|
||||
L"Sky_Swampland",
|
||||
L"Sky_River",
|
||||
L"Sky_Hell",
|
||||
L"Sky_Sky",
|
||||
L"Sky_FrozenOcean",
|
||||
L"Sky_FrozenRiver",
|
||||
L"Sky_IcePlains",
|
||||
L"Sky_IceMountains",
|
||||
L"Sky_MushroomIsland",
|
||||
L"Sky_MushroomIslandShore",
|
||||
L"Sky_Beach",
|
||||
L"Sky_DesertHills",
|
||||
L"Sky_ForestHills",
|
||||
L"Sky_TaigaHills",
|
||||
L"Sky_ExtremeHillsEdge",
|
||||
L"Sky_Jungle",
|
||||
L"Sky_JungleHills",
|
||||
|
||||
L"Tile_RedstoneDust",
|
||||
L"Tile_RedstoneDustUnlit",
|
||||
L"Tile_RedstoneDustLitMin",
|
||||
L"Tile_RedstoneDustLitMax",
|
||||
L"Tile_StemMin",
|
||||
L"Tile_StemMax",
|
||||
L"Tile_WaterLily",
|
||||
|
||||
L"Sky_Dawn_Dark",
|
||||
L"Sky_Dawn_Bright",
|
||||
|
||||
L"Material_None",
|
||||
L"Material_Grass",
|
||||
L"Material_Sand",
|
||||
L"Material_Cloth",
|
||||
L"Material_Fire",
|
||||
L"Material_Ice",
|
||||
L"Material_Metal",
|
||||
L"Material_Plant",
|
||||
L"Material_Snow",
|
||||
L"Material_Clay",
|
||||
L"Material_Dirt",
|
||||
L"Material_Stone",
|
||||
L"Material_Water",
|
||||
L"Material_Wood",
|
||||
L"Material_Emerald",
|
||||
|
||||
L"Particle_Note_00",
|
||||
L"Particle_Note_01",
|
||||
L"Particle_Note_02",
|
||||
L"Particle_Note_03",
|
||||
L"Particle_Note_04",
|
||||
L"Particle_Note_05",
|
||||
L"Particle_Note_06",
|
||||
L"Particle_Note_07",
|
||||
L"Particle_Note_08",
|
||||
L"Particle_Note_09",
|
||||
L"Particle_Note_10",
|
||||
L"Particle_Note_11",
|
||||
L"Particle_Note_12",
|
||||
L"Particle_Note_13",
|
||||
L"Particle_Note_14",
|
||||
L"Particle_Note_15",
|
||||
L"Particle_Note_16",
|
||||
L"Particle_Note_17",
|
||||
L"Particle_Note_18",
|
||||
L"Particle_Note_19",
|
||||
L"Particle_Note_20",
|
||||
L"Particle_Note_21",
|
||||
L"Particle_Note_22",
|
||||
L"Particle_Note_23",
|
||||
L"Particle_Note_24",
|
||||
|
||||
L"Particle_NetherPortal",
|
||||
L"Particle_EnderPortal",
|
||||
L"Particle_Smoke",
|
||||
L"Particle_Ender",
|
||||
|
||||
L"Particle_Explode",
|
||||
L"Particle_HugeExplosion",
|
||||
|
||||
L"Particle_DripWater",
|
||||
L"Particle_DripLavaStart",
|
||||
L"Particle_DripLavaEnd",
|
||||
|
||||
L"Particle_EnchantmentTable",
|
||||
L"Particle_DragonBreathMin",
|
||||
L"Particle_DragonBreathMax",
|
||||
L"Particle_Suspend",
|
||||
|
||||
L"Particle_CritStart", // arrow in air
|
||||
L"Particle_CritEnd", // arrow in air
|
||||
|
||||
L"Effect_MovementSpeed",
|
||||
L"Effect_MovementSlowDown",
|
||||
L"Effect_DigSpeed",
|
||||
L"Effect_DigSlowdown",
|
||||
L"Effect_DamageBoost",
|
||||
L"Effect_Heal",
|
||||
L"Effect_Harm",
|
||||
L"Effect_Jump",
|
||||
L"Effect_Confusion",
|
||||
L"Effect_Regeneration",
|
||||
L"Effect_DamageResistance",
|
||||
L"Effect_FireResistance",
|
||||
L"Effect_WaterBreathing",
|
||||
L"Effect_Invisiblity",
|
||||
L"Effect_Blindness",
|
||||
L"Effect_NightVision",
|
||||
L"Effect_Hunger",
|
||||
L"Effect_Weakness",
|
||||
L"Effect_Poison",
|
||||
L"Effect_Wither",
|
||||
L"Effect_HealthBoost",
|
||||
L"Effect_Absorption",
|
||||
L"Effect_Saturation",
|
||||
|
||||
L"Potion_BaseColour",
|
||||
|
||||
L"Mob_Creeper_Colour1",
|
||||
L"Mob_Creeper_Colour2",
|
||||
L"Mob_Skeleton_Colour1",
|
||||
L"Mob_Skeleton_Colour2",
|
||||
L"Mob_Spider_Colour1",
|
||||
L"Mob_Spider_Colour2",
|
||||
L"Mob_Zombie_Colour1",
|
||||
L"Mob_Zombie_Colour2",
|
||||
L"Mob_Slime_Colour1",
|
||||
L"Mob_Slime_Colour2",
|
||||
L"Mob_Ghast_Colour1",
|
||||
L"Mob_Ghast_Colour2",
|
||||
L"Mob_PigZombie_Colour1",
|
||||
L"Mob_PigZombie_Colour2",
|
||||
L"Mob_Enderman_Colour1",
|
||||
L"Mob_Enderman_Colour2",
|
||||
L"Mob_CaveSpider_Colour1",
|
||||
L"Mob_CaveSpider_Colour2",
|
||||
L"Mob_Silverfish_Colour1",
|
||||
L"Mob_Silverfish_Colour2",
|
||||
L"Mob_Blaze_Colour1",
|
||||
L"Mob_Blaze_Colour2",
|
||||
L"Mob_LavaSlime_Colour1",
|
||||
L"Mob_LavaSlime_Colour2",
|
||||
L"Mob_Pig_Colour1",
|
||||
L"Mob_Pig_Colour2",
|
||||
L"Mob_Sheep_Colour1",
|
||||
L"Mob_Sheep_Colour2",
|
||||
L"Mob_Cow_Colour1",
|
||||
L"Mob_Cow_Colour2",
|
||||
L"Mob_Chicken_Colour1",
|
||||
L"Mob_Chicken_Colour2",
|
||||
L"Mob_Squid_Colour1",
|
||||
L"Mob_Squid_Colour2",
|
||||
L"Mob_Wolf_Colour1",
|
||||
L"Mob_Wolf_Colour2",
|
||||
L"Mob_MushroomCow_Colour1",
|
||||
L"Mob_MushroomCow_Colour2",
|
||||
L"Mob_Ocelot_Colour1",
|
||||
L"Mob_Ocelot_Colour2",
|
||||
L"Mob_Villager_Colour1",
|
||||
L"Mob_Villager_Colour2",
|
||||
L"Mob_Bat_Colour1",
|
||||
L"Mob_Bat_Colour2",
|
||||
L"Mob_Witch_Colour1",
|
||||
L"Mob_Witch_Colour2",
|
||||
L"Mob_Horse_Colour1",
|
||||
L"Mob_Horse_Colour2",
|
||||
|
||||
L"Armour_Default_Leather_Colour",
|
||||
L"Under_Water_Clear_Colour",
|
||||
L"Under_Lava_Clear_Colour",
|
||||
L"In_Cloud_Base_Colour",
|
||||
|
||||
L"Under_Water_Fog_Colour",
|
||||
L"Under_Lava_Fog_Colour",
|
||||
L"In_Cloud_Fog_Colour",
|
||||
|
||||
L"Default_Fog_Colour",
|
||||
L"Nether_Fog_Colour",
|
||||
L"End_Fog_Colour",
|
||||
|
||||
L"Sign_Text",
|
||||
L"Map_Text",
|
||||
|
||||
L"Leash_Light_Colour",
|
||||
L"Leash_Dark_Colour",
|
||||
|
||||
L"Fire_Overlay",
|
||||
|
||||
L"HTMLColor_0",
|
||||
L"HTMLColor_1",
|
||||
L"HTMLColor_2",
|
||||
L"HTMLColor_3",
|
||||
L"HTMLColor_4",
|
||||
L"HTMLColor_5",
|
||||
L"HTMLColor_6",
|
||||
L"HTMLColor_7",
|
||||
L"HTMLColor_8",
|
||||
L"HTMLColor_9",
|
||||
L"HTMLColor_a",
|
||||
L"HTMLColor_b",
|
||||
L"HTMLColor_c",
|
||||
L"HTMLColor_d",
|
||||
L"HTMLColor_e",
|
||||
L"HTMLColor_f",
|
||||
L"HTMLColor_dark_0",
|
||||
L"HTMLColor_dark_1",
|
||||
L"HTMLColor_dark_2",
|
||||
L"HTMLColor_dark_3",
|
||||
L"HTMLColor_dark_4",
|
||||
L"HTMLColor_dark_5",
|
||||
L"HTMLColor_dark_6",
|
||||
L"HTMLColor_dark_7",
|
||||
L"HTMLColor_dark_8",
|
||||
L"HTMLColor_dark_9",
|
||||
L"HTMLColor_dark_a",
|
||||
L"HTMLColor_dark_b",
|
||||
L"HTMLColor_dark_c",
|
||||
L"HTMLColor_dark_d",
|
||||
L"HTMLColor_dark_e",
|
||||
L"HTMLColor_dark_f",
|
||||
L"HTMLColor_T1",
|
||||
L"HTMLColor_T2",
|
||||
L"HTMLColor_T3",
|
||||
L"HTMLColor_Black",
|
||||
L"HTMLColor_White",
|
||||
L"Color_EnchantText",
|
||||
L"Color_EnchantTextFocus",
|
||||
L"Color_EnchantTextDisabled",
|
||||
L"Color_RenamedItemTitle",
|
||||
};
|
||||
|
||||
void ColourTable::staticCtor() {
|
||||
for (unsigned int i = eMinecraftColour_NOT_SET; i < eMinecraftColour_COUNT;
|
||||
++i) {
|
||||
s_colourNamesMap.insert(
|
||||
std::unordered_map<std::wstring, eMinecraftColour>::value_type(
|
||||
ColourTableElements[i], (eMinecraftColour)i));
|
||||
}
|
||||
}
|
||||
|
||||
ColourTable::ColourTable(std::uint8_t* pbData, std::uint32_t dataLength) {
|
||||
loadColoursFromData(pbData, dataLength);
|
||||
}
|
||||
|
||||
ColourTable::ColourTable(ColourTable* defaultColours, std::uint8_t* pbData,
|
||||
std::uint32_t dataLength) {
|
||||
// 4J Stu - Default the colours that of the table passed in
|
||||
memcpy((void*)m_colourValues, (void*)defaultColours->m_colourValues,
|
||||
sizeof(int) * eMinecraftColour_COUNT);
|
||||
loadColoursFromData(pbData, dataLength);
|
||||
}
|
||||
void ColourTable::loadColoursFromData(std::uint8_t* pbData,
|
||||
std::uint32_t dataLength) {
|
||||
std::vector<uint8_t> src(pbData, pbData + dataLength);
|
||||
|
||||
ByteArrayInputStream bais(src);
|
||||
DataInputStream dis(&bais);
|
||||
|
||||
int versionNumber = dis.readInt();
|
||||
int coloursCount = dis.readInt();
|
||||
|
||||
for (int i = 0; i < coloursCount; ++i) {
|
||||
std::wstring colourId = dis.readUTF();
|
||||
int colourValue = dis.readInt();
|
||||
setColour(colourId, colourValue);
|
||||
auto it = s_colourNamesMap.find(colourId);
|
||||
}
|
||||
|
||||
bais.reset();
|
||||
}
|
||||
|
||||
void ColourTable::setColour(const std::wstring& colourName, int value) {
|
||||
auto it = s_colourNamesMap.find(colourName);
|
||||
if (it != s_colourNamesMap.end()) {
|
||||
m_colourValues[(int)it->second] = value;
|
||||
}
|
||||
}
|
||||
|
||||
void ColourTable::setColour(const std::wstring& colourName,
|
||||
const std::wstring& value) {
|
||||
setColour(colourName, fromHexWString<int>(value));
|
||||
}
|
||||
|
||||
unsigned int ColourTable::getColour(eMinecraftColour id) {
|
||||
return m_colourValues[(int)id];
|
||||
}
|
||||
@@ -3,14 +3,14 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "minecraft/GameEnums.h"
|
||||
#include "app/common/App_enums.h"
|
||||
|
||||
class ColourTable {
|
||||
private:
|
||||
unsigned int m_colourValues[eMinecraftColour_COUNT];
|
||||
|
||||
static const char* ColourTableElements[eMinecraftColour_COUNT];
|
||||
static std::unordered_map<std::string, eMinecraftColour> s_colourNamesMap;
|
||||
static const wchar_t* ColourTableElements[eMinecraftColour_COUNT];
|
||||
static std::unordered_map<std::wstring, eMinecraftColour> s_colourNamesMap;
|
||||
|
||||
public:
|
||||
static void staticCtor();
|
||||
@@ -23,6 +23,6 @@ public:
|
||||
unsigned int getColor(eMinecraftColour id) { return getColour(id); }
|
||||
|
||||
void loadColoursFromData(std::uint8_t* pbData, std::uint32_t dataLength);
|
||||
void setColour(const std::string& colourName, int value);
|
||||
void setColour(const std::string& colourName, const std::string& value);
|
||||
void setColour(const std::wstring& colourName, int value);
|
||||
void setColour(const std::wstring& colourName, const std::wstring& value);
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "ConsoleGameMode.h"
|
||||
|
||||
#include "app/common/Tutorial/Tutorial.h"
|
||||
#include "app/common/Tutorial/TutorialMode.h"
|
||||
#include "app/common/src/Tutorial/Tutorial.h"
|
||||
#include "app/common/src/Tutorial/TutorialMode.h"
|
||||
|
||||
class ClientConnection;
|
||||
class Minecraft;
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "app/common/Tutorial/TutorialMode.h"
|
||||
#include "app/common/src/Tutorial/TutorialMode.h"
|
||||
|
||||
class ClientConnection;
|
||||
class Minecraft;
|
||||
@@ -5,17 +5,40 @@
|
||||
#include <cstring>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "platform/sdl2/Render.h"
|
||||
#include "platform/sdl2/Storage.h"
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/DLC/DLCFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "platform/XboxStubs.h"
|
||||
#include "platform/renderer/renderer.h"
|
||||
#include "platform/storage/storage.h"
|
||||
#include "util/StringHelpers.h"
|
||||
#include "app/common/src/DLC/DLCFile.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "app/include/XboxStubs.h"
|
||||
#if defined(_WINDOWS64)
|
||||
#include "app/windows/XML/ATGXmlParser.h"
|
||||
#include "app/windows/XML/xmlFilesCallback.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
constexpr std::size_t AUDIO_DLC_WCHAR_BIN_SIZE = 2;
|
||||
|
||||
#if WCHAR_MAX > 0xFFFF
|
||||
static std::wstring ReadAudioDlcWString(const void* data) {
|
||||
const std::uint16_t* chars = static_cast<const std::uint16_t*>(data);
|
||||
const std::uint16_t* end = chars;
|
||||
while (*end != 0) {
|
||||
++end;
|
||||
}
|
||||
|
||||
std::wstring out(static_cast<std::size_t>(end - chars), 0);
|
||||
for (std::size_t i = 0; i < out.size(); ++i) {
|
||||
out[i] = static_cast<wchar_t>(chars[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
#else
|
||||
static std::wstring ReadAudioDlcWString(const void* data) {
|
||||
return std::wstring(static_cast<const wchar_t*>(data));
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
T ReadAudioDlcValue(const std::uint8_t* data, unsigned int offset = 0) {
|
||||
T value;
|
||||
@@ -30,24 +53,23 @@ void ReadAudioDlcStruct(T* out, const std::uint8_t* data,
|
||||
}
|
||||
|
||||
inline unsigned int AudioParamAdvance(unsigned int wcharCount) {
|
||||
return static_cast<unsigned int>(sizeof(IPlatformStorage::DLC_FILE_PARAM) +
|
||||
return static_cast<unsigned int>(sizeof(C4JStorage::DLC_FILE_PARAM) +
|
||||
wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
|
||||
}
|
||||
|
||||
inline unsigned int AudioDetailAdvance(unsigned int wcharCount) {
|
||||
return static_cast<unsigned int>(
|
||||
sizeof(IPlatformStorage::DLC_FILE_DETAILS) +
|
||||
wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
|
||||
return static_cast<unsigned int>(sizeof(C4JStorage::DLC_FILE_DETAILS) +
|
||||
wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
|
||||
}
|
||||
|
||||
inline std::string ReadAudioParamString(const std::uint8_t* data,
|
||||
unsigned int offset) {
|
||||
return dlc_read_wstring(
|
||||
data + offset + offsetof(IPlatformStorage::DLC_FILE_PARAM, wchData));
|
||||
inline std::wstring ReadAudioParamString(const std::uint8_t* data,
|
||||
unsigned int offset) {
|
||||
return ReadAudioDlcWString(data + offset +
|
||||
offsetof(C4JStorage::DLC_FILE_PARAM, wchData));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
DLCAudioFile::DLCAudioFile(const std::string& path)
|
||||
DLCAudioFile::DLCAudioFile(const std::wstring& path)
|
||||
: DLCFile(DLCManager::e_DLCType_Audio, path) {
|
||||
m_pbData = nullptr;
|
||||
m_dataBytes = 0;
|
||||
@@ -65,13 +87,13 @@ std::uint8_t* DLCAudioFile::getData(std::uint32_t& dataBytes) {
|
||||
return m_pbData;
|
||||
}
|
||||
|
||||
const char* DLCAudioFile::wchTypeNamesA[] = {
|
||||
"CUENAME",
|
||||
"CREDIT",
|
||||
const wchar_t* DLCAudioFile::wchTypeNamesA[] = {
|
||||
L"CUENAME",
|
||||
L"CREDIT",
|
||||
};
|
||||
|
||||
DLCAudioFile::EAudioParameterType DLCAudioFile::getParameterType(
|
||||
const std::string& paramName) {
|
||||
const std::wstring& paramName) {
|
||||
EAudioParameterType type = e_AudioParamType_Invalid;
|
||||
|
||||
for (int i = 0; i < e_AudioParamType_Max; ++i) {
|
||||
@@ -85,7 +107,7 @@ DLCAudioFile::EAudioParameterType DLCAudioFile::getParameterType(
|
||||
}
|
||||
|
||||
void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
|
||||
const std::string& value) {
|
||||
const std::wstring& value) {
|
||||
switch (ptype) {
|
||||
case e_AudioParamType_Credit: // If this parameter exists, then mark
|
||||
// this as free
|
||||
@@ -100,8 +122,8 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
|
||||
|
||||
int maximumChars = 55;
|
||||
|
||||
bool bIsSDMode = !PlatformRenderer.IsHiDef() &&
|
||||
!PlatformRenderer.IsWidescreen();
|
||||
bool bIsSDMode =
|
||||
!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
|
||||
|
||||
if (bIsSDMode) {
|
||||
maximumChars = 45;
|
||||
@@ -114,14 +136,14 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
|
||||
maximumChars = 35;
|
||||
break;
|
||||
}
|
||||
std::string creditValue = value;
|
||||
std::wstring creditValue = value;
|
||||
while (creditValue.length() > maximumChars) {
|
||||
unsigned int i = 1;
|
||||
while (i < creditValue.length() &&
|
||||
(i + 1) <= maximumChars) {
|
||||
i++;
|
||||
}
|
||||
int iLast = (int)creditValue.find_last_of(" ", i);
|
||||
int iLast = (int)creditValue.find_last_of(L" ", i);
|
||||
switch (XGetLanguage()) {
|
||||
case XC_LANGUAGE_JAPANESE:
|
||||
case XC_LANGUAGE_TCHINESE:
|
||||
@@ -129,7 +151,7 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
|
||||
iLast = maximumChars;
|
||||
break;
|
||||
default:
|
||||
iLast = (int)creditValue.find_last_of(" ", i);
|
||||
iLast = (int)creditValue.find_last_of(L" ", i);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -174,13 +196,14 @@ bool DLCAudioFile::processDLCDataFile(std::uint8_t* pbData,
|
||||
unsigned int uiParameterTypeCount =
|
||||
ReadAudioDlcValue<unsigned int>(pbData, uiCurrentByte);
|
||||
uiCurrentByte += sizeof(int);
|
||||
IPlatformStorage::DLC_FILE_PARAM paramBuf;
|
||||
C4JStorage::DLC_FILE_PARAM paramBuf;
|
||||
ReadAudioDlcStruct(¶mBuf, pbData, uiCurrentByte);
|
||||
|
||||
for (unsigned int i = 0; i < uiParameterTypeCount; i++) {
|
||||
// Map DLC strings to application strings, then store the DLC index
|
||||
// mapping to application index
|
||||
std::string parameterName = ReadAudioParamString(pbData, uiCurrentByte);
|
||||
std::wstring parameterName =
|
||||
ReadAudioParamString(pbData, uiCurrentByte);
|
||||
EAudioParameterType type = getParameterType(parameterName);
|
||||
if (type != e_AudioParamType_Invalid) {
|
||||
parameterMapping[paramBuf.dwType] = type;
|
||||
@@ -191,7 +214,7 @@ bool DLCAudioFile::processDLCDataFile(std::uint8_t* pbData,
|
||||
unsigned int uiFileCount =
|
||||
ReadAudioDlcValue<unsigned int>(pbData, uiCurrentByte);
|
||||
uiCurrentByte += sizeof(int);
|
||||
IPlatformStorage::DLC_FILE_DETAILS fileBuf;
|
||||
C4JStorage::DLC_FILE_DETAILS fileBuf;
|
||||
ReadAudioDlcStruct(&fileBuf, pbData, uiCurrentByte);
|
||||
|
||||
unsigned int tempByteOffset = uiCurrentByte;
|
||||
@@ -234,7 +257,7 @@ int DLCAudioFile::GetCountofType(DLCAudioFile::EAudioType eType) {
|
||||
return m_parameters[eType].size();
|
||||
}
|
||||
|
||||
std::string& DLCAudioFile::GetSoundName(int iIndex) {
|
||||
std::wstring& DLCAudioFile::GetSoundName(int iIndex) {
|
||||
int iWorldType = e_AudioType_Overworld;
|
||||
while (iIndex >= m_parameters[iWorldType].size()) {
|
||||
iIndex -= m_parameters[iWorldType].size();
|
||||
@@ -27,16 +27,16 @@ public:
|
||||
e_AudioParamType_Max,
|
||||
|
||||
};
|
||||
static const char* wchTypeNamesA[e_AudioParamType_Max];
|
||||
static const wchar_t* wchTypeNamesA[e_AudioParamType_Max];
|
||||
|
||||
DLCAudioFile(const std::string& path);
|
||||
DLCAudioFile(const std::wstring& path);
|
||||
|
||||
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
|
||||
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
|
||||
|
||||
bool processDLCDataFile(std::uint8_t* pbData, std::uint32_t dataLength);
|
||||
int GetCountofType(DLCAudioFile::EAudioType ptype);
|
||||
std::string& GetSoundName(int iIndex);
|
||||
std::wstring& GetSoundName(int iIndex);
|
||||
|
||||
private:
|
||||
using DLCFile::addParameter;
|
||||
@@ -44,13 +44,13 @@ private:
|
||||
std::uint8_t* m_pbData;
|
||||
std::uint32_t m_dataBytes;
|
||||
static const int CURRENT_AUDIO_VERSION_NUM = 1;
|
||||
// std::unordered_map<int, std::string> m_parameters;
|
||||
std::vector<std::string> m_parameters[e_AudioType_Max];
|
||||
// std::unordered_map<int, std::wstring> m_parameters;
|
||||
std::vector<std::wstring> m_parameters[e_AudioType_Max];
|
||||
|
||||
// use the EAudioType to order these
|
||||
void addParameter(DLCAudioFile::EAudioType type,
|
||||
DLCAudioFile::EAudioParameterType ptype,
|
||||
const std::string& value);
|
||||
const std::wstring& value);
|
||||
DLCAudioFile::EAudioParameterType getParameterType(
|
||||
const std::string& paramName);
|
||||
const std::wstring& paramName);
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "DLCCapeFile.h"
|
||||
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/DLC/DLCFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/src/DLC/DLCFile.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
|
||||
DLCCapeFile::DLCCapeFile(const std::string& path)
|
||||
DLCCapeFile::DLCCapeFile(const std::wstring& path)
|
||||
: DLCFile(DLCManager::e_DLCType_Cape, path) {}
|
||||
|
||||
void DLCCapeFile::addData(std::uint8_t* pbData, std::uint32_t dataBytes) {
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
class DLCCapeFile : public DLCFile {
|
||||
public:
|
||||
DLCCapeFile(const std::string& path);
|
||||
DLCCapeFile(const std::wstring& path);
|
||||
|
||||
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
|
||||
};
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "DLCColourTableFile.h"
|
||||
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/DLC/DLCFile.h"
|
||||
#include "app/common/Game.h"
|
||||
#include "app/common/src/Colours/ColourTable.h"
|
||||
#include "app/common/src/DLC/DLCFile.h"
|
||||
#include "app/linux/LinuxGame.h"
|
||||
#include "minecraft/client/Minecraft.h"
|
||||
#include "minecraft/client/resources/Colours/ColourTable.h"
|
||||
#include "minecraft/client/skins/TexturePack.h"
|
||||
#include "minecraft/client/skins/TexturePackRepository.h"
|
||||
|
||||
DLCColourTableFile::DLCColourTableFile(const std::string& path)
|
||||
DLCColourTableFile::DLCColourTableFile(const std::wstring& path)
|
||||
: DLCFile(DLCManager::e_DLCType_ColourTable, path) {
|
||||
m_colourTable = nullptr;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ private:
|
||||
ColourTable* m_colourTable;
|
||||
|
||||
public:
|
||||
DLCColourTableFile(const std::string& path);
|
||||
DLCColourTableFile(const std::wstring& path);
|
||||
~DLCColourTableFile();
|
||||
|
||||
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
|
||||
@@ -2,20 +2,20 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "app/common/DLC/DLCManager.h"
|
||||
#include "minecraft/Minecraft_Macros.h"
|
||||
#include "app/common/Minecraft_Macros.h"
|
||||
#include "app/common/src/DLC/DLCManager.h"
|
||||
|
||||
DLCFile::DLCFile(DLCManager::EDLCType type, const std::string& path) {
|
||||
DLCFile::DLCFile(DLCManager::EDLCType type, const std::wstring& path) {
|
||||
m_type = type;
|
||||
m_path = path;
|
||||
|
||||
// store the id
|
||||
bool dlcSkin = path.substr(0, 3).compare("dlc") == 0;
|
||||
bool dlcSkin = path.substr(0, 3).compare(L"dlc") == 0;
|
||||
|
||||
if (dlcSkin) {
|
||||
std::string skinValue = path.substr(7, path.size());
|
||||
skinValue = skinValue.substr(0, skinValue.find_first_of('.'));
|
||||
std::stringstream ss;
|
||||
std::wstring skinValue = path.substr(7, path.size());
|
||||
skinValue = skinValue.substr(0, skinValue.find_first_of(L'.'));
|
||||
std::wstringstream ss;
|
||||
ss << std::dec << skinValue.c_str();
|
||||
ss >> m_dwSkinId;
|
||||
m_dwSkinId = MAKE_SKIN_BITMASK(true, m_dwSkinId);
|
||||
@@ -7,15 +7,15 @@
|
||||
class DLCFile {
|
||||
protected:
|
||||
DLCManager::EDLCType m_type;
|
||||
std::string m_path;
|
||||
std::wstring m_path;
|
||||
std::uint32_t m_dwSkinId;
|
||||
|
||||
public:
|
||||
DLCFile(DLCManager::EDLCType type, const std::string& path);
|
||||
DLCFile(DLCManager::EDLCType type, const std::wstring& path);
|
||||
virtual ~DLCFile() {}
|
||||
|
||||
DLCManager::EDLCType getType() { return m_type; }
|
||||
std::string getPath() { return m_path; }
|
||||
std::wstring getPath() { return m_path; }
|
||||
std::uint32_t getSkinID() { return m_dwSkinId; }
|
||||
|
||||
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes) {}
|
||||
@@ -24,11 +24,11 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
virtual void addParameter(DLCManager::EDLCParameterType type,
|
||||
const std::string& value) {}
|
||||
const std::wstring& value) {}
|
||||
|
||||
virtual std::string getParameterAsString(
|
||||
virtual std::wstring getParameterAsString(
|
||||
DLCManager::EDLCParameterType type) {
|
||||
return "";
|
||||
return L"";
|
||||
}
|
||||
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type) {
|
||||
return false;
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "DLCFile.h"
|
||||
#include "app/common/src/GameRules/LevelGeneration/LevelGenerationOptions.h"
|
||||
|
||||
class DLCGameRules : public DLCFile {
|
||||
public:
|
||||
DLCGameRules(DLCManager::EDLCType type, const std::wstring& path)
|
||||
: DLCFile(type, path) {}
|
||||
};
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "DLCGameRulesFile.h"
|
||||
|
||||
#include "DLCManager.h"
|
||||
#include "app/common/DLC/DLCGameRules.h"
|
||||
#include "app/common/src/DLC/DLCGameRules.h"
|
||||
|
||||
DLCGameRulesFile::DLCGameRulesFile(const std::string& path)
|
||||
DLCGameRulesFile::DLCGameRulesFile(const std::wstring& path)
|
||||
: DLCGameRules(DLCManager::e_DLCType_GameRules, path) {
|
||||
m_pbData = nullptr;
|
||||
m_dataBytes = 0;
|
||||
@@ -10,7 +10,7 @@ private:
|
||||
std::uint32_t m_dataBytes;
|
||||
|
||||
public:
|
||||
DLCGameRulesFile(const std::string& path);
|
||||
DLCGameRulesFile(const std::wstring& path);
|
||||
|
||||
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
|
||||
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
|
||||