Browse Source

Merge branch 'gravgun' of https://github.com/SDLash3D/hlsdk-xash3d into gravgun

AR2
mittorn 9 years ago
parent
commit
cb47997b3b
  1. 32
      android/AndroidManifest.xml
  2. 16
      android/build-manual.sh
  3. 6
      android/build.sh
  4. 92
      android/build.xml
  5. 6
      android/jni/Android.mk
  6. 11
      android/jni/Application.mk
  7. 14
      android/jni/mod_config.mk
  8. 1
      android/jni/server
  9. BIN
      android/pak/models/p_gravcannon.mdl
  10. BIN
      android/pak/models/v_gravcannon.mdl
  11. BIN
      android/pak/models/w_gravcannon.mdl
  12. BIN
      android/pak/models/w_gravcannont.mdl
  13. 9
      android/pak/sprites/weapon_gravgun.txt
  14. 11
      android/project.properties
  15. BIN
      android/res/drawable/gravgun.png
  16. 14
      android/src/in/celest/xash3d/InstallReceiver.java
  17. 160
      android/src/in/celest/xash3d/LauncherActivity.java
  18. 2
      dlls/gravgun.cpp

32
android/AndroidManifest.xml

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Set your package name here -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="in.celest.xash3d.gravgun"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="5"/>
<!-- Set your application name here -->
<application android:label="Half-Life Gravgun" android:debuggable="true" android:icon="@drawable/gravgun">
<!-- Set your launcher title here -->
<activity android:name="in.celest.xash3d.LauncherActivity"
android:label="Half-Life Gravgun"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="in.celest.xash3d.InstallReceiver">
<intent-filter android:priority="100">
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" />
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
</application>
</manifest>

16
android/build-manual.sh

@ -0,0 +1,16 @@
ANDROID_JAR=../android-13.jar
AAPT=./../aapt
DX=./../dx
APKBUILDER=./../apkbuilder
NAME=gravgun
mkdir bin
mkdir bin/classes
mkdir assets/
$AAPT package -M AndroidManifest.xml -m -S res -I $ANDROID_JAR
$JAVA_HOME/bin/javac -d bin/classes -s bin/classes -cp $ANDROID_JAR src/in/celest/xash3d/*
$DX --dex --output=bin/classes.dex bin/classes/
$AAPT package -f -M AndroidManifest.xml -S res -I $ANDROID_JAR -F bin/$NAME.apk.unaligned
python2 makepak.py pak/ assets/extras.pak
zip -r bin/$NAME.apk.unaligned assets/
$APKBUILDER bin/$NAME.apk -u -nf libs/ -rj libs -f bin/classes.dex -z bin/$NAME.apk.unaligned
#java -jar /mnt/app/apktool/signapk.jar /mnt/app/apktool/testkey.x509.pem /mnt/app/apktool/testkey.pk8 bin/$NAME.apk bin/$NAME-signed.apk

6
android/build.sh

@ -0,0 +1,6 @@
#!/bin/sh
ndk-build NDK_TOOLCHAIN_VERSION=4.8 NDK_DEBUG=1 V=1 -j5 APP_CFLAGS="-w"
ant debug
#jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../myks.keystore bin/mod-unsigned.apk xashdroid -tsa https://timestamp.geotrust.com/tsa
#zipalign 4 bin/cs16-client-unsigned.apk bin/mod.apk

92
android/build.xml

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="mod" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

6
android/jni/Android.mk

@ -0,0 +1,6 @@
override TARGET_arm_release_CFLAGS :=
override TARGET_thumb_release_CFLAGS :=
override TARGET_arm_debug_CFLAGS :=
override TARGET_thumb_debug_CFLAGS :=
override TARGET_CFLAGS :=
include $(call all-subdir-makefiles)

11
android/jni/Application.mk

@ -0,0 +1,11 @@
CFLAGS_OPT := -O3 -fomit-frame-pointer -ggdb -funsafe-math-optimizations -ftree-vectorize -fgraphite-identity -floop-interchange -floop-block -funsafe-loop-optimizations -finline-limit=1024
CFLAGS_OPT_ARM := -mthumb -mfpu=neon -mcpu=cortex-a9 -pipe -mvectorize-with-neon-quad -DVECTORIZE_SINCOS
CFLAGS_OPT_ARMv5 :=-march=armv6 -mfpu=vfp -marm -pipe
CFLAGS_OPT_X86 := -mtune=atom -march=atom -mssse3 -mfpmath=sse -funroll-loops -pipe -DVECTORIZE_SINCOS
CFLAGS_HARDFP := -D_NDK_MATH_NO_SOFTFP=1 -mhard-float -mfloat-abi=hard -DLOAD_HARDFP -DSOFTFP_LINK
APPLICATIONMK_PATH = $(call my-dir)
XASH3D_CONFIG := $(APPLICATIONMK_PATH)/mod_config.mk
APP_ABI := x86 armeabi-v7a-hard armeabi
APP_MODULES := server

14
android/jni/mod_config.mk

@ -0,0 +1,14 @@
LOCAL_CFLAGS += $(CFLAGS_OPT)
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a-hard)
LOCAL_CFLAGS += $(CFLAGS_OPT_ARM) $(CFLAGS_HARDFP)
endif
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_CFLAGS += $(CFLAGS_OPT_ARM) -mfloat-abi=softfp
endif
ifeq ($(TARGET_ARCH_ABI),armeabi)
LOCAL_CFLAGS += $(CFLAGS_OPT_ARMv5)
endif
ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_CFLAGS += $(CFLAGS_OPT_X86)
endif

1
android/jni/server

@ -0,0 +1 @@
../../dlls

BIN
android/pak/models/p_gravcannon.mdl

Binary file not shown.

BIN
android/pak/models/v_gravcannon.mdl

Binary file not shown.

BIN
android/pak/models/w_gravcannon.mdl

Binary file not shown.

BIN
android/pak/models/w_gravcannont.mdl

Binary file not shown.

9
android/pak/sprites/weapon_gravgun.txt

@ -0,0 +1,9 @@
8
weapon 320 320hud1 80 120 80 20
weapon_s 320 320hud1 80 140 80 20
ammo 320 320hud2 0 34 18 18
crosshair 320 crosshairs 72 48 24 24
weapon 640 640hud2 0 135 170 45
weapon_s 640 640hud5 0 135 170 45
ammo 640 640hud7 0 96 24 24
crosshair 640 crosshairs 72 48 24 24

11
android/project.properties

@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-3

BIN
android/res/drawable/gravgun.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

14
android/src/in/celest/xash3d/InstallReceiver.java

@ -0,0 +1,14 @@
package in.celest.xash3d;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class InstallReceiver extends BroadcastReceiver {
private static final String TAG = "MOD_LAUNCHER";
@Override
public void onReceive(Context context, Intent arg1) {
Log.d( TAG, "Install received, extracting PAK" );
LauncherActivity.extractPAK( context, true );
}
}

160
android/src/in/celest/xash3d/LauncherActivity.java

@ -0,0 +1,160 @@
package in.celest.xash3d;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.content.Intent;
import android.widget.EditText;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.Button;
import android.widget.TextView;
import android.content.ComponentName;
import android.content.pm.PackageManager;
import android.content.SharedPreferences;
import java.lang.reflect.Method;
import java.io.FileOutputStream;
import java.io.File;
import java.io.InputStream;
import android.content.Context;
import android.util.Log;
public class LauncherActivity extends Activity {
private static final int PAK_VERSION = 1;
static Boolean isExtracting = false;
static EditText cmdArgs;
static SharedPreferences mPref;
private static final String TAG = "MOD_LAUNCHER";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Build layout
LinearLayout launcher = new LinearLayout(this);
launcher.setOrientation(LinearLayout.VERTICAL);
launcher.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
TextView titleView = new TextView(this);
titleView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
titleView.setText("Command-line arguments");
titleView.setTextAppearance(this, android.R.attr.textAppearanceLarge);
cmdArgs = new EditText(this);
cmdArgs.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
Button startButton = new Button(this);
// Set launch button title here
startButton.setText("Launch with gravgun!");
LayoutParams buttonParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
buttonParams.gravity = 5;
startButton.setLayoutParams(buttonParams);
startButton.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
startXash(v);
}
});
launcher.addView(titleView);
launcher.addView(cmdArgs);
// Add other options here
launcher.addView(startButton);
setContentView(launcher);
mPref = getSharedPreferences("mod", 0);
extractPAK(this, false);
cmdArgs.setText(mPref.getString("argv","-dev 3 -log"));
}
public void startXash(View view)
{
Intent intent = new Intent();
intent.setAction("in.celest.xash3d.START");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
SharedPreferences.Editor editor = mPref.edit();
editor.putString("argv", cmdArgs.getText().toString());
editor.commit();
editor.apply();
if(cmdArgs.length() != 0) intent.putExtra("argv", cmdArgs.getText().toString());
// Uncomment to set gamedir here
// intent.putExtra("gamedir", "mod" );
intent.putExtra("gamelibdir", getFilesDir().getAbsolutePath().replace("/files","/lib"));
intent.putExtra("pakfile", getFilesDir().getAbsolutePath() + "/extras.pak" );
startActivity(intent);
}
private static int chmod(String path, int mode) {
int ret = -1;
try
{
ret = Runtime.getRuntime().exec("chmod " + Integer.toOctalString(mode) + " " + path).waitFor();
Log.d(TAG, "chmod " + Integer.toOctalString(mode) + " " + path + ": " + ret );
}
catch(Exception e)
{
ret = -1;
Log.d(TAG, "chmod: Runtime not worked: " + e.toString() );
}
try
{
Class fileUtils = Class.forName("android.os.FileUtils");
Method setPermissions = fileUtils.getMethod("setPermissions",
String.class, int.class, int.class, int.class);
ret = (Integer) setPermissions.invoke(null, path,
mode, -1, -1);
}
catch(Exception e)
{
ret = -1;
Log.d(TAG, "chmod: FileUtils not worked: " + e.toString() );
}
return ret;
}
private static void extractFile(Context context, String path) {
try
{
InputStream is = null;
FileOutputStream os = null;
is = context.getAssets().open(path);
File out = new File(context.getFilesDir().getPath()+'/'+path);
out.getParentFile().mkdirs();
chmod( out.getParent(), 0777 );
os = new FileOutputStream(out);
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
os.close();
is.close();
chmod( context.getFilesDir().getPath()+'/'+path, 0777 );
} catch( Exception e )
{
Log.e( TAG, "Failed to extract file:" + e.toString() );
e.printStackTrace();
}
}
public static void extractPAK(Context context, Boolean force) {
if(isExtracting)
return;
isExtracting = true;
try {
if( mPref == null )
mPref = context.getSharedPreferences("mod", 0);
if( mPref.getInt( "pakversion", 0 ) == PAK_VERSION && !force )
return;
extractFile(context, "extras.pak");
SharedPreferences.Editor editor = mPref.edit();
editor.putInt( "pakversion", PAK_VERSION );
editor.commit();
editor.apply();
} catch( Exception e )
{
Log.e( TAG, "Failed to extract PAK:" + e.toString() );
}
isExtracting = false;
}
}

2
dlls/gravgun.cpp

@ -504,7 +504,7 @@ void CGrav::Pull(CBaseEntity* ent,float force)
ent->pev->velocity = (target - origin).Normalize()*550; ent->pev->velocity = (target - origin).Normalize()*550;
pev->velocity.z += 15; pev->velocity.z += 15;
} }
ent->pev->velocity = ent->pev->velocity + m_pPlayer->pev->velocity; //ent->pev->velocity = ent->pev->velocity + m_pPlayer->pev->velocity;
///// /////
#ifdef BEAMS #ifdef BEAMS
CBeam* m_pBeam1 = CBeam::BeamCreate(GRAV_BEAM_SPRITE, 40); CBeam* m_pBeam1 = CBeam::BeamCreate(GRAV_BEAM_SPRITE, 40);

Loading…
Cancel
Save