mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
remove android from trunk so doesn't interfere with finishing winmo
This commit is contained in:
parent
c68c01a82a
commit
cce0114e66
50 changed files with 0 additions and 4089 deletions
|
@ -1,60 +0,0 @@
|
||||||
# -*- mode: Makefile -*-
|
|
||||||
|
|
||||||
LOCAL_PATH := $(call my-dir)
|
|
||||||
|
|
||||||
include $(CLEAR_VARS)
|
|
||||||
|
|
||||||
local_C_INCLUDES+= \
|
|
||||||
-I$(LOCAL_PATH)/../common \
|
|
||||||
-I$(LOCAL_PATH)/../relay \
|
|
||||||
|
|
||||||
local_LDLIBS += -llog
|
|
||||||
|
|
||||||
local_DEFINES += \
|
|
||||||
-DMEM_DEBUG -DDEBUG \
|
|
||||||
-DENABLE_LOGGING \
|
|
||||||
-DXWFEATURE_TURNCHANGENOTIFY \
|
|
||||||
-DXWFEATURE_SEARCHLIMIT \
|
|
||||||
-DKEYBOARD_NAV \
|
|
||||||
-DKEY_SUPPORT \
|
|
||||||
-DPOINTER_SUPPORT \
|
|
||||||
-DSTUBBED_DICT \
|
|
||||||
-DNODE_CAN_4 \
|
|
||||||
-D__LITTLE_ENDIAN \
|
|
||||||
|
|
||||||
local_SRC_FILES += \
|
|
||||||
xwjni.c \
|
|
||||||
utilwrapper.c \
|
|
||||||
drawwrapper.c \
|
|
||||||
anddict.c \
|
|
||||||
andutils.c \
|
|
||||||
|
|
||||||
common_SRC_FILES += \
|
|
||||||
../common/boarddrw.c \
|
|
||||||
../common/scorebdp.c \
|
|
||||||
../common/dragdrpp.c \
|
|
||||||
../common/pool.c \
|
|
||||||
../common/tray.c \
|
|
||||||
../common/dictnry.c \
|
|
||||||
../common/mscore.c \
|
|
||||||
../common/vtabmgr.c \
|
|
||||||
../common/strutils.c \
|
|
||||||
../common/engine.c \
|
|
||||||
../common/board.c \
|
|
||||||
../common/mempool.c \
|
|
||||||
../common/game.c \
|
|
||||||
../common/server.c \
|
|
||||||
../common/model.c \
|
|
||||||
../common/comms.c \
|
|
||||||
../common/memstream.c \
|
|
||||||
../common/movestak.c \
|
|
||||||
|
|
||||||
|
|
||||||
LOCAL_CFLAGS+=$(local_C_INCLUDES) $(local_DEFINES)
|
|
||||||
LOCAL_SRC_FILES := $(linux_SRC_FILES) $(local_SRC_FILES) $(common_SRC_FILES)
|
|
||||||
LOCAL_MODULE := xwjni
|
|
||||||
LOCAL_LDLIBS := -L${SYSROOT}/usr/lib -llog -lz
|
|
||||||
|
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
|
||||||
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
APP_PROJECT_PATH := $(call my-dir)/XWords4
|
|
||||||
APP_MODULES := xwjni
|
|
|
@ -1,17 +0,0 @@
|
||||||
Here's how I'm building crosswords for Android.
|
|
||||||
|
|
||||||
First, my working directory is XWords within this (android/)
|
|
||||||
directory.
|
|
||||||
|
|
||||||
Build the jni library (the cross-platform code):
|
|
||||||
# ../scripts/ndkbuild.sh
|
|
||||||
|
|
||||||
Then build the app for the emulator (first time)
|
|
||||||
# ant install
|
|
||||||
|
|
||||||
subsequent times
|
|
||||||
# ant reinstall
|
|
||||||
|
|
||||||
Build for a device (requires you've set up your keys. I did this too
|
|
||||||
long ago to remember how but the info's easy to find):
|
|
||||||
# ant release
|
|
|
@ -1,34 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
/* stub this out for now. Need a localization strategy that uses
|
|
||||||
string.xml */
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _LOCALIZEDSTRINCLUDES_H_
|
|
||||||
#define _LOCALIZEDSTRINCLUDES_H_
|
|
||||||
|
|
||||||
# define STRD_ROBOT_TRADED 1000
|
|
||||||
# define STR_ROBOT_MOVED 1001
|
|
||||||
# define STRS_VALUES_HEADER 1002
|
|
||||||
# define STRD_REMAINING_TILES_ADD 1003
|
|
||||||
# define STRD_UNUSED_TILES_SUB 1004
|
|
||||||
# define STR_REMOTE_MOVED 1005
|
|
||||||
# define STRD_TIME_PENALTY_SUB 1006
|
|
||||||
# define STR_PASS 1000
|
|
||||||
# define STRS_MOVE_ACROSS 1000
|
|
||||||
# define STRS_MOVE_DOWN 1000
|
|
||||||
# define STRS_TRAY_AT_START 1000
|
|
||||||
# define STRSS_TRADED_FOR 1000
|
|
||||||
# define STR_PHONY_REJECTED 1000
|
|
||||||
# define STRD_CUMULATIVE_SCORE 1000
|
|
||||||
# define STRS_NEW_TILES 1000
|
|
||||||
# define STR_PASSED 1000
|
|
||||||
# define STRSD_SUMMARYSCORED 1000
|
|
||||||
# define STRD_TRADED 1000
|
|
||||||
# define STR_LOSTTURN 1000
|
|
||||||
# define STR_COMMIT_CONFIRM 1000
|
|
||||||
# define STR_LOCAL_NAME 1000
|
|
||||||
# define STR_NONLOCAL_NAME 1000
|
|
||||||
# define STR_BONUS_ALL 1000
|
|
||||||
# define STRD_TURN_SCORE 1000
|
|
||||||
#endif
|
|
|
@ -1,88 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2007 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- Declare the contents of this Android application. The namespace
|
|
||||||
attribute brings in the Android platform namespace, and the package
|
|
||||||
supplies a unique name for the application. When writing your
|
|
||||||
own application, the package name must be changed from "com.example.*"
|
|
||||||
to come from a domain that you own or have control over. -->
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="org.eehouse.android.xw4"
|
|
||||||
>
|
|
||||||
<application android:icon="@drawable/icon48x48"
|
|
||||||
android:label="@string/app_name"
|
|
||||||
>
|
|
||||||
|
|
||||||
<activity android:name="GamesList" android:label="@string/title_games_list">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
<action android:name="android.intent.action.EDIT" />
|
|
||||||
<action android:name="android.intent.action.PICK" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
|
|
||||||
</intent-filter>
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.GET_CONTENT" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="vnd.android.cursor.item/vnd.eehouse.org.game" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name="GameConfig"
|
|
||||||
android:theme="@android:style/Theme.Light"
|
|
||||||
android:label="@string/title_game"
|
|
||||||
android:screenOrientation="sensor"
|
|
||||||
android:configChanges="keyboardHidden|orientation"
|
|
||||||
>
|
|
||||||
<!-- This filter says that we can view or edit the data of
|
|
||||||
a single note -->
|
|
||||||
<intent-filter android:label="@string/resolve_edit">
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
|
||||||
<action android:name="android.intent.action.EDIT" />
|
|
||||||
<action android:name="org.eehouse.android.xw4.action.EDIT_GAME" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="vnd.android.cursor.item/vnd.org.eehouse.android.xw4.game" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity android:name="BoardActivity"
|
|
||||||
android:theme="@android:style/Theme.Light"
|
|
||||||
android:label="@string/title_game"
|
|
||||||
android:screenOrientation="sensor"
|
|
||||||
>
|
|
||||||
<!-- This filter says that we can edit the data of a game, i.e. play -->
|
|
||||||
<intent-filter android:label="@string/play">
|
|
||||||
<action android:name="android.intent.action.EDIT" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="vnd.android.cursor.item/vnd.org.eehouse.android.xw4.game" />
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<!-- This filter says that we can create a new note inside
|
|
||||||
of a directory of notes. -->
|
|
||||||
<!--intent-filter>
|
|
||||||
<action android:name="android.intent.action.INSERT" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
<data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
|
|
||||||
</intent-filter-->
|
|
||||||
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
</application>
|
|
||||||
</manifest>
|
|
Binary file not shown.
|
@ -1,67 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project name="XWords4" 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 in in Version
|
|
||||||
Control Systems. -->
|
|
||||||
<property file="local.properties" />
|
|
||||||
|
|
||||||
<!-- The build.properties file can be created by you and is never touched
|
|
||||||
by the 'android' tool. This is the place to change some of the default property values
|
|
||||||
used by the Ant rules.
|
|
||||||
Here are some properties you may want to change/update:
|
|
||||||
|
|
||||||
application.package
|
|
||||||
the name of your application package as defined in the manifest. Used by the
|
|
||||||
'uninstall' rule.
|
|
||||||
source.dir
|
|
||||||
the name of the source directory. Default is 'src'.
|
|
||||||
out.dir
|
|
||||||
the name of the output directory. Default is 'bin'.
|
|
||||||
|
|
||||||
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 in in Version Control Systems.
|
|
||||||
|
|
||||||
-->
|
|
||||||
<property file="build.properties" />
|
|
||||||
|
|
||||||
<!-- The default.properties file is created and updated by the 'android' tool, as well
|
|
||||||
as ADT.
|
|
||||||
This file is an integral part of the build system for your application and
|
|
||||||
should be checked in in Version Control Systems. -->
|
|
||||||
<property file="default.properties" />
|
|
||||||
|
|
||||||
<!-- Custom Android task to deal with the project target, and import the proper rules.
|
|
||||||
This requires ant 1.6.0 or above. -->
|
|
||||||
<path id="android.antlibs">
|
|
||||||
<pathelement path="${sdk.dir}/tools/lib/anttasks.jar" />
|
|
||||||
<pathelement path="${sdk.dir}/tools/lib/sdklib.jar" />
|
|
||||||
<pathelement path="${sdk.dir}/tools/lib/androidprefs.jar" />
|
|
||||||
<pathelement path="${sdk.dir}/tools/lib/apkbuilder.jar" />
|
|
||||||
<pathelement path="${sdk.dir}/tools/lib/jarutils.jar" />
|
|
||||||
</path>
|
|
||||||
|
|
||||||
<taskdef name="setup"
|
|
||||||
classname="com.android.ant.SetupTask"
|
|
||||||
classpathref="android.antlibs" />
|
|
||||||
|
|
||||||
<!-- Execute the Android Setup task that will setup some properties specific to the target,
|
|
||||||
and import the build rules files.
|
|
||||||
|
|
||||||
The rules file is imported from
|
|
||||||
<SDK>/platforms/<target_platform>/templates/android_rules.xml
|
|
||||||
|
|
||||||
To customize some build steps for your project:
|
|
||||||
- copy the content of the main node <project> from android_rules.xml
|
|
||||||
- paste it in this build.xml below the <setup /> task.
|
|
||||||
- disable the import by changing the setup task below to <setup import="false" />
|
|
||||||
|
|
||||||
This will ensure that the properties are setup correctly but that your customized
|
|
||||||
build steps are used.
|
|
||||||
-->
|
|
||||||
<setup />
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,13 +0,0 @@
|
||||||
# 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.
|
|
||||||
|
|
||||||
# Indicates whether an apk should be generated for each density.
|
|
||||||
split.density=false
|
|
||||||
# Project target.
|
|
||||||
target=android-3
|
|
|
@ -1,10 +0,0 @@
|
||||||
# This file is automatically generated by Android Tools.
|
|
||||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
|
||||||
#
|
|
||||||
# This file must *NOT* be checked in Version Control Systems,
|
|
||||||
# as it contains information specific to your local configuration.
|
|
||||||
|
|
||||||
# location of the SDK. This is only used by Ant
|
|
||||||
# For customization when using a Version Control System, please read the
|
|
||||||
# header note.
|
|
||||||
sdk.dir=/home/andy/android-sdk-linux
|
|
Binary file not shown.
Before Width: | Height: | Size: 181 B |
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 192 B |
Binary file not shown.
Before Width: | Height: | Size: 187 B |
|
@ -1,21 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:paddingLeft="8dp"
|
|
||||||
android:paddingRight="8dp"
|
|
||||||
>
|
|
||||||
|
|
||||||
<org.eehouse.android.xw4.BoardView
|
|
||||||
android:id="@+id/board_view"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:focusable="true"
|
|
||||||
android:clickable="true"
|
|
||||||
android:longClickable="true"
|
|
||||||
android:drawSelectorOnTop="false"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -1,58 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2007 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="fill_parent" android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0"
|
|
||||||
android:paddingBottom="4dip"
|
|
||||||
android:text="@string/player_label"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:layout_width="fill_parent" android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/player_1_name"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="fill_parent" android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="0"
|
|
||||||
android:paddingBottom="4dip"
|
|
||||||
android:text="@string/player_label"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:layout_width="fill_parent" android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/player_2_name"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Button android:id="@+id/game_config_open"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="right"
|
|
||||||
android:text="@string/game_config_open" />
|
|
||||||
|
|
||||||
<Button android:id="@+id/game_config_done"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="right"
|
|
||||||
android:text="@string/game_config_done" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:paddingLeft="8dp"
|
|
||||||
android:paddingRight="8dp">
|
|
||||||
|
|
||||||
<ListView android:id="@id/android:list"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:drawSelectorOnTop="false"/>
|
|
||||||
|
|
||||||
<Button android:id="@+id/new_game"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="right"
|
|
||||||
android:text="@string/button_new_game" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
|
@ -1,59 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item android:id="@+id/board_menu_done"
|
|
||||||
android:title="@string/board_menu_done" />
|
|
||||||
<item android:id="@+id/board_menu_juggle"
|
|
||||||
android:title="@string/board_menu_juggle" />
|
|
||||||
<item android:id="@+id/board_menu_flip"
|
|
||||||
android:title="@string/board_menu_flip" />
|
|
||||||
<item android:id="@+id/board_menu_trade"
|
|
||||||
android:title="@string/board_menu_trade" />
|
|
||||||
<item android:id="@+id/board_menu_tray"
|
|
||||||
android:title="@string/board_menu_tray" />
|
|
||||||
|
|
||||||
<item android:title="@string/board_submenu_undo">
|
|
||||||
<menu>
|
|
||||||
<item android:id="@+id/board_menu_undo_current"
|
|
||||||
android:title="@string/board_menu_undo_current" />
|
|
||||||
<item android:id="@+id/board_menu_undo_last"
|
|
||||||
android:title="@string/board_menu_undo_last" />
|
|
||||||
</menu>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
<item android:title="@string/board_submenu_hint">
|
|
||||||
<menu>
|
|
||||||
<item android:id="@+id/board_menu_hint_next"
|
|
||||||
android:title="@string/board_menu_hint_next" />
|
|
||||||
<item android:id="@+id/board_menu_hint"
|
|
||||||
android:title="@string/board_menu_hint" />
|
|
||||||
</menu>
|
|
||||||
</item>
|
|
||||||
<item android:title="@string/board_submenu_game">
|
|
||||||
<menu>
|
|
||||||
<item android:id="@+id/board_menu_game_counts"
|
|
||||||
android:title="@string/board_menu_game_counts" />
|
|
||||||
<item android:id="@+id/board_menu_game_left"
|
|
||||||
android:title="@string/board_menu_game_left" />
|
|
||||||
<item android:id="@+id/board_menu_game_info"
|
|
||||||
android:title="@string/board_menu_game_info" />
|
|
||||||
<item android:id="@+id/board_menu_game_history"
|
|
||||||
android:title="@string/board_menu_game_history" />
|
|
||||||
<item android:id="@+id/board_menu_game_final"
|
|
||||||
android:title="@string/board_menu_game_final" />
|
|
||||||
<item android:id="@+id/board_menu_game_resend"
|
|
||||||
android:title="@string/board_menu_game_resend" />
|
|
||||||
</menu>
|
|
||||||
</item>
|
|
||||||
<item android:title="@string/board_submenu_file">
|
|
||||||
<menu>
|
|
||||||
<item android:id="@+id/board_menu_file_new"
|
|
||||||
android:title="@string/board_menu_file_new" />
|
|
||||||
<item android:id="@+id/board_menu_file_prefs"
|
|
||||||
android:title="@string/board_menu_file_prefs" />
|
|
||||||
<item android:id="@+id/board_menu_file_about"
|
|
||||||
android:title="@string/board_menu_file_about" />
|
|
||||||
</menu>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
</menu>
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<item android:id="@+id/list_item_open"
|
|
||||||
android:title="@string/list_item_open" />
|
|
||||||
<item android:id="@+id/list_item_view"
|
|
||||||
android:title="@string/list_item_view" />
|
|
||||||
<item android:id="@+id/list_item_hide"
|
|
||||||
android:title="@string/list_item_hide" />
|
|
||||||
<item android:id="@+id/list_item_delete"
|
|
||||||
android:title="@string/list_item_delete" />
|
|
||||||
</menu>
|
|
|
@ -1,74 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2007 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<resources>
|
|
||||||
<string name="menu_delete">Delete</string>
|
|
||||||
<string name="menu_insert">Add game</string>
|
|
||||||
<string name="button_new_game">Add game</string>
|
|
||||||
<string name="menu_revert">Revert</string>
|
|
||||||
<string name="menu_discard">Discard</string>
|
|
||||||
|
|
||||||
<string name="list_item_open">Open</string>
|
|
||||||
<string name="list_item_view">View</string>
|
|
||||||
<string name="list_item_hide">Hide</string>
|
|
||||||
<string name="list_item_delete">Delete</string>
|
|
||||||
|
|
||||||
<string name="resolve_edit">Edit note</string>
|
|
||||||
<string name="resolve_title">Edit title</string>
|
|
||||||
|
|
||||||
<string name="play">Play game</string>
|
|
||||||
|
|
||||||
<string name="title_create">Create game</string>
|
|
||||||
<string name="title_edit">Edit game</string>
|
|
||||||
<string name="title_games_list">Crosswords</string>
|
|
||||||
<string name="title_game">Game</string>
|
|
||||||
<string name="title_edit_title">Game name:</string>
|
|
||||||
|
|
||||||
<string name="app_name">Crosswords</string>
|
|
||||||
|
|
||||||
<string name="button_ok">OK</string>
|
|
||||||
|
|
||||||
<string name="player_label">Name:</string>
|
|
||||||
<string name="game_config_open">Open</string>
|
|
||||||
<string name="game_config_done">Done</string>
|
|
||||||
|
|
||||||
<string name="error_title">Error</string>
|
|
||||||
<string name="error_message">Error loading game</string>
|
|
||||||
|
|
||||||
<!-- system menu for main board view -->
|
|
||||||
<string name="board_menu_done">Turn done</string>
|
|
||||||
<string name="board_menu_juggle">Juggle</string>
|
|
||||||
<string name="board_menu_flip">Flip</string>
|
|
||||||
<string name="board_menu_trade">Trade</string>
|
|
||||||
<string name="board_menu_tray">Hide/Show</string>
|
|
||||||
<string name="board_submenu_undo">Undo</string>
|
|
||||||
<string name="board_menu_undo_current">Undo current</string>
|
|
||||||
<string name="board_menu_undo_last">Undo last</string>
|
|
||||||
<string name="board_submenu_hint">Hint</string>
|
|
||||||
<string name="board_menu_hint_next">Next hint</string>
|
|
||||||
<string name="board_menu_hint">Hint</string>
|
|
||||||
<string name="board_submenu_game">Game</string>
|
|
||||||
<string name="board_menu_game_counts">Counts and values</string>
|
|
||||||
<string name="board_menu_game_left">Tiles remaining</string>
|
|
||||||
<string name="board_menu_game_info">Game info</string>
|
|
||||||
<string name="board_menu_game_history">Game history</string>
|
|
||||||
<string name="board_menu_game_final">Final scores</string>
|
|
||||||
<string name="board_menu_game_resend">Resend messages</string>
|
|
||||||
<string name="board_submenu_file">File</string>
|
|
||||||
<string name="board_menu_file_new">New game</string>
|
|
||||||
<string name="board_menu_file_prefs">Preferences</string>
|
|
||||||
<string name="board_menu_file_about">About Crosswords</string>
|
|
||||||
</resources>
|
|
|
@ -1,217 +0,0 @@
|
||||||
/* -*- compile-command: "cd ../../../../../; ant reinstall"; -*- */
|
|
||||||
|
|
||||||
|
|
||||||
package org.eehouse.android.xw4;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.content.res.AssetManager;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.content.res.Configuration;
|
|
||||||
|
|
||||||
import org.eehouse.android.xw4.jni.*;
|
|
||||||
|
|
||||||
public class BoardActivity extends Activity implements XW_UtilCtxt, Runnable {
|
|
||||||
|
|
||||||
private BoardView m_view;
|
|
||||||
private int m_jniGamePtr;
|
|
||||||
private CurGameInfo m_gi;
|
|
||||||
private CommonPrefs m_prefs;
|
|
||||||
private Handler m_handler;
|
|
||||||
private TimerRunnable[] m_timers;
|
|
||||||
|
|
||||||
public class TimerRunnable implements Runnable {
|
|
||||||
private int m_gamePtr;
|
|
||||||
private int m_why;
|
|
||||||
private int m_when;
|
|
||||||
private int m_handle;
|
|
||||||
private TimerRunnable( int why, int when, int handle ) {
|
|
||||||
m_why = why;
|
|
||||||
m_when = when;
|
|
||||||
m_handle = handle;
|
|
||||||
}
|
|
||||||
public void run() {
|
|
||||||
m_timers[m_why] = null;
|
|
||||||
XwJNI.timerFired( m_jniGamePtr, m_why, m_when, m_handle );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onCreate( Bundle savedInstanceState ) {
|
|
||||||
super.onCreate( savedInstanceState );
|
|
||||||
|
|
||||||
setContentView( R.layout.board );
|
|
||||||
m_handler = new Handler();
|
|
||||||
m_timers = new TimerRunnable[4]; // needs to be in sync with XWTimerReason
|
|
||||||
|
|
||||||
m_prefs = new CommonPrefs();
|
|
||||||
m_gi = new CurGameInfo();
|
|
||||||
|
|
||||||
m_view = (BoardView)findViewById( R.id.board_view );
|
|
||||||
|
|
||||||
byte[] dictBytes = null;
|
|
||||||
InputStream dict = null;
|
|
||||||
AssetManager am = getAssets();
|
|
||||||
try {
|
|
||||||
dict = am.open( m_gi.dictName,
|
|
||||||
android.content.res.AssetManager.ACCESS_RANDOM );
|
|
||||||
Utils.logf( "opened dict" );
|
|
||||||
|
|
||||||
int len = dict.available();
|
|
||||||
Utils.logf( "dict size: " + len );
|
|
||||||
dictBytes = new byte[len];
|
|
||||||
int nRead = dict.read( dictBytes, 0, len );
|
|
||||||
if ( nRead != len ) {
|
|
||||||
Utils.logf( "**** warning ****; read only " + nRead + " of "
|
|
||||||
+ len + " bytes." );
|
|
||||||
}
|
|
||||||
} catch ( java.io.IOException ee ){
|
|
||||||
Utils.logf( "failed to open" );
|
|
||||||
}
|
|
||||||
// am.close(); don't close! won't work subsequently
|
|
||||||
|
|
||||||
Utils.logf( "calling game_makeNewGame; passing bytes: " + dictBytes.length );
|
|
||||||
m_jniGamePtr = XwJNI.game_makeNewGame( m_gi, this, m_view, 0,
|
|
||||||
m_prefs, null, dictBytes );
|
|
||||||
m_view.startHandling( this, m_jniGamePtr, m_gi );
|
|
||||||
|
|
||||||
XwJNI.server_do( m_jniGamePtr );
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
MenuInflater inflater = getMenuInflater();
|
|
||||||
inflater.inflate( R.menu.board_menu, menu );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean toggleTray() {
|
|
||||||
boolean draw;
|
|
||||||
int state = XwJNI.board_getTrayVisState( m_jniGamePtr );
|
|
||||||
if ( state == XwJNI.TRAY_REVEALED ) {
|
|
||||||
draw = XwJNI.board_hideTray( m_jniGamePtr );
|
|
||||||
} else {
|
|
||||||
draw = XwJNI.board_showTray( m_jniGamePtr );
|
|
||||||
}
|
|
||||||
return draw;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
boolean draw = false;
|
|
||||||
boolean handled = true;
|
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.board_menu_done:
|
|
||||||
draw = XwJNI.board_commitTurn( m_jniGamePtr );
|
|
||||||
break;
|
|
||||||
case R.id.board_menu_juggle:
|
|
||||||
draw = XwJNI.board_juggleTray( m_jniGamePtr );
|
|
||||||
break;
|
|
||||||
case R.id.board_menu_flip:
|
|
||||||
draw = XwJNI.board_flip( m_jniGamePtr );
|
|
||||||
break;
|
|
||||||
case R.id.board_menu_tray:
|
|
||||||
draw = toggleTray();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.board_menu_undo_current:
|
|
||||||
draw = XwJNI.board_replaceTiles( m_jniGamePtr );
|
|
||||||
break;
|
|
||||||
case R.id.board_menu_undo_last:
|
|
||||||
XwJNI.server_handleUndo( m_jniGamePtr );
|
|
||||||
draw = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.board_menu_hint:
|
|
||||||
XwJNI.board_resetEngine( m_jniGamePtr );
|
|
||||||
// fallthru
|
|
||||||
case R.id.board_menu_hint_next:
|
|
||||||
draw = XwJNI.board_requestHint( m_jniGamePtr, false, null );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Utils.logf( "menuitem " + item.getItemId() + " not handled" );
|
|
||||||
handled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( draw ) {
|
|
||||||
m_view.invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
return handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
// gets called for orientation changes only if
|
|
||||||
// android:configChanges="orientation" set in AndroidManifest.xml
|
|
||||||
|
|
||||||
// public void onConfigurationChanged( Configuration newConfig )
|
|
||||||
// {
|
|
||||||
// super.onConfigurationChanged( newConfig );
|
|
||||||
// }
|
|
||||||
|
|
||||||
//////////////////////////////////////////
|
|
||||||
// XW_UtilCtxt interface implementation //
|
|
||||||
//////////////////////////////////////////
|
|
||||||
static final int[] s_buttsBoard = {
|
|
||||||
BONUS_TRIPLE_WORD, BONUS_NONE, BONUS_NONE,BONUS_DOUBLE_LETTER,BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_TRIPLE_WORD,
|
|
||||||
BONUS_NONE, BONUS_DOUBLE_WORD, BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_TRIPLE_LETTER,BONUS_NONE,BONUS_NONE,
|
|
||||||
|
|
||||||
BONUS_NONE, BONUS_NONE, BONUS_DOUBLE_WORD,BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_DOUBLE_LETTER,BONUS_NONE,
|
|
||||||
BONUS_DOUBLE_LETTER,BONUS_NONE, BONUS_NONE,BONUS_DOUBLE_WORD,BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_DOUBLE_LETTER,
|
|
||||||
|
|
||||||
BONUS_NONE, BONUS_NONE, BONUS_NONE,BONUS_NONE,BONUS_DOUBLE_WORD,BONUS_NONE,BONUS_NONE,BONUS_NONE,
|
|
||||||
BONUS_NONE, BONUS_TRIPLE_LETTER,BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_TRIPLE_LETTER,BONUS_NONE,BONUS_NONE,
|
|
||||||
|
|
||||||
BONUS_NONE, BONUS_NONE, BONUS_DOUBLE_LETTER,BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_DOUBLE_LETTER,BONUS_NONE,
|
|
||||||
BONUS_TRIPLE_WORD, BONUS_NONE, BONUS_NONE,BONUS_DOUBLE_LETTER,BONUS_NONE,BONUS_NONE,BONUS_NONE,BONUS_DOUBLE_WORD,
|
|
||||||
}; /* buttsBoard */
|
|
||||||
|
|
||||||
public int getSquareBonus( int col, int row ) {
|
|
||||||
int bonus = BONUS_NONE;
|
|
||||||
if ( col > 7 ) { col = 14 - col; }
|
|
||||||
if ( row > 7 ) { row = 14 - row; }
|
|
||||||
int index = (row*8) + col;
|
|
||||||
if ( index < 8*8 ) {
|
|
||||||
bonus = s_buttsBoard[index];
|
|
||||||
}
|
|
||||||
return bonus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
if ( XwJNI.server_do( m_jniGamePtr ) ) {
|
|
||||||
m_view.invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void requestTime() {
|
|
||||||
m_handler.post( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimer( int why, int when, int handle )
|
|
||||||
{
|
|
||||||
if ( null != m_timers[why] ) {
|
|
||||||
m_handler.removeCallbacks( m_timers[why] );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_timers[why] = new TimerRunnable( why, when, handle );
|
|
||||||
m_handler.postDelayed( m_timers[why], 500 );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearTimer( int why )
|
|
||||||
{
|
|
||||||
Utils.logf( "clearTimer called" );
|
|
||||||
if ( null != m_timers[why] ) {
|
|
||||||
m_handler.removeCallbacks( m_timers[why] );
|
|
||||||
m_timers[why] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't need this unless we have a scroll thumb to indicate position
|
|
||||||
// public void yOffsetChange( int oldOffset, int newOffset )
|
|
||||||
// {
|
|
||||||
// Utils.logf( "yOffsetChange(" + oldOffset + "," + newOffset + ")" );
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,371 +0,0 @@
|
||||||
/* -*- compile-command: "cd ../../../../../; ant reinstall"; -*- */
|
|
||||||
|
|
||||||
package org.eehouse.android.xw4;
|
|
||||||
|
|
||||||
import android.view.View;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import org.eehouse.android.xw4.jni.*;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.content.res.Resources;
|
|
||||||
|
|
||||||
public class BoardView extends View implements DrawCtx,
|
|
||||||
BoardHandler {
|
|
||||||
|
|
||||||
private Paint m_fillPaint;
|
|
||||||
private Paint m_strokePaint;
|
|
||||||
private int m_jniGamePtr;
|
|
||||||
private CurGameInfo m_gi;
|
|
||||||
private boolean m_boardSet = false;
|
|
||||||
private Canvas m_canvas;
|
|
||||||
private Bitmap m_bitmap;
|
|
||||||
private int m_trayOwner;
|
|
||||||
private Rect m_valRect;
|
|
||||||
private Rect m_letterRect;
|
|
||||||
private Drawable m_rightArrow;
|
|
||||||
private Drawable m_downArrow;
|
|
||||||
private Drawable m_origin;
|
|
||||||
private int m_top, m_left;
|
|
||||||
|
|
||||||
private static final int BLACK = 0xFF000000;
|
|
||||||
private static final int WHITE = 0xFFFFFFFF;
|
|
||||||
private static final int TILE_BACK = 0xFFFFFF99;
|
|
||||||
private int [] m_bonusColors = { WHITE, // BONUS_NONE
|
|
||||||
0xFFAFAF00, /* bonus 1 */
|
|
||||||
0xFF00AFAF,
|
|
||||||
0xFFAF00AF,
|
|
||||||
0xFFAFAFAF };
|
|
||||||
private static final int[] m_playerColors = {
|
|
||||||
0xFF000000,
|
|
||||||
0xFFFF0000,
|
|
||||||
0xFF0000FF,
|
|
||||||
0xFF008F00,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public BoardView( Context context ) {
|
|
||||||
super( context );
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
// called when inflating xml
|
|
||||||
public BoardView( Context context, AttributeSet attrs ) {
|
|
||||||
super( context, attrs );
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
// public boolean onClick( View view ) {
|
|
||||||
// Utils.logf( "onClick called" );
|
|
||||||
// return view == this;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public boolean onTouchEvent( MotionEvent event ) {
|
|
||||||
int action = event.getAction();
|
|
||||||
int xx = (int)event.getX() - m_left;
|
|
||||||
int yy = (int)event.getY() - m_top;
|
|
||||||
boolean draw = false;
|
|
||||||
|
|
||||||
switch ( action ) {
|
|
||||||
case MotionEvent.ACTION_DOWN:
|
|
||||||
boolean[] handled = new boolean[1];
|
|
||||||
draw = XwJNI.board_handlePenDown( m_jniGamePtr, xx, yy, handled );
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_MOVE:
|
|
||||||
draw = XwJNI.board_handlePenMove( m_jniGamePtr, xx, yy );
|
|
||||||
break;
|
|
||||||
case MotionEvent.ACTION_UP:
|
|
||||||
draw = XwJNI.board_handlePenUp( m_jniGamePtr, xx, yy );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Utils.logf( "unknown action: " + action );
|
|
||||||
Utils.logf( event.toString() );
|
|
||||||
}
|
|
||||||
if ( draw ) {
|
|
||||||
invalidate();
|
|
||||||
}
|
|
||||||
return true; // required to get subsequent events
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onDraw( Canvas canvas ) {
|
|
||||||
if ( layoutBoardOnce() ) {
|
|
||||||
if ( !XwJNI.board_draw( m_jniGamePtr ) ) {
|
|
||||||
Utils.logf( "draw not complete" );
|
|
||||||
}
|
|
||||||
canvas.drawBitmap( m_bitmap, m_left, m_top, new Paint() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
m_fillPaint = new Paint();
|
|
||||||
m_fillPaint.setTextAlign( Paint.Align.CENTER ); // center horizontally
|
|
||||||
m_strokePaint = new Paint();
|
|
||||||
m_strokePaint.setStyle( Paint.Style.STROKE );
|
|
||||||
|
|
||||||
Resources res = getResources();
|
|
||||||
m_rightArrow = res.getDrawable( R.drawable.rightarrow );
|
|
||||||
m_downArrow = res.getDrawable( R.drawable.downarrow );
|
|
||||||
m_origin = res.getDrawable( R.drawable.origin );
|
|
||||||
|
|
||||||
// Move this to finalize?
|
|
||||||
// XwJNI.game_dispose( jniGamePtr );
|
|
||||||
// Utils.logf( "game_dispose returned" );
|
|
||||||
// jniGamePtr = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean layoutBoardOnce() {
|
|
||||||
if ( !m_boardSet && null != m_gi ) {
|
|
||||||
m_boardSet = true;
|
|
||||||
|
|
||||||
// For now we're assuming vertical orientation. Fix way
|
|
||||||
// later.
|
|
||||||
|
|
||||||
int width = getWidth();
|
|
||||||
int height = getHeight();
|
|
||||||
int nCells = m_gi.boardSize;
|
|
||||||
int cellSize = width / nCells;
|
|
||||||
m_left = (width % nCells) / 2;
|
|
||||||
|
|
||||||
// If we're vertical, we can likely fit all the board and
|
|
||||||
// have a tall tray too. If horizontal, let's assume
|
|
||||||
// that's so things will be big, and rather than make 'em
|
|
||||||
// small assume some scrolling. So make the tray 1.5 to
|
|
||||||
// 2.5x a cell width in height and then scroll however
|
|
||||||
// many.
|
|
||||||
|
|
||||||
int trayHt = cellSize * 2;
|
|
||||||
int scoreHt = cellSize; // scoreboard ht same as cells for
|
|
||||||
// proportion
|
|
||||||
int wantHt = trayHt + scoreHt + (cellSize * nCells);
|
|
||||||
int nToScroll = 0;
|
|
||||||
if ( wantHt <= height ) {
|
|
||||||
m_top = (height - wantHt) / 2;
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
nToScroll = nCells - ((height - (cellSize*3)) / cellSize);
|
|
||||||
Utils.logf( "nToScroll: " + nToScroll );
|
|
||||||
trayHt = height - (cellSize * (1 + (nCells-nToScroll)));
|
|
||||||
m_top = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
XwJNI.board_setScoreboardLoc( m_jniGamePtr, 0, 0,
|
|
||||||
nCells * cellSize, // width
|
|
||||||
scoreHt, true );
|
|
||||||
|
|
||||||
XwJNI.board_setPos( m_jniGamePtr, 0, scoreHt, false );
|
|
||||||
XwJNI.board_setScale( m_jniGamePtr, cellSize, cellSize );
|
|
||||||
|
|
||||||
XwJNI.board_setTrayLoc( m_jniGamePtr, 0,
|
|
||||||
scoreHt + ((nCells-nToScroll) * cellSize),
|
|
||||||
nCells * cellSize, // width
|
|
||||||
trayHt, // height
|
|
||||||
4 );
|
|
||||||
|
|
||||||
XwJNI.board_setShowColors( m_jniGamePtr, true ); // get from prefs!
|
|
||||||
XwJNI.board_invalAll( m_jniGamePtr );
|
|
||||||
|
|
||||||
m_bitmap = Bitmap.createBitmap( 1 + (cellSize*nCells),
|
|
||||||
1 + trayHt + scoreHt
|
|
||||||
+ (cellSize *(nCells-nToScroll)),
|
|
||||||
Bitmap.Config.ARGB_8888 );
|
|
||||||
m_canvas = new Canvas( m_bitmap );
|
|
||||||
}
|
|
||||||
return m_boardSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startHandling( Context context, int gamePtr, CurGameInfo gi ) {
|
|
||||||
m_jniGamePtr = gamePtr;
|
|
||||||
m_gi = gi;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// DrawCtxt interface implementation
|
|
||||||
public void scoreBegin( Rect rect, int numPlayers, int[] scores,
|
|
||||||
int remCount, int dfs )
|
|
||||||
{
|
|
||||||
clearToBack( rect );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void measureRemText( Rect r, int nTilesLeft, int[] width,
|
|
||||||
int[] height )
|
|
||||||
{
|
|
||||||
width[0] = 30;
|
|
||||||
height[0] = r.bottom - r.top;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void measureScoreText( Rect r, DrawScoreInfo dsi,
|
|
||||||
int[] width, int[] height )
|
|
||||||
{
|
|
||||||
width[0] = 60;
|
|
||||||
height[0] = r.bottom - r.top;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawRemText( Rect rInner, Rect rOuter, int nTilesLeft,
|
|
||||||
boolean focussed )
|
|
||||||
{
|
|
||||||
String text = String.format( "%d", nTilesLeft ); // should cache a formatter
|
|
||||||
m_fillPaint.setColor( TILE_BACK );
|
|
||||||
m_canvas.drawRect( rOuter, m_fillPaint );
|
|
||||||
|
|
||||||
m_fillPaint.setTextSize( rInner.bottom - rInner.top );
|
|
||||||
m_fillPaint.setColor( BLACK );
|
|
||||||
drawCentered( text, rInner );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void score_drawPlayer( Rect rInner, Rect rOuter, DrawScoreInfo dsi )
|
|
||||||
{
|
|
||||||
String text = String.format( "%s:%d", dsi.name, dsi.totalScore );
|
|
||||||
m_fillPaint.setTextSize( rInner.bottom - rInner.top );
|
|
||||||
m_fillPaint.setColor( m_playerColors[dsi.playerNum] );
|
|
||||||
drawCentered( text, rInner );
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean drawCell( Rect rect, String text, Object[] bitmaps, int tile,
|
|
||||||
int owner, int bonus, int hintAtts, int flags )
|
|
||||||
{
|
|
||||||
int backColor;
|
|
||||||
int foreColor = WHITE; // must be initialized :-(
|
|
||||||
boolean empty = null == text && null == bitmaps;
|
|
||||||
boolean pending = 0 != (flags & CELL_HIGHLIGHT);
|
|
||||||
|
|
||||||
clearToBack( rect );
|
|
||||||
|
|
||||||
if ( empty ) {
|
|
||||||
backColor = m_bonusColors[bonus];
|
|
||||||
} else if ( pending ) {
|
|
||||||
backColor = BLACK;
|
|
||||||
} else {
|
|
||||||
backColor = TILE_BACK;
|
|
||||||
foreColor = m_playerColors[owner];
|
|
||||||
}
|
|
||||||
|
|
||||||
m_fillPaint.setColor( backColor );
|
|
||||||
m_canvas.drawRect( rect, m_fillPaint );
|
|
||||||
|
|
||||||
if ( empty ) {
|
|
||||||
if ( (CELL_ISSTAR & flags) != 0 ) {
|
|
||||||
m_origin.setBounds( rect );
|
|
||||||
m_origin.draw( m_canvas );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m_fillPaint.setTextSize( rect.bottom - rect.top );
|
|
||||||
if ( owner < 0 ) { // showColors option not turned on
|
|
||||||
owner = 0;
|
|
||||||
}
|
|
||||||
m_fillPaint.setColor( foreColor );
|
|
||||||
drawCentered( text, rect );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_canvas.drawRect( rect, m_strokePaint );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawBoardArrow ( Rect rect, int bonus, boolean vert,
|
|
||||||
int hintAtts, int flags )
|
|
||||||
{
|
|
||||||
rect.inset( 2, 2 );
|
|
||||||
Drawable arrow = vert? m_downArrow : m_rightArrow;
|
|
||||||
arrow.setBounds( rect );
|
|
||||||
arrow.draw( m_canvas );
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean vertScrollBoard( Rect /*out*/ rect, int dist, int dfs )
|
|
||||||
{
|
|
||||||
Utils.logf( "vertScrollBoard" );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean trayBegin ( Rect rect, int owner, int dfs ) {
|
|
||||||
m_trayOwner = owner;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawTile( Rect rect, String text, Object[] bitmaps, int val,
|
|
||||||
int flags ) {
|
|
||||||
boolean valHidden = (flags & CELL_VALHIDDEN) != 0;
|
|
||||||
boolean notEmpty = (flags & CELL_ISEMPTY) == 0;
|
|
||||||
boolean isCursor = (flags & CELL_ISCURSOR) != 0;
|
|
||||||
|
|
||||||
clearToBack( rect );
|
|
||||||
|
|
||||||
if ( isCursor || notEmpty ) {
|
|
||||||
m_fillPaint.setColor( TILE_BACK );
|
|
||||||
m_canvas.drawRect( rect, m_fillPaint );
|
|
||||||
|
|
||||||
if ( null != text ) {
|
|
||||||
m_fillPaint.setColor( m_playerColors[m_trayOwner] );
|
|
||||||
positionDrawTile( rect, text, val );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_canvas.drawRect( rect, m_strokePaint ); // frame
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawTileMidDrag ( Rect rect, String text, Object[] bitmaps,
|
|
||||||
int val, int owner, int flags )
|
|
||||||
{
|
|
||||||
drawTile( rect, text, bitmaps, val, flags );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawTileBack( Rect rect, int flags )
|
|
||||||
{
|
|
||||||
drawTile( rect, "?", null, 0, flags );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawTrayDivider( Rect rect, int flags )
|
|
||||||
{
|
|
||||||
clearToBack( rect );
|
|
||||||
m_fillPaint.setColor( BLACK ); // black for now
|
|
||||||
m_canvas.drawRect( rect, m_fillPaint );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void score_pendingScore( Rect rect, int score, int playerNum,
|
|
||||||
int flags )
|
|
||||||
{
|
|
||||||
String text = score >= 0? String.format( "%d", score ) : "??";
|
|
||||||
clearToBack( rect );
|
|
||||||
m_fillPaint.setColor( BLACK );
|
|
||||||
m_fillPaint.setTextSize( (rect.bottom - rect.top) / 2 );
|
|
||||||
drawCentered( text, rect );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void drawCentered( String text, Rect rect ) {
|
|
||||||
int bottom = rect.bottom;
|
|
||||||
int center = rect.left + ( (rect.right - rect.left) / 2 );
|
|
||||||
m_canvas.drawText( text, center, bottom, m_fillPaint );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void positionDrawTile( Rect rect, String text, int val )
|
|
||||||
{
|
|
||||||
if ( null == m_letterRect ) {
|
|
||||||
// assumes show values is on
|
|
||||||
m_letterRect = new Rect( 0, 0, rect.width() * 3 / 4, rect.height() * 3 / 4 );
|
|
||||||
}
|
|
||||||
m_letterRect.offsetTo( rect.left, rect.top );
|
|
||||||
m_fillPaint.setTextSize( m_letterRect.height() );
|
|
||||||
drawCentered( text, m_letterRect );
|
|
||||||
|
|
||||||
if ( null == m_valRect ) {
|
|
||||||
m_valRect = new Rect( 0, 0, rect.width() / 4, rect.height() / 4 );
|
|
||||||
}
|
|
||||||
m_valRect.offsetTo( rect.right - (rect.width() / 4),
|
|
||||||
rect.bottom - (rect.height() / 4) );
|
|
||||||
text = String.format( "%d", val );
|
|
||||||
m_fillPaint.setTextSize( m_valRect.height() );
|
|
||||||
drawCentered( text, m_valRect );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clearToBack( Rect rect )
|
|
||||||
{
|
|
||||||
m_fillPaint.setColor( WHITE );
|
|
||||||
m_canvas.drawRect( rect, m_fillPaint );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,183 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.eehouse.android.xw4;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.ContentValues;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import android.text.Editable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A generic activity for editing a note in a database. This can be used
|
|
||||||
* either to simply view a note {@link Intent#ACTION_VIEW}, view and edit a note
|
|
||||||
* {@link Intent#ACTION_EDIT}, or create a new note {@link Intent#ACTION_INSERT}.
|
|
||||||
*/
|
|
||||||
public class GameConfig extends Activity implements View.OnClickListener {
|
|
||||||
private static final String TAG = "Games";
|
|
||||||
|
|
||||||
/** The index of the note column */
|
|
||||||
private static final int COLUMN_INDEX_NOTE = 1;
|
|
||||||
|
|
||||||
// This is our state data that is stored when freezing.
|
|
||||||
private static final String ORIGINAL_CONTENT = "origContent";
|
|
||||||
|
|
||||||
// Identifiers for our menu items.
|
|
||||||
private static final int REVERT_ID = Menu.FIRST;
|
|
||||||
private static final int DISCARD_ID = Menu.FIRST + 1;
|
|
||||||
private static final int DELETE_ID = Menu.FIRST + 2;
|
|
||||||
|
|
||||||
// The different distinct states the activity can be run in.
|
|
||||||
private static final int STATE_EDIT = 0;
|
|
||||||
private static final int STATE_INSERT = 1;
|
|
||||||
|
|
||||||
private int mState;
|
|
||||||
private boolean mNoteOnly = false;
|
|
||||||
private Uri mUri;
|
|
||||||
private String mOriginalContent;
|
|
||||||
|
|
||||||
private Button mDoneB;
|
|
||||||
private Button mOpenB;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
final Intent intent = getIntent();
|
|
||||||
|
|
||||||
// Do some setup based on the action being performed.
|
|
||||||
|
|
||||||
final String action = intent.getAction();
|
|
||||||
Utils.logf( "action: " + action );
|
|
||||||
if (Intent.ACTION_EDIT.equals(action)) {
|
|
||||||
// Requested to edit: set that state, and the data being edited.
|
|
||||||
mState = STATE_EDIT;
|
|
||||||
mUri = intent.getData();
|
|
||||||
} else if (Intent.ACTION_INSERT.equals(action)) {
|
|
||||||
Utils.logf( "matches insert" );
|
|
||||||
// Requested to insert: set that state, and create a new entry
|
|
||||||
// in the container.
|
|
||||||
mState = STATE_INSERT;
|
|
||||||
// mUri = getContentResolver().insert(intent.getData(), null);
|
|
||||||
// Utils.logf( mUri.toString() );
|
|
||||||
|
|
||||||
// If we were unable to create a new note, then just finish
|
|
||||||
// this activity. A RESULT_CANCELED will be sent back to the
|
|
||||||
// original activity if they requested a result.
|
|
||||||
// if (mUri == null) {
|
|
||||||
// Log.e(TAG, "Failed to insert new note into " + getIntent().getData());
|
|
||||||
// finish();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// The new entry was created, so assume all will end well and
|
|
||||||
// set the result to be returned.
|
|
||||||
// setResult(RESULT_OK, (new Intent()).setAction(mUri.toString()));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Whoops, unknown action! Bail.
|
|
||||||
Utils.logf("Unknown action, exiting");
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setContentView(R.layout.game_config);
|
|
||||||
|
|
||||||
mOpenB = (Button)findViewById(R.id.game_config_open);
|
|
||||||
mOpenB.setOnClickListener( this );
|
|
||||||
mDoneB = (Button)findViewById(R.id.game_config_done);
|
|
||||||
mDoneB.setOnClickListener( this );
|
|
||||||
|
|
||||||
// If an instance of this activity had previously stopped, we can
|
|
||||||
// get the original text it started with.
|
|
||||||
// if (savedInstanceState != null) {
|
|
||||||
// mOriginalContent = savedInstanceState.getString(ORIGINAL_CONTENT);
|
|
||||||
// }
|
|
||||||
} // onCreate
|
|
||||||
|
|
||||||
public void onClick( View view ) {
|
|
||||||
|
|
||||||
if ( mDoneB == view ) {
|
|
||||||
EditText et = (EditText)findViewById( R.id.player_1_name );
|
|
||||||
Editable text = et.getText();
|
|
||||||
String name1 = text.toString();
|
|
||||||
et = (EditText)findViewById( R.id.player_2_name );
|
|
||||||
text = et.getText();
|
|
||||||
String name2 = text.toString();
|
|
||||||
|
|
||||||
if ( name1.length() > 0 && name2.length() > 0 ) {
|
|
||||||
Integer num = 0;
|
|
||||||
int ii;
|
|
||||||
String[] files = fileList();
|
|
||||||
String name = null;
|
|
||||||
|
|
||||||
while ( name == null ) {
|
|
||||||
name = "game " + num.toString();
|
|
||||||
for ( ii = 0; ii < files.length; ++ii ) {
|
|
||||||
Utils.logf( "comparing " + name + " with " + files[ii] );
|
|
||||||
if ( files[ii].equals(name) ) {
|
|
||||||
++num;
|
|
||||||
name = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Utils.logf( "using name " + name );
|
|
||||||
|
|
||||||
FileOutputStream out;
|
|
||||||
try {
|
|
||||||
out = openFileOutput( name, MODE_PRIVATE );
|
|
||||||
PrintStream ps = new PrintStream( out );
|
|
||||||
ps.println( name1 );
|
|
||||||
ps.println( name2 );
|
|
||||||
ps.close();
|
|
||||||
try {
|
|
||||||
out.close();
|
|
||||||
} catch ( java.io.IOException ex ) {
|
|
||||||
Utils.logf( "got IOException: " + ex.toString() );
|
|
||||||
}
|
|
||||||
} catch ( java.io.FileNotFoundException ex ) {
|
|
||||||
Utils.logf( "got FileNotFoundException: " + ex.toString() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finish();
|
|
||||||
} else if ( mOpenB == view ) {
|
|
||||||
// finish but after posting an intent that'll cause the
|
|
||||||
// list view to launch us -- however that's done.
|
|
||||||
Utils.logf( "got open" );
|
|
||||||
} else {
|
|
||||||
Utils.logf( "unknown v: " + view.toString() );
|
|
||||||
}
|
|
||||||
} // onClick
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
package org.eehouse.android.xw4;
|
|
||||||
|
|
||||||
import android.widget.Adapter;
|
|
||||||
import android.widget.ListAdapter;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.database.DataSetObserver;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.nio.CharBuffer;
|
|
||||||
|
|
||||||
public class GameListAdapter implements ListAdapter {
|
|
||||||
Context m_context;
|
|
||||||
String[] m_files;
|
|
||||||
|
|
||||||
public GameListAdapter( Context context ) {
|
|
||||||
m_context = context;
|
|
||||||
m_files = context.fileList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean areAllItemsEnabled() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled( int position ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCount() {
|
|
||||||
return m_files.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Object getItem( int position ) {
|
|
||||||
TextView view = new TextView(m_context);
|
|
||||||
|
|
||||||
try {
|
|
||||||
FileInputStream in = m_context.openFileInput( m_files[position] );
|
|
||||||
|
|
||||||
InputStreamReader reader = new InputStreamReader( in );
|
|
||||||
try {
|
|
||||||
int len = in.available();
|
|
||||||
CharBuffer buf = CharBuffer.allocate(len);
|
|
||||||
reader.read( buf.array(), 0, len );
|
|
||||||
reader.close();
|
|
||||||
view.setText( buf );
|
|
||||||
} catch ( java.io.IOException ex ) {
|
|
||||||
Utils.logf( "got IOException: " + ex.toString() );
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
in.close();
|
|
||||||
} catch ( java.io.IOException ex ) {
|
|
||||||
Utils.logf( "got IOException: " + ex.toString() );
|
|
||||||
}
|
|
||||||
} catch ( java.io.FileNotFoundException ex ) {
|
|
||||||
Utils.logf( "got FileNotFoundException: " + ex.toString() );
|
|
||||||
}
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getItemId( int position ) {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getItemViewType( int position ) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public View getView( int position, View convertView, ViewGroup parent ) {
|
|
||||||
return (View)getItem( position );
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getViewTypeCount() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasStableIds() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return getCount() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerDataSetObserver(DataSetObserver observer) {}
|
|
||||||
public void unregisterDataSetObserver(DataSetObserver observer) {}
|
|
||||||
}
|
|
|
@ -1,253 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.eehouse.android.xw4;
|
|
||||||
|
|
||||||
import android.app.ListActivity;
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.ContentUris;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.database.Cursor;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.ContextMenu;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.SimpleCursorAdapter;
|
|
||||||
import android.content.res.AssetManager;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
|
|
||||||
import org.eehouse.android.xw4.XWords4.Games; // for constants
|
|
||||||
|
|
||||||
public class GamesList extends ListActivity implements View.OnClickListener {
|
|
||||||
private static final String TAG = "GamesList";
|
|
||||||
// private InputStream m_dict;
|
|
||||||
private GameListAdapter m_adapter;
|
|
||||||
|
|
||||||
// Menu item ids
|
|
||||||
public static final int MENU_ITEM_DELETE = Menu.FIRST;
|
|
||||||
public static final int MENU_ITEM_INSERT = Menu.FIRST + 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
|
|
||||||
setContentView(R.layout.game_list);
|
|
||||||
|
|
||||||
// setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
|
|
||||||
|
|
||||||
// AssetManager am = getAssets();
|
|
||||||
// try {
|
|
||||||
// m_dict = am.open( "BasEnglish2to8.xwd",
|
|
||||||
// android.content.res.AssetManager.ACCESS_RANDOM );
|
|
||||||
// Utils.logf( "opened" );
|
|
||||||
// } catch ( java.io.IOException ee ){
|
|
||||||
// m_dict = null;
|
|
||||||
// Utils.logf( "failed to open" );
|
|
||||||
// }
|
|
||||||
|
|
||||||
m_adapter = new GameListAdapter( this );
|
|
||||||
setListAdapter( m_adapter );
|
|
||||||
|
|
||||||
registerForContextMenu( getListView() );
|
|
||||||
|
|
||||||
Button newGameB = (Button)findViewById(R.id.new_game);
|
|
||||||
newGameB.setOnClickListener( this );
|
|
||||||
Utils.logf( "got button" );
|
|
||||||
|
|
||||||
// If no data was given in the intent (because we were started
|
|
||||||
// as a MAIN activity), then use our default content provider.
|
|
||||||
Intent intent = getIntent();
|
|
||||||
Utils.logf( intent.toString() );
|
|
||||||
if (intent.getData() == null) {
|
|
||||||
intent.setData(Games.CONTENT_URI);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Inform the list we provide context menus for items
|
|
||||||
// getListView().setOnCreateContextMenuListener(this);
|
|
||||||
|
|
||||||
// Perform a managed query. The Activity will handle closing
|
|
||||||
// and requerying the cursor when needed.
|
|
||||||
// Cursor cursor = managedQuery(getIntent().getData(), PROJECTION, null, null,
|
|
||||||
// Notes.DEFAULT_SORT_ORDER);
|
|
||||||
|
|
||||||
// Used to map notes entries from the database to views
|
|
||||||
// SimpleCursorAdapter adapter =
|
|
||||||
// new SimpleCursorAdapter(this, R.layout.noteslist_item, cursor,
|
|
||||||
// new String[] { Notes.TITLE },
|
|
||||||
// new int[] { android.R.id.text1 });
|
|
||||||
// setListAdapter(adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
// super.onCreateOptionsMenu(menu);
|
|
||||||
|
|
||||||
// // This is our one standard application action -- inserting a
|
|
||||||
// // new note into the list.
|
|
||||||
// menu.add(0, MENU_ITEM_INSERT, 0, R.string.menu_insert)
|
|
||||||
// .setShortcut('3', 'a')
|
|
||||||
// .setIcon(android.R.drawable.ic_menu_add);
|
|
||||||
|
|
||||||
// // Generate any additional actions that can be performed on the
|
|
||||||
// // overall list. In a normal install, there are no additional
|
|
||||||
// // actions found here, but this allows other applications to extend
|
|
||||||
// // our menu with their own actions.
|
|
||||||
// Intent intent = new Intent(null, getIntent().getData());
|
|
||||||
// intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
|
|
||||||
// menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0,
|
|
||||||
// new ComponentName(this, GamesList.class), null, intent, 0, null);
|
|
||||||
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean onPrepareOptionsMenu(Menu menu) {
|
|
||||||
// super.onPrepareOptionsMenu(menu);
|
|
||||||
// final boolean haveItems = getListAdapter().getCount() > 0;
|
|
||||||
|
|
||||||
// // If there are any notes in the list (which implies that one of
|
|
||||||
// // them is selected), then we need to generate the actions that
|
|
||||||
// // can be performed on the current selection. This will be a combination
|
|
||||||
// // of our own specific actions along with any extensions that can be
|
|
||||||
// // found.
|
|
||||||
// if (haveItems) {
|
|
||||||
// // This is the selected item.
|
|
||||||
// Uri uri = ContentUris.withAppendedId(getIntent().getData(), getSelectedItemId());
|
|
||||||
|
|
||||||
// // Build menu... always starts with the EDIT action...
|
|
||||||
// Intent[] specifics = new Intent[1];
|
|
||||||
// specifics[0] = new Intent(Intent.ACTION_EDIT, uri);
|
|
||||||
// MenuItem[] items = new MenuItem[1];
|
|
||||||
|
|
||||||
// // ... is followed by whatever other actions are available...
|
|
||||||
// Intent intent = new Intent(null, uri);
|
|
||||||
// intent.addCategory(Intent.CATEGORY_ALTERNATIVE);
|
|
||||||
// menu.addIntentOptions(Menu.CATEGORY_ALTERNATIVE, 0, 0, null, specifics, intent, 0,
|
|
||||||
// items);
|
|
||||||
|
|
||||||
// // Give a shortcut to the edit action.
|
|
||||||
// if (items[0] != null) {
|
|
||||||
// items[0].setShortcut('1', 'e');
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// menu.removeGroup(Menu.CATEGORY_ALTERNATIVE);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
// switch (item.getItemId()) {
|
|
||||||
// case MENU_ITEM_INSERT:
|
|
||||||
// // Launch activity to insert a new item
|
|
||||||
// startActivity(new Intent(Intent.ACTION_INSERT, getIntent().getData()));
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// return super.onOptionsItemSelected(item);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreateContextMenu( ContextMenu menu, View view,
|
|
||||||
ContextMenuInfo menuInfo ) {
|
|
||||||
// AdapterView.AdapterContextMenuInfo info;
|
|
||||||
// try {
|
|
||||||
// info = (AdapterView.AdapterContextMenuInfo) menuInfo;
|
|
||||||
// } catch (ClassCastException e) {
|
|
||||||
// Log.e(TAG, "bad menuInfo", e);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
Utils.logf( "onCreateContextMenu called" );
|
|
||||||
MenuInflater inflater = getMenuInflater();
|
|
||||||
inflater.inflate( R.menu.games_list_item_menu, menu );
|
|
||||||
|
|
||||||
// Cursor cursor = (Cursor) getListAdapter().getItem(info.position);
|
|
||||||
// if (cursor == null) {
|
|
||||||
// // For some reason the requested item isn't available, do nothing
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Setup the menu header
|
|
||||||
// menu.setHeaderTitle(cursor.getString(COLUMN_INDEX_TITLE));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doOpen() {
|
|
||||||
Intent intent = new Intent( Intent.ACTION_EDIT );
|
|
||||||
intent.setClassName( "org.eehouse.android.xw4",
|
|
||||||
"org.eehouse.android.xw4.BoardActivity");
|
|
||||||
startActivity( intent );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onContextItemSelected( MenuItem item ) {
|
|
||||||
boolean handled = false;
|
|
||||||
AdapterView.AdapterContextMenuInfo info;
|
|
||||||
try {
|
|
||||||
info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
|
|
||||||
} catch (ClassCastException e) {
|
|
||||||
Log.e(TAG, "bad menuInfo", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.list_item_open:
|
|
||||||
doOpen();
|
|
||||||
handled = true;
|
|
||||||
break;
|
|
||||||
case R.id.list_item_view:
|
|
||||||
Utils.logf( "view" );
|
|
||||||
handled = true;
|
|
||||||
break;
|
|
||||||
case R.id.list_item_hide:
|
|
||||||
Utils.logf( "hide" );
|
|
||||||
handled = true;
|
|
||||||
break;
|
|
||||||
case R.id.list_item_delete:
|
|
||||||
Utils.logf( "delete" );
|
|
||||||
handled = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClick( View v ) {
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setClassName( "org.eehouse.android.xw4",
|
|
||||||
"org.eehouse.android.xw4.GameConfig");
|
|
||||||
intent.setAction( Intent.ACTION_INSERT );
|
|
||||||
startActivity( intent );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
|
||||||
doOpen();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static {
|
|
||||||
System.loadLibrary("xwjni");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
|
|
||||||
public class Utils {
|
|
||||||
static final String TAG = "EJAVA";
|
|
||||||
|
|
||||||
private Utils() {}
|
|
||||||
|
|
||||||
public static void logf( String format ) {
|
|
||||||
Log.d( TAG, format );
|
|
||||||
} // logf
|
|
||||||
|
|
||||||
public static void logf( String format, Object[] args ) {
|
|
||||||
MessageFormat mfmt = new MessageFormat( format );
|
|
||||||
logf( mfmt.format( args ) );
|
|
||||||
} // logf
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.eehouse.android.xw4;
|
|
||||||
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.provider.BaseColumns;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience definitions
|
|
||||||
*/
|
|
||||||
public final class XWords4 {
|
|
||||||
public static final String AUTHORITY = "org.eehouse.android.xw4";
|
|
||||||
|
|
||||||
// This class cannot be instantiated
|
|
||||||
private XWords4() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notes table
|
|
||||||
*/
|
|
||||||
public static final class Games implements BaseColumns {
|
|
||||||
// This class cannot be instantiated
|
|
||||||
private Games() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The content:// style URL for this table
|
|
||||||
*/
|
|
||||||
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/games");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The MIME type of {@link #CONTENT_URI} providing a directory of notes.
|
|
||||||
*/
|
|
||||||
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.eehouse.org.xwgamesdir";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The MIME type of a {@link #CONTENT_URI} sub-directory of a single note.
|
|
||||||
*/
|
|
||||||
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.eehouse.org.xwgame";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The default sort order for this table
|
|
||||||
*/
|
|
||||||
public static final String DEFAULT_SORT_ORDER = "modified DESC";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The title of the note
|
|
||||||
* <P>Type: TEXT</P>
|
|
||||||
*/
|
|
||||||
//public static final String TITLE = "title";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The note itself
|
|
||||||
* <P>Type: binary</P>
|
|
||||||
*/
|
|
||||||
public static final String DATA = "data";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The timestamp for when the game was created
|
|
||||||
* <P>Type: INTEGER (long from System.curentTimeMillis())</P>
|
|
||||||
*/
|
|
||||||
public static final String CREATED_DATE = "created";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The timestamp for when the game was last modified
|
|
||||||
* <P>Type: INTEGER (long from System.curentTimeMillis())</P>
|
|
||||||
*/
|
|
||||||
public static final String MODIFIED_DATE = "modified";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4.jni;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
public interface BoardHandler {
|
|
||||||
|
|
||||||
void startHandling( Context context, int gamePtr, CurGameInfo gi );
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package org.eehouse.android.xw4.jni;
|
|
||||||
|
|
||||||
public class CommonPrefs {
|
|
||||||
public boolean showBoardArrow;
|
|
||||||
public boolean showRobotScores;
|
|
||||||
public boolean hideTileValues;
|
|
||||||
public boolean skipCommitConfirm;
|
|
||||||
|
|
||||||
public CommonPrefs() {
|
|
||||||
showBoardArrow = true;
|
|
||||||
showRobotScores = false;
|
|
||||||
hideTileValues = false;
|
|
||||||
skipCommitConfirm = true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4.jni;
|
|
||||||
|
|
||||||
|
|
||||||
public class CurGameInfo {
|
|
||||||
|
|
||||||
private static final String BUILTIN_DICT = "OWL2_2to9.xwd";
|
|
||||||
|
|
||||||
public enum XWPhoniesChoice { PHONIES_IGNORE, PHONIES_WARN, PHONIES_DISALLOW };
|
|
||||||
public enum DeviceRole { SERVER_STANDALONE, SERVER_ISSERVER, SERVER_ISCLIENT };
|
|
||||||
|
|
||||||
public String dictName;
|
|
||||||
public LocalPlayer[] players;
|
|
||||||
public int gameID;
|
|
||||||
public int gameSeconds; /* for timer */
|
|
||||||
public int nPlayers;
|
|
||||||
public int boardSize;
|
|
||||||
public DeviceRole serverRole;
|
|
||||||
|
|
||||||
public boolean hintsNotAllowed;
|
|
||||||
public boolean timerEnabled;
|
|
||||||
public boolean allowPickTiles;
|
|
||||||
public boolean allowHintRect;
|
|
||||||
public int robotSmartness;
|
|
||||||
public XWPhoniesChoice phoniesAction;
|
|
||||||
public boolean confirmBTConnect; /* only used for BT */
|
|
||||||
|
|
||||||
public CurGameInfo() {
|
|
||||||
nPlayers = 3;
|
|
||||||
boardSize = 15;
|
|
||||||
players = new LocalPlayer[nPlayers];
|
|
||||||
serverRole = DeviceRole.SERVER_STANDALONE;
|
|
||||||
dictName = BUILTIN_DICT;
|
|
||||||
hintsNotAllowed = false;
|
|
||||||
players[0] = new LocalPlayer( "Eric");
|
|
||||||
players[1] = new LocalPlayer( "Kati", true );
|
|
||||||
players[2] = new LocalPlayer( "Brynn", true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
package org.eehouse.android.xw4.jni;
|
|
||||||
|
|
||||||
import android.graphics.Rect;
|
|
||||||
|
|
||||||
public interface DrawCtx {
|
|
||||||
static final int CELL_NONE = 0x00;
|
|
||||||
static final int CELL_ISBLANK = 0x01;
|
|
||||||
static final int CELL_HIGHLIGHT = 0x02;
|
|
||||||
static final int CELL_ISSTAR = 0x04;
|
|
||||||
static final int CELL_ISCURSOR = 0x08;
|
|
||||||
static final int CELL_ISEMPTY = 0x10; /* of a tray tile slot */
|
|
||||||
static final int CELL_VALHIDDEN = 0x20; /* show letter only, not value */
|
|
||||||
static final int CELL_DRAGSRC = 0x40; /* where drag originated */
|
|
||||||
static final int CELL_DRAGCUR = 0x80; /* where drag is now */
|
|
||||||
static final int CELL_ALL = 0xFF;
|
|
||||||
|
|
||||||
|
|
||||||
void scoreBegin( Rect rect, int numPlayers, int[] scores, int remCount,
|
|
||||||
int dfs );
|
|
||||||
void measureRemText( Rect r, int nTilesLeft, int[] width, int[] height );
|
|
||||||
void measureScoreText( Rect r, DrawScoreInfo dsi, int[] width, int[] height );
|
|
||||||
void drawRemText( Rect rInner,Rect rOuter, int nTilesLeft, boolean focussed );
|
|
||||||
void score_drawPlayer( Rect rInner, Rect rOuter, DrawScoreInfo dsi );
|
|
||||||
|
|
||||||
boolean drawCell( Rect rect, String text, Object[] bitmaps, int tile,
|
|
||||||
int owner, int bonus, int hintAtts, int flags );
|
|
||||||
void drawBoardArrow ( Rect rect, int bonus, boolean vert, int hintAtts,
|
|
||||||
int flags );
|
|
||||||
boolean vertScrollBoard( Rect /*out*/ rect, int dist, int dfs );
|
|
||||||
|
|
||||||
boolean trayBegin ( Rect rect, int owner, int dfs );
|
|
||||||
void drawTile( Rect rect, String text, Object[] bitmaps, int val, int flags );
|
|
||||||
void drawTileMidDrag ( Rect rect, String text, Object[] bitmaps,
|
|
||||||
int val, int owner, int flags );
|
|
||||||
void drawTileBack( Rect rect, int flags );
|
|
||||||
void drawTrayDivider( Rect rect, int flags );
|
|
||||||
void score_pendingScore( Rect rect, int score, int playerNum, int flags );
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4.jni;
|
|
||||||
|
|
||||||
public class DrawScoreInfo {
|
|
||||||
|
|
||||||
public static final int CELL_NONE = 0x00;
|
|
||||||
public static final int CELL_ISBLANK = 0x01;
|
|
||||||
public static final int CELL_HIGHLIGHT = 0x02;
|
|
||||||
public static final int CELL_ISSTAR = 0x04;
|
|
||||||
public static final int CELL_ISCURSOR = 0x08;
|
|
||||||
public static final int CELL_ISEMPTY = 0x10; /* of a tray tile slot */
|
|
||||||
public static final int CELL_VALHIDDEN = 0x20; /* show letter only, not value */
|
|
||||||
public static final int CELL_DRAGSRC = 0x40; /* where drag originated */
|
|
||||||
public static final int CELL_DRAGCUR = 0x80; /* where drag is now */
|
|
||||||
public static final int CELL_ALL = 0xFF;
|
|
||||||
|
|
||||||
// LastScoreCallback lsc;
|
|
||||||
// void* lscClosure;
|
|
||||||
public String name;
|
|
||||||
public int playerNum;
|
|
||||||
public int totalScore;
|
|
||||||
public int nTilesLeft; /* < 0 means don't use */
|
|
||||||
public int flags; // was CellFlags; use CELL_ constants above
|
|
||||||
public boolean isTurn;
|
|
||||||
public boolean selected;
|
|
||||||
public boolean isRemote;
|
|
||||||
public boolean isRobot;
|
|
||||||
};
|
|
|
@ -1,23 +0,0 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4.jni;
|
|
||||||
|
|
||||||
public class LocalPlayer {
|
|
||||||
public String name;
|
|
||||||
public String password;
|
|
||||||
public int secondsUsed;
|
|
||||||
public boolean isRobot;
|
|
||||||
public boolean isLocal;
|
|
||||||
|
|
||||||
public LocalPlayer( String nm ) {
|
|
||||||
isLocal = true;
|
|
||||||
isRobot = false;
|
|
||||||
name = nm;
|
|
||||||
password = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalPlayer( String nm, boolean robot ) {
|
|
||||||
this( nm );
|
|
||||||
isRobot = robot;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4.jni;
|
|
||||||
|
|
||||||
public interface TransportProcs {
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
|
|
||||||
package org.eehouse.android.xw4.jni;
|
|
||||||
|
|
||||||
public interface XW_UtilCtxt {
|
|
||||||
static final int BONUS_NONE = 0;
|
|
||||||
static final int BONUS_DOUBLE_LETTER = 1;
|
|
||||||
static final int BONUS_DOUBLE_WORD = 2;
|
|
||||||
static final int BONUS_TRIPLE_LETTER = 3;
|
|
||||||
static final int BONUS_TRIPLE_WORD = 4;
|
|
||||||
|
|
||||||
int getSquareBonus( int col, int row );
|
|
||||||
|
|
||||||
void setTimer( int why, int when, int handle );
|
|
||||||
void clearTimer( int why );
|
|
||||||
void requestTime();
|
|
||||||
|
|
||||||
// Don't need this unless we have a scroll thumb to indicate position
|
|
||||||
//void yOffsetChange( int oldOffset, int newOffset );
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
package org.eehouse.android.xw4.jni;
|
|
||||||
|
|
||||||
|
|
||||||
// Collection of native methods
|
|
||||||
public class XwJNI {
|
|
||||||
|
|
||||||
/* XW_TrayVisState enum */
|
|
||||||
public static final int TRAY_HIDDEN = 0;
|
|
||||||
public static final int TRAY_REVERSED = 1;
|
|
||||||
public static final int TRAY_REVEALED = 2;
|
|
||||||
|
|
||||||
// Methods not part of the common interface but necessitated by
|
|
||||||
// how java/jni work (or perhaps my limited understanding of it.)
|
|
||||||
|
|
||||||
// callback into jni from java when timer set here fires.
|
|
||||||
public static native boolean timerFired( int gamePtr, int why,
|
|
||||||
int when, int handle );
|
|
||||||
|
|
||||||
// Game methods
|
|
||||||
public static native int game_makeNewGame( CurGameInfo gi, XW_UtilCtxt util,
|
|
||||||
DrawCtx draw, int gameID, CommonPrefs cp,
|
|
||||||
TransportProcs procs, byte[] dict );
|
|
||||||
public static native void game_dispose( int gamePtr );
|
|
||||||
|
|
||||||
// Board methods
|
|
||||||
|
|
||||||
public static native void board_invalAll( int gamePtr );
|
|
||||||
public static native boolean board_draw( int gamePtr );
|
|
||||||
public static native void board_setPos( int gamePtr, int left, int top,
|
|
||||||
boolean lefty );
|
|
||||||
public static native void board_setScale( int gamePtr, int hscale, int vscale );
|
|
||||||
public static native boolean board_setShowColors( int gamePtr, boolean on );
|
|
||||||
public static native void board_setScoreboardLoc( int gamePtr, int left,
|
|
||||||
int top, int width,
|
|
||||||
int height,
|
|
||||||
boolean divideHorizontally );
|
|
||||||
public static native void board_setTrayLoc( int gamePtr, int left,
|
|
||||||
int top, int width,
|
|
||||||
int height, int minDividerWidth );
|
|
||||||
public static native boolean board_handlePenDown( int gamePtr, int xx, int yy,
|
|
||||||
boolean[] handled );
|
|
||||||
public static native boolean board_handlePenMove( int gamePtr, int xx, int yy );
|
|
||||||
public static native boolean board_handlePenUp( int gamePtr, int xx, int yy );
|
|
||||||
|
|
||||||
public static native boolean board_juggleTray( int gamePtr );
|
|
||||||
public static native int board_getTrayVisState( int gamePtr );
|
|
||||||
public static native boolean board_hideTray( int gamePtr );
|
|
||||||
public static native boolean board_showTray( int gamePtr );
|
|
||||||
public static native boolean board_commitTurn( int gamePtr );
|
|
||||||
public static native boolean board_flip( int gamePtr );
|
|
||||||
public static native boolean board_replaceTiles( int gamePtr );
|
|
||||||
public static native void board_resetEngine( int gamePtr );
|
|
||||||
public static native boolean board_requestHint( int gamePtr, boolean useTileLimits,
|
|
||||||
boolean[] workRemains );
|
|
||||||
|
|
||||||
public static native void server_handleUndo( int gamePtr );
|
|
||||||
public static native boolean server_do( int gamePtr );
|
|
||||||
}
|
|
|
@ -1,340 +0,0 @@
|
||||||
|
|
||||||
#include <jni.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "anddict.h"
|
|
||||||
#include "xptypes.h"
|
|
||||||
#include "dictnry.h"
|
|
||||||
#include "strutils.h"
|
|
||||||
|
|
||||||
typedef struct _AndDictionaryCtxt {
|
|
||||||
DictionaryCtxt super;
|
|
||||||
JNIEnv *env;
|
|
||||||
XP_U8* bytes;
|
|
||||||
} AndDictionaryCtxt;
|
|
||||||
|
|
||||||
void
|
|
||||||
dict_splitFaces( DictionaryCtxt* dict, const XP_U8* bytes,
|
|
||||||
XP_U16 nBytes, XP_U16 nFaces )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
|
|
||||||
XP_UCHAR* faces = (XP_UCHAR*)XP_CALLOC( dict->mpool, nBytes + nFaces );
|
|
||||||
XP_UCHAR** ptrs = (XP_UCHAR**)XP_CALLOC( dict->mpool, nFaces * sizeof(ptrs[0]));
|
|
||||||
XP_U16 ii;
|
|
||||||
XP_UCHAR* next = faces;
|
|
||||||
|
|
||||||
/* now split; this will not work for utf8!!! */
|
|
||||||
for ( ii = 0; ii < nFaces; ++ii ) {
|
|
||||||
ptrs[ii] = next;
|
|
||||||
*next++ = *bytes++;
|
|
||||||
*next++ = 0;
|
|
||||||
XP_LOGF( "pointing at str: %s", ptrs[ii] );
|
|
||||||
}
|
|
||||||
|
|
||||||
XP_ASSERT( next == faces + nFaces + nBytes );
|
|
||||||
XP_ASSERT( !dict->faces );
|
|
||||||
dict->faces = faces;
|
|
||||||
XP_ASSERT( !dict->facePtrs );
|
|
||||||
dict->facePtrs = ptrs;
|
|
||||||
}
|
|
||||||
|
|
||||||
static XP_U32
|
|
||||||
n_ptr_tohl( XP_U8** inp )
|
|
||||||
{
|
|
||||||
XP_U32 t;
|
|
||||||
XP_MEMCPY( &t, *inp, sizeof(t) );
|
|
||||||
|
|
||||||
*inp += sizeof(t);
|
|
||||||
|
|
||||||
return XP_NTOHL(t);
|
|
||||||
} /* n_ptr_tohl */
|
|
||||||
|
|
||||||
static XP_U16
|
|
||||||
n_ptr_tohs( XP_U8** inp )
|
|
||||||
{
|
|
||||||
XP_U16 t;
|
|
||||||
XP_MEMCPY( &t, *inp, sizeof(t) );
|
|
||||||
|
|
||||||
*inp += sizeof(t);
|
|
||||||
|
|
||||||
return XP_NTOHS(t);
|
|
||||||
} /* n_ptr_tohs */
|
|
||||||
|
|
||||||
static XP_U16
|
|
||||||
andCountSpecials( AndDictionaryCtxt* ctxt )
|
|
||||||
{
|
|
||||||
XP_U16 result = 0;
|
|
||||||
XP_U16 ii;
|
|
||||||
|
|
||||||
for ( ii = 0; ii < ctxt->super.nFaces; ++ii ) {
|
|
||||||
if ( IS_SPECIAL( ctxt->super.facePtrs[ii][0] ) ) {
|
|
||||||
++result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
} /* ceCountSpecials */
|
|
||||||
|
|
||||||
static XP_Bitmap
|
|
||||||
andMakeBitmap( XP_U8** ptrp )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
XP_U8* ptr = *ptrp;
|
|
||||||
XP_U8 nCols = *ptr++;
|
|
||||||
XP_Bitmap bitmap = NULL;
|
|
||||||
/* CEBitmapInfo* bitmap = (CEBitmapInfo*)NULL; */
|
|
||||||
|
|
||||||
if ( nCols > 0 ) {
|
|
||||||
XP_ASSERT(0);
|
|
||||||
#if 0
|
|
||||||
XP_U8* dest;
|
|
||||||
XP_U8* savedDest;
|
|
||||||
XP_U8 nRows = *ptr++;
|
|
||||||
XP_U16 rowBytes = (nCols+7) / 8;
|
|
||||||
XP_U8 srcByte = 0;
|
|
||||||
XP_U8 destByte = 0;
|
|
||||||
XP_U8 nBits;
|
|
||||||
XP_U16 i;
|
|
||||||
|
|
||||||
bitmap = (CEBitmapInfo*)XP_CALLOC( ctxt->super.mpool,
|
|
||||||
sizeof(bitmap) );
|
|
||||||
bitmap->nCols = nCols;
|
|
||||||
bitmap->nRows = nRows;
|
|
||||||
dest = XP_MALLOC( ctxt->super.mpool, rowBytes * nRows );
|
|
||||||
bitmap->bits = savedDest = dest;
|
|
||||||
|
|
||||||
nBits = nRows * nCols;
|
|
||||||
for ( i = 0; i < nBits; ++i ) {
|
|
||||||
XP_U8 srcBitIndex = i % 8;
|
|
||||||
XP_U8 destBitIndex = (i % nCols) % 8;
|
|
||||||
XP_U8 srcMask, bit;
|
|
||||||
|
|
||||||
if ( srcBitIndex == 0 ) {
|
|
||||||
srcByte = *ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
srcMask = 1 << (7 - srcBitIndex);
|
|
||||||
bit = (srcByte & srcMask) != 0;
|
|
||||||
destByte |= bit << (7 - destBitIndex);
|
|
||||||
|
|
||||||
/* we need to put the byte if we've filled it or if we're done
|
|
||||||
with the row */
|
|
||||||
if ( (destBitIndex==7) || ((i%nCols) == (nCols-1)) ) {
|
|
||||||
*dest++ = destByte;
|
|
||||||
destByte = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* printBitmapData1( nCols, nRows, savedDest ); */
|
|
||||||
/* printBitmapData2( nCols, nRows, savedDest ); */
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
*ptrp = ptr;
|
|
||||||
return (XP_Bitmap)bitmap;
|
|
||||||
} /* andMakeBitmap */
|
|
||||||
|
|
||||||
static void
|
|
||||||
andLoadSpecialData( AndDictionaryCtxt* ctxt, XP_U8** ptrp )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
XP_U16 nSpecials = andCountSpecials( ctxt );
|
|
||||||
XP_U8* ptr = *ptrp;
|
|
||||||
Tile ii;
|
|
||||||
XP_UCHAR** texts;
|
|
||||||
SpecialBitmaps* bitmaps;
|
|
||||||
|
|
||||||
texts = (XP_UCHAR**)XP_MALLOC( ctxt->super.mpool,
|
|
||||||
nSpecials * sizeof(*texts) );
|
|
||||||
bitmaps = (SpecialBitmaps*)
|
|
||||||
XP_CALLOC( ctxt->super.mpool, nSpecials * sizeof(*bitmaps) );
|
|
||||||
|
|
||||||
for ( ii = 0; ii < ctxt->super.nFaces; ++ii ) {
|
|
||||||
|
|
||||||
const XP_UCHAR* facep = ctxt->super.facePtrs[(short)ii];
|
|
||||||
if ( IS_SPECIAL(*facep) ) {
|
|
||||||
/* get the string */
|
|
||||||
XP_U8 txtlen = *ptr++;
|
|
||||||
XP_UCHAR* text = (XP_UCHAR*)XP_MALLOC(ctxt->super.mpool, txtlen+1);
|
|
||||||
XP_MEMCPY( text, ptr, txtlen );
|
|
||||||
ptr += txtlen;
|
|
||||||
text[txtlen] = '\0';
|
|
||||||
XP_ASSERT( *facep < nSpecials );
|
|
||||||
texts[(int)*facep] = text;
|
|
||||||
|
|
||||||
bitmaps[(int)*facep].largeBM = andMakeBitmap( &ptr );
|
|
||||||
bitmaps[(int)*facep].smallBM = andMakeBitmap( &ptr );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ctxt->super.chars = texts;
|
|
||||||
ctxt->super.bitmaps = bitmaps;
|
|
||||||
|
|
||||||
*ptrp = ptr;
|
|
||||||
LOG_RETURN_VOID();
|
|
||||||
} /* andLoadSpecialData */
|
|
||||||
|
|
||||||
static void
|
|
||||||
parseDict( AndDictionaryCtxt* ctxt, XP_U8* ptr, XP_U32 dictLength )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
while( !!ptr ) { /* lets us break.... */
|
|
||||||
XP_U32 offset;
|
|
||||||
XP_U16 numFaces, numFaceBytes = 0;
|
|
||||||
XP_U16 i;
|
|
||||||
XP_U16 flags;
|
|
||||||
void* mappedBase = (void*)ptr;
|
|
||||||
XP_U8 nodeSize;
|
|
||||||
XP_Bool isUTF8 = XP_FALSE;
|
|
||||||
|
|
||||||
flags = n_ptr_tohs( &ptr );
|
|
||||||
|
|
||||||
#ifdef NODE_CAN_4
|
|
||||||
if ( flags == 0x0002 ) {
|
|
||||||
nodeSize = 3;
|
|
||||||
} else if ( flags == 0x0003 ) {
|
|
||||||
nodeSize = 4;
|
|
||||||
} else if ( flags == 0x0004 ) {
|
|
||||||
isUTF8 = XP_TRUE;
|
|
||||||
nodeSize = 3;
|
|
||||||
} else if ( flags == 0x0005 ) {
|
|
||||||
isUTF8 = XP_TRUE;
|
|
||||||
nodeSize = 4;
|
|
||||||
} else {
|
|
||||||
break; /* we want to return NULL */
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if( flags != 0x0001 ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if ( isUTF8 ) {
|
|
||||||
numFaceBytes = (XP_U16)(*ptr++);
|
|
||||||
}
|
|
||||||
numFaces = (XP_U16)(*ptr++);
|
|
||||||
if ( numFaces > 64 ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctxt->super.nodeSize = nodeSize;
|
|
||||||
|
|
||||||
if ( !isUTF8 ) {
|
|
||||||
numFaceBytes = numFaces * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctxt->super.nFaces = (XP_U8)numFaces;
|
|
||||||
ctxt->super.isUTF8 = isUTF8;
|
|
||||||
|
|
||||||
if ( isUTF8 ) {
|
|
||||||
XP_ASSERT(0);
|
|
||||||
dict_splitFaces( &ctxt->super, ptr, numFaceBytes, numFaces );
|
|
||||||
ptr += numFaceBytes;
|
|
||||||
} else {
|
|
||||||
XP_U8 tmp[numFaces*4]; /* should be enough... */
|
|
||||||
XP_U16 nBytes = 0;
|
|
||||||
XP_U16 ii;
|
|
||||||
/* Need to translate from iso-8859-n to utf8 */
|
|
||||||
for ( ii = 0; ii < numFaces; ++ii ) {
|
|
||||||
XP_UCHAR ch = ptr[1];
|
|
||||||
|
|
||||||
ptr += 2;
|
|
||||||
|
|
||||||
tmp[nBytes] = ch;
|
|
||||||
nBytes += 1;
|
|
||||||
}
|
|
||||||
dict_splitFaces( &ctxt->super, tmp, nBytes, numFaces );
|
|
||||||
}
|
|
||||||
|
|
||||||
ctxt->super.is_4_byte = (ctxt->super.nodeSize == 4);
|
|
||||||
|
|
||||||
ctxt->super.countsAndValues =
|
|
||||||
(XP_U8*)XP_MALLOC(ctxt->super.mpool, numFaces*2);
|
|
||||||
|
|
||||||
ptr += 2; /* skip xloc header */
|
|
||||||
for ( i = 0; i < numFaces*2; i += 2 ) {
|
|
||||||
ctxt->super.countsAndValues[i] = *ptr++;
|
|
||||||
ctxt->super.countsAndValues[i+1] = *ptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
andLoadSpecialData( ctxt, &ptr );
|
|
||||||
|
|
||||||
dictLength -= ptr - (XP_U8*)mappedBase;
|
|
||||||
if ( dictLength > sizeof(XP_U32) ) {
|
|
||||||
offset = n_ptr_tohl( &ptr );
|
|
||||||
dictLength -= sizeof(offset);
|
|
||||||
#ifdef NODE_CAN_4
|
|
||||||
XP_ASSERT( dictLength % ctxt->super.nodeSize == 0 );
|
|
||||||
# ifdef DEBUG
|
|
||||||
ctxt->super.numEdges = dictLength / ctxt->super.nodeSize;
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
XP_ASSERT( dictLength % 3 == 0 );
|
|
||||||
# ifdef DEBUG
|
|
||||||
ctxt->super.numEdges = dictLength / 3;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
offset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( dictLength > 0 ) {
|
|
||||||
ctxt->super.base = (array_edge*)ptr;
|
|
||||||
#ifdef NODE_CAN_4
|
|
||||||
ctxt->super.topEdge = ctxt->super.base
|
|
||||||
+ (offset * ctxt->super.nodeSize);
|
|
||||||
#else
|
|
||||||
ctxt->super.topEdge = ctxt->super.base + (offset * 3);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
ctxt->super.topEdge = (array_edge*)NULL;
|
|
||||||
ctxt->super.base = (array_edge*)NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
setBlankTile( &ctxt->super );
|
|
||||||
|
|
||||||
ctxt->super.name = copyString(ctxt->super.mpool, "no name dict" );
|
|
||||||
break; /* exit phony while loop */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_dictionary_destroy( DictionaryCtxt* dict )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DictionaryCtxt*
|
|
||||||
makeDict( MPFORMAL JNIEnv *env, jbyteArray jbytes )
|
|
||||||
{
|
|
||||||
XP_Bool formatOk = XP_TRUE;
|
|
||||||
XP_Bool isUTF8 = XP_FALSE;
|
|
||||||
XP_U16 charSize;
|
|
||||||
LOG_FUNC();
|
|
||||||
AndDictionaryCtxt* anddict = NULL;
|
|
||||||
|
|
||||||
jsize len = (*env)->GetArrayLength( env, jbytes );
|
|
||||||
XP_LOGF( "%s: got %d bytes", __func__, len );
|
|
||||||
|
|
||||||
XP_U8* localBytes = XP_MALLOC( mpool, len );
|
|
||||||
jbyte* src = (*env)->GetByteArrayElements( env, jbytes, NULL );
|
|
||||||
XP_MEMCPY( localBytes, src, len );
|
|
||||||
(*env)->ReleaseByteArrayElements( env, jbytes, src, 0 );
|
|
||||||
|
|
||||||
anddict = (AndDictionaryCtxt*)XP_CALLOC( mpool, sizeof( *anddict ) );
|
|
||||||
dict_super_init( (DictionaryCtxt*)anddict );
|
|
||||||
anddict->super.destructor = and_dictionary_destroy;
|
|
||||||
/* anddict->super.func_dict_getShortName = and_dict_getShortName; */
|
|
||||||
|
|
||||||
MPASSIGN(anddict->super.mpool, mpool);
|
|
||||||
anddict->bytes = localBytes;
|
|
||||||
anddict->env = env;
|
|
||||||
|
|
||||||
parseDict( anddict, localBytes, len );
|
|
||||||
setBlankTile( &anddict->super );
|
|
||||||
|
|
||||||
err:
|
|
||||||
LOG_RETURNF( "%p", anddict );
|
|
||||||
return (DictionaryCtxt*)anddict;
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
#ifndef _ANDDICT_H_
|
|
||||||
#define _ANDDICT_H_
|
|
||||||
|
|
||||||
#include "dictnry.h"
|
|
||||||
|
|
||||||
void
|
|
||||||
dict_splitFaces( DictionaryCtxt* dict, const XP_U8* bytes,
|
|
||||||
XP_U16 nBytes, XP_U16 nFaces );
|
|
||||||
|
|
||||||
DictionaryCtxt* makeDict( MPFORMAL JNIEnv *env, jbyteArray bytes );
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,16 +0,0 @@
|
||||||
|
|
||||||
#ifndef _ANDGLOBALS_H_
|
|
||||||
#define _ANDGLOBALS_H_
|
|
||||||
|
|
||||||
#include "vtabmgr.h"
|
|
||||||
#include "dictnry.h"
|
|
||||||
|
|
||||||
typedef struct _AndGlobals {
|
|
||||||
VTableMgr* vtMgr;
|
|
||||||
CurGameInfo* gi;
|
|
||||||
DrawCtx* dctx;
|
|
||||||
DictionaryCtxt* dict;
|
|
||||||
XW_UtilCtxt* util;
|
|
||||||
} AndGlobals;
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,206 +0,0 @@
|
||||||
#include "andutils.h"
|
|
||||||
|
|
||||||
#include "comtypes.h"
|
|
||||||
|
|
||||||
void
|
|
||||||
and_assert( const char* test, int line, const char* file, const char* func )
|
|
||||||
{
|
|
||||||
XP_LOGF( "assertion \"%s\" failed: line %d in %s() in %s",
|
|
||||||
test, line, file, func );
|
|
||||||
__android_log_assert( test, "ASSERT", "line %d in %s() in %s",
|
|
||||||
line, file, func );
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __LITTLE_ENDIAN
|
|
||||||
|
|
||||||
XP_U32
|
|
||||||
and_ntohl(XP_U32 l)
|
|
||||||
{
|
|
||||||
XP_U32 result = 0L;
|
|
||||||
result |= l << 24;
|
|
||||||
result |= (l << 16) & 0x00FF0000;
|
|
||||||
result |= (l >> 16) & 0x0000FF00;
|
|
||||||
result |= (l >> 24);
|
|
||||||
|
|
||||||
XP_LOGF( "%s: %lx -> %lx", __func__, l, result );
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
XP_U16
|
|
||||||
and_ntohs(XP_U16 s)
|
|
||||||
{
|
|
||||||
XP_U16 result;
|
|
||||||
result = s << 8;
|
|
||||||
result |= s >> 8;
|
|
||||||
|
|
||||||
XP_LOGF( "%s: %x -> %x", __func__, s, result );
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
XP_U32
|
|
||||||
and_htonl(XP_U32 l)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
XP_U16
|
|
||||||
and_htons(XP_U16 s)
|
|
||||||
{
|
|
||||||
return and_ntohs( s );
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool
|
|
||||||
getInt( JNIEnv* env, jobject obj, const char* name, int* result )
|
|
||||||
{
|
|
||||||
bool success = false;
|
|
||||||
jclass cls = (*env)->GetObjectClass( env, obj );
|
|
||||||
jfieldID fid = (*env)->GetFieldID( env, cls, name, "I");
|
|
||||||
if ( 0 != fid ) {
|
|
||||||
*result = (*env)->GetIntField( env, obj, fid );
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
(*env)->DeleteLocalRef( env, cls );
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
setInt( JNIEnv* env, jobject obj, const char* name, int value )
|
|
||||||
{
|
|
||||||
bool success = false;
|
|
||||||
jclass cls = (*env)->GetObjectClass( env, obj );
|
|
||||||
jfieldID fid = (*env)->GetFieldID( env, cls, name, "I");
|
|
||||||
if ( 0 != fid ) {
|
|
||||||
(*env)->SetIntField( env, obj, fid, value );
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
(*env)->DeleteLocalRef( env, cls );
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
setBool( JNIEnv* env, jobject obj, const char* name, bool value )
|
|
||||||
{
|
|
||||||
bool success = false;
|
|
||||||
jclass cls = (*env)->GetObjectClass( env, obj );
|
|
||||||
jfieldID fid = (*env)->GetFieldID( env, cls, name, "Z");
|
|
||||||
if ( 0 != fid ) {
|
|
||||||
(*env)->SetBooleanField( env, obj, fid, value );
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
(*env)->DeleteLocalRef( env, cls );
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
setString( JNIEnv* env, jobject obj, const char* name, const XP_UCHAR* value )
|
|
||||||
{
|
|
||||||
bool success = false;
|
|
||||||
jclass cls = (*env)->GetObjectClass( env, obj );
|
|
||||||
jfieldID fid = (*env)->GetFieldID( env, cls, name, "Ljava/lang/String;" );
|
|
||||||
if ( 0 != fid ) {
|
|
||||||
jstring str = (*env)->NewStringUTF( env, value );
|
|
||||||
(*env)->SetObjectField( env, obj, fid, str );
|
|
||||||
success = true;
|
|
||||||
(*env)->DeleteLocalRef( env, str );
|
|
||||||
}
|
|
||||||
(*env)->DeleteLocalRef( env, cls );
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
getString( JNIEnv* env, jobject obj, const char* name, XP_UCHAR* buf,
|
|
||||||
int bufLen )
|
|
||||||
{
|
|
||||||
jclass cls = (*env)->GetObjectClass( env, obj );
|
|
||||||
XP_ASSERT( !!cls );
|
|
||||||
jfieldID fid = (*env)->GetFieldID( env, cls, name, "Ljava/lang/String;" );
|
|
||||||
XP_ASSERT( !!fid );
|
|
||||||
jstring jstr = (*env)->GetObjectField( env, obj, fid );
|
|
||||||
XP_ASSERT( !!jstr );
|
|
||||||
|
|
||||||
jsize len = (*env)->GetStringUTFLength( env, jstr );
|
|
||||||
XP_ASSERT( len < bufLen );
|
|
||||||
const char* chars = (*env)->GetStringUTFChars( env, jstr, NULL );
|
|
||||||
XP_MEMCPY( buf, chars, len );
|
|
||||||
(*env)->ReleaseStringUTFChars( env, jstr, chars );
|
|
||||||
buf[len] = '\0';
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, cls );
|
|
||||||
(*env)->DeleteLocalRef( env, jstr );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
getObject( JNIEnv* env, jobject obj, const char* name, const char* sig,
|
|
||||||
jobject* ret )
|
|
||||||
{
|
|
||||||
jclass cls = (*env)->GetObjectClass( env, obj );
|
|
||||||
XP_ASSERT( !!cls );
|
|
||||||
jfieldID fid = (*env)->GetFieldID( env, cls, name, sig );
|
|
||||||
XP_ASSERT( !!fid ); /* failed */
|
|
||||||
*ret = (*env)->GetObjectField( env, obj, fid );
|
|
||||||
XP_ASSERT( !!*ret );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, cls );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* return false on failure, e.g. exception raised */
|
|
||||||
bool
|
|
||||||
getBool( JNIEnv* env, jobject obj, const char* name, XP_Bool* result )
|
|
||||||
{
|
|
||||||
bool success = false;
|
|
||||||
jclass cls = (*env)->GetObjectClass( env, obj );
|
|
||||||
XP_ASSERT( !!cls );
|
|
||||||
jfieldID fid = (*env)->GetFieldID( env, cls, name, "Z");
|
|
||||||
XP_ASSERT( !!fid );
|
|
||||||
if ( 0 != fid ) {
|
|
||||||
*result = (*env)->GetBooleanField( env, obj, fid );
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
(*env)->DeleteLocalRef( env, cls );
|
|
||||||
XP_ASSERT( success );
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
jintArray
|
|
||||||
makeIntArray( JNIEnv *env, int siz, const jint* vals )
|
|
||||||
{
|
|
||||||
jintArray array = (*env)->NewIntArray( env, siz );
|
|
||||||
XP_ASSERT( !!array );
|
|
||||||
if ( !!vals ) {
|
|
||||||
jint* elems = (*env)->GetIntArrayElements( env, array, NULL );
|
|
||||||
XP_ASSERT( !!elems );
|
|
||||||
XP_MEMCPY( elems, vals, siz * sizeof(*elems) );
|
|
||||||
(*env)->ReleaseIntArrayElements( env, array, elems, 0 );
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
getIntFromArray( JNIEnv* env, jintArray arr, bool del )
|
|
||||||
{
|
|
||||||
jint* ints = (*env)->GetIntArrayElements(env, arr, 0);
|
|
||||||
int result = ints[0];
|
|
||||||
(*env)->ReleaseIntArrayElements( env, arr, ints, 0);
|
|
||||||
if ( del ) {
|
|
||||||
(*env)->DeleteLocalRef( env, arr );
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
jmethodID
|
|
||||||
getMethodID( JNIEnv* env, jobject obj, const char* proc, const char* sig )
|
|
||||||
{
|
|
||||||
XP_ASSERT( !!env );
|
|
||||||
jclass cls = (*env)->GetObjectClass( env, obj );
|
|
||||||
XP_ASSERT( !!cls );
|
|
||||||
jmethodID mid = (*env)->GetMethodID( env, cls, proc, sig );
|
|
||||||
XP_ASSERT( !!mid );
|
|
||||||
(*env)->DeleteLocalRef( env, cls );
|
|
||||||
return mid;
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
#ifndef _ANDUTILS_H_
|
|
||||||
#define _ANDUTILS_H_
|
|
||||||
|
|
||||||
#include <jni.h>
|
|
||||||
|
|
||||||
#include "xptypes.h"
|
|
||||||
|
|
||||||
XP_U32 and_ntohl(XP_U32 l);
|
|
||||||
XP_U16 and_ntohs(XP_U16 l);
|
|
||||||
XP_U32 and_htonl(XP_U32 l);
|
|
||||||
XP_U16 and_htons(XP_U16 l);
|
|
||||||
|
|
||||||
bool getInt( JNIEnv* env, jobject obj, const char* name, int* result );
|
|
||||||
bool setInt( JNIEnv* env, jobject obj, const char* name, int value );
|
|
||||||
bool getBool( JNIEnv* env, jobject obj, const char* name, XP_Bool* result );
|
|
||||||
bool setBool( JNIEnv* env, jobject obj, const char* name, bool value );
|
|
||||||
bool setString( JNIEnv* env, jobject obj, const char* name, const XP_UCHAR* value );
|
|
||||||
bool getString( JNIEnv* env, jobject jlp, const char* name, XP_UCHAR* buf,
|
|
||||||
int bufLen );
|
|
||||||
bool getObject( JNIEnv* env, jobject obj, const char* name, const char* sig,
|
|
||||||
jobject* ret );
|
|
||||||
|
|
||||||
jintArray makeIntArray( JNIEnv *env, int size, const jint* vals );
|
|
||||||
int getIntFromArray( JNIEnv* env, jintArray arr, bool del );
|
|
||||||
|
|
||||||
/* Note: jmethodID can be cached. Should not look up more than once. */
|
|
||||||
jmethodID getMethodID( JNIEnv* env, jobject obj, const char* proc,
|
|
||||||
const char* sig );
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,493 +0,0 @@
|
||||||
/* -*-mode: C; compile-command: "cd XWords4; ../scripts/ndkbuild.sh"; -*- */
|
|
||||||
/*
|
|
||||||
* Copyright 2001-2009 by Eric House (xwords@eehouse.org). All rights
|
|
||||||
* reserved.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "drawwrapper.h"
|
|
||||||
#include "andutils.h"
|
|
||||||
|
|
||||||
typedef struct _AndDraw {
|
|
||||||
DrawCtxVTable* vtable;
|
|
||||||
JNIEnv *env;
|
|
||||||
jobject j_draw; /* global ref; free it! */
|
|
||||||
} AndDraw;
|
|
||||||
|
|
||||||
static jobject
|
|
||||||
makeJRect( JNIEnv *env, const XP_Rect* rect )
|
|
||||||
{
|
|
||||||
jclass rclass = (*env)->FindClass( env, "android/graphics/Rect");
|
|
||||||
jmethodID initId = (*env)->GetMethodID( env, rclass, "<init>", "(IIII)V" );
|
|
||||||
jobject robj = (*env)->NewObject( env, rclass, initId, rect->left, rect->top,
|
|
||||||
rect->left + rect->width,
|
|
||||||
rect->top + rect->height );
|
|
||||||
#ifdef DEBUG
|
|
||||||
int test;
|
|
||||||
XP_ASSERT( getInt( env, robj, "left", &test ) && (test == rect->left) );
|
|
||||||
XP_ASSERT( getInt( env, robj, "top", &test ) && (test == rect->top) );
|
|
||||||
XP_ASSERT( getInt( env, robj, "right", &test )
|
|
||||||
&& (test == rect->left + rect->width ) );
|
|
||||||
XP_ASSERT( getInt( env, robj, "bottom", &test )
|
|
||||||
&& (test == rect->top + rect->height ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, rclass );
|
|
||||||
return robj;
|
|
||||||
} /* makeJRect */
|
|
||||||
|
|
||||||
static void
|
|
||||||
copyJRect( JNIEnv* env, XP_Rect* dest, jobject jrect )
|
|
||||||
{
|
|
||||||
int tmp;
|
|
||||||
getInt( env, jrect, "left", &tmp );
|
|
||||||
dest->left = tmp;
|
|
||||||
getInt( env, jrect, "top", &tmp );
|
|
||||||
dest->top = tmp;
|
|
||||||
getInt( env, jrect, "right", &tmp );
|
|
||||||
dest->width = tmp - dest->left;
|
|
||||||
getInt( env, jrect, "bottom", &tmp );
|
|
||||||
dest->height = tmp - dest->top;
|
|
||||||
}
|
|
||||||
|
|
||||||
static jobject
|
|
||||||
makeDSI( JNIEnv* env, const DrawScoreInfo* dsi )
|
|
||||||
{
|
|
||||||
jclass rclass = (*env)->FindClass( env, "org/eehouse/android/xw4/jni/DrawScoreInfo");
|
|
||||||
jmethodID initId = (*env)->GetMethodID( env, rclass, "<init>", "()V" );
|
|
||||||
jobject dsiobj = (*env)->NewObject( env, rclass, initId );
|
|
||||||
|
|
||||||
/* public String name; */
|
|
||||||
/* public int playerNum; */
|
|
||||||
/* public int totalScore; */
|
|
||||||
/* public int nTilesLeft; /\* < 0 means don't use *\/ */
|
|
||||||
/* public int flags; // was CellFlags; use CELL_ constants above */
|
|
||||||
/* public boolean isTurn; */
|
|
||||||
/* public boolean selected; */
|
|
||||||
/* public boolean isRemote; */
|
|
||||||
/* public boolean isRobot; */
|
|
||||||
|
|
||||||
|
|
||||||
bool success = setInt( env, dsiobj, "playerNum", dsi->playerNum )
|
|
||||||
&& setInt( env, dsiobj, "totalScore", dsi->totalScore )
|
|
||||||
&& setInt( env, dsiobj, "nTilesLeft", dsi->nTilesLeft )
|
|
||||||
&& setInt( env, dsiobj, "flags", dsi->flags )
|
|
||||||
&& setBool( env, dsiobj, "isTurn", dsi->isTurn )
|
|
||||||
&& setBool( env, dsiobj, "selected", dsi->selected )
|
|
||||||
&& setBool( env, dsiobj, "isRemote", dsi->isRemote )
|
|
||||||
&& setBool( env, dsiobj, "isRobot", dsi->isRobot )
|
|
||||||
&& setString( env, dsiobj, "name", dsi->name )
|
|
||||||
;
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, rclass );
|
|
||||||
|
|
||||||
return dsiobj;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_scoreBegin( DrawCtx* dctx, const XP_Rect* rect,
|
|
||||||
XP_U16 numPlayers,
|
|
||||||
const XP_S16* const scores,
|
|
||||||
XP_S16 remCount, DrawFocusState dfs )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;I[III)V";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "scoreBegin", sig );
|
|
||||||
|
|
||||||
jint jarr[numPlayers];
|
|
||||||
int ii;
|
|
||||||
for ( ii = 0; ii < numPlayers; ++ii ) {
|
|
||||||
jarr[ii] = scores[ii];
|
|
||||||
}
|
|
||||||
jintArray jscores = makeIntArray( env, numPlayers, jarr );
|
|
||||||
jobject jrect = makeJRect( env, rect );
|
|
||||||
|
|
||||||
(*env)->CallVoidMethod( env, draw->j_draw, mid,
|
|
||||||
jrect, numPlayers, jscores, remCount, dfs );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jscores );
|
|
||||||
(*env)->DeleteLocalRef( env, jrect );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_measureRemText( DrawCtx* dctx, const XP_Rect* r,
|
|
||||||
XP_S16 nTilesLeft,
|
|
||||||
XP_U16* width, XP_U16* height )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;I[I[I)V";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "measureRemText", sig );
|
|
||||||
|
|
||||||
jintArray widthArray = makeIntArray( env, 1, NULL );
|
|
||||||
jintArray heightArray = makeIntArray( env, 1, NULL );
|
|
||||||
jobject jrect = makeJRect( env, r );
|
|
||||||
|
|
||||||
(*env)->CallVoidMethod( env, draw->j_draw, mid, jrect, nTilesLeft, widthArray,
|
|
||||||
heightArray );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jrect );
|
|
||||||
|
|
||||||
*width = getIntFromArray( env, widthArray, true );
|
|
||||||
*height = getIntFromArray( env, heightArray, true );
|
|
||||||
} /* and_draw_measureRemText */
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_measureScoreText( DrawCtx* dctx,
|
|
||||||
const XP_Rect* r,
|
|
||||||
const DrawScoreInfo* dsi,
|
|
||||||
XP_U16* width, XP_U16* height )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
|
|
||||||
jobject jrect = makeJRect( env, r );
|
|
||||||
jobject jdsi = makeDSI( env, dsi );
|
|
||||||
|
|
||||||
jintArray widthArray = makeIntArray( env, 1, NULL );
|
|
||||||
jintArray heightArray = makeIntArray( env, 1, NULL );
|
|
||||||
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "measureScoreText",
|
|
||||||
"(Landroid/graphics/Rect;Lorg/eehouse/android/"
|
|
||||||
"xw4/jni/DrawScoreInfo;[I[I)V" );
|
|
||||||
(*env)->CallVoidMethod( env, draw->j_draw, mid, jrect, jdsi,
|
|
||||||
widthArray, heightArray );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jrect );
|
|
||||||
(*env)->DeleteLocalRef( env, jdsi );
|
|
||||||
|
|
||||||
*width = getIntFromArray( env, widthArray, true );
|
|
||||||
*height = getIntFromArray( env, heightArray, true );
|
|
||||||
} /* and_draw_measureScoreText */
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_drawRemText( DrawCtx* dctx, const XP_Rect* rInner,
|
|
||||||
const XP_Rect* rOuter,
|
|
||||||
XP_S16 nTilesLeft, XP_Bool focussed )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;Landroid/graphics/Rect;IZ)V";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "drawRemText", sig );
|
|
||||||
|
|
||||||
jobject jrinner = makeJRect( env, rInner );
|
|
||||||
jobject jrouter = makeJRect( env, rOuter );
|
|
||||||
|
|
||||||
(*env)->CallVoidMethod( env, draw->j_draw, mid, jrinner, jrouter, nTilesLeft,
|
|
||||||
focussed );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jrinner );
|
|
||||||
(*env)->DeleteLocalRef( env, jrouter );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_score_drawPlayer( DrawCtx* dctx,
|
|
||||||
const XP_Rect* rInner,
|
|
||||||
const XP_Rect* rOuter,
|
|
||||||
const DrawScoreInfo* dsi )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;Landroid/graphics/Rect;"
|
|
||||||
"Lorg/eehouse/android/xw4/jni/DrawScoreInfo;)V";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "score_drawPlayer", sig );
|
|
||||||
|
|
||||||
jobject jrinner = makeJRect( env, rInner );
|
|
||||||
jobject jrouter = makeJRect( env, rOuter );
|
|
||||||
jobject jdsi = makeDSI( env, dsi );
|
|
||||||
|
|
||||||
(*env)->CallVoidMethod( env, draw->j_draw, mid, jrinner, jrouter, jdsi );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jrinner);
|
|
||||||
(*env)->DeleteLocalRef( env, jrouter );
|
|
||||||
(*env)->DeleteLocalRef( env, jdsi );
|
|
||||||
} /* and_draw_score_drawPlayer */
|
|
||||||
|
|
||||||
static XP_Bool
|
|
||||||
and_draw_boardBegin( DrawCtx* dctx, const XP_Rect* rect, DrawFocusState dfs )
|
|
||||||
{
|
|
||||||
return XP_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static XP_Bool
|
|
||||||
and_draw_drawCell( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text,
|
|
||||||
const XP_Bitmaps* bitmaps, Tile tile, XP_S16 owner,
|
|
||||||
XWBonusType bonus, HintAtts hintAtts, CellFlags flags )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;Ljava/lang/String;"
|
|
||||||
"[Ljava/lang/Object;IIIII)Z";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "drawCell", sig );
|
|
||||||
|
|
||||||
jobject jrect = makeJRect( env, rect );
|
|
||||||
jstring jtext = NULL;
|
|
||||||
if ( !!text ) {
|
|
||||||
jtext = (*env)->NewStringUTF( env, text );
|
|
||||||
}
|
|
||||||
|
|
||||||
jboolean result = (*env)->CallBooleanMethod( env, draw->j_draw, mid,
|
|
||||||
jrect, jtext, NULL, tile,
|
|
||||||
owner, bonus, hintAtts,
|
|
||||||
flags );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jrect );
|
|
||||||
if ( !!jtext ) {
|
|
||||||
(*env)->DeleteLocalRef( env, jtext );
|
|
||||||
}
|
|
||||||
|
|
||||||
return XP_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_drawBoardArrow(DrawCtx* dctx, const XP_Rect* rect, XWBonusType bonus,
|
|
||||||
XP_Bool vert, HintAtts hintAtts, CellFlags flags )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;IZII)V";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "drawBoardArrow", sig );
|
|
||||||
|
|
||||||
jobject jrect = makeJRect( env, rect );
|
|
||||||
(*env)->CallVoidMethod( env, draw->j_draw, mid,
|
|
||||||
jrect, bonus, vert, hintAtts, flags );
|
|
||||||
(*env)->DeleteLocalRef( env, jrect );
|
|
||||||
}
|
|
||||||
|
|
||||||
static XP_Bool
|
|
||||||
and_draw_vertScrollBoard( DrawCtx* dctx, XP_Rect* rect, XP_S16 dist,
|
|
||||||
DrawFocusState dfs )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;II)Z";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "vertScrollBoard", sig );
|
|
||||||
jobject jrect = makeJRect( env, rect );
|
|
||||||
jboolean result = (*env)->CallBooleanMethod( env, draw->j_draw, mid,
|
|
||||||
jrect, dist, dfs );
|
|
||||||
copyJRect( env, rect, jrect );
|
|
||||||
(*env)->DeleteLocalRef( env, jrect );
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static XP_Bool
|
|
||||||
and_draw_trayBegin( DrawCtx* dctx, const XP_Rect* rect, XP_U16 owner,
|
|
||||||
DrawFocusState dfs )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;II)Z";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "trayBegin", sig );
|
|
||||||
|
|
||||||
jobject jrect = makeJRect( env, rect );
|
|
||||||
|
|
||||||
jboolean result = (*env)->CallBooleanMethod( env, draw->j_draw, mid,
|
|
||||||
jrect, owner, (jint)dfs );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jrect );
|
|
||||||
|
|
||||||
return XP_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_drawTile( DrawCtx* dctx, const XP_Rect* rect, const XP_UCHAR* text,
|
|
||||||
const XP_Bitmaps* bitmaps, XP_U16 val, CellFlags flags )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;Ljava/lang/String;"
|
|
||||||
"[Ljava/lang/Object;II)V";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "drawTile", sig );
|
|
||||||
|
|
||||||
jobject jrect = makeJRect( env, rect );
|
|
||||||
jstring jtext = NULL;
|
|
||||||
if ( !!text ) {
|
|
||||||
jtext = (*env)->NewStringUTF( env, text );
|
|
||||||
}
|
|
||||||
|
|
||||||
(*env)->CallVoidMethod( env, draw->j_draw, mid,
|
|
||||||
jrect, jtext, NULL, val, flags );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jrect );
|
|
||||||
if ( !!jtext ) {
|
|
||||||
(*env)->DeleteLocalRef( env, jtext );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_drawTileMidDrag( DrawCtx* dctx, const XP_Rect* rect,
|
|
||||||
const XP_UCHAR* text, const XP_Bitmaps* bitmaps,
|
|
||||||
XP_U16 val, XP_U16 owner, CellFlags flags )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;Ljava/lang/String;"
|
|
||||||
"[Ljava/lang/Object;III)V";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "drawTileMidDrag", sig );
|
|
||||||
|
|
||||||
jobject jrect = makeJRect( env, rect );
|
|
||||||
jstring jtext = NULL;
|
|
||||||
if ( !!text ) {
|
|
||||||
jtext = (*env)->NewStringUTF( env, text );
|
|
||||||
}
|
|
||||||
|
|
||||||
(*env)->CallVoidMethod( env, draw->j_draw, mid,
|
|
||||||
jrect, jtext, NULL, val, owner, flags );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jrect );
|
|
||||||
if ( !!jtext ) {
|
|
||||||
(*env)->DeleteLocalRef( env, jtext );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_drawTileBack( DrawCtx* dctx, const XP_Rect* rect, CellFlags flags )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;I)V";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "drawTileBack", sig );
|
|
||||||
|
|
||||||
jobject jrect = makeJRect( env, rect );
|
|
||||||
|
|
||||||
(*env)->CallVoidMethod( env, draw->j_draw, mid,
|
|
||||||
jrect, flags );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jrect );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_drawTrayDivider( DrawCtx* dctx, const XP_Rect* rect, CellFlags flags )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;I)V";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "drawTrayDivider", sig );
|
|
||||||
|
|
||||||
jobject jrect = makeJRect( env, rect );
|
|
||||||
|
|
||||||
(*env)->CallVoidMethod( env, draw->j_draw, mid,
|
|
||||||
jrect, flags );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jrect );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_score_pendingScore( DrawCtx* dctx, const XP_Rect* rect,
|
|
||||||
XP_S16 score, XP_U16 playerNum,
|
|
||||||
CellFlags flags )
|
|
||||||
{
|
|
||||||
AndDraw* draw = (AndDraw*)dctx;
|
|
||||||
JNIEnv* env = draw->env;
|
|
||||||
const char* sig = "(Landroid/graphics/Rect;III)V";
|
|
||||||
jmethodID mid = getMethodID( env, draw->j_draw, "score_pendingScore", sig );
|
|
||||||
|
|
||||||
jobject jrect = makeJRect( env, rect );
|
|
||||||
|
|
||||||
(*env)->CallVoidMethod( env, draw->j_draw, mid,
|
|
||||||
jrect, score, playerNum, flags );
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jrect );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_objFinished( DrawCtx* dctx, BoardObjectType typ,
|
|
||||||
const XP_Rect* rect,
|
|
||||||
DrawFocusState dfs )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_dictChanged( DrawCtx* dctx, const DictionaryCtxt* dict )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
static const XP_UCHAR*
|
|
||||||
and_draw_getMiniWText( DrawCtx* dctx, XWMiniTextType textHint )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
return "hi";
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_measureMiniWText( DrawCtx* dctx, const XP_UCHAR* textP,
|
|
||||||
XP_U16* width, XP_U16* height )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_draw_drawMiniWindow( DrawCtx* dctx, const XP_UCHAR* text,
|
|
||||||
const XP_Rect* rect, void** closure )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
static XP_Bool
|
|
||||||
draw_doNothing( DrawCtx* dctx, ... )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
return XP_FALSE;
|
|
||||||
} /* draw_doNothing */
|
|
||||||
|
|
||||||
DrawCtx*
|
|
||||||
makeDraw( MPFORMAL JNIEnv *env, jobject j_draw )
|
|
||||||
{
|
|
||||||
AndDraw* draw = XP_MALLOC( mpool, sizeof(*draw) );
|
|
||||||
XP_MEMSET( draw, 0, sizeof(*draw) );
|
|
||||||
draw->vtable = XP_MALLOC( mpool, sizeof(*draw->vtable) );
|
|
||||||
draw->j_draw = (*env)->NewGlobalRef( env, j_draw );
|
|
||||||
draw->env = env;
|
|
||||||
|
|
||||||
int ii;
|
|
||||||
for ( ii = 0; ii < sizeof(*draw->vtable)/4; ++ii ) {
|
|
||||||
((void**)(draw->vtable))[ii] = draw_doNothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SET_PROC(nam) draw->vtable->m_draw_##nam = and_draw_##nam
|
|
||||||
SET_PROC(boardBegin);
|
|
||||||
SET_PROC(scoreBegin);
|
|
||||||
SET_PROC(measureRemText);
|
|
||||||
SET_PROC(measureScoreText);
|
|
||||||
SET_PROC(drawRemText);
|
|
||||||
SET_PROC(score_drawPlayer);
|
|
||||||
SET_PROC(drawCell);
|
|
||||||
SET_PROC(drawBoardArrow);
|
|
||||||
SET_PROC(vertScrollBoard);
|
|
||||||
|
|
||||||
SET_PROC(trayBegin);
|
|
||||||
SET_PROC(drawTile);
|
|
||||||
SET_PROC(drawTileMidDrag);
|
|
||||||
SET_PROC(drawTileBack);
|
|
||||||
SET_PROC(drawTrayDivider);
|
|
||||||
SET_PROC(score_pendingScore);
|
|
||||||
|
|
||||||
SET_PROC(objFinished);
|
|
||||||
SET_PROC(dictChanged);
|
|
||||||
|
|
||||||
SET_PROC(getMiniWText);
|
|
||||||
SET_PROC(measureMiniWText);
|
|
||||||
SET_PROC(drawMiniWindow);
|
|
||||||
|
|
||||||
#undef SET_PROC
|
|
||||||
|
|
||||||
return (DrawCtx*)draw;
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
/* -*-mode: C; fill-column: 76; c-basic-offset: 4; -*- */
|
|
||||||
/*
|
|
||||||
* Copyright 2001-2009 by Eric House (xwords@eehouse.org). All rights
|
|
||||||
* reserved.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _DRAWWRAPPER_H_
|
|
||||||
#define _DRAWWRAPPER_H_
|
|
||||||
|
|
||||||
#include <jni.h>
|
|
||||||
|
|
||||||
#include "draw.h"
|
|
||||||
|
|
||||||
DrawCtx* makeDraw( MPFORMAL JNIEnv *env, jobject j_draw );
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,30 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo "usage: $0 [<package-unsigned.apk>]" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FILES="$1"
|
|
||||||
|
|
||||||
if [ -z "$FILES" ]; then
|
|
||||||
FILES=$(ls $(dirname $0)/../*/bin/*-unsigned.apk)
|
|
||||||
if [ -z "$FILES" ]; then
|
|
||||||
echo "unable to find any unsigned packages" >&2
|
|
||||||
usage
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
for PACK_UNSIGNED in $FILES; do
|
|
||||||
echo $FILE
|
|
||||||
|
|
||||||
PACK_SIGNED=$(basename $PACK_UNSIGNED)
|
|
||||||
echo "base: $PACK_SIGNED"
|
|
||||||
PACK_SIGNED=${PACK_SIGNED/-unsigned}
|
|
||||||
echo "signed: $PACK_SIGNED"
|
|
||||||
jarsigner -verbose -keystore ~/.keystore $PACK_UNSIGNED mykey
|
|
||||||
rm -f $PACK_SIGNED
|
|
||||||
zipalign -v 4 $PACK_UNSIGNED $PACK_SIGNED
|
|
||||||
[ -n "$XW_WWW_PATH" ] && cp $PACK_SIGNED $XW_WWW_PATH
|
|
||||||
done
|
|
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
BASE=$(dirname $0)
|
|
||||||
cd $BASE/../XWords4/bin/classes
|
|
||||||
|
|
||||||
javah -o /tmp/javah$$.txt org.eehouse.android.xw4.jni.XwJNI
|
|
||||||
javap -s org.eehouse.android.xw4.jni.DrawCtx
|
|
||||||
javap -s org.eehouse.android.xw4.jni.XW_UtilCtxt
|
|
||||||
cat /tmp/javah$$.txt
|
|
||||||
rm /tmp/javah$$.txt
|
|
|
@ -1,41 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
APP=xwords4
|
|
||||||
|
|
||||||
OLDDIR=$(pwd)
|
|
||||||
|
|
||||||
if [ -z "$NDK_ROOT" ]; then
|
|
||||||
echo -n "NDK_ROOT not set... "
|
|
||||||
NDK_ROOT="$HOME/android-ndk-1.5_r1"
|
|
||||||
if [ -d $NDK_ROOT ]; then
|
|
||||||
echo "using $NDK_ROOT"
|
|
||||||
else
|
|
||||||
echo "NDK not found; install and set NDK_ROOT to point to it"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $(dirname $0)
|
|
||||||
cd ../
|
|
||||||
|
|
||||||
if [ -h $NDK_ROOT/sources/$APP -a $(readlink $NDK_ROOT/sources/$APP) != $(pwd) ]; then
|
|
||||||
rm $NDK_ROOT/sources/$APP
|
|
||||||
fi
|
|
||||||
if [ ! -h $NDK_ROOT/sources/$APP ]; then
|
|
||||||
echo "adding symlink to sources"
|
|
||||||
ln -sf $(pwd) $NDK_ROOT/sources/$APP
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -h $NDK_ROOT/apps/$APP -a $(readlink $NDK_ROOT/apps/$APP) != $(pwd) ]; then
|
|
||||||
rm $NDK_ROOT/apps/$APP
|
|
||||||
fi
|
|
||||||
if [ ! -h $NDK_ROOT/apps/$APP ]; then
|
|
||||||
echo "adding symlink to apps"
|
|
||||||
ln -sf $(pwd) $NDK_ROOT/apps/$APP
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $NDK_ROOT
|
|
||||||
make APP=$APP
|
|
||||||
|
|
||||||
cd $OLDDIR
|
|
||||||
echo "$0 done"
|
|
|
@ -1,7 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
XP_U32 and_ntohl(XP_U32 l);
|
|
||||||
XP_U16 and_ntohs(XP_U16 l);
|
|
||||||
XP_U32 and_htonl(XP_U32 l);
|
|
||||||
XP_U16 and_htons(XP_U16 l);
|
|
|
@ -1,326 +0,0 @@
|
||||||
/* -*-mode: C; fill-column: 76; c-basic-offset: 4; -*- */
|
|
||||||
/*
|
|
||||||
* Copyright 2001-2009 by Eric House (xwords@eehouse.org). All rights
|
|
||||||
* reserved.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
#include <jni.h>
|
|
||||||
#include "utilwrapper.h"
|
|
||||||
#include "andutils.h"
|
|
||||||
|
|
||||||
typedef struct _TimerStorage {
|
|
||||||
XWTimerProc proc;
|
|
||||||
void* closure;
|
|
||||||
} TimerStorage;
|
|
||||||
|
|
||||||
typedef struct _AndUtil {
|
|
||||||
XW_UtilCtxt util;
|
|
||||||
JNIEnv* env;
|
|
||||||
jobject j_util; /* global ref to object implementing XW_UtilCtxt */
|
|
||||||
TimerStorage timerStorage[NUM_TIMERS_PLUS_ONE];
|
|
||||||
} AndUtil;
|
|
||||||
|
|
||||||
|
|
||||||
static VTableMgr*
|
|
||||||
and_util_getVTManager( XW_UtilCtxt* uc )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
AndGlobals* globals = (AndGlobals*)uc->closure;
|
|
||||||
return globals->vtMgr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
|
||||||
static XWStreamCtxt*
|
|
||||||
and_util_makeStreamFromAddr( XW_UtilCtxt* uc, XP_PlayerAddr channelNo )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static XWBonusType and_util_getSquareBonus( XW_UtilCtxt* uc,
|
|
||||||
const ModelCtxt* XP_UNUSED(model),
|
|
||||||
XP_U16 col, XP_U16 row )
|
|
||||||
{
|
|
||||||
AndUtil* util = (AndUtil*)uc;
|
|
||||||
JNIEnv* env = util->env;
|
|
||||||
const char* sig = "(II)I";
|
|
||||||
jmethodID mid = getMethodID( env, util->j_util, "getSquareBonus", sig );
|
|
||||||
return (*env)->CallIntMethod( env, util->j_util, mid,
|
|
||||||
col, row );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
|
||||||
{
|
|
||||||
XP_LOGF( "%s(id=%d)", __func__, id );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static XP_Bool
|
|
||||||
and_util_userQuery( XW_UtilCtxt* uc, UtilQueryID id, XWStreamCtxt* stream )
|
|
||||||
{
|
|
||||||
XP_LOGF( "%s(id=%d)", __func__, id );
|
|
||||||
}
|
|
||||||
|
|
||||||
static XP_S16
|
|
||||||
and_util_userPickTile( XW_UtilCtxt* uc, const PickInfo* pi,
|
|
||||||
XP_U16 playerNum, const XP_UCHAR** texts, XP_U16 nTiles )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static XP_Bool
|
|
||||||
and_util_askPassword( XW_UtilCtxt* uc, const XP_UCHAR* name,
|
|
||||||
XP_UCHAR* buf, XP_U16* len )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_util_trayHiddenChange(XW_UtilCtxt* uc, XW_TrayVisState newState,
|
|
||||||
XP_U16 nVisibleRows )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_util_yOffsetChange(XW_UtilCtxt* uc, XP_U16 oldOffset, XP_U16 newOffset )
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
AndUtil* util = (AndUtil*)uc;
|
|
||||||
JNIEnv* env = util->env;
|
|
||||||
const char* sig = "(II)V";
|
|
||||||
jmethodID mid = getMethodID( env, util->j_util, "yOffsetChange", sig );
|
|
||||||
|
|
||||||
(*env)->CallVoidMethod( env, util->j_util, mid,
|
|
||||||
oldOffset, newOffset );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef XWFEATURE_TURNCHANGENOTIFY
|
|
||||||
static void
|
|
||||||
and_util_turnChanged(XW_UtilCtxt* uc)
|
|
||||||
{
|
|
||||||
/* don't log; this is getting called a lot */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
static void
|
|
||||||
and_util_notifyGameOver( XW_UtilCtxt* uc )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static XP_Bool
|
|
||||||
and_util_hiliteCell( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row )
|
|
||||||
{
|
|
||||||
/* don't log; this is getting called a lot */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static XP_Bool
|
|
||||||
and_util_engineProgressCallback( XW_UtilCtxt* uc )
|
|
||||||
{
|
|
||||||
/* don't log; this is getting called a lot */
|
|
||||||
return XP_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is added for java, not part of the util api */
|
|
||||||
bool
|
|
||||||
utilTimerFired( XW_UtilCtxt* uc, XWTimerReason why, int handle )
|
|
||||||
{
|
|
||||||
AndUtil* util = (AndUtil*)uc;
|
|
||||||
TimerStorage* timerStorage = &util->timerStorage[why];
|
|
||||||
XP_ASSERT( handle == (int)timerStorage );
|
|
||||||
return (*timerStorage->proc)( timerStorage->closure, why );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when,
|
|
||||||
XWTimerProc proc, void* closure )
|
|
||||||
{
|
|
||||||
AndUtil* util = (AndUtil*)uc;
|
|
||||||
JNIEnv* env = util->env;
|
|
||||||
const char* sig = "(III)V";
|
|
||||||
jmethodID mid = getMethodID( env, util->j_util, "setTimer", sig );
|
|
||||||
|
|
||||||
XP_ASSERT( why < VSIZE(util->timerStorage) );
|
|
||||||
TimerStorage* storage = &util->timerStorage[why];
|
|
||||||
storage->proc = proc;
|
|
||||||
storage->closure = closure;
|
|
||||||
(*env)->CallVoidMethod( env, util->j_util, mid,
|
|
||||||
why, when, (int)storage );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_util_clearTimer( XW_UtilCtxt* uc, XWTimerReason why )
|
|
||||||
{
|
|
||||||
AndUtil* util = (AndUtil*)uc;
|
|
||||||
JNIEnv* env = util->env;
|
|
||||||
const char* sig = "(I)V";
|
|
||||||
jmethodID mid = getMethodID( env, util->j_util, "clearTimer", sig );
|
|
||||||
(*env)->CallVoidMethod( env, util->j_util, mid, why );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_util_requestTime( XW_UtilCtxt* uc )
|
|
||||||
{
|
|
||||||
AndUtil* util = (AndUtil*)uc;
|
|
||||||
JNIEnv* env = util->env;
|
|
||||||
const char* sig = "()V";
|
|
||||||
jmethodID mid = getMethodID( env, util->j_util, "requestTime", sig );
|
|
||||||
(*env)->CallVoidMethod( env, util->j_util, mid );
|
|
||||||
}
|
|
||||||
|
|
||||||
static XP_Bool
|
|
||||||
and_util_altKeyDown( XW_UtilCtxt* uc )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
return XP_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static XP_U32
|
|
||||||
and_util_getCurSeconds( XW_UtilCtxt* uc )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static DictionaryCtxt*
|
|
||||||
and_util_makeEmptyDict( XW_UtilCtxt* uc )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const XP_UCHAR*
|
|
||||||
and_util_getUserString( XW_UtilCtxt* uc, XP_U16 stringCode )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static XP_Bool
|
|
||||||
and_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi,
|
|
||||||
XP_U16 turn, XP_Bool turnLost )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_util_remSelected(XW_UtilCtxt* uc)
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
|
||||||
static void
|
|
||||||
and_util_addrChange( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr,
|
|
||||||
const CommsAddrRec* newAddr )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef XWFEATURE_SEARCHLIMIT
|
|
||||||
static XP_Bool
|
|
||||||
and_util_getTraySearchLimits(XW_UtilCtxt* uc, XP_U16* min, XP_U16* max )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SHOW_PROGRESS
|
|
||||||
static void
|
|
||||||
and_util_engineStarting( XW_UtilCtxt* uc, XP_U16 nBlanks )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
and_util_engineStopping( XW_UtilCtxt* uc )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
XW_UtilCtxt*
|
|
||||||
makeUtil( MPFORMAL JNIEnv *env, jobject j_util, CurGameInfo* gi,
|
|
||||||
AndGlobals* closure )
|
|
||||||
{
|
|
||||||
AndUtil* util = XP_MALLOC( mpool, sizeof(*util) );
|
|
||||||
XP_MEMSET( util, 0, sizeof(*util ) );
|
|
||||||
UtilVtable* vtable = XP_MALLOC( mpool, sizeof(*vtable) );
|
|
||||||
XP_MEMSET( vtable, 0, sizeof(*vtable ) );
|
|
||||||
util->env = env;
|
|
||||||
util->j_util = (*env)->NewGlobalRef( env, j_util );
|
|
||||||
util->util.vtable = vtable;
|
|
||||||
util->util.mpool = mpool;
|
|
||||||
util->util.closure = closure;
|
|
||||||
util->util.gameInfo = gi;
|
|
||||||
|
|
||||||
#define SET_PROC(nam) vtable->m_util_##nam = and_util_##nam
|
|
||||||
SET_PROC(getVTManager);
|
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
|
||||||
SET_PROC(makeStreamFromAddr);
|
|
||||||
#endif
|
|
||||||
SET_PROC(getSquareBonus);
|
|
||||||
SET_PROC(userError);
|
|
||||||
SET_PROC(userQuery);
|
|
||||||
SET_PROC(userPickTile);
|
|
||||||
SET_PROC(askPassword);
|
|
||||||
SET_PROC(trayHiddenChange);
|
|
||||||
SET_PROC(yOffsetChange);
|
|
||||||
#ifdef XWFEATURE_TURNCHANGENOTIFY
|
|
||||||
SET_PROC( turnChanged);
|
|
||||||
#endif
|
|
||||||
SET_PROC(notifyGameOver);
|
|
||||||
SET_PROC(hiliteCell);
|
|
||||||
SET_PROC(engineProgressCallback);
|
|
||||||
SET_PROC(setTimer);
|
|
||||||
SET_PROC(clearTimer);
|
|
||||||
SET_PROC(requestTime);
|
|
||||||
SET_PROC(altKeyDown);
|
|
||||||
SET_PROC(getCurSeconds);
|
|
||||||
SET_PROC(makeEmptyDict);
|
|
||||||
SET_PROC(getUserString);
|
|
||||||
SET_PROC(warnIllegalWord);
|
|
||||||
SET_PROC(remSelected);
|
|
||||||
|
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
|
||||||
SET_PROC(addrChange);
|
|
||||||
#endif
|
|
||||||
#ifdef XWFEATURE_SEARCHLIMIT
|
|
||||||
SET_PROC(getTraySearchLimits);
|
|
||||||
#endif
|
|
||||||
#ifdef SHOW_PROGRESS
|
|
||||||
SET_PROC(engineStarting);
|
|
||||||
SET_PROC(engineStopping);
|
|
||||||
#endif
|
|
||||||
#undef SET_PROC
|
|
||||||
|
|
||||||
return (XW_UtilCtxt*)util;
|
|
||||||
} /* makeUtil */
|
|
|
@ -1,35 +0,0 @@
|
||||||
/* -*-mode: C; fill-column: 76; c-basic-offset: 4; -*- */
|
|
||||||
/*
|
|
||||||
* Copyright 2001-2009 by Eric House (xwords@eehouse.org). All rights
|
|
||||||
* reserved.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _UTILWRAPPER_H_
|
|
||||||
#define _UTILWRAPPER_H_
|
|
||||||
|
|
||||||
#include <jni.h>
|
|
||||||
|
|
||||||
#include "game.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "andglobals.h"
|
|
||||||
|
|
||||||
XW_UtilCtxt* makeUtil( MPFORMAL JNIEnv *env, jobject j_util,
|
|
||||||
CurGameInfo* gi, AndGlobals* globals );
|
|
||||||
bool utilTimerFired( XW_UtilCtxt* util, XWTimerReason why, int handle );
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,111 +0,0 @@
|
||||||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
|
||||||
/*
|
|
||||||
* Copyright 1999-2009 by Eric House (xwords@eehouse.org). All rights reserved.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _XPTYPES_H_
|
|
||||||
#define _XPTYPES_H_
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <android/log.h>
|
|
||||||
|
|
||||||
typedef unsigned char XP_U8;
|
|
||||||
typedef signed char XP_S8;
|
|
||||||
|
|
||||||
typedef unsigned short XP_U16;
|
|
||||||
typedef signed short XP_S16;
|
|
||||||
|
|
||||||
typedef unsigned long XP_U32;
|
|
||||||
typedef signed long XP_S32;
|
|
||||||
|
|
||||||
typedef char XP_UCHAR;
|
|
||||||
|
|
||||||
typedef signed short XP_FontCode; /* not sure how I'm using this yet */
|
|
||||||
typedef bool XP_Bool;
|
|
||||||
typedef XP_U32 XP_Time;
|
|
||||||
|
|
||||||
#define XP_TRUE ((XP_Bool)(1==1))
|
|
||||||
#define XP_FALSE ((XP_Bool)(1==0))
|
|
||||||
|
|
||||||
#define XP_S "%s"
|
|
||||||
#define XP_P "%p"
|
|
||||||
#define XP_CR "\n"
|
|
||||||
#define XP_LD "%ld"
|
|
||||||
|
|
||||||
# define XP_RANDOM() rand()
|
|
||||||
|
|
||||||
#ifdef MEM_DEBUG
|
|
||||||
# define XP_PLATMALLOC(nbytes) malloc(nbytes)
|
|
||||||
# define XP_PLATREALLOC(p,s) realloc((p), (s))
|
|
||||||
# define XP_PLATFREE(p) free(p)
|
|
||||||
#else
|
|
||||||
# define XP_MALLOC(pool, nbytes) malloc(nbytes)
|
|
||||||
# define XP_REALLOC(pool, p, bytes) realloc((p), (bytes))
|
|
||||||
# define XP_FREE(pool, p) free(p)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define XP_MEMSET(src, val, nbytes) memset( (src), (val), (nbytes) )
|
|
||||||
#define XP_MEMCPY(d,s,l) memcpy((d),(s),(l))
|
|
||||||
#define XP_MEMMOVE(d,s,l) memmove((d),(s),(l))
|
|
||||||
#define XP_MEMCMP( a1, a2, l ) memcmp((a1),(a2),(l))
|
|
||||||
#define XP_STRLEN(s) strlen((s))
|
|
||||||
#define XP_STRCAT(d,s) strcat((d),(s))
|
|
||||||
#define XP_STRCMP(s1,s2) strcmp((char*)(s1),(char*)(s2))
|
|
||||||
#define XP_STRNCMP(s1,s2,l) strncmp((char*)(s1),(char*)(s2),(l))
|
|
||||||
#define XP_STRNCPY(s,d,l) strncpy((s),(d),(l))
|
|
||||||
#define XP_SNPRINTF snprintf
|
|
||||||
|
|
||||||
#define XP_MIN(a,b) ((a)<(b)?(a):(b))
|
|
||||||
#define XP_MAX(a,b) ((a)>(b)?(a):(b))
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
void and_assert( const char* test, int line, const char* file, const char* func );
|
|
||||||
#define XP_ASSERT(b) if(!(b)) { and_assert(#b, __LINE__, __FILE__, __func__); }
|
|
||||||
#else
|
|
||||||
# define XP_ASSERT(b)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//#define XP_STATUSF if(0)p_ignore
|
|
||||||
#define XP_STATUSF XP_DEBUGF
|
|
||||||
|
|
||||||
#ifdef ENABLE_LOGGING
|
|
||||||
#define XP_DEBUGF(...) __android_log_print( ANDROID_LOG_DEBUG, "tag", __VA_ARGS__)
|
|
||||||
#define XP_LOGF(...) __android_log_print( ANDROID_LOG_DEBUG, "tag", __VA_ARGS__)
|
|
||||||
#define XP_WARNF(...) __android_log_print( ANDROID_LOG_DEBUG, "tag", __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define XP_DEBUGF(...)
|
|
||||||
#define XP_LOGF(...)
|
|
||||||
#define XP_WARNF(...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define XP_NTOHL(l) and_ntohl(l)
|
|
||||||
#define XP_NTOHS(s) and_ntohs(s)
|
|
||||||
#define XP_HTONL(l) and_htonl(l)
|
|
||||||
#define XP_HTONS(s) and_htons(s)
|
|
||||||
|
|
||||||
#ifdef CPLUS
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CPLUS
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,397 +0,0 @@
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <jni.h>
|
|
||||||
#include <android/log.h>
|
|
||||||
|
|
||||||
#include "comtypes.h"
|
|
||||||
#include "game.h"
|
|
||||||
#include "board.h"
|
|
||||||
#include "mempool.h"
|
|
||||||
#include "strutils.h"
|
|
||||||
|
|
||||||
#include "utilwrapper.h"
|
|
||||||
#include "drawwrapper.h"
|
|
||||||
#include "anddict.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* static JNIEnv* g_env = NULL; */
|
|
||||||
|
|
||||||
static CurGameInfo*
|
|
||||||
makeGI( MPFORMAL JNIEnv* env, jobject j_gi )
|
|
||||||
{
|
|
||||||
CurGameInfo* gi = XP_MALLOC( mpool, sizeof(*gi) );
|
|
||||||
XP_MEMSET( gi, 0, sizeof(*gi) );
|
|
||||||
int nPlayers, robotSmartness, boardSize;
|
|
||||||
int ii;
|
|
||||||
XP_UCHAR buf[256]; /* in case needs whole path */
|
|
||||||
|
|
||||||
bool success = getInt( env, j_gi, "nPlayers", &nPlayers )
|
|
||||||
&& getInt( env, j_gi, "boardSize", &boardSize )
|
|
||||||
&& getInt( env, j_gi, "robotSmartness", &robotSmartness )
|
|
||||||
&& getBool( env, j_gi, "hintsNotAllowed", &gi->hintsNotAllowed )
|
|
||||||
&& getBool( env, j_gi, "timerEnabled", &gi->timerEnabled )
|
|
||||||
&& getBool( env, j_gi, "allowPickTiles", &gi->allowPickTiles )
|
|
||||||
&& getBool( env, j_gi, "allowHintRect", &gi->allowHintRect )
|
|
||||||
;
|
|
||||||
XP_ASSERT( success );
|
|
||||||
|
|
||||||
gi->nPlayers = nPlayers;
|
|
||||||
gi->robotSmartness = robotSmartness;
|
|
||||||
gi->boardSize = boardSize;
|
|
||||||
gi->serverRole = SERVER_STANDALONE; /* figure out enums later */
|
|
||||||
|
|
||||||
getString( env, j_gi, "dictName", buf, VSIZE(buf) );
|
|
||||||
gi->dictName = copyString( mpool, buf );
|
|
||||||
XP_LOGF( "dict name: %s", gi->dictName );
|
|
||||||
|
|
||||||
XP_ASSERT( nPlayers < MAX_NUM_PLAYERS );
|
|
||||||
|
|
||||||
jobject jplayers;
|
|
||||||
if ( getObject( env, j_gi, "players",
|
|
||||||
"[Lorg/eehouse/android/xw4/jni/LocalPlayer;",
|
|
||||||
&jplayers ) ) {
|
|
||||||
for ( ii = 0; ii < gi->nPlayers; ++ii ) {
|
|
||||||
LocalPlayer* lp = &gi->players[ii];
|
|
||||||
|
|
||||||
jobject jlp = (*env)->GetObjectArrayElement( env, jplayers, ii );
|
|
||||||
|
|
||||||
getBool( env, jlp, "isRobot", &lp->isRobot );
|
|
||||||
getBool( env, jlp, "isLocal", &lp->isLocal );
|
|
||||||
|
|
||||||
getString( env, jlp, "name", &buf, VSIZE(buf) );
|
|
||||||
lp->name = copyString( mpool, buf );
|
|
||||||
getString( env, jlp, "password", &buf, VSIZE(buf) );
|
|
||||||
lp->password = copyString( mpool, buf );
|
|
||||||
|
|
||||||
lp->secondsUsed = 0;
|
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jlp );
|
|
||||||
}
|
|
||||||
(*env)->DeleteLocalRef( env, jplayers );
|
|
||||||
} else {
|
|
||||||
XP_ASSERT(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return gi;
|
|
||||||
} /* makeGI */
|
|
||||||
|
|
||||||
static bool
|
|
||||||
loadCommonPrefs( JNIEnv* env, CommonPrefs* cp, jobject j_cp )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
bool success = getBool( env, j_cp, "showBoardArrow", &cp->showBoardArrow )
|
|
||||||
&& getBool( env, j_cp, "showRobotScores", &cp->showRobotScores )
|
|
||||||
&& getBool( env, j_cp, "hideTileValues", &cp->hideTileValues )
|
|
||||||
&& getBool( env, j_cp, "skipCommitConfirm", &cp->skipCommitConfirm );
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
generated by running:
|
|
||||||
(cd /home/andy/dev/XWORDS/android/XWords4/bin/classes; javah -o /tmp/foo.h org.eehouse.android.xw4.jni.XwJNI)
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct _GameAndMPool {
|
|
||||||
XWGame game;
|
|
||||||
AndGlobals* globals;
|
|
||||||
MPSLOT
|
|
||||||
} GameAndMPool;
|
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeNewGame
|
|
||||||
( JNIEnv *env, jclass C, jobject j_gi, jobject j_util, jobject j_draw,
|
|
||||||
jint gameID, jobject j_cp, jobject j_procs, jbyteArray jDictBytes )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
MemPoolCtx* mpool = mpool_make();
|
|
||||||
|
|
||||||
GameAndMPool* game = XP_MALLOC( mpool, sizeof(*game) );
|
|
||||||
AndGlobals* globals = XP_MALLOC( mpool, sizeof( *globals ) );
|
|
||||||
game->mpool = mpool;
|
|
||||||
game->globals = globals;
|
|
||||||
globals->vtMgr = make_vtablemgr(MPPARM_NOCOMMA(mpool));
|
|
||||||
|
|
||||||
CurGameInfo* gi = makeGI( MPPARM(mpool) env, j_gi );
|
|
||||||
globals->gi = gi;
|
|
||||||
XW_UtilCtxt* util = makeUtil( MPPARM(mpool) env, j_util, gi, globals );
|
|
||||||
globals->util = util;
|
|
||||||
DrawCtx* dctx = makeDraw( MPPARM(mpool) env, j_draw );
|
|
||||||
globals->dctx = dctx;
|
|
||||||
CommonPrefs cp;
|
|
||||||
(void)loadCommonPrefs( env, &cp, j_cp );
|
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
|
||||||
/* TransportProcs proc; */
|
|
||||||
/* loadTransportProcs( &procs, j_procs ); */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
XP_LOGF( "calling game_makeNewGame" );
|
|
||||||
game_makeNewGame( MPPARM(mpool) &game->game, gi, util, dctx, gameID,
|
|
||||||
&cp, NULL );
|
|
||||||
|
|
||||||
DictionaryCtxt* dict = makeDict( MPPARM(mpool) env, jDictBytes );
|
|
||||||
#ifdef STUBBED_DICT
|
|
||||||
if ( !dict ) {
|
|
||||||
XP_LOGF( "falling back to stubbed dict" );
|
|
||||||
dict = make_stubbed_dict( mpool );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
XP_ASSERT( !!dict );
|
|
||||||
|
|
||||||
globals->dict = dict;
|
|
||||||
model_setDictionary( game->game.model, dict );
|
|
||||||
|
|
||||||
return (jint) game;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_game_1dispose
|
|
||||||
(JNIEnv * env, jclass claz, jint gamePtr )
|
|
||||||
{
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
MemPoolCtx* mpool = game->mpool;
|
|
||||||
game_dispose( &game->game );
|
|
||||||
XP_FREE( mpool, game->globals );
|
|
||||||
XP_FREE( mpool, game );
|
|
||||||
mpool_destroy( mpool );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1invalAll
|
|
||||||
( JNIEnv *env, jclass C, jint gamePtr )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
board_invalAll( board );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1draw
|
|
||||||
( JNIEnv *env, jclass C, jint gamePtr )
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
XP_Bool success = board_draw( board );
|
|
||||||
return (jboolean)success;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1setPos
|
|
||||||
(JNIEnv *env, jclass C, jint gamePtr, jint left, jint top, jboolean lefty )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
XP_LOGF( "calling setPos(%d,%d)", left, top );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
board_setPos( board, left, top, lefty );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1setScale
|
|
||||||
(JNIEnv *env, jclass C, jint gamePtr, jint hscale, jint vscale )
|
|
||||||
{
|
|
||||||
XP_LOGF( "calling setScale(%d,%d)", hscale, vscale );
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
board_setScale( board, hscale, vscale );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1setShowColors
|
|
||||||
( JNIEnv *env, jclass C, jint gamePtr, jboolean on )
|
|
||||||
{
|
|
||||||
LOG_FUNC();
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
board_setShowColors( board, on );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1setScoreboardLoc
|
|
||||||
( JNIEnv *env, jclass C, jint gamePtr, jint left, jint top,
|
|
||||||
jint width, jint height, jboolean divideHorizontally )
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
XP_LOGF( "calling setScoreboardLoc(%d,%d,%d,%d,%d)", left, top,
|
|
||||||
width, height, divideHorizontally );
|
|
||||||
board_setScoreboardLoc( board, left, top, width, height, divideHorizontally );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1setTrayLoc
|
|
||||||
( JNIEnv *env, jclass C, jint gamePtr, jint left, jint top,
|
|
||||||
jint width, jint height, jint minDividerWidth )
|
|
||||||
{
|
|
||||||
XP_LOGF( "calling setTrayLoc(%d,%d,%d,%d,%d)", left, top,
|
|
||||||
width, height, minDividerWidth );
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
board_setTrayLoc( board, left, top, width, height, minDividerWidth );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1handlePenDown
|
|
||||||
(JNIEnv *env, jclass C, jint gamePtr, jint xx, jint yy, jbooleanArray barray )
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
XP_Bool bb; /* drop this for now */
|
|
||||||
return board_handlePenDown( board, xx, yy, &bb );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1handlePenMove
|
|
||||||
( JNIEnv *env, jclass C, jint gamePtr, jint xx, jint yy )
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
return board_handlePenMove( board, xx, yy );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1handlePenUp
|
|
||||||
( JNIEnv *env, jclass C, jint gamePtr, jint xx, jint yy )
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
return board_handlePenUp( board, xx, yy );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1juggleTray
|
|
||||||
(JNIEnv* env, jclass C, jint gamePtr )
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
return board_juggleTray( board );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1getTrayVisState
|
|
||||||
(JNIEnv* env, jclass C, jint gamePtr)
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
return board_getTrayVisState( board );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1hideTray
|
|
||||||
(JNIEnv* env, jclass C, jint gamePtr)
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
return board_hideTray( board );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1showTray
|
|
||||||
(JNIEnv* env, jclass C, jint gamePtr)
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
return board_showTray( board );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1commitTurn
|
|
||||||
(JNIEnv* env, jclass C, jint gamePtr)
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
return board_commitTurn( board );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1flip
|
|
||||||
(JNIEnv* env, jclass C, jint gamePtr)
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
return board_flip( board );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1replaceTiles
|
|
||||||
(JNIEnv* env, jclass C, jint gamePtr)
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
return board_replaceTiles( board );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_server_1handleUndo
|
|
||||||
(JNIEnv* env, jclass C, jint gamePtr)
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
ServerCtxt* server = game->game.server;
|
|
||||||
server_handleUndo( server );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_server_1do
|
|
||||||
(JNIEnv* env, jclass C, jint gamePtr )
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
ServerCtxt* server = game->game.server;
|
|
||||||
return server_do( server );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
org_eehouse_android_xw4_jni_XwJNI_board_1resetEngine
|
|
||||||
(JNIEnv* env, jclass C, jint gamePtr )
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
board_resetEngine( board );
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_board_1requestHint
|
|
||||||
( JNIEnv* env, jclass C, jint gamePtr, jboolean useLimits,
|
|
||||||
jbooleanArray workRemains )
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
BoardCtxt* board = game->game.board;
|
|
||||||
|
|
||||||
XP_Bool tmpbool;
|
|
||||||
jboolean result = board_requestHint( board, useLimits, &tmpbool );
|
|
||||||
|
|
||||||
/* If passed need to do workRemains[0] = tmpbool */
|
|
||||||
XP_ASSERT( !workRemains );
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_timerFired
|
|
||||||
( JNIEnv* env, jclass C, jint gamePtr, jint why, jint when, jint handle )
|
|
||||||
{
|
|
||||||
XP_ASSERT( 0 != gamePtr );
|
|
||||||
GameAndMPool* game = (GameAndMPool*)gamePtr;
|
|
||||||
AndGlobals* globals = game->globals;
|
|
||||||
XW_UtilCtxt* util = globals->util;
|
|
||||||
return utilTimerFired( util, why, handle );
|
|
||||||
}
|
|
Loading…
Reference in a new issue