Latest compatible version of Classicube from the original GitHub repository (https://github.com/ClassiCube/ClassiCube) that can be compiled on Classicube for PowerMac PPC running Mac OS X 10.4.

This commit is contained in:
Andrei Alexandru
2025-12-17 13:17:57 +02:00
commit c71492f846
1248 changed files with 422858 additions and 0 deletions

119
android/app/CMakeLists.txt Normal file
View File

@@ -0,0 +1,119 @@
#
# Copyright (C) The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.4.1)
# build native_app_glue as a static lib
set(${CMAKE_C_FLAGS}, "${CMAKE_C_FLAGS}")
# now build app's shared lib
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -Werror")
add_library(classicube SHARED
../../src/main.c
../../src/IsometricDrawer.c
../../src/Builder.c
../../src/ExtMath.c
../../src/_ftbitmap.c
../../src/Utils.c
../../src/Camera.c
../../src/Game.c
../../src/GameVersion.c
../../src/Window_Android.c
../../src/_ftbase.c
../../src/Graphics_GL2.c
../../src/Deflate.c
../../src/_cff.c
../../src/_ftsynth.c
../../src/String.c
../../src/LWidgets.c
../../src/Options.c
../../src/Drawer2D.c
../../src/Server.c
../../src/Entity.c
../../src/Drawer.c
../../src/Vorbis.c
../../src/Protocol.c
../../src/World.c
../../src/SelOutlineRenderer.c
../../src/Platform_Posix.c
../../src/Platform_Android.c
../../src/LScreens.c
../../src/_truetype.c
../../src/_ftglyph.c
../../src/Model.c
../../src/_autofit.c
../../src/Vectors.c
../../src/HeldBlockRenderer.c
../../src/Inventory.c
../../src/Launcher.c
../../src/Block.c
../../src/LWeb.c
../../src/Stream.c
../../src/Lighting.c
../../src/Resources.c
../../src/PackedCol.c
../../src/Screens.c
../../src/Formats.c
../../src/_sfnt.c
../../src/Bitmap.c
../../src/EntityComponents.c
../../src/_pshinter.c
../../src/Http_Worker.c
../../src/MapRenderer.c
../../src/Audio.c
../../src/_ftinit.c
../../src/Event.c
../../src/Logger.c
../../src/Widgets.c
../../src/TexturePack.c
../../src/Menus.c
../../src/BlockPhysics.c
../../src/_psmodule.c
../../src/Chat.c
../../src/Gui.c
../../src/AxisLinesRenderer.c
../../src/Picking.c
../../src/_type1.c
../../src/_smooth.c
../../src/_psaux.c
../../src/Generator.c
../../src/Input.c
../../src/Particle.c
../../src/Physics.c
../../src/SelectionBox.c
../../src/EnvRenderer.c
../../src/Animations.c
../../src/LBackend.c
../../src/SystemFonts.c
../../src/Commands.c
../../src/EntityRenderers.c
../../src/Audio_SLES.c
../../src/TouchUI.c
../../src/LBackend_Android.c
../../src/InputHandler.c
../../src/MenuOptions.c
../../src/FancyLighting.c
../../src/Queue.c
)
# add lib dependencies
target_link_libraries(classicube
android
EGL
GLESv2
log
OpenSLES
jnigraphics)

29
android/app/build.gradle Normal file
View File

@@ -0,0 +1,29 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId = 'com.classicube.android.client'
minSdkVersion 13
targetSdkVersion 26
externalNativeBuild {
cmake {
arguments '-DANDROID_STL=c++_static'
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
version '3.10.2'
path 'CMakeLists.txt'
}
}
}

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.classicube.android.client"
android:versionCode="1370"
android:versionName="1.3.7">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="26"/>
<application android:icon="@mipmap/ccicon" android:label="ClassiCube">
<provider
android:name="com.classicube.CCFileProvider"
android:authorities="com.classicube.android.client.provider"
android:exported="false"
android:grantUriPermissions="true" >
</provider>
<activity android:name="com.classicube.MainActivity" android:label="ClassiCube"
android:configChanges="orientation|screenSize|keyboard|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<!-- END_INCLUDE(manifest) -->

View File

@@ -0,0 +1,115 @@
package com.classicube;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.content.pm.ProviderInfo;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.provider.MediaStore;
import android.provider.OpenableColumns;
public class CCFileProvider extends ContentProvider
{
final static String[] DEFAULT_COLUMNS = { OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE, MediaStore.MediaColumns.DATA };
File root;
@Override
public boolean onCreate() {
return true;
}
@Override
public void attachInfo(Context context, ProviderInfo info) {
super.attachInfo(context, info);
root = context.getExternalFilesDir(null); // getGameDataDirectory
}
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
File file = getFileForUri(uri);
// can be null when caller is requesting all columns
if (projection == null) projection = DEFAULT_COLUMNS;
ArrayList<String> cols = new ArrayList<String>(3);
ArrayList<Object> vals = new ArrayList<Object>(3);
for (String column : projection) {
if (column.equals(OpenableColumns.DISPLAY_NAME)) {
cols.add(OpenableColumns.DISPLAY_NAME);
vals.add(file.getName());
} else if (column.equals(OpenableColumns.SIZE)) {
cols.add(OpenableColumns.SIZE);
vals.add(file.length());
} else if (column.equals(MediaStore.MediaColumns.DATA)) {
cols.add(MediaStore.MediaColumns.DATA);
vals.add(file.getAbsolutePath());
}
}
// https://stackoverflow.com/questions/4042434/converting-arrayliststring-to-string-in-java
MatrixCursor cursor = new MatrixCursor(cols.toArray(new String[0]), 1);
cursor.addRow(vals.toArray());
return cursor;
}
@Override
public String getType(Uri uri) {
String path = uri.getEncodedPath();
int sepExt = path.lastIndexOf('.');
if (sepExt >= 0) {
String fileExt = path.substring(sepExt);
if (fileExt.equals(".png")) return "image/png";
}
return "application/octet-stream";
}
@Override
public Uri insert(Uri uri, ContentValues values) {
throw new UnsupportedOperationException("Readonly access");
}
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
throw new UnsupportedOperationException("Readonly access");
}
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
throw new UnsupportedOperationException("Readonly access");
}
@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
File file = getFileForUri(uri);
return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
}
public static Uri getUriForFile(String path) {
// See AndroidManifest.xml for authority
return new Uri.Builder()
.scheme("content")
.authority("com.classicube.android.client.provider")
.encodedPath(Uri.encode(path, "/"))
.build();
}
File getFileForUri(Uri uri) {
String path = uri.getPath();
File file = new File(root, path);
file = file.getAbsoluteFile();
// security validation check
if (!file.getPath().startsWith(root.getPath())) {
throw new SecurityException("Resolved path lies outside app directory:" + path);
}
return file;
}
}

View File

@@ -0,0 +1,57 @@
package com.classicube;
import android.view.InputDevice;
import android.view.MotionEvent;
import android.view.View;
public class CCMotionListener implements View.OnGenericMotionListener {
MainActivity activity;
public CCMotionListener(MainActivity activity) {
this.activity = activity;
}
// https://developer.android.com/develop/ui/views/touch-and-input/game-controllers/controller-input#java
@Override
public boolean onGenericMotion(View view, MotionEvent event) {
if (event.getAction() != MotionEvent.ACTION_MOVE) return false;
boolean source_joystick = (event.getSource() & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK;
boolean source_gamepad = (event.getSource() & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD;
if (source_joystick || source_gamepad) {
int historySize = event.getHistorySize();
for (int i = 0; i < historySize; i++) {
processJoystickInput(event, i);
}
processJoystickInput(event, -1);
return true;
}
return false;
}
void processJoystickInput(MotionEvent event, int historyPos) {
float x1 = getAxisValue(event, MotionEvent.AXIS_X, historyPos);
float y1 = getAxisValue(event, MotionEvent.AXIS_Y, historyPos);
float x2 = getAxisValue(event, MotionEvent.AXIS_Z, historyPos);
float y2 = getAxisValue(event, MotionEvent.AXIS_RZ, historyPos);
if (x1 != 0 || y1 != 0)
pushAxisMovement(MainActivity.CMD_GPAD_AXISL, x1, y1);
if (x2 != 0 || y2 != 0)
pushAxisMovement(MainActivity.CMD_GPAD_AXISR, x2, y2);
}
float getAxisValue(MotionEvent event, int axis, int historyPos) {
float value = historyPos < 0 ? event.getAxisValue(axis) :
event.getHistoricalAxisValue(axis, historyPos);
// Deadzone detection
if (value >= -0.25f && value <= 0.25f) value = 0;
return value;
}
void pushAxisMovement(int axis, float x, float y) {
activity.pushCmd(axis, (int)(x * 4096), (int)(y * 4096));
}
}

View File

@@ -0,0 +1,108 @@
package com.classicube;
import android.text.Editable;
import android.text.Selection;
import android.text.SpannableStringBuilder;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
public class CCView extends SurfaceView {
SpannableStringBuilder kbText;
MainActivity activity;
public CCView(MainActivity activity) {
// setFocusable, setFocusableInTouchMode - API level 1
super(activity);
this.activity = activity;
setFocusable(true);
setFocusableInTouchMode(true);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
return activity.handleTouchEvent(ev) || super.dispatchTouchEvent(ev);
}
@Override
public InputConnection onCreateInputConnection(EditorInfo attrs) {
// BaseInputConnection, IME_ACTION_GO, IME_FLAG_NO_EXTRACT_UI - API level 3
attrs.actionLabel = null;
attrs.inputType = MainActivity.calcKeyboardType(activity.keyboardType);
attrs.imeOptions = MainActivity.calcKeyboardOptions(activity.keyboardType);
kbText = new SpannableStringBuilder(activity.keyboardText);
InputConnection ic = new BaseInputConnection(this, true) {
boolean inited;
void updateText() {
activity.pushCmd(MainActivity.CMD_KEY_TEXT, kbText.toString());
}
@Override
public Editable getEditable() {
if (!inited) {
// needed to set selection, otherwise random crashes later with backspacing
// set selection to end, so backspacing after opening keyboard with text still works
Selection.setSelection(kbText, kbText.toString().length());
inited = true;
}
return kbText;
}
@Override
public boolean setComposingText(CharSequence text, int newCursorPosition) {
boolean success = super.setComposingText(text, newCursorPosition);
updateText();
return success;
}
@Override
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
boolean success = super.deleteSurroundingText(beforeLength, afterLength);
updateText();
return success;
}
@Override
public boolean commitText(CharSequence text, int newCursorPosition) {
boolean success = super.commitText(text, newCursorPosition);
updateText();
return success;
}
@Override
public boolean sendKeyEvent(KeyEvent ev) {
// getSelectionStart - API level 1
if (ev.getAction() != KeyEvent.ACTION_DOWN) return super.sendKeyEvent(ev);
int code = ev.getKeyCode();
int uni = ev.getUnicodeChar();
// start is -1 sometimes, and trying to insert/delete there crashes
int start = Selection.getSelectionStart(kbText);
if (start == -1) start = kbText.toString().length();
if (code == KeyEvent.KEYCODE_ENTER) {
// enter maps to \n but that should not be intercepted
} else if (code == KeyEvent.KEYCODE_DEL) {
if (start <= 0) return false;
kbText.delete(start - 1, start);
updateText();
return false;
} else if (uni != 0) {
kbText.insert(start, String.valueOf((char) uni));
updateText();
return false;
}
return super.sendKeyEvent(ev);
}
};
//String text = MainActivity.this.keyboardText;
//if (text != null) ic.setComposingText(text, 0);
return ic;
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>