Compare commits
15 Commits
wagic-v0.2
...
qt_resourc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14d4bede9a | ||
|
|
8636a99d0d | ||
|
|
73cdbd6b88 | ||
|
|
3482afeb84 | ||
|
|
de40146462 | ||
|
|
94d5a85043 | ||
|
|
4811fbcc9f | ||
|
|
6fd136a211 | ||
|
|
d98640fc01 | ||
|
|
685317b457 | ||
|
|
a9a59d7b8e | ||
|
|
fe9ad84ee5 | ||
|
|
3f43648b22 | ||
|
|
afb4c4605b | ||
|
|
fec4468aea |
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,38 +0,0 @@
|
|||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to help us improve
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe the bug**
|
|
||||||
A clear and concise description of what the bug is.
|
|
||||||
|
|
||||||
**To Reproduce**
|
|
||||||
Steps to reproduce the behavior:
|
|
||||||
1. Go to '...'
|
|
||||||
2. Click on '....'
|
|
||||||
3. Scroll down to '....'
|
|
||||||
4. See error
|
|
||||||
|
|
||||||
**Expected behavior**
|
|
||||||
A clear and concise description of what you expected to happen.
|
|
||||||
|
|
||||||
**Screenshots**
|
|
||||||
If applicable, add screenshots to help explain your problem.
|
|
||||||
|
|
||||||
**Desktop (please complete the following information):**
|
|
||||||
- OS: [e.g. iOS]
|
|
||||||
- Browser [e.g. chrome, safari]
|
|
||||||
- Version [e.g. 22]
|
|
||||||
|
|
||||||
**Smartphone (please complete the following information):**
|
|
||||||
- Device: [e.g. iPhone6]
|
|
||||||
- OS: [e.g. iOS8.1]
|
|
||||||
- Browser [e.g. stock browser, safari]
|
|
||||||
- Version [e.g. 22]
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context about the problem here.
|
|
||||||
10
.github/ISSUE_TEMPLATE/custom.md
vendored
@@ -1,10 +0,0 @@
|
|||||||
---
|
|
||||||
name: Custom issue template
|
|
||||||
about: Describe this issue template's purpose here.
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,20 +0,0 @@
|
|||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
||||||
92
.travis.yml
@@ -1,73 +1,31 @@
|
|||||||
language: cpp
|
language: cpp
|
||||||
dist: xenial
|
|
||||||
branches:
|
branches:
|
||||||
only:
|
except:
|
||||||
- master
|
- latest-master
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- export BUILD_PSP=YES
|
- export PSPDEV="$TRAVIS_BUILD_DIR/opt/pspsdk"
|
||||||
- export BUILD_ANDROID=YES
|
- export PSPSDK="$PSPDEV/psp/sdk"
|
||||||
- export BUILD_Qt=YES
|
- export PATH="$PATH:$PSPDEV/bin:$PSPSDK/bin"
|
||||||
- export BUILD_MAC=NO
|
- export ANDROID="android-sdk-linux/tools/android"
|
||||||
- echo -e "machine github.com\n login $GITHUB_TOKEN" > ~/.netrc
|
|
||||||
- git lfs pull
|
|
||||||
# Only building on Mac when not handling pull request
|
|
||||||
# - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
|
||||||
# export BUILD_MAC=YES;
|
|
||||||
# fi
|
|
||||||
- sudo apt-get update -qq
|
|
||||||
# Building for PSP here
|
|
||||||
- if [ "$BUILD_PSP" == "YES" ]; then
|
|
||||||
export PSPDEV="$TRAVIS_BUILD_DIR/opt/pspsdk" &&
|
|
||||||
export PSPSDK="$PSPDEV/psp/sdk" &&
|
|
||||||
export PATH="$PATH:$PSPDEV/bin:$PSPSDK/bin" &&
|
|
||||||
wget --no-check-certificate -O sdk.lzma http://downloads.sourceforge.net/project/minpspw/SDK%20%2B%20devpak/pspsdk%200.11.2/minpspw_0.11.2-amd64.tar.lzma;
|
|
||||||
fi
|
|
||||||
# Building for Qt here
|
|
||||||
- if [ "$BUILD_Qt" == "YES" ]; then
|
|
||||||
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu xenial universe" &&
|
|
||||||
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu xenial main" &&
|
|
||||||
sudo apt-get -qq update &&
|
|
||||||
sudo apt-get -qq install qt5-qmake qtbase5-dev qtdeclarative5-dev qttools5-dev qtmultimedia5-dev libqt5opengl5 libqt5opengl5-dev pulseaudio libpulse-dev &&
|
|
||||||
export QMAKE="qmake -qt=qt5";
|
|
||||||
fi
|
|
||||||
# Building for Android here
|
|
||||||
- if [ "$BUILD_ANDROID" == "YES" ]; then
|
|
||||||
export ANDROID="android-sdk-linux/tools/android" &&
|
|
||||||
if [ `uname -m` = x86_64 ]; then
|
|
||||||
sudo dpkg --add-architecture i386 && sudo apt-get update &&
|
|
||||||
sudo apt-get install -qq --force-yes libgd2-xpm-dev libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1 jq ant; fi &&
|
|
||||||
wget https://dl.google.com/android/repository/android-ndk-r22-linux-x86_64.zip -nv &&
|
|
||||||
wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz -nv;
|
|
||||||
fi
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- if [ "$BUILD_PSP" == "YES" ]; then
|
- sudo add-apt-repository ppa:tobydox/mingw -y
|
||||||
tar -x --xz -f sdk.lzma;
|
- sudo apt-get update -qq
|
||||||
fi
|
- if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch jq mingw32-x-gcc mingw32-x-qt; fi
|
||||||
- if [ "$BUILD_ANDROID" == "YES" ]; then
|
- sudo ln -s /opt/mingw32/bin/moc /opt/mingw32/bin/i686-w64-mingw32-moc
|
||||||
unzip android-ndk-r22-linux-x86_64.zip &&
|
- sudo ln -s /opt/mingw32/bin/rcc /opt/mingw32/bin/i686-w64-mingw32-rcc
|
||||||
tar -zxf android-sdk_r24.4.1-linux.tgz &&
|
- wget -O sdk.lzma http://sourceforge.net/projects/minpspw/files/SDK%20%2B%20devpak/pspsdk%200.11.2/minpspw_0.11.2-amd64.tar.lzma/download
|
||||||
$ANDROID list sdk --extended -a &&
|
- tar -x --xz -f sdk.lzma
|
||||||
echo yes | $ANDROID update sdk -a -t tools,platform-tools,build-tools-23.0.1,android-23 --no-ui --force --no-https;
|
- wget http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2 -nv
|
||||||
sudo apt-get install openjdk-8-jdk;
|
- wget http://dl.google.com/android/android-sdk_r22-linux.tgz -nv
|
||||||
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64;
|
- tar --absolute-names -jxf android-ndk-r9-linux-x86_64.tar.bz2
|
||||||
export PATH=$JAVA_HOME/bin:$PATH;
|
- tar -zxf android-sdk_r22-linux.tgz
|
||||||
fi
|
- $ANDROID list sdk -a
|
||||||
- sudo pip install --upgrade pip
|
- echo yes | $ANDROID update sdk -a --filter 1,2,5,19 --no-ui --force > log.txt
|
||||||
- sudo pip install setuptools-rust
|
|
||||||
- sudo pip install pyOpenSSL
|
|
||||||
- sudo pip install pyjavaproperties
|
- sudo pip install pyjavaproperties
|
||||||
- sudo pip install github3.py
|
script: ./travis-script.sh
|
||||||
- sudo pip install cpp-coveralls
|
env:
|
||||||
|
global:
|
||||||
|
secure: "fJgWlCFbde96OSQNGKUmowGX+ERPeqP+n1EOMf1+FJzOU4DdkTLRAlV5+5qnEX9jB/3mWN6iPpmG1qEz/SdDG3KHxJYs4ZU/Lu485O24zZ/+GdYBNsrvhPD9ckPGEMLDa1foEVTDnW0Dlkz3BCFcszjhtXGUJv7v6Pj6LRk1Mg8="
|
||||||
|
|
||||||
before_script:
|
script: "./travis-script.sh"
|
||||||
- export REQUESTS_CA_BUNDLE=/usr/local/lib/python2.7/dist-packages/certifi/cacert.pem
|
after_success: ./upload-binaries.sh
|
||||||
script: "tools/travis-script.sh"
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- coveralls -b . -e JGE/src -e JGE/include -i projects/mtg/include -i projects/mtg/src --gcov-options '\-lp'
|
|
||||||
- python tools/upload-binaries.py -t $GITHUB_TOKEN -s $TRAVIS_COMMIT -l core.zip -r Wagic-core.zip -b $TRAVIS_BRANCH
|
|
||||||
- python tools/upload-binaries.py -t $GH_TOKEN -s $TRAVIS_COMMIT -l projects/mtg/Android/bin/Wagic-debug.apk -r Wagic-android.apk -b $TRAVIS_BRANCH
|
|
||||||
- python tools/upload-binaries.py -t $GH_TOKEN -s $TRAVIS_COMMIT -l projects/mtg/psprelease.zip -r Wagic-psp.zip -b $TRAVIS_BRANCH
|
|
||||||
- python tools/upload-binaries.py -t $GITHUB_TOKEN -s $TRAVIS_COMMIT -l qt-gui-build/linuxqtrelease.zip -r Wagic-linux-QT.zip -b $TRAVIS_BRANCH
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace boost {
|
|||||||
|
|
||||||
enum xtime_clock_types
|
enum xtime_clock_types
|
||||||
{
|
{
|
||||||
TIME_UTC_=1
|
TIME_UTC=1
|
||||||
// TIME_TAI,
|
// TIME_TAI,
|
||||||
// TIME_MONOTONIC,
|
// TIME_MONOTONIC,
|
||||||
// TIME_PROCESS,
|
// TIME_PROCESS,
|
||||||
@@ -68,7 +68,7 @@ inline xtime get_xtime(boost::system_time const& abs_time)
|
|||||||
|
|
||||||
inline int xtime_get(struct xtime* xtp, int clock_type)
|
inline int xtime_get(struct xtime* xtp, int clock_type)
|
||||||
{
|
{
|
||||||
if (clock_type == TIME_UTC_)
|
if (clock_type == TIME_UTC)
|
||||||
{
|
{
|
||||||
*xtp=get_xtime(get_system_time());
|
*xtp=get_xtime(get_system_time());
|
||||||
return clock_type;
|
return clock_type;
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ namespace boost
|
|||||||
cond.timed_wait(lock, xt);
|
cond.timed_wait(lock, xt);
|
||||||
# endif
|
# endif
|
||||||
xtime cur;
|
xtime cur;
|
||||||
xtime_get(&cur, TIME_UTC_);
|
xtime_get(&cur, TIME_UTC);
|
||||||
if (xtime_cmp(xt, cur) <= 0)
|
if (xtime_cmp(xt, cur) <= 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -365,7 +365,7 @@ namespace boost
|
|||||||
BOOST_VERIFY(!pthread_yield());
|
BOOST_VERIFY(!pthread_yield());
|
||||||
# else
|
# else
|
||||||
xtime xt;
|
xtime xt;
|
||||||
xtime_get(&xt, TIME_UTC_);
|
xtime_get(&xt, TIME_UTC);
|
||||||
sleep(xt);
|
sleep(xt);
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ const int NANOSECONDS_PER_MICROSECOND = 1000;
|
|||||||
inline void to_time(int milliseconds, boost::xtime& xt)
|
inline void to_time(int milliseconds, boost::xtime& xt)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
res = boost::xtime_get(&xt, boost::TIME_UTC_);
|
res = boost::xtime_get(&xt, boost::TIME_UTC);
|
||||||
BOOST_ASSERT(res == boost::TIME_UTC_);
|
BOOST_ASSERT(res == boost::TIME_UTC);
|
||||||
|
|
||||||
xt.sec += (milliseconds / MILLISECONDS_PER_SECOND);
|
xt.sec += (milliseconds / MILLISECONDS_PER_SECOND);
|
||||||
xt.nsec += ((milliseconds % MILLISECONDS_PER_SECOND) *
|
xt.nsec += ((milliseconds % MILLISECONDS_PER_SECOND) *
|
||||||
@@ -57,8 +57,8 @@ inline void to_timespec_duration(const boost::xtime& xt, timespec& ts)
|
|||||||
{
|
{
|
||||||
boost::xtime cur;
|
boost::xtime cur;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
res = boost::xtime_get(&cur, boost::TIME_UTC_);
|
res = boost::xtime_get(&cur, boost::TIME_UTC);
|
||||||
BOOST_ASSERT(res == boost::TIME_UTC_);
|
BOOST_ASSERT(res == boost::TIME_UTC);
|
||||||
|
|
||||||
if (boost::xtime_cmp(xt, cur) <= 0)
|
if (boost::xtime_cmp(xt, cur) <= 0)
|
||||||
{
|
{
|
||||||
@@ -88,8 +88,8 @@ inline void to_duration(boost::xtime xt, int& milliseconds)
|
|||||||
{
|
{
|
||||||
boost::xtime cur;
|
boost::xtime cur;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
res = boost::xtime_get(&cur, boost::TIME_UTC_);
|
res = boost::xtime_get(&cur, boost::TIME_UTC);
|
||||||
BOOST_ASSERT(res == boost::TIME_UTC_);
|
BOOST_ASSERT(res == boost::TIME_UTC);
|
||||||
|
|
||||||
if (boost::xtime_cmp(xt, cur) <= 0)
|
if (boost::xtime_cmp(xt, cur) <= 0)
|
||||||
milliseconds = 0;
|
milliseconds = 0;
|
||||||
@@ -110,8 +110,8 @@ inline void to_microduration(boost::xtime xt, int& microseconds)
|
|||||||
{
|
{
|
||||||
boost::xtime cur;
|
boost::xtime cur;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
res = boost::xtime_get(&cur, boost::TIME_UTC_);
|
res = boost::xtime_get(&cur, boost::TIME_UTC);
|
||||||
BOOST_ASSERT(res == boost::TIME_UTC_);
|
BOOST_ASSERT(res == boost::TIME_UTC);
|
||||||
|
|
||||||
if (boost::xtime_cmp(xt, cur) <= 0)
|
if (boost::xtime_cmp(xt, cur) <= 0)
|
||||||
microseconds = 0;
|
microseconds = 0;
|
||||||
|
|||||||
1768
CHANGELOG.md
@@ -77,13 +77,6 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
|
|||||||
: "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory");
|
: "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory");
|
||||||
return (result == 0);
|
return (result == 0);
|
||||||
|
|
||||||
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
|
||||||
int result;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"lock ; xchgl %0, (%1)\n"
|
|
||||||
: "=r" (result) : "r" (lock), "0" (1) : "cc", "memory");
|
|
||||||
return (result == 0);
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* Need CPU instructions for spinlock here! */
|
/* Need CPU instructions for spinlock here! */
|
||||||
__need_spinlock_implementation__
|
__need_spinlock_implementation__
|
||||||
|
|||||||
@@ -474,7 +474,7 @@
|
|||||||
|
|
||||||
#ifndef PNG_VERSION_INFO_ONLY
|
#ifndef PNG_VERSION_INFO_ONLY
|
||||||
/* include the compression library's header */
|
/* include the compression library's header */
|
||||||
#include "../include/zlib.h"
|
#include "zlib.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* include all user configurable info, including optional assembler routines */
|
/* include all user configurable info, including optional assembler routines */
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ HGE_OBJS = src/hge/hgecolor.o src/hge/hgeparticle.o \
|
|||||||
|
|
||||||
CXXFLAGS = -W -Wall -Werror -Wno-unused
|
CXXFLAGS = -W -Wall -Werror -Wno-unused
|
||||||
CXXFLAGS += -DTIXML_USE_STL
|
CXXFLAGS += -DTIXML_USE_STL
|
||||||
CXXFLAGS += -Wno-deprecated-declarations -Wno-sign-compare
|
|
||||||
|
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
CXXFLAGS += -ggdb3
|
CXXFLAGS += -ggdb3
|
||||||
@@ -83,8 +82,8 @@ ifeq ($(TARGET_ARCHITECTURE),linux)
|
|||||||
OBJS = $(GENERIC_OBJS) $(LINUX_OBJS)
|
OBJS = $(GENERIC_OBJS) $(LINUX_OBJS)
|
||||||
TARGET_LIB = libjge.a
|
TARGET_LIB = libjge.a
|
||||||
TARGET_HGE = libhgetools.a
|
TARGET_HGE = libhgetools.a
|
||||||
INCDIR = $(shell freetype-config --cflags 2> /dev/null) -I/usr/X11/include -I/usr/include/boost -Isrc/zipFS -Iinclude/
|
INCDIR = $(shell freetype-config --cflags 2> /dev/null) -I/usr/X11/include -I../Boost -Isrc/zipFS -Iinclude/
|
||||||
CXXFLAGS += -DLINUX -DNETWORK_SUPPORT $(FMOD)
|
CXXFLAGS += -DLINUX $(FMOD)
|
||||||
CXXFLAGS += $(INCDIR)
|
CXXFLAGS += $(INCDIR)
|
||||||
LIBDIR = lib/linux
|
LIBDIR = lib/linux
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ using namespace std;
|
|||||||
template <class T>
|
template <class T>
|
||||||
std::string ToHex(T* pointer)
|
std::string ToHex(T* pointer)
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
stream << hex << showbase << setfill('0') << setw(8) << (uint64_t) pointer;
|
stream << hex << showbase << setfill('0') << setw(8) << (uint64_t) pointer;
|
||||||
return stream.str();
|
return stream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
@@ -42,9 +42,9 @@ std::string ToHex(T* pointer)
|
|||||||
#else // CAPTURE_STDERR
|
#else // CAPTURE_STDERR
|
||||||
#define DebugTrace(inString) \
|
#define DebugTrace(inString) \
|
||||||
{ \
|
{ \
|
||||||
std::ostringstream stream; \
|
std::ostringstream stream; \
|
||||||
stream << inString; \
|
stream << inString; \
|
||||||
qDebug("%s", stream.str().c_str()); \
|
qDebug("%s", stream.str().c_str()); \
|
||||||
}
|
}
|
||||||
#endif // CAPTURE_STDERR
|
#endif // CAPTURE_STDERR
|
||||||
|
|
||||||
@@ -52,16 +52,16 @@ std::string ToHex(T* pointer)
|
|||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#define DebugTrace(inString) \
|
#define DebugTrace(inString) \
|
||||||
{ \
|
{ \
|
||||||
std::ostringstream stream; \
|
std::ostringstream stream; \
|
||||||
stream << inString; \
|
stream << inString; \
|
||||||
__android_log_write(ANDROID_LOG_DEBUG, "Wagic", stream.str().c_str());\
|
__android_log_write(ANDROID_LOG_DEBUG, "Wagic", stream.str().c_str());\
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define DebugTrace(inString) \
|
#define DebugTrace(inString) \
|
||||||
{ \
|
{ \
|
||||||
std::ostringstream stream; \
|
std::ostringstream stream; \
|
||||||
stream << inString << std::endl; \
|
stream << inString << std::endl; \
|
||||||
OutputDebugStringA(stream.str().c_str()); \
|
OutputDebugStringA(stream.str().c_str()); \
|
||||||
}
|
}
|
||||||
#endif // QT_CONFIG
|
#endif // QT_CONFIG
|
||||||
#endif // Win32, Linux
|
#endif // Win32, Linux
|
||||||
@@ -71,7 +71,7 @@ std::string ToHex(T* pointer)
|
|||||||
#ifndef DebugTrace
|
#ifndef DebugTrace
|
||||||
#define DebugTrace(inString) \
|
#define DebugTrace(inString) \
|
||||||
{ \
|
{ \
|
||||||
std::cerr << inString << std::endl; \
|
std::cerr << inString << std::endl; \
|
||||||
}
|
}
|
||||||
#endif //DEBUG
|
#endif //DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,128 +0,0 @@
|
|||||||
#ifndef DOWNLOADER_H
|
|
||||||
#define DOWNLOADER_H
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// This class handles download of remote resources (any kind of file)
|
|
||||||
// All the resources are stored locally in the userPath
|
|
||||||
// For every resources, the downloader verifies if the resource was modifed
|
|
||||||
// on the server before downloading the update. The Downloader maintains a catalogue
|
|
||||||
// of resource downloaded to be able to check if they need to be updated.
|
|
||||||
//
|
|
||||||
// The interface can be used completly synchronously by the application and some
|
|
||||||
// context or message loop is needed in the implementation of this interface
|
|
||||||
//
|
|
||||||
// Note that the Downloader could in theory by implemented on top of JNetwork.
|
|
||||||
//
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
#include <string>
|
|
||||||
#include <ostream>
|
|
||||||
#include <istream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <map>
|
|
||||||
#include "Threading.h"
|
|
||||||
#ifdef QT_CONFIG
|
|
||||||
#include <QObject>
|
|
||||||
#include <QNetworkRequest>
|
|
||||||
#include <QNetworkReply>
|
|
||||||
#include <QNetworkAccessManager>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class DownloadRequest
|
|
||||||
#ifdef QT_CONFIG
|
|
||||||
: public QObject
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#ifdef QT_CONFIG
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
#endif
|
|
||||||
void fileDownloaded();
|
|
||||||
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
|
||||||
|
|
||||||
#ifdef QT_CONFIG
|
|
||||||
signals:
|
|
||||||
void percentChanged(int percent);
|
|
||||||
void statusChanged(int);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef enum {
|
|
||||||
NOT_PRESENT,
|
|
||||||
DOWNLOADING,
|
|
||||||
DOWNLOADED,
|
|
||||||
DOWNLOAD_ERROR
|
|
||||||
} DownloadStatus;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
string mLocalPath;
|
|
||||||
string mRemoteResourceURL;
|
|
||||||
// previous one is the original, next one can change after redirection
|
|
||||||
string mRequestedRemoteResourceURL;
|
|
||||||
string mETag;
|
|
||||||
DownloadStatus mDownloadStatus;
|
|
||||||
bool mUpgradeAvailable;
|
|
||||||
size_t mTotalSize;
|
|
||||||
size_t mCurrentSize;
|
|
||||||
ofstream mFile;
|
|
||||||
#ifdef QT_CONFIG
|
|
||||||
QNetworkReply* mNetworkReply;
|
|
||||||
static QNetworkAccessManager networkAccessManager;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
DownloadRequest(string localPath="",
|
|
||||||
string remoteResourceURL="",
|
|
||||||
string ETag = "",
|
|
||||||
DownloadStatus downloadStatus=NOT_PRESENT,
|
|
||||||
size_t totalSize = 0,
|
|
||||||
size_t currentSize = 0);
|
|
||||||
~DownloadRequest();
|
|
||||||
static bool NetworkIsAccessible();
|
|
||||||
|
|
||||||
string getTempLocalPath() const { return (mLocalPath+".tmp"); };
|
|
||||||
string getLocalPath() const { return mLocalPath; };
|
|
||||||
string getRemoteResource() const { return mRemoteResourceURL; };
|
|
||||||
string getETag() const { return mETag; };
|
|
||||||
void startGet();
|
|
||||||
void startHead();
|
|
||||||
DownloadStatus getDownloadStatus() const { return mDownloadStatus; };
|
|
||||||
bool upgradeAvailable() const { return mUpgradeAvailable; };
|
|
||||||
void getSizes(size_t& totalSize, size_t¤tSize) {
|
|
||||||
totalSize = mTotalSize;
|
|
||||||
currentSize = mCurrentSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
friend ostream& operator<<(ostream& out, const DownloadRequest& d);
|
|
||||||
friend istream& operator>>(istream&, DownloadRequest&);
|
|
||||||
friend class Downloader;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class Downloader
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
Downloader(string globalRemoteURL="", string localCacheRecords="");
|
|
||||||
virtual ~Downloader();
|
|
||||||
static Downloader* mInstance;
|
|
||||||
string mGlobalRemoteURL;
|
|
||||||
string mLocalCacheRecords;
|
|
||||||
boost::mutex mMutex;
|
|
||||||
map<string, DownloadRequest*> mRequestMap;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static Downloader* GetInstance();
|
|
||||||
static void Release();
|
|
||||||
|
|
||||||
void Update();
|
|
||||||
DownloadRequest* Get(string localPath, string remoteResourceURL="");
|
|
||||||
|
|
||||||
friend ostream& operator<<(ostream& out, const Downloader& d);
|
|
||||||
friend istream& operator>>(istream&, Downloader&);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DOWNLOADER_H
|
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
#ifndef _J_FILE_SYSTEM_H_
|
#ifndef _J_FILE_SYSTEM_H_
|
||||||
#define _J_FILE_SYSTEM_H_
|
#define _J_FILE_SYSTEM_H_
|
||||||
|
|
||||||
|
#ifdef QT_CONFIG
|
||||||
|
#include <QFile>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "zfsystem.h"
|
#include "zfsystem.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
using zip_file_system::filesystem;
|
using zip_file_system::filesystem;
|
||||||
@@ -18,13 +22,38 @@ using namespace std;
|
|||||||
/// archive file.
|
/// archive file.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
class JFile {
|
||||||
|
friend class JFileSystem;
|
||||||
|
filesystem::limited_file_info * mCurrentFileInZip;
|
||||||
|
izfstream mFile;
|
||||||
|
#ifdef QT_CONFIG
|
||||||
|
QFile *mpqFile;
|
||||||
|
#endif
|
||||||
|
public:
|
||||||
|
JFile() : mCurrentFileInZip(0)
|
||||||
|
#ifdef QT_CONFIG
|
||||||
|
, mpqFile(0)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
};
|
||||||
|
~JFile() {
|
||||||
|
#ifdef QT_CONFIG
|
||||||
|
if(mpqFile) {
|
||||||
|
mpqFile->close();
|
||||||
|
delete mpqFile;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (mFile)
|
||||||
|
mFile.close();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class JZipCache {
|
class JZipCache {
|
||||||
public:
|
public:
|
||||||
JZipCache();
|
JZipCache();
|
||||||
~JZipCache();
|
~JZipCache();
|
||||||
map<string, filesystem::limited_file_info> dir;
|
map<string, filesystem::limited_file_info> dir;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class JFileSystem {
|
class JFileSystem {
|
||||||
@@ -32,23 +61,21 @@ private:
|
|||||||
string mSystemFSPath, mUserFSPath;
|
string mSystemFSPath, mUserFSPath;
|
||||||
filesystem * mSystemFS, * mUserFS;
|
filesystem * mSystemFS, * mUserFS;
|
||||||
static JFileSystem* mInstance;
|
static JFileSystem* mInstance;
|
||||||
izfstream mFile;
|
|
||||||
|
|
||||||
map<string,JZipCache *>mZipCache;
|
map<string,JZipCache *>mZipCache;
|
||||||
unsigned int mZipCachedElementsCount;
|
unsigned int mZipCachedElementsCount;
|
||||||
string mZipFileName;
|
string mZipFileName;
|
||||||
int mFileSize;
|
|
||||||
char *mPassword;
|
char *mPassword;
|
||||||
bool mZipAvailable;
|
bool mZipAvailable;
|
||||||
void preloadZip(const string& filename);
|
void preloadZip(const string& filename);
|
||||||
izfstream mZipFile;
|
izfstream mZipFile;
|
||||||
filesystem::limited_file_info * mCurrentFileInZip;
|
|
||||||
|
|
||||||
std::vector<std::string>& scanRealFolder(const std::string& folderName, std::vector<std::string>& results);
|
std::vector<std::string>& scanRealFolder(const std::string& folderName, std::vector<std::string>& results);
|
||||||
|
bool openForRead(izfstream & File, const string & FilePath);
|
||||||
|
int GetFileSize(izfstream & file);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Attach ZIP archive to the file system.
|
/// Attach ZIP archive to the file system.
|
||||||
///
|
///
|
||||||
@@ -83,7 +110,7 @@ public:
|
|||||||
/// Open file for reading.
|
/// Open file for reading.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
bool OpenFile(const string &filename);
|
JFile* OpenFile(const string &filename);
|
||||||
|
|
||||||
//Fills the vector results with a list of children of the given folder
|
//Fills the vector results with a list of children of the given folder
|
||||||
std::vector<std::string>& scanfolder(const std::string& folderName, std::vector<std::string>& results);
|
std::vector<std::string>& scanfolder(const std::string& folderName, std::vector<std::string>& results);
|
||||||
@@ -97,20 +124,19 @@ public:
|
|||||||
/// @return Number of bytes read.
|
/// @return Number of bytes read.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
int ReadFile(void *buffer, int size);
|
int ReadFile(JFile*, void *buffer, int size);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Get size of file.
|
/// Get size of file.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
int GetFileSize();
|
int GetFileSize(JFile*);
|
||||||
int GetFileSize(izfstream & file);
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Close file.
|
/// Close file.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void CloseFile();
|
void CloseFile(JFile*);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Set root for all the following file operations
|
/// Set root for all the following file operations
|
||||||
@@ -124,11 +150,10 @@ public:
|
|||||||
void SetUSerRoot(const string& resourceRoot);
|
void SetUSerRoot(const string& resourceRoot);
|
||||||
string GetUserRoot() { return mUserFSPath; };
|
string GetUserRoot() { return mUserFSPath; };
|
||||||
|
|
||||||
bool openForRead(izfstream & File, const string & FilePath);
|
|
||||||
bool readIntoString(const string & FilePath, string & target);
|
bool readIntoString(const string & FilePath, string & target);
|
||||||
|
bool ReadFileLine(JFile*, string&);
|
||||||
bool openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode = ios_base::out );
|
bool openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode = ios_base::out );
|
||||||
bool Rename(string from, string to);
|
bool Rename(string from, string to);
|
||||||
bool Remove(string aFile);
|
|
||||||
|
|
||||||
//Returns true if strFilename exists somewhere in the fileSystem
|
//Returns true if strFilename exists somewhere in the fileSystem
|
||||||
bool FileExists(const string& strFilename);
|
bool FileExists(const string& strFilename);
|
||||||
|
|||||||
@@ -394,7 +394,6 @@ class JGE
|
|||||||
void SetJNIEnv(JNIEnv * env, jclass cls);
|
void SetJNIEnv(JNIEnv * env, jclass cls);
|
||||||
void sendJNICommand(std::string command);
|
void sendJNICommand(std::string command);
|
||||||
std::string getFileSystemLocation();
|
std::string getFileSystemLocation();
|
||||||
std::string getFileUserFolderPath();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ const int kInfoMenuID = -200;
|
|||||||
const int kRandomPlayerMenuID = -11;
|
const int kRandomPlayerMenuID = -11;
|
||||||
const int kRandomAIPlayerMenuID = -12;
|
const int kRandomAIPlayerMenuID = -12;
|
||||||
const int kEvilTwinMenuID = -14;
|
const int kEvilTwinMenuID = -14;
|
||||||
const int kCommanderMenuID = -33;
|
|
||||||
|
|
||||||
class JGuiListener
|
class JGuiListener
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ private:
|
|||||||
float mSpacing;
|
float mSpacing;
|
||||||
|
|
||||||
PIXEL_TYPE mColor;
|
PIXEL_TYPE mColor;
|
||||||
|
|
||||||
int mBase;
|
int mBase;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -598,6 +598,8 @@ private:
|
|||||||
GLint prog2_positionLoc;
|
GLint prog2_positionLoc;
|
||||||
GLint prog2_texCoordLoc;
|
GLint prog2_texCoordLoc;
|
||||||
GLint prog2_colorLoc;
|
GLint prog2_colorLoc;
|
||||||
|
// MVP matrix
|
||||||
|
ESMatrix prog2_mvpMatrix;
|
||||||
// Uniform locations
|
// Uniform locations
|
||||||
GLint prog2_mvpLoc;
|
GLint prog2_mvpLoc;
|
||||||
|
|
||||||
@@ -610,11 +612,13 @@ private:
|
|||||||
int mCurrentTextureFormat;
|
int mCurrentTextureFormat;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PSP
|
|
||||||
bool mVsync;
|
bool mVsync;
|
||||||
int mTexCounter;
|
|
||||||
#endif
|
|
||||||
int mSwizzle;
|
int mSwizzle;
|
||||||
|
int mTexCounter;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int mCurrentTextureFilter;
|
int mCurrentTextureFilter;
|
||||||
|
|
||||||
int mCurrTexBlendSrc;
|
int mCurrTexBlendSrc;
|
||||||
|
|||||||
@@ -23,32 +23,28 @@
|
|||||||
#include "SLES/OpenSLES_Android.h"
|
#include "SLES/OpenSLES_Android.h"
|
||||||
|
|
||||||
#elif defined USE_PHONON
|
#elif defined USE_PHONON
|
||||||
#include <phonon/AudioOutput>
|
#include <phonon/AudioOutput>
|
||||||
#include <phonon/MediaObject>
|
#include <phonon/MediaObject>
|
||||||
#elif (defined QT_CONFIG)
|
|
||||||
#include "QMediaPlayer"
|
|
||||||
#include "QMediaPlaylist"
|
|
||||||
#include "QSoundEffect"
|
|
||||||
#elif defined WIN32
|
#elif defined WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define WITH_FMOD
|
#define WITH_FMOD
|
||||||
#elif defined (PSP)
|
#elif defined (PSP)
|
||||||
#include <pspgu.h>
|
#include <pspgu.h>
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
#include <pspdisplay.h>
|
#include <pspdisplay.h>
|
||||||
#include <pspdebug.h>
|
#include <pspdebug.h>
|
||||||
#include <pspctrl.h>
|
#include <pspctrl.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pspaudiolib.h>
|
#include <pspaudiolib.h>
|
||||||
#include <psprtc.h>
|
#include <psprtc.h>
|
||||||
|
|
||||||
#include "JAudio.h"
|
#include "JAudio.h"
|
||||||
#include "JMP3.h"
|
#include "JMP3.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_FMOD
|
#ifdef WITH_FMOD
|
||||||
#include "../Dependencies/include/fmod.h"
|
#include "../Dependencies/include/fmod.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
@@ -71,7 +67,7 @@ public:
|
|||||||
#ifdef USE_PHONON
|
#ifdef USE_PHONON
|
||||||
Phonon::AudioOutput* mOutput;
|
Phonon::AudioOutput* mOutput;
|
||||||
Phonon::MediaObject* mMediaObject;
|
Phonon::MediaObject* mMediaObject;
|
||||||
public slots:
|
public slots:
|
||||||
void seekAtTheBegining();
|
void seekAtTheBegining();
|
||||||
#elif defined (PSP)
|
#elif defined (PSP)
|
||||||
JMP3* mTrack;
|
JMP3* mTrack;
|
||||||
@@ -86,10 +82,6 @@ public slots:
|
|||||||
SLPlayItf playInterface;
|
SLPlayItf playInterface;
|
||||||
SLSeekItf seekInterface;
|
SLSeekItf seekInterface;
|
||||||
SLVolumeItf musicVolumeInterface;
|
SLVolumeItf musicVolumeInterface;
|
||||||
#elif (defined QT_CONFIG)
|
|
||||||
QMediaPlaylist* playlist;
|
|
||||||
QMediaPlayer* player;
|
|
||||||
string fullpath;
|
|
||||||
#else
|
#else
|
||||||
void* mTrack;
|
void* mTrack;
|
||||||
#endif //WITH_FMOD
|
#endif //WITH_FMOD
|
||||||
@@ -100,15 +92,13 @@ public slots:
|
|||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
class JSample
|
class JSample
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
JSample();
|
JSample();
|
||||||
~JSample();
|
~JSample();
|
||||||
|
|
||||||
unsigned long fileSize();
|
unsigned long fileSize();
|
||||||
#if (defined QT_CONFIG) && (!defined USE_PHONON)
|
|
||||||
QMediaPlayer* effect;
|
#if defined (PSP)
|
||||||
void* mSample;
|
|
||||||
#elif defined (PSP)
|
|
||||||
WAVDATA *mSample;
|
WAVDATA *mSample;
|
||||||
#elif defined (IOS)
|
#elif defined (IOS)
|
||||||
std::string filename;
|
std::string filename;
|
||||||
@@ -143,130 +133,126 @@ class JSoundSystem
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Get the singleton instance
|
/// Get the singleton instance
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
static JSoundSystem* GetInstance();
|
static JSoundSystem* GetInstance();
|
||||||
|
|
||||||
static void Destroy();
|
static void Destroy();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Load music.
|
/// Load music.
|
||||||
///
|
///
|
||||||
/// @note MP3 is the only supported format for the moment.
|
/// @note MP3 is the only supported format for the moment.
|
||||||
///
|
///
|
||||||
/// @param filename - Name of the music file.
|
/// @param filename - Name of the music file.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
JMusic *LoadMusic(const char *fileName);
|
JMusic *LoadMusic(const char *fileName);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Delete music from memory.
|
/// Delete music from memory.
|
||||||
///
|
///
|
||||||
/// @param music - Music to be deleted.
|
/// @param music - Music to be deleted.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//void FreeMusic(JMusic *music);
|
//void FreeMusic(JMusic *music);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Play music.
|
/// Play music.
|
||||||
///
|
///
|
||||||
/// @param music - Music to be played.
|
/// @param music - Music to be played.
|
||||||
/// @param looping - Play the music in a loop.
|
/// @param looping - Play the music in a loop.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void PlayMusic(JMusic *music, bool looping = false);
|
void PlayMusic(JMusic *music, bool looping = false);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Stop playing.
|
/// Stop playing.
|
||||||
///
|
///
|
||||||
/// @param music - Music to be stopped.
|
/// @param music - Music to be stopped.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void StopMusic(JMusic *music);
|
void StopMusic(JMusic *music);
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Resume playing.
|
/// Resume playing.
|
||||||
///
|
///
|
||||||
/// @param music - Music to be resumed.
|
/// @param music - Music to be resumed.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void ResumeMusic(JMusic *music);
|
void ResumeMusic(JMusic *music);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Pause playing.
|
/// Pause playing.
|
||||||
///
|
///
|
||||||
/// @param music - Music to be paused.
|
/// @param music - Music to be paused.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void PauseMusic(JMusic *music);
|
void PauseMusic(JMusic *music);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Load sound effect.
|
/// Load sound effect.
|
||||||
///
|
///
|
||||||
/// @note WAV sound effect only.
|
/// @note WAV sound effect only.
|
||||||
///
|
///
|
||||||
/// @param fileName - Sound effect for loading.
|
/// @param fileName - Sound effect for loading.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
JSample *LoadSample(const char *fileName);
|
JSample *LoadSample(const char *fileName);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Delete sound effect from memory.
|
/// Delete sound effect from memory.
|
||||||
///
|
///
|
||||||
/// @param sample - Sound to be deleted.
|
/// @param sample - Sound to be deleted.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//void FreeSample(JSample *sample);
|
//void FreeSample(JSample *sample);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Play sound effect.
|
/// Play sound effect.
|
||||||
///
|
///
|
||||||
/// @param sample - Sound for playing.
|
/// @param sample - Sound for playing.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void PlaySample(JSample *sample);
|
void PlaySample(JSample *sample);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Set volume for audio playback.
|
/// Set volume for audio playback.
|
||||||
///
|
///
|
||||||
/// @param volume - New volume.
|
/// @param volume - New volume.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void SetVolume(int volume);
|
void SetVolume(int volume);
|
||||||
|
|
||||||
void SetMusicVolume(int volume);
|
void SetMusicVolume(int volume);
|
||||||
|
|
||||||
void SetSfxVolume(int volume);
|
void SetSfxVolume(int volume);
|
||||||
|
|
||||||
int mChannel;
|
int mChannel;
|
||||||
protected:
|
protected:
|
||||||
JSoundSystem();
|
JSoundSystem();
|
||||||
~JSoundSystem();
|
~JSoundSystem();
|
||||||
|
|
||||||
void InitSoundSystem();
|
void InitSoundSystem();
|
||||||
void DestroySoundSystem();
|
void DestroySoundSystem();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if (defined PSP || defined ANDROID)
|
|
||||||
JMusic *mCurrentMusic;
|
JMusic *mCurrentMusic;
|
||||||
JSample *mCurrentSample;
|
JSample *mCurrentSample;
|
||||||
#endif
|
|
||||||
|
|
||||||
int mVolume;
|
int mVolume;
|
||||||
#ifndef IOS
|
int mMusicVolume;
|
||||||
int mMusicVolume;
|
int mSampleVolume;
|
||||||
#endif
|
|
||||||
int mSampleVolume;
|
|
||||||
|
|
||||||
|
|
||||||
static JSoundSystem* mInstance;
|
static JSoundSystem* mInstance;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,12 @@ using namespace std;
|
|||||||
|
|
||||||
#define MID_POINT_THRESHOLD 1.0f
|
#define MID_POINT_THRESHOLD 1.0f
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Position of a single dot on screen.
|
/// Position of a single dot on screen.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
class JPoint
|
class Point
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -33,13 +34,13 @@ public:
|
|||||||
/// @param _y - Y position.
|
/// @param _y - Y position.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
JPoint(float _x, float _y) { x = _x; y = _y; }
|
Point(float _x, float _y) { x = _x; y = _y; }
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Constructor, set position to default (0.0f, 0.0f)
|
/// Constructor, set position to default (0.0f, 0.0f)
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
JPoint() { x = 0.0f; y = 0.0f; }
|
Point() { x = 0.0f; y = 0.0f; }
|
||||||
|
|
||||||
float x; ///< X position.
|
float x; ///< X position.
|
||||||
float y; ///< Y position.
|
float y; ///< Y position.
|
||||||
@@ -94,7 +95,7 @@ public:
|
|||||||
/// @param pt - Control point.
|
/// @param pt - Control point.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void AddControlPoint(const JPoint &pt);
|
void AddControlPoint(const Point &pt);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Get a control point of the spline.
|
/// Get a control point of the spline.
|
||||||
@@ -104,7 +105,7 @@ public:
|
|||||||
/// @return Control point.
|
/// @return Control point.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void GetControlPoint(JPoint &point, int index);
|
void GetControlPoint(Point &point, int index);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Work out all pixels of the spline.
|
/// Work out all pixels of the spline.
|
||||||
@@ -127,7 +128,7 @@ public:
|
|||||||
/// @return Position of the desire point.
|
/// @return Position of the desire point.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void PointOnCurve(JPoint &out, float t, const JPoint &p0, const JPoint &p1, const JPoint &p2, const JPoint &p3);
|
void PointOnCurve(Point &out, float t, const Point &p0, const Point &p1, const Point &p2, const Point &p3);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Get a number of pixels for this spline.
|
/// Get a number of pixels for this spline.
|
||||||
@@ -145,7 +146,7 @@ public:
|
|||||||
/// @return Position of the desire point.
|
/// @return Position of the desire point.
|
||||||
///
|
///
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
void GetPixel(JPoint &point, int index);
|
void GetPixel(Point &point, int index);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
/// Render the spline to screen.
|
/// Render the spline to screen.
|
||||||
@@ -155,8 +156,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
vector<JPoint> mMidPoints;
|
vector<Point> mMidPoints;
|
||||||
vector<JPoint> mPixels;
|
vector<Point> mPixels;
|
||||||
int mCount;
|
int mCount;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -311,7 +311,9 @@ namespace boost
|
|||||||
|
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QSharedPointer>
|
|
||||||
|
#include <boost/bind.hpp>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include "../include/JLogger.h"
|
#include "../include/JLogger.h"
|
||||||
|
|
||||||
@@ -418,25 +420,23 @@ namespace boost
|
|||||||
virtual void run() = 0;
|
virtual void run() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef boost::shared_ptr<detail::thread_data_base> thread_data_ptr;
|
||||||
|
|
||||||
typedef QSharedPointer<detail::thread_data_base> thread_data_ptr;
|
template<typename F>
|
||||||
|
|
||||||
template<typename F, typename A1>
|
|
||||||
class thread_data : public detail::thread_data_base
|
class thread_data : public detail::thread_data_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
thread_data(F f_, A1 a1_) : f(f_), a1(a1_)
|
thread_data(F f_) : f(f_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
f(a1);
|
f();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
F f;
|
F f;
|
||||||
A1 a1;
|
|
||||||
|
|
||||||
void operator=(thread_data&);
|
void operator=(thread_data&);
|
||||||
thread_data(thread_data&);
|
thread_data(thread_data&);
|
||||||
@@ -493,7 +493,7 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class F,class A1>
|
template <class F,class A1>
|
||||||
thread(F f, A1 a1) : mThreadInfo(make_thread_info(f, a1))
|
thread(F f, A1 a1) : mThreadInfo(make_thread_info(boost::bind(boost::type<void>(), f, a1)))
|
||||||
{
|
{
|
||||||
mpThread = new threadImpl(mThreadInfo);
|
mpThread = new threadImpl(mThreadInfo);
|
||||||
LOG("Calling start func");
|
LOG("Calling start func");
|
||||||
@@ -510,10 +510,10 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename F, typename A1>
|
template<typename F>
|
||||||
static inline detail::thread_data_ptr make_thread_info(F f, A1 a1)
|
static inline detail::thread_data_ptr make_thread_info(F f)
|
||||||
{
|
{
|
||||||
return detail::thread_data_ptr(new detail::thread_data<F, A1>(f, a1));
|
return detail::thread_data_ptr(new detail::thread_data<F>(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
detail::thread_data_ptr mThreadInfo;
|
detail::thread_data_ptr mThreadInfo;
|
||||||
|
|||||||
@@ -137,14 +137,14 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int lastPosx(){
|
int lastPosx(){
|
||||||
#if QT_VERSION >= 0x050100
|
#if QT_VERSION >= 0x050000
|
||||||
return m_lastPos.x()*devicePixelRatio();
|
return m_lastPos.x()*devicePixelRatio();
|
||||||
#else
|
#else
|
||||||
return m_lastPos.x();
|
return m_lastPos.x();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
int lastPosy(){
|
int lastPosy(){
|
||||||
#if QT_VERSION >= 0x050100
|
#if QT_VERSION >= 0x050000
|
||||||
return m_lastPos.y()*devicePixelRatio();
|
return m_lastPos.y()*devicePixelRatio();
|
||||||
#else
|
#else
|
||||||
return m_lastPos.y();
|
return m_lastPos.y();
|
||||||
|
|||||||
@@ -1,298 +0,0 @@
|
|||||||
#include "DebugRoutines.h"
|
|
||||||
#include "JFileSystem.h"
|
|
||||||
#include "Downloader.h"
|
|
||||||
|
|
||||||
#define RECORDS_DEFAULT_FILE "cache/records.txt"
|
|
||||||
|
|
||||||
#ifdef QT_CONFIG
|
|
||||||
QNetworkAccessManager DownloadRequest::networkAccessManager;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DownloadRequest::DownloadRequest(string localPath,
|
|
||||||
string remoteResourceURL,
|
|
||||||
string ETag,
|
|
||||||
DownloadStatus downloadStatus,
|
|
||||||
size_t totalSize,
|
|
||||||
size_t currentSize):
|
|
||||||
mLocalPath(localPath),
|
|
||||||
mRemoteResourceURL(remoteResourceURL),
|
|
||||||
mRequestedRemoteResourceURL(remoteResourceURL),
|
|
||||||
mETag(ETag),
|
|
||||||
mDownloadStatus(downloadStatus),
|
|
||||||
mUpgradeAvailable(false),
|
|
||||||
mTotalSize(totalSize),
|
|
||||||
mCurrentSize(currentSize)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadRequest::~DownloadRequest()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadRequest::startHead()
|
|
||||||
{
|
|
||||||
#ifdef QT_CONFIG
|
|
||||||
QNetworkRequest request(QUrl(QString(mRequestedRemoteResourceURL.c_str())));
|
|
||||||
request.setRawHeader("If-None-Match", mETag.c_str());
|
|
||||||
mNetworkReply = networkAccessManager.head(request);
|
|
||||||
connect(mNetworkReply, SIGNAL(finished()), SLOT(fileDownloaded()));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadRequest::startGet()
|
|
||||||
{
|
|
||||||
#ifdef QT_CONFIG
|
|
||||||
mNetworkReply = networkAccessManager.get(QNetworkRequest(QUrl(QString(mRequestedRemoteResourceURL.c_str()))));
|
|
||||||
#endif
|
|
||||||
mFile.close();
|
|
||||||
JFileSystem::GetInstance()->Remove(getTempLocalPath());
|
|
||||||
JFileSystem::GetInstance()->openForWrite(mFile, getTempLocalPath());
|
|
||||||
#ifdef QT_CONFIG
|
|
||||||
connect(mNetworkReply, SIGNAL(downloadProgress(qint64, qint64)),
|
|
||||||
SLOT(downloadProgress(qint64, qint64)));
|
|
||||||
connect(mNetworkReply, SIGNAL(finished()), SLOT(fileDownloaded()));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadRequest::fileDownloaded()
|
|
||||||
{
|
|
||||||
do {
|
|
||||||
QByteArray eTagByteArray = mNetworkReply->rawHeader("ETag");
|
|
||||||
if(!eTagByteArray.isEmpty()) {
|
|
||||||
string oldETag = mETag;
|
|
||||||
mETag = QString(eTagByteArray).toStdString();
|
|
||||||
if(oldETag!="" && oldETag != mETag)
|
|
||||||
mUpgradeAvailable = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// let's check some error
|
|
||||||
if(mNetworkReply->error() != QNetworkReply::NoError) {
|
|
||||||
DebugTrace(mNetworkReply->errorString().toStdString());
|
|
||||||
mDownloadStatus = DownloadRequest::DOWNLOAD_ERROR;
|
|
||||||
mFile.close();
|
|
||||||
JFileSystem::GetInstance()->Remove(getTempLocalPath());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if we're getting redirected
|
|
||||||
QVariant redirectionTarget = mNetworkReply->attribute(QNetworkRequest::RedirectionTargetAttribute);
|
|
||||||
if (!redirectionTarget.isNull()) {
|
|
||||||
QUrl newUrl = QUrl(mRequestedRemoteResourceURL.c_str()).resolved(redirectionTarget.toUrl());
|
|
||||||
DebugTrace(string("Redirect to ")+ newUrl.toString().toStdString());
|
|
||||||
|
|
||||||
mRequestedRemoteResourceURL = newUrl.toString().toStdString();
|
|
||||||
mNetworkReply->deleteLater();
|
|
||||||
if(mFile.is_open())
|
|
||||||
startGet();
|
|
||||||
else
|
|
||||||
startHead();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mFile.is_open())
|
|
||||||
{
|
|
||||||
QByteArray byteArray = mNetworkReply->readAll();
|
|
||||||
mFile.write(byteArray.constData(), byteArray.size());
|
|
||||||
mFile.close();
|
|
||||||
if(!JFileSystem::GetInstance()->Rename(getTempLocalPath(), mLocalPath)) {
|
|
||||||
mDownloadStatus = DownloadRequest::DOWNLOAD_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mDownloadStatus = DownloadRequest::DOWNLOADED;
|
|
||||||
} while(0);
|
|
||||||
|
|
||||||
Downloader::GetInstance()->Update();
|
|
||||||
mNetworkReply->deleteLater();
|
|
||||||
|
|
||||||
emit statusChanged((int)mDownloadStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DownloadRequest::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
|
||||||
{
|
|
||||||
QByteArray byteArray = mNetworkReply->readAll();
|
|
||||||
mFile.write(byteArray.constData(), byteArray.size());
|
|
||||||
mCurrentSize = bytesReceived;
|
|
||||||
mTotalSize = bytesTotal;
|
|
||||||
int percent = 0;
|
|
||||||
if(bytesTotal)
|
|
||||||
percent = (bytesReceived/bytesTotal)*100;
|
|
||||||
emit percentChanged(percent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Downloader* Downloader::mInstance = 0;
|
|
||||||
|
|
||||||
Downloader::Downloader(string globalRemoteURL, string localcacheRecords):
|
|
||||||
mGlobalRemoteURL(globalRemoteURL),
|
|
||||||
mLocalCacheRecords(localcacheRecords)
|
|
||||||
{
|
|
||||||
JFileSystem::GetInstance()->MakeDir("cache");
|
|
||||||
|
|
||||||
izfstream downloadRecords;
|
|
||||||
if(mLocalCacheRecords.empty())
|
|
||||||
mLocalCacheRecords = RECORDS_DEFAULT_FILE;
|
|
||||||
if(JFileSystem::GetInstance()->openForRead(downloadRecords, mLocalCacheRecords))
|
|
||||||
{// File exists, let's read it.
|
|
||||||
downloadRecords >> (*this);
|
|
||||||
}
|
|
||||||
JFileSystem::GetInstance()->CloseFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
Downloader::~Downloader()
|
|
||||||
{
|
|
||||||
map<string, DownloadRequest*>::iterator ite;
|
|
||||||
for(ite = mRequestMap.begin(); ite != mRequestMap.end(); ite++)
|
|
||||||
{
|
|
||||||
delete (*ite).second;
|
|
||||||
}
|
|
||||||
mRequestMap.erase(mRequestMap.begin(), mRequestMap.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
Downloader* Downloader::GetInstance()
|
|
||||||
{
|
|
||||||
if(!mInstance)
|
|
||||||
{
|
|
||||||
mInstance = new Downloader();
|
|
||||||
}
|
|
||||||
return mInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Downloader::Release()
|
|
||||||
{
|
|
||||||
if(mInstance)
|
|
||||||
{
|
|
||||||
delete mInstance;
|
|
||||||
mInstance = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DownloadRequest::NetworkIsAccessible()
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
#ifdef QT_CONFIG
|
|
||||||
networkAccessManager.setNetworkAccessible(QNetworkAccessManager::Accessible);
|
|
||||||
result = networkAccessManager.networkAccessible();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadRequest* Downloader::Get(string localPath, string remoteResourceURL)
|
|
||||||
{
|
|
||||||
map<string, DownloadRequest*>::iterator ite = mRequestMap.find(localPath);
|
|
||||||
if(ite == mRequestMap.end())
|
|
||||||
{ // request does not exist, let's create it
|
|
||||||
DownloadRequest* request = new DownloadRequest(localPath, remoteResourceURL);
|
|
||||||
std::pair<std::map<string,DownloadRequest*>::iterator,bool> ret;
|
|
||||||
ret = mRequestMap.insert ( std::pair<string,DownloadRequest*>(localPath, request) );
|
|
||||||
if (ret.second==false) {
|
|
||||||
DebugTrace("Downloader::Get Error inserting request in Map");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
ite = ret.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now, we can check the server
|
|
||||||
if((*ite).second->getDownloadStatus() == DownloadRequest::NOT_PRESENT ||
|
|
||||||
(*ite).second->upgradeAvailable())
|
|
||||||
{ // File is not here or an update is available, let's get it
|
|
||||||
(*ite).second->startGet();
|
|
||||||
(*ite).second->mDownloadStatus = DownloadRequest::DOWNLOADING;
|
|
||||||
}
|
|
||||||
else if ((*ite).second->getDownloadStatus() == DownloadRequest::DOWNLOADED)
|
|
||||||
{ // File is here, let's check if there is some update without blocking the playback
|
|
||||||
(*ite).second->startHead();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (*ite).second;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Downloader::Update()
|
|
||||||
{
|
|
||||||
ofstream downloadRecords;
|
|
||||||
if(JFileSystem::GetInstance()->openForWrite(downloadRecords, mLocalCacheRecords))
|
|
||||||
{
|
|
||||||
downloadRecords << (*this);
|
|
||||||
}
|
|
||||||
downloadRecords.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
ostream& operator<<(ostream& out, const DownloadRequest& d)
|
|
||||||
{
|
|
||||||
// HEAD request fails, so this line erase cache record after upgrade check :(
|
|
||||||
// if(d.getDownloadStatus() == DownloadRequest::DOWNLOADED)
|
|
||||||
{
|
|
||||||
out << "localPath=" << d.mLocalPath << endl;
|
|
||||||
out << "remoteResource=" << d.mRemoteResourceURL << endl;
|
|
||||||
out << "ETag=" << d.mETag << endl;
|
|
||||||
out << "upgradeAvailable=" << d.mUpgradeAvailable <<endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
istream& operator>>(istream& in, DownloadRequest& d)
|
|
||||||
{
|
|
||||||
string s;
|
|
||||||
|
|
||||||
while(std::getline(in, s))
|
|
||||||
{
|
|
||||||
size_t limiter = s.find("=");
|
|
||||||
string areaS;
|
|
||||||
if (limiter != string::npos)
|
|
||||||
{
|
|
||||||
areaS = s.substr(0, limiter);
|
|
||||||
if (areaS.compare("localPath") == 0)
|
|
||||||
{
|
|
||||||
d.mLocalPath = s.substr(limiter + 1);
|
|
||||||
}
|
|
||||||
else if (areaS.compare("remoteResource") == 0)
|
|
||||||
{
|
|
||||||
d.mRemoteResourceURL = s.substr(limiter + 1);
|
|
||||||
d.mRequestedRemoteResourceURL = d.mRemoteResourceURL;
|
|
||||||
}
|
|
||||||
else if (areaS.compare("ETag") == 0)
|
|
||||||
{
|
|
||||||
d.mETag = s.substr(limiter + 1);
|
|
||||||
d.mDownloadStatus = DownloadRequest::DOWNLOADED;
|
|
||||||
}
|
|
||||||
else if (areaS.compare("upgradeAvailable") == 0)
|
|
||||||
{
|
|
||||||
d.mUpgradeAvailable = (bool)atoi(s.substr(limiter + 1).c_str());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
ostream& operator<<(ostream& out, const Downloader& d)
|
|
||||||
{
|
|
||||||
map<string, DownloadRequest*>::const_iterator ite;
|
|
||||||
for(ite = d.mRequestMap.begin(); ite != d.mRequestMap.end(); ite++)
|
|
||||||
{
|
|
||||||
out << (*(*ite).second) << endl;
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
istream& operator>>(istream& in, Downloader& d)
|
|
||||||
{
|
|
||||||
while(!in.eof())
|
|
||||||
{
|
|
||||||
DownloadRequest* downloadRequest = new DownloadRequest();
|
|
||||||
in >> (*downloadRequest);
|
|
||||||
|
|
||||||
if(!downloadRequest->getLocalPath().empty() &&
|
|
||||||
!downloadRequest->getRemoteResource().empty() &&
|
|
||||||
!downloadRequest->getETag().empty()) {
|
|
||||||
d.mRequestMap[downloadRequest->getLocalPath()] = downloadRequest;
|
|
||||||
} else {
|
|
||||||
delete downloadRequest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -44,11 +44,12 @@ bool JAnimator::Load(const char* scriptFile)
|
|||||||
JFileSystem *fileSystem = JFileSystem::GetInstance();
|
JFileSystem *fileSystem = JFileSystem::GetInstance();
|
||||||
if (fileSystem == NULL) return false;
|
if (fileSystem == NULL) return false;
|
||||||
|
|
||||||
if (!fileSystem->OpenFile(scriptFile)) return false;
|
JFile* jFile = fileSystem->OpenFile(scriptFile);
|
||||||
|
if (!jFile) return false;
|
||||||
|
|
||||||
int size = fileSystem->GetFileSize();
|
int size = fileSystem->GetFileSize(jFile);
|
||||||
char *xmlBuffer = new char[size];
|
char *xmlBuffer = new char[size];
|
||||||
fileSystem->ReadFile(xmlBuffer, size);
|
fileSystem->ReadFile(jFile, xmlBuffer, size);
|
||||||
|
|
||||||
TiXmlDocument doc;
|
TiXmlDocument doc;
|
||||||
doc.Parse(xmlBuffer);
|
doc.Parse(xmlBuffer);
|
||||||
@@ -173,7 +174,7 @@ bool JAnimator::Load(const char* scriptFile)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
delete[] xmlBuffer;
|
delete[] xmlBuffer;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
|||||||
{
|
{
|
||||||
|
|
||||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
if (!fileSystem->OpenFile(fileName))
|
JFile* jFile = fileSystem->OpenFile(fileName);
|
||||||
|
if (!jFile)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memset(p_wav, 0, sizeof(WAVDATA));
|
memset(p_wav, 0, sizeof(WAVDATA));
|
||||||
@@ -57,14 +58,14 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
|||||||
char head[256];
|
char head[256];
|
||||||
memset(head, 0, 256);
|
memset(head, 0, 256);
|
||||||
//sceIoRead(fd, head, 20);
|
//sceIoRead(fd, head, 20);
|
||||||
fileSystem->ReadFile(head, 20);
|
fileSystem->ReadFile(jFile, head, 20);
|
||||||
char string[8];
|
char string[8];
|
||||||
memset(string, 0, 8);
|
memset(string, 0, 8);
|
||||||
memcpy(string, head, 4);
|
memcpy(string, head, 4);
|
||||||
if (0!=strcmp(string, "RIFF"))
|
if (0!=strcmp(string, "RIFF"))
|
||||||
{
|
{
|
||||||
//sceIoClose(fd);
|
//sceIoClose(fd);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
memset(string, 0, 8);
|
memset(string, 0, 8);
|
||||||
@@ -72,7 +73,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
|||||||
if (0!=strcmp(string, "WAVE"))
|
if (0!=strcmp(string, "WAVE"))
|
||||||
{
|
{
|
||||||
//sceIoClose(fd);
|
//sceIoClose(fd);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
memset(string, 0, 8);
|
memset(string, 0, 8);
|
||||||
@@ -80,42 +81,42 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
|||||||
if (0!=strcmp(string, "fmt"))
|
if (0!=strcmp(string, "fmt"))
|
||||||
{
|
{
|
||||||
//sceIoClose(fd);
|
//sceIoClose(fd);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int fmtSize = 0;
|
int fmtSize = 0;
|
||||||
memcpy(&fmtSize, head+16, 4);
|
memcpy(&fmtSize, head+16, 4);
|
||||||
//sceIoRead(fd, head+20, fmtSize);
|
//sceIoRead(fd, head+20, fmtSize);
|
||||||
fileSystem->ReadFile(head+20,fmtSize );
|
fileSystem->ReadFile(jFile, head+20,fmtSize );
|
||||||
p_wav->headSize = 20+fmtSize;
|
p_wav->headSize = 20+fmtSize;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
//sceIoRead(fd, head+p_wav->headSize, 4);
|
//sceIoRead(fd, head+p_wav->headSize, 4);
|
||||||
fileSystem->ReadFile(head+p_wav->headSize, 4);
|
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4);
|
||||||
memset(string, 0, 8);
|
memset(string, 0, 8);
|
||||||
memcpy(string, head+p_wav->headSize, 4);
|
memcpy(string, head+p_wav->headSize, 4);
|
||||||
p_wav->headSize += 4;
|
p_wav->headSize += 4;
|
||||||
if (0!=strcmp(string, "data"))
|
if (0!=strcmp(string, "data"))
|
||||||
{
|
{
|
||||||
//sceIoRead(fd, head+p_wav->headSize, 4);
|
//sceIoRead(fd, head+p_wav->headSize, 4);
|
||||||
fileSystem->ReadFile(head+p_wav->headSize, 4);
|
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4);
|
||||||
memcpy(&fmtSize, head+p_wav->headSize, 4);
|
memcpy(&fmtSize, head+p_wav->headSize, 4);
|
||||||
p_wav->headSize += 4;
|
p_wav->headSize += 4;
|
||||||
//sceIoRead(fd, head+p_wav->headSize, fmtSize);
|
//sceIoRead(fd, head+p_wav->headSize, fmtSize);
|
||||||
fileSystem->ReadFile(head+p_wav->headSize, fmtSize);
|
fileSystem->ReadFile(jFile, head+p_wav->headSize, fmtSize);
|
||||||
p_wav->headSize += fmtSize;
|
p_wav->headSize += fmtSize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//sceIoRead(fd, head+p_wav->headSize, 4);
|
//sceIoRead(fd, head+p_wav->headSize, 4);
|
||||||
fileSystem->ReadFile(head+p_wav->headSize, 4);
|
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4);
|
||||||
p_wav->headSize += 4;
|
p_wav->headSize += 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (p_wav->headSize>191)
|
if (p_wav->headSize>191)
|
||||||
{
|
{
|
||||||
//sceIoClose(fd);
|
//sceIoClose(fd);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +127,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
|||||||
if (p_wav->channelCount!=1 && p_wav->channelCount!=2)
|
if (p_wav->channelCount!=1 && p_wav->channelCount!=2)
|
||||||
{
|
{
|
||||||
//sceIoClose(fd);
|
//sceIoClose(fd);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
memcpy(&p_wav->samplePerSecond, head+24, 4);
|
memcpy(&p_wav->samplePerSecond, head+24, 4);
|
||||||
@@ -136,7 +137,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
|||||||
if (p_wav->bytePerSample!=1 && p_wav->bytePerSample!=2)
|
if (p_wav->bytePerSample!=1 && p_wav->bytePerSample!=2)
|
||||||
{
|
{
|
||||||
//sceIoClose(fd);
|
//sceIoClose(fd);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
p_wav->nSample = 44100 / p_wav->samplePerSecond;
|
p_wav->nSample = 44100 / p_wav->samplePerSecond;
|
||||||
@@ -147,17 +148,17 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
|
|||||||
if (p_wav->soundSize>4096000)
|
if (p_wav->soundSize>4096000)
|
||||||
{
|
{
|
||||||
//sceIoClose(fd);
|
//sceIoClose(fd);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
p_wav->buffer = (char*)malloc(p_wav->soundSize);
|
p_wav->buffer = (char*)malloc(p_wav->soundSize);
|
||||||
memset(p_wav->buffer, 0, p_wav->soundSize);
|
memset(p_wav->buffer, 0, p_wav->soundSize);
|
||||||
//sceIoRead(fd, p_wav->buffer, p_wav->soundSize);
|
//sceIoRead(fd, p_wav->buffer, p_wav->soundSize);
|
||||||
fileSystem->ReadFile(p_wav->buffer, p_wav->soundSize);
|
fileSystem->ReadFile(jFile, p_wav->buffer, p_wav->soundSize);
|
||||||
p_wav->bytePosition = 0;
|
p_wav->bytePosition = 0;
|
||||||
p_wav->fd = -1;
|
p_wav->fd = -1;
|
||||||
//sceIoClose(fd);
|
//sceIoClose(fd);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,14 +16,9 @@ User folder is the only one that is really needed to guarantee both read and wri
|
|||||||
The content that users should not be touching.
|
The content that users should not be touching.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined (ANDROID)
|
#ifndef PSP
|
||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#endif //ANDROID
|
#endif //PSP
|
||||||
|
|
||||||
#if defined (LINUX)
|
|
||||||
#include "../../projects/mtg/include/PrecompiledHeader.h"
|
|
||||||
#endif //LINUX
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#pragma warning(disable : 4786)
|
#pragma warning(disable : 4786)
|
||||||
@@ -43,12 +38,6 @@ The content that users should not be touching.
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
#ifdef IOS
|
|
||||||
#include <Foundation/Foundation.h>
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
JFileSystem* JFileSystem::mInstance = NULL;
|
JFileSystem* JFileSystem::mInstance = NULL;
|
||||||
|
|
||||||
JZipCache::JZipCache()
|
JZipCache::JZipCache()
|
||||||
@@ -118,7 +107,6 @@ JFileSystem* JFileSystem::GetInstance()
|
|||||||
// Tries to set the system and user paths.
|
// Tries to set the system and user paths.
|
||||||
// On some OSes, the parameters get overriden by hardcoded values
|
// On some OSes, the parameters get overriden by hardcoded values
|
||||||
JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
|
JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
|
||||||
|
|
||||||
{
|
{
|
||||||
string systemPath = _systemPath;
|
string systemPath = _systemPath;
|
||||||
string userPath = _userPath;
|
string userPath = _userPath;
|
||||||
@@ -131,11 +119,10 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
|
|||||||
systemPath = [[documentsDirectory stringByAppendingString: @"/Res/"] cStringUsingEncoding:1];
|
systemPath = [[documentsDirectory stringByAppendingString: @"/Res/"] cStringUsingEncoding:1];
|
||||||
|
|
||||||
#elif defined (ANDROID)
|
#elif defined (ANDROID)
|
||||||
userPath = JGE::GetInstance()->getFileUserFolderPath();
|
userPath = JGE::GetInstance()->getFileSystemLocation();
|
||||||
systemPath = JGE::GetInstance()->getFileSystemLocation();
|
systemPath = "";
|
||||||
|
|
||||||
DebugTrace("User path " << userPath);
|
DebugTrace("User path " << userPath);
|
||||||
DebugTrace("System path " << systemPath);
|
|
||||||
#elif defined (QT_CONFIG)
|
#elif defined (QT_CONFIG)
|
||||||
|
|
||||||
QDir sysDir(RESDIR);
|
QDir sysDir(RESDIR);
|
||||||
@@ -143,8 +130,8 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
|
|||||||
dir.mkdir(USERDIR);
|
dir.mkdir(USERDIR);
|
||||||
dir.cd(USERDIR);
|
dir.cd(USERDIR);
|
||||||
|
|
||||||
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
|
|
||||||
systemPath = QDir::toNativeSeparators(sysDir.absolutePath()).toStdString();
|
systemPath = QDir::toNativeSeparators(sysDir.absolutePath()).toStdString();
|
||||||
|
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
|
||||||
|
|
||||||
DebugTrace("User path " << userPath);
|
DebugTrace("User path " << userPath);
|
||||||
DebugTrace("System path " << systemPath);
|
DebugTrace("System path " << systemPath);
|
||||||
@@ -204,9 +191,6 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
|
|||||||
mZipAvailable = false;
|
mZipAvailable = false;
|
||||||
mZipCachedElementsCount = 0;
|
mZipCachedElementsCount = 0;
|
||||||
mPassword = NULL;
|
mPassword = NULL;
|
||||||
mFileSize = 0;
|
|
||||||
mCurrentFileInZip = NULL;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void JFileSystem::Destroy()
|
void JFileSystem::Destroy()
|
||||||
@@ -220,14 +204,26 @@ void JFileSystem::Destroy()
|
|||||||
|
|
||||||
bool JFileSystem::DirExists(const string& strDirname)
|
bool JFileSystem::DirExists(const string& strDirname)
|
||||||
{
|
{
|
||||||
return (mSystemFS && mSystemFS->DirExists(strDirname)) || mUserFS->DirExists(strDirname);
|
return (
|
||||||
|
(mSystemFS && mSystemFS->DirExists(strDirname))
|
||||||
|
|| mUserFS->DirExists(strDirname)
|
||||||
|
#ifdef QT_CONFIG
|
||||||
|
|| QDir(QString(":/") + strDirname.c_str()).exists()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JFileSystem::FileExists(const string& strFilename)
|
bool JFileSystem::FileExists(const string& strFilename)
|
||||||
{
|
{
|
||||||
if (strFilename.length() < 1 ) return false;
|
if (strFilename.length() < 1 ) return false;
|
||||||
|
|
||||||
return (mSystemFS && mSystemFS->FileExists(strFilename)) || mUserFS->FileExists(strFilename);
|
return (
|
||||||
|
(mSystemFS && mSystemFS->FileExists(strFilename))
|
||||||
|
|| mUserFS->FileExists(strFilename)
|
||||||
|
#ifdef QT_CONFIG
|
||||||
|
|| QFile(QString(":/") + strFilename.c_str()).exists()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JFileSystem::MakeDir(const string & dir)
|
bool JFileSystem::MakeDir(const string & dir)
|
||||||
@@ -260,15 +256,14 @@ void JFileSystem::clearZipCache()
|
|||||||
|
|
||||||
bool JFileSystem::AttachZipFile(const string &zipfile, char *password /* = NULL */)
|
bool JFileSystem::AttachZipFile(const string &zipfile, char *password /* = NULL */)
|
||||||
{
|
{
|
||||||
#ifndef WIN32
|
if (mZipAvailable && mZipFile != NULL)
|
||||||
if (mZipAvailable && mZipFile.is_open())
|
|
||||||
{
|
{
|
||||||
if (mZipFileName != zipfile)
|
if (mZipFileName != zipfile)
|
||||||
DetachZipFile(); // close the previous zip file
|
DetachZipFile(); // close the previous zip file
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
mZipFileName = zipfile;
|
mZipFileName = zipfile;
|
||||||
mPassword = password;
|
mPassword = password;
|
||||||
|
|
||||||
@@ -288,7 +283,6 @@ bool JFileSystem::AttachZipFile(const string &zipfile, char *password /* = NULL
|
|||||||
}
|
}
|
||||||
mZipAvailable = true;
|
mZipAvailable = true;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -298,7 +292,6 @@ void JFileSystem::DetachZipFile()
|
|||||||
{
|
{
|
||||||
mZipFile.close();
|
mZipFile.close();
|
||||||
}
|
}
|
||||||
mCurrentFileInZip = NULL;
|
|
||||||
mZipAvailable = false;
|
mZipAvailable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,28 +313,58 @@ bool JFileSystem::openForRead(izfstream & File, const string & FilePath) {
|
|||||||
|
|
||||||
bool JFileSystem::readIntoString(const string & FilePath, string & target)
|
bool JFileSystem::readIntoString(const string & FilePath, string & target)
|
||||||
{
|
{
|
||||||
izfstream file;
|
bool result = false;
|
||||||
if (!openForRead(file, FilePath))
|
|
||||||
return false;
|
// Trying first with a izfstream
|
||||||
|
do {
|
||||||
int fileSize = GetFileSize(file);
|
izfstream file;
|
||||||
|
if (!openForRead(file, FilePath))
|
||||||
|
break;
|
||||||
|
|
||||||
|
int fileSize = GetFileSize(file);
|
||||||
|
|
||||||
#ifndef __MINGW32__
|
#ifndef __MINGW32__
|
||||||
try {
|
try {
|
||||||
#endif
|
#endif
|
||||||
target.resize((std::string::size_type) fileSize);
|
target.resize((std::string::size_type) fileSize);
|
||||||
#ifndef __MINGW32__
|
#ifndef __MINGW32__
|
||||||
} catch (bad_alloc&) {
|
} catch (bad_alloc&) {
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (fileSize)
|
||||||
|
file.read(&target[0], fileSize);
|
||||||
if (fileSize)
|
|
||||||
file.read(&target[0], fileSize);
|
file.close();
|
||||||
|
result = true;
|
||||||
file.close();
|
} while (0);
|
||||||
return true;
|
#ifdef QT_CONFIG
|
||||||
|
// Now we try with qrc if we haven't finc anything yet
|
||||||
|
if (!result) do {
|
||||||
|
string path = string(":/") + FilePath.c_str();
|
||||||
|
QFile qfile(path.c_str());
|
||||||
|
qfile.open(QIODevice::ReadOnly);
|
||||||
|
if(!qfile.isReadable())
|
||||||
|
break;
|
||||||
|
int fileSize = qfile.size();
|
||||||
|
#ifndef __MINGW32__
|
||||||
|
try {
|
||||||
|
#endif
|
||||||
|
target.resize((std::string::size_type) fileSize);
|
||||||
|
#ifndef __MINGW32__
|
||||||
|
} catch (bad_alloc&) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (fileSize)
|
||||||
|
qfile.read(&target[0], fileSize);
|
||||||
|
|
||||||
|
qfile.close();
|
||||||
|
result = true;
|
||||||
|
} while (0);
|
||||||
|
#endif //QT_CONFIG
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode)
|
bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode)
|
||||||
@@ -387,57 +410,72 @@ bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_bas
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JFileSystem::OpenFile(const string &filename)
|
JFile* JFileSystem::OpenFile(const string &filename)
|
||||||
{
|
{
|
||||||
mCurrentFileInZip = NULL;
|
bool result;
|
||||||
|
JFile* jFile = new JFile();
|
||||||
|
jFile->mCurrentFileInZip = NULL;
|
||||||
|
|
||||||
if (!mZipAvailable || !mZipFile)
|
do {
|
||||||
return openForRead(mFile, filename);
|
if (!mZipAvailable || !mZipFile) {
|
||||||
|
result = openForRead(jFile->mFile, filename);
|
||||||
|
if(!result) {
|
||||||
|
#ifdef QT_CONFIG
|
||||||
|
string path = string(":/") + filename.c_str();
|
||||||
|
jFile->mpqFile = new QFile(path.c_str());
|
||||||
|
jFile->mpqFile->open(QIODevice::ReadOnly);
|
||||||
|
result = jFile->mpqFile->isReadable();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
preloadZip(mZipFileName);
|
preloadZip(mZipFileName);
|
||||||
map<string,JZipCache *>::iterator it = mZipCache.find(mZipFileName);
|
map<string,JZipCache *>::iterator it = mZipCache.find(mZipFileName);
|
||||||
if (it == mZipCache.end())
|
if (it == mZipCache.end())
|
||||||
{
|
{
|
||||||
//DetachZipFile();
|
//DetachZipFile();
|
||||||
//return OpenFile(filename);
|
//return OpenFile(filename);
|
||||||
return openForRead(mFile, filename);
|
result = openForRead(jFile->mFile, filename);
|
||||||
}
|
break;
|
||||||
JZipCache * zc = it->second;
|
}
|
||||||
map<string, filesystem::limited_file_info>::iterator it2 = zc->dir.find(filename);
|
JZipCache * zc = it->second;
|
||||||
if (it2 == zc->dir.end())
|
map<string, filesystem::limited_file_info>::iterator it2 = zc->dir.find(filename);
|
||||||
{
|
if (it2 == zc->dir.end())
|
||||||
/*DetachZipFile();
|
{
|
||||||
|
/*DetachZipFile();
|
||||||
return OpenFile(filename); */
|
return OpenFile(filename); */
|
||||||
return openForRead(mFile, filename);
|
result = openForRead(jFile->mFile, filename);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
jFile->mCurrentFileInZip = &(it2->second);
|
||||||
|
result = true;
|
||||||
|
} while(0);
|
||||||
|
|
||||||
|
if(result)
|
||||||
|
return jFile;
|
||||||
|
else {
|
||||||
|
delete jFile;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mCurrentFileInZip = &(it2->second);
|
|
||||||
mFileSize = it2->second.m_Size;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JFileSystem::CloseFile()
|
void JFileSystem::CloseFile(JFile* jFile)
|
||||||
{
|
{
|
||||||
if (mZipAvailable && mZipFile)
|
delete jFile;
|
||||||
{
|
|
||||||
mCurrentFileInZip = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mFile)
|
|
||||||
mFile.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns 0 if less than "size" bits were read
|
//returns 0 if less than "size" bits were read
|
||||||
int JFileSystem::ReadFile(void *buffer, int size)
|
int JFileSystem::ReadFile(JFile* jFile, void *buffer, int size)
|
||||||
{
|
{
|
||||||
if (mCurrentFileInZip)
|
if (jFile->mCurrentFileInZip)
|
||||||
{
|
{
|
||||||
assert(mZipFile);
|
assert(mZipFile);
|
||||||
if((size_t)size > mCurrentFileInZip->m_Size) //only support "store" method for zip inside zips
|
if((size_t)size > jFile->mCurrentFileInZip->m_Size) //only support "store" method for zip inside zips
|
||||||
return 0;
|
return 0;
|
||||||
std::streamoff offset = filesystem::SkipLFHdr(mZipFile, mCurrentFileInZip->m_Offset);
|
std::streamoff offset = filesystem::SkipLFHdr(mZipFile, jFile->mCurrentFileInZip->m_Offset);
|
||||||
if (!mZipFile.seekg(offset))
|
if (!mZipFile.seekg(offset))
|
||||||
return 0;
|
return 0;
|
||||||
mZipFile.read((char *) buffer, size);
|
mZipFile.read((char *) buffer, size);
|
||||||
@@ -445,16 +483,43 @@ int JFileSystem::ReadFile(void *buffer, int size)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mFile)
|
#ifdef QT_CONFIG
|
||||||
|
if(jFile->mpqFile) {
|
||||||
|
return jFile->mpqFile->read((char*)buffer, size);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!jFile->mFile)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
assert(!mFile.Zipped() || (size_t)size <= mFile.getUncompSize());
|
assert(!jFile->mFile.Zipped() || (size_t)size <= jFile->mFile.getUncompSize());
|
||||||
mFile.read((char *)buffer, size);
|
jFile->mFile.read((char *)buffer, size);
|
||||||
if (mFile.eof())
|
if (jFile->mFile.eof())
|
||||||
return 0;
|
return 0;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JFileSystem::ReadFileLine(JFile* jFile, string& s)
|
||||||
|
{
|
||||||
|
if(!jFile) return false;
|
||||||
|
#ifdef QT_CONFIG
|
||||||
|
if(jFile->mpqFile) {
|
||||||
|
QString qs = jFile->mpqFile->readLine();
|
||||||
|
if(qs.isEmpty())
|
||||||
|
return false;
|
||||||
|
else {
|
||||||
|
s = qs.toStdString();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if(!jFile->mFile)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
assert(!jFile->mFile.Zipped());
|
||||||
|
return std::getline(jFile->mFile, s);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string>& JFileSystem::scanRealFolder(const std::string& folderName, std::vector<std::string>& results)
|
std::vector<std::string>& JFileSystem::scanRealFolder(const std::string& folderName, std::vector<std::string>& results)
|
||||||
{
|
{
|
||||||
DIR *dip = opendir(folderName.c_str());
|
DIR *dip = opendir(folderName.c_str());
|
||||||
@@ -542,8 +607,17 @@ std::vector<std::string>& JFileSystem::scanfolder(const std::string& _folderName
|
|||||||
seen[systemReal[i]] = true;
|
seen[systemReal[i]] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef QT_CONFIG
|
||||||
|
string path = string(":/") + folderName;
|
||||||
|
QDir dir(path.c_str());
|
||||||
|
QStringList list = dir.entryList();
|
||||||
|
for(int i = 0; i < list.size(); i++)
|
||||||
|
{
|
||||||
|
seen[list.at(i).toStdString()] = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for(map<string,bool>::iterator it = seen.begin(); it != seen.end(); ++it)
|
for(map<string,bool>::iterator it = seen.begin(); it != seen.end(); ++it)
|
||||||
{
|
{
|
||||||
results.push_back(it->first);
|
results.push_back(it->first);
|
||||||
}
|
}
|
||||||
@@ -557,12 +631,18 @@ std::vector<std::string> JFileSystem::scanfolder(const std::string& folderName)
|
|||||||
return scanfolder(folderName, result);
|
return scanfolder(folderName, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int JFileSystem::GetFileSize()
|
int JFileSystem::GetFileSize(JFile* jFile)
|
||||||
{
|
{
|
||||||
if (mCurrentFileInZip)
|
if (jFile->mCurrentFileInZip)
|
||||||
return mFileSize;
|
return jFile->mCurrentFileInZip->m_Size;
|
||||||
|
|
||||||
return GetFileSize(mFile);
|
#ifdef QT_CONFIG
|
||||||
|
if(jFile->mpqFile) {
|
||||||
|
return jFile->mpqFile->size();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return GetFileSize(jFile->mFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JFileSystem::Rename(string _from, string _to)
|
bool JFileSystem::Rename(string _from, string _to)
|
||||||
@@ -570,13 +650,7 @@ bool JFileSystem::Rename(string _from, string _to)
|
|||||||
string from = mUserFSPath + _from;
|
string from = mUserFSPath + _from;
|
||||||
string to = mUserFSPath + _to;
|
string to = mUserFSPath + _to;
|
||||||
std::remove(to.c_str());
|
std::remove(to.c_str());
|
||||||
return (rename(from.c_str(), to.c_str()) == 0);
|
return rename(from.c_str(), to.c_str()) ? true: false;
|
||||||
}
|
|
||||||
|
|
||||||
bool JFileSystem::Remove(string aFile)
|
|
||||||
{
|
|
||||||
string toRemove = mUserFSPath + aFile;
|
|
||||||
return (std::remove(toRemove.c_str()) == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int JFileSystem::GetFileSize(izfstream & file)
|
int JFileSystem::GetFileSize(izfstream & file)
|
||||||
|
|||||||
@@ -116,25 +116,26 @@ bool JGBKFont::Init(const char* engFileName, const char* chnFileName, int fontsi
|
|||||||
int size;
|
int size;
|
||||||
|
|
||||||
JFileSystem *fileSys = JFileSystem::GetInstance();
|
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||||
if (!fileSys->OpenFile(engFileName))
|
JFile* jFile = fileSys->OpenFile(engFileName);
|
||||||
|
if (!jFile)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
size = fileSys->GetFileSize();
|
size = fileSys->GetFileSize(jFile);
|
||||||
mEngFont = new BYTE[size];
|
mEngFont = new BYTE[size];
|
||||||
|
|
||||||
fileSys->ReadFile(mEngFont, size);
|
fileSys->ReadFile(jFile, mEngFont, size);
|
||||||
fileSys->CloseFile();
|
fileSys->CloseFile(jFile);
|
||||||
|
|
||||||
|
jFile = fileSys->OpenFile(chnFileName);
|
||||||
if (!fileSys->OpenFile(chnFileName))
|
if (!jFile)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
size = fileSys->GetFileSize();
|
size = fileSys->GetFileSize(jFile);
|
||||||
|
|
||||||
mChnFont = new BYTE[size];
|
mChnFont = new BYTE[size];
|
||||||
|
|
||||||
fileSys->ReadFile(mChnFont, size);
|
fileSys->ReadFile(jFile, mChnFont, size);
|
||||||
fileSys->CloseFile();
|
fileSys->CloseFile(jFile);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,7 +249,6 @@ u32 JGE::BindKey(LocalKeySym sym, JButton button)
|
|||||||
u32 JGE::UnbindKey(LocalKeySym sym, JButton button)
|
u32 JGE::UnbindKey(LocalKeySym sym, JButton button)
|
||||||
{
|
{
|
||||||
for (keycodes_it it = keyBinds.begin(); it != keyBinds.end(); )
|
for (keycodes_it it = keyBinds.begin(); it != keyBinds.end(); )
|
||||||
{
|
|
||||||
if (sym == it->first && button == it->second)
|
if (sym == it->first && button == it->second)
|
||||||
{
|
{
|
||||||
keycodes_it er = it;
|
keycodes_it er = it;
|
||||||
@@ -257,8 +256,7 @@ u32 JGE::UnbindKey(LocalKeySym sym, JButton button)
|
|||||||
keyBinds.erase(er);
|
keyBinds.erase(er);
|
||||||
}
|
}
|
||||||
else ++it;
|
else ++it;
|
||||||
}
|
return keyBinds.size();
|
||||||
return keyBinds.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 JGE::UnbindKey(LocalKeySym sym)
|
u32 JGE::UnbindKey(LocalKeySym sym)
|
||||||
@@ -668,7 +666,7 @@ string JGE::getFileSystemLocation()
|
|||||||
if (env == NULL)
|
if (env == NULL)
|
||||||
{
|
{
|
||||||
DebugTrace("An Error Occurred in getting the JNI Environment whie trying to get the system folder location. Defaulting to /mnt/sdcard/net.wagic.app/Wagic");
|
DebugTrace("An Error Occurred in getting the JNI Environment whie trying to get the system folder location. Defaulting to /mnt/sdcard/net.wagic.app/Wagic");
|
||||||
return "/mnt/sdcard/Wagic/Res";
|
return "/mnt/sdcard/Wagic";
|
||||||
};
|
};
|
||||||
|
|
||||||
jclass jniClass = env->FindClass("org/libsdl/app/SDLActivity");
|
jclass jniClass = env->FindClass("org/libsdl/app/SDLActivity");
|
||||||
@@ -677,36 +675,7 @@ string JGE::getFileSystemLocation()
|
|||||||
if (methodId == 0)
|
if (methodId == 0)
|
||||||
{
|
{
|
||||||
DebugTrace("An Error Occurred in getting the JNI methodID for getSystemFolderPath. Defaulting to /mnt/sdcard/Wagic");
|
DebugTrace("An Error Occurred in getting the JNI methodID for getSystemFolderPath. Defaulting to /mnt/sdcard/Wagic");
|
||||||
return "/mnt/sdcard/Wagic/Res";
|
return "/mnt/sdcard/Wagic";
|
||||||
};
|
|
||||||
|
|
||||||
jstring systemPath = (jstring) env->CallStaticObjectMethod(jniClass, methodId);
|
|
||||||
|
|
||||||
// Now convert the Java String to C++ char array
|
|
||||||
const char* cstr = env->GetStringUTFChars(systemPath, 0);
|
|
||||||
string retVal (cstr);
|
|
||||||
env->ReleaseStringUTFChars(systemPath, cstr);
|
|
||||||
env->DeleteLocalRef(systemPath);
|
|
||||||
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
string JGE::getFileUserFolderPath()
|
|
||||||
{
|
|
||||||
JNIEnv * env = getJNIEnv();
|
|
||||||
if (env == NULL)
|
|
||||||
{
|
|
||||||
DebugTrace("An Error Occurred in getting the JNI Environment whie trying to get the system folder location. Defaulting to /mnt/sdcard/net.wagic.app/Wagic");
|
|
||||||
return "/mnt/sdcard/Wagic/User";
|
|
||||||
};
|
|
||||||
|
|
||||||
jclass jniClass = env->FindClass("org/libsdl/app/SDLActivity");
|
|
||||||
jmethodID methodId = env->GetStaticMethodID( jniClass, "getUserFolderPath", "()Ljava/lang/String;");
|
|
||||||
|
|
||||||
if (methodId == 0)
|
|
||||||
{
|
|
||||||
DebugTrace("An Error Occurred in getting the JNI methodID for getSystemFolderPath. Defaulting to /mnt/sdcard/Wagic");
|
|
||||||
return "/mnt/sdcard/Wagic/User";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
jstring systemPath = (jstring) env->CallStaticObjectMethod(jniClass, methodId);
|
jstring systemPath = (jstring) env->CallStaticObjectMethod(jniClass, methodId);
|
||||||
|
|||||||
@@ -892,9 +892,10 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
|
|||||||
{
|
{
|
||||||
png_size_t check;
|
png_size_t check;
|
||||||
|
|
||||||
JFileSystem *fileSystem = (JFileSystem*)png_ptr->io_ptr;
|
JFile* jFile = (JFile*)png_ptr->io_ptr;
|
||||||
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
|
|
||||||
check = fileSystem->ReadFile(data, length);
|
check = fileSystem->ReadFile(jFile, data, length);
|
||||||
|
|
||||||
if (check != length)
|
if (check != length)
|
||||||
{
|
{
|
||||||
@@ -1038,23 +1039,24 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
|
|||||||
bits32 = NULL;
|
bits32 = NULL;
|
||||||
|
|
||||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
if (!fileSystem->OpenFile(filename))
|
JFile* jFile = fileSystem->OpenFile(filename);
|
||||||
|
if (!jFile)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rawsize = fileSystem->GetFileSize();
|
rawsize = fileSystem->GetFileSize(jFile);
|
||||||
|
|
||||||
rawdata = new u8[rawsize];
|
rawdata = new u8[rawsize];
|
||||||
|
|
||||||
if (!rawdata)
|
if (!rawdata)
|
||||||
{
|
{
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSystem->ReadFile(rawdata, rawsize);
|
fileSystem->ReadFile(jFile, rawdata, rawsize);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
|
|
||||||
|
|
||||||
cinfo.err = jpeg_std_error(&jerr);
|
cinfo.err = jpeg_std_error(&jerr);
|
||||||
@@ -1362,24 +1364,25 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
|
|||||||
u32* line;
|
u32* line;
|
||||||
|
|
||||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
if (!fileSystem->OpenFile(filename)) return JGE_ERR_CANT_OPEN_FILE;
|
JFile* jFile = fileSystem->OpenFile(filename);
|
||||||
|
if (!jFile) return JGE_ERR_CANT_OPEN_FILE;
|
||||||
|
|
||||||
//JLOG("PNG opened - creating read struct");
|
//JLOG("PNG opened - creating read struct");
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
if (png_ptr == NULL) {
|
if (png_ptr == NULL) {
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
return JGE_ERR_PNG;
|
return JGE_ERR_PNG;
|
||||||
}
|
}
|
||||||
//JLOG("Setting error callback func");
|
//JLOG("Setting error callback func");
|
||||||
png_set_error_fn(png_ptr, (png_voidp) NULL, (png_error_ptr) NULL, PNGCustomWarningFn);
|
png_set_error_fn(png_ptr, (png_voidp) NULL, (png_error_ptr) NULL, PNGCustomWarningFn);
|
||||||
info_ptr = png_create_info_struct(png_ptr);
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
if (info_ptr == NULL) {
|
if (info_ptr == NULL) {
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||||
return JGE_ERR_PNG;
|
return JGE_ERR_PNG;
|
||||||
}
|
}
|
||||||
png_init_io(png_ptr, NULL);
|
png_init_io(png_ptr, NULL);
|
||||||
png_set_read_fn(png_ptr, (png_voidp)fileSystem, PNGCustomReadDataFn);
|
png_set_read_fn(png_ptr, (png_voidp)jFile, PNGCustomReadDataFn);
|
||||||
|
|
||||||
png_set_sig_bytes(png_ptr, sig_read);
|
png_set_sig_bytes(png_ptr, sig_read);
|
||||||
png_read_info(png_ptr, info_ptr);
|
png_read_info(png_ptr, info_ptr);
|
||||||
@@ -1392,7 +1395,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
|
|||||||
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
|
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
|
||||||
line = (u32*) malloc(width * 4);
|
line = (u32*) malloc(width * 4);
|
||||||
if (!line) {
|
if (!line) {
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||||
return JGE_ERR_MALLOC_FAILED;
|
return JGE_ERR_MALLOC_FAILED;
|
||||||
}
|
}
|
||||||
@@ -1430,7 +1433,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
|
|||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
stream << "Alloc failed for: Tex Width: " << texWidth << " Tex Height: " << kVerticalBlockSize << ", total bytes: " << texWidth * kVerticalBlockSize * sizeof(PIXEL_TYPE);
|
stream << "Alloc failed for: Tex Width: " << texWidth << " Tex Height: " << kVerticalBlockSize << ", total bytes: " << texWidth * kVerticalBlockSize * sizeof(PIXEL_TYPE);
|
||||||
JLOG(stream.str().c_str());
|
JLOG(stream.str().c_str());
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||||
return JGE_ERR_MALLOC_FAILED;
|
return JGE_ERR_MALLOC_FAILED;
|
||||||
}
|
}
|
||||||
@@ -1505,7 +1508,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
|
|||||||
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
|
||||||
|
|
||||||
//JLOG("Closing PNG");
|
//JLOG("Closing PNG");
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
|
|
||||||
if (done)
|
if (done)
|
||||||
{
|
{
|
||||||
@@ -1725,9 +1728,9 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
|||||||
|
|
||||||
int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
|
int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
|
||||||
{
|
{
|
||||||
|
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||||
JFileSystem *fileSys = (JFileSystem *)ft->UserData;
|
JFile* jFile = (JFile*)ft->UserData;
|
||||||
if (fileSys->ReadFile(buf, size))
|
if (fileSys->ReadFile(jFile, buf, size))
|
||||||
return size;
|
return size;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1740,15 +1743,17 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
|
|||||||
|
|
||||||
|
|
||||||
JFileSystem *fileSys = JFileSystem::GetInstance();
|
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||||
if (!fileSys->OpenFile(filename))
|
JFile* jFile = fileSys->OpenFile(filename);
|
||||||
|
|
||||||
|
if (!jFile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DWORD bkcol;
|
DWORD bkcol;
|
||||||
int result = image_readgif(fileSys, textureInfo, &bkcol, image_gif_read, mode);
|
int result = image_readgif(jFile, textureInfo, &bkcol, image_gif_read, mode);
|
||||||
|
|
||||||
if(result!=0)
|
if(result!=0)
|
||||||
textureInfo.mBits=NULL;
|
textureInfo.mBits=NULL;
|
||||||
fileSys->CloseFile();
|
fileSys->CloseFile(jFile);
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
@@ -2262,4 +2267,4 @@ void JRenderer::FillRoundRect(float x, float y, float w, float h, float radius,
|
|||||||
void JRenderer::SetImageFilter(JImageFilter* imageFilter)
|
void JRenderer::SetImageFilter(JImageFilter* imageFilter)
|
||||||
{
|
{
|
||||||
mImageFilter = imageFilter;
|
mImageFilter = imageFilter;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ bool JGuiController::CheckUserInput(JButton key)
|
|||||||
mObjects[mCurr]->Entering();
|
mObjects[mCurr]->Entering();
|
||||||
}
|
}
|
||||||
mEngine->LeftClickedProcessed();
|
mEngine->LeftClickedProcessed();
|
||||||
mEngine->ResetInput();
|
mEngine->ResetInput();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
mEngine->LeftClickedProcessed();
|
mEngine->LeftClickedProcessed();
|
||||||
|
|||||||
@@ -42,10 +42,11 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
|
|||||||
|
|
||||||
//FILE *file;
|
//FILE *file;
|
||||||
JFileSystem *fileSys = JFileSystem::GetInstance();
|
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||||
if (!fileSys->OpenFile(filename)) return;
|
JFile* jFile = fileSys->OpenFile(filename);
|
||||||
|
if (!jFile) return;
|
||||||
|
|
||||||
fileSys->ReadFile((u8 *)buffer, 2048);
|
fileSys->ReadFile(jFile, (u8 *)buffer, 2048);
|
||||||
fileSys->CloseFile();
|
fileSys->CloseFile(jFile);
|
||||||
|
|
||||||
sprintf(filename, "%s.png", fontname);
|
sprintf(filename, "%s.png", fontname);
|
||||||
mTexture = mRenderer->LoadTexture(filename, useVideoRAM);
|
mTexture = mRenderer->LoadTexture(filename, useVideoRAM);
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ bool JMD2Model::Load(char *filename, char *textureName)
|
|||||||
// open the model file
|
// open the model file
|
||||||
|
|
||||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
if (!fileSystem->OpenFile(filename))
|
JFile* jFile = fileSystem->OpenFile(filename);
|
||||||
|
if (!jFile)
|
||||||
return false;
|
return false;
|
||||||
//filePtr = fopen(filename, "rb");
|
//filePtr = fopen(filename, "rb");
|
||||||
//if (filePtr == NULL)
|
//if (filePtr == NULL)
|
||||||
@@ -107,13 +108,13 @@ bool JMD2Model::Load(char *filename, char *textureName)
|
|||||||
//fileLen = ftell(filePtr);
|
//fileLen = ftell(filePtr);
|
||||||
//fseek(filePtr, 0, SEEK_SET);
|
//fseek(filePtr, 0, SEEK_SET);
|
||||||
|
|
||||||
fileLen = fileSystem->GetFileSize();
|
fileLen = fileSystem->GetFileSize(jFile);
|
||||||
|
|
||||||
// read entire file into buffer
|
// read entire file into buffer
|
||||||
buffer = (char*)malloc(fileLen + 1);
|
buffer = (char*)malloc(fileLen + 1);
|
||||||
//fread(buffer, sizeof(char), fileLen, filePtr);
|
//fread(buffer, sizeof(char), fileLen, filePtr);
|
||||||
fileSystem->ReadFile(buffer, fileLen);
|
fileSystem->ReadFile(jFile, buffer, fileLen);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
|
|
||||||
// extract model file header from buffer
|
// extract model file header from buffer
|
||||||
modelHeader = (modelHeader_t*)buffer;
|
modelHeader = (modelHeader_t*)buffer;
|
||||||
|
|||||||
@@ -47,14 +47,15 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
|
|||||||
{
|
{
|
||||||
|
|
||||||
JFileSystem* fileSys = JFileSystem::GetInstance();
|
JFileSystem* fileSys = JFileSystem::GetInstance();
|
||||||
if (!fileSys->OpenFile(modelName))
|
JFile* jFile = fileSys->OpenFile(modelName);
|
||||||
|
if (!jFile)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int size = fileSys->GetFileSize();
|
int size = fileSys->GetFileSize(jFile);
|
||||||
char *buffer = new char[size];
|
char *buffer = new char[size];
|
||||||
|
|
||||||
fileSys->ReadFile(buffer, size);
|
fileSys->ReadFile(jFile, buffer, size);
|
||||||
fileSys->CloseFile();
|
fileSys->CloseFile(jFile);
|
||||||
|
|
||||||
Vector3D vert;
|
Vector3D vert;
|
||||||
|
|
||||||
|
|||||||
@@ -55,11 +55,12 @@ bool JParticleEffect::Load(const char* filename)
|
|||||||
JFileSystem *fileSystem = JFileSystem::GetInstance();
|
JFileSystem *fileSystem = JFileSystem::GetInstance();
|
||||||
if (fileSystem == NULL) return false;
|
if (fileSystem == NULL) return false;
|
||||||
|
|
||||||
if (!fileSystem->OpenFile(filename)) return false;
|
JFile* jFile = fileSystem->OpenFile(filename);
|
||||||
|
if (!jFile) return false;
|
||||||
|
|
||||||
int size = fileSystem->GetFileSize();
|
int size = fileSystem->GetFileSize(jFile);
|
||||||
char *xmlBuffer = new char[size];
|
char *xmlBuffer = new char[size];
|
||||||
fileSystem->ReadFile(xmlBuffer, size);
|
fileSystem->ReadFile(jFile, xmlBuffer, size);
|
||||||
|
|
||||||
TiXmlDocument doc;
|
TiXmlDocument doc;
|
||||||
|
|
||||||
@@ -296,7 +297,7 @@ bool JParticleEffect::Load(const char* filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
delete[] xmlBuffer;
|
delete[] xmlBuffer;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -93,13 +93,13 @@ bool JResourceManager::LoadResource(const string& resourceName)
|
|||||||
JFileSystem *fileSystem = JFileSystem::GetInstance();
|
JFileSystem *fileSystem = JFileSystem::GetInstance();
|
||||||
if (fileSystem == NULL) return false;
|
if (fileSystem == NULL) return false;
|
||||||
|
|
||||||
|
JFile* jFile = fileSystem->OpenFile(path.c_str());
|
||||||
|
|
||||||
|
if (!jFile) return false;
|
||||||
|
|
||||||
if (!fileSystem->OpenFile(path.c_str())) return false;
|
int size = fileSystem->GetFileSize(jFile);
|
||||||
|
|
||||||
int size = fileSystem->GetFileSize();
|
|
||||||
char *xmlBuffer = new char[size];
|
char *xmlBuffer = new char[size];
|
||||||
fileSystem->ReadFile(xmlBuffer, size);
|
fileSystem->ReadFile(jFile, xmlBuffer, size);
|
||||||
|
|
||||||
TiXmlDocument doc;
|
TiXmlDocument doc;
|
||||||
doc.Parse(xmlBuffer);
|
doc.Parse(xmlBuffer);
|
||||||
@@ -179,7 +179,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
delete[] xmlBuffer;
|
delete[] xmlBuffer;
|
||||||
// JGERelease();
|
// JGERelease();
|
||||||
|
|
||||||
|
|||||||
@@ -41,11 +41,12 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
|
|||||||
JFileSystem *fileSystem = JFileSystem::GetInstance();
|
JFileSystem *fileSystem = JFileSystem::GetInstance();
|
||||||
|
|
||||||
if (fileSystem == NULL) return false;
|
if (fileSystem == NULL) return false;
|
||||||
if (!fileSystem->OpenFile(filename)) return false;
|
JFile* jFile = fileSystem->OpenFile(filename);
|
||||||
|
if (!jFile) return false;
|
||||||
|
|
||||||
int size = fileSystem->GetFileSize();
|
int size = fileSystem->GetFileSize(jFile);
|
||||||
char *xmlBuffer = new char[size];
|
char *xmlBuffer = new char[size];
|
||||||
fileSystem->ReadFile(xmlBuffer, size);
|
fileSystem->ReadFile(jFile, xmlBuffer, size);
|
||||||
|
|
||||||
TiXmlDocument doc;
|
TiXmlDocument doc;
|
||||||
doc.Parse(xmlBuffer);
|
doc.Parse(xmlBuffer);
|
||||||
@@ -71,12 +72,12 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
|
|||||||
element->QueryFloatAttribute("x", &xx);
|
element->QueryFloatAttribute("x", &xx);
|
||||||
element->QueryFloatAttribute("y", &yy);
|
element->QueryFloatAttribute("y", &yy);
|
||||||
|
|
||||||
JPoint pt(xx*xscale, yy*yscale);
|
Point pt(xx*xscale, yy*yscale);
|
||||||
AddControlPoint(pt);
|
AddControlPoint(pt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
delete[] xmlBuffer;
|
delete[] xmlBuffer;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -84,7 +85,7 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void JSpline::PointOnCurve(JPoint &out, float t, const JPoint &p0, const JPoint &p1, const JPoint &p2, const JPoint &p3)
|
void JSpline::PointOnCurve(Point &out, float t, const Point &p0, const Point &p1, const Point &p2, const Point &p3)
|
||||||
{
|
{
|
||||||
float t2 = t * t;
|
float t2 = t * t;
|
||||||
float t3 = t2 * t;
|
float t3 = t2 * t;
|
||||||
@@ -113,8 +114,8 @@ void JSpline::GeneratePixels()
|
|||||||
x = mMidPoints[1].x;
|
x = mMidPoints[1].x;
|
||||||
y = mMidPoints[1].y;
|
y = mMidPoints[1].y;
|
||||||
|
|
||||||
JPoint newPt(x, y);
|
Point newPt(x, y);
|
||||||
JPoint extraPt;
|
Point extraPt;
|
||||||
|
|
||||||
mPixels.push_back(newPt);
|
mPixels.push_back(newPt);
|
||||||
|
|
||||||
@@ -151,13 +152,13 @@ void JSpline::GeneratePixels()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JSpline::AddControlPoint(const JPoint &pt)
|
void JSpline::AddControlPoint(const Point &pt)
|
||||||
{
|
{
|
||||||
mMidPoints.push_back(pt);
|
mMidPoints.push_back(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JSpline::GetControlPoint(JPoint &point, int index)
|
void JSpline::GetControlPoint(Point &point, int index)
|
||||||
{
|
{
|
||||||
if (index < (int)mMidPoints.size())
|
if (index < (int)mMidPoints.size())
|
||||||
{
|
{
|
||||||
@@ -167,7 +168,7 @@ void JSpline::GetControlPoint(JPoint &point, int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JSpline::GetPixel(JPoint &point, int index)
|
void JSpline::GetPixel(Point &point, int index)
|
||||||
{
|
{
|
||||||
if (index < (int)mPixels.size())
|
if (index < (int)mPixels.size())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -199,15 +199,16 @@ bool JTTFont::Load(const char *filename, int size, int mode)
|
|||||||
|
|
||||||
if (FT_Init_FreeType( &mLibrary ) == 0)
|
if (FT_Init_FreeType( &mLibrary ) == 0)
|
||||||
{
|
{
|
||||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
if (fileSystem->OpenFile(filename))
|
JFile* jFile = fileSystem->OpenFile(filename);
|
||||||
|
if (jFile)
|
||||||
{
|
{
|
||||||
mFontBitsSize = fileSystem->GetFileSize();
|
mFontBitsSize = fileSystem->GetFileSize(jFile);
|
||||||
|
|
||||||
mFontBits = (FT_Byte*)malloc(mFontBitsSize);
|
mFontBits = (FT_Byte*)malloc(mFontBitsSize);
|
||||||
|
|
||||||
fileSystem->ReadFile(mFontBits, mFontBitsSize);
|
fileSystem->ReadFile(jFile, mFontBits, mFontBitsSize);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
|
|
||||||
if (FT_New_Memory_Face(mLibrary, mFontBits, mFontBitsSize, 0, &mFace ) == 0)
|
if (FT_New_Memory_Face(mLibrary, mFontBits, mFontBitsSize, 0, &mFace ) == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ WagicWrapper::~WagicWrapper()
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
WagicWrapper* wagicCore = new WagicWrapper();
|
WagicWrapper* wagicCore = new WagicWrapper();
|
||||||
MTGCollection()->loadFolder("sets/primitives/");
|
MTGCollection()->loadFolder("sets/primitives/");
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
#include <QtDeclarative>
|
#include <QtDeclarative>
|
||||||
#include "qmlapplicationviewer.h"
|
#include "qmlapplicationviewer.h"
|
||||||
#endif //QT_WIDGET
|
#endif //QT_WIDGET
|
||||||
#include "Downloader.h"
|
#include "filedownloader.h"
|
||||||
#include "GameApp.h"
|
#include "GameApp.h"
|
||||||
#include "corewrapper.h"
|
#include "corewrapper.h"
|
||||||
|
|
||||||
WagicCore* g_glwidget = NULL;
|
QWidget* g_glwidget = NULL;
|
||||||
|
|
||||||
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
|
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
|
||||||
{
|
{
|
||||||
@@ -69,25 +69,18 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
#endif //QT_WIDGET
|
#endif //QT_WIDGET
|
||||||
|
|
||||||
|
if(argc >= 2 && string(argv[1]) == "testsuite")
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
result += WagicCore::runTestSuite();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
app->setApplicationName(WagicCore::getApplicationName());
|
app->setApplicationName(WagicCore::getApplicationName());
|
||||||
DownloadRequest* downloadRequest = NULL;
|
FileDownloader fileDownloader(USERDIR, WAGIC_RESOURCE_NAME);
|
||||||
#ifdef WAGIC_RESOURCE_URL
|
|
||||||
Downloader*downloader = Downloader::GetInstance();
|
|
||||||
downloadRequest = downloader->Get(
|
|
||||||
"core.zip",
|
|
||||||
WAGIC_RESOURCE_URL
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
#ifdef QT_WIDGET
|
#ifdef QT_WIDGET
|
||||||
g_glwidget = new WagicCore();
|
g_glwidget = new WagicCore();
|
||||||
if(!downloadRequest || downloadRequest->getDownloadStatus() == DownloadRequest::DOWNLOADED)
|
g_glwidget->connect(&fileDownloader, SIGNAL(finished(int)), SLOT(start(int)));
|
||||||
{
|
|
||||||
g_glwidget->start(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_glwidget->connect(downloadRequest, SIGNAL(statusChanged(int)), SLOT(start(int)));
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
qmlRegisterType<WagicCore>("CustomComponents", 1, 0, "WagicCore");
|
qmlRegisterType<WagicCore>("CustomComponents", 1, 0, "WagicCore");
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,6 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#ifndef WIN32
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#if (defined FORCE_GLES)
|
#if (defined FORCE_GLES)
|
||||||
#undef GL_ES_VERSION_2_0
|
#undef GL_ES_VERSION_2_0
|
||||||
@@ -58,7 +53,6 @@ JGameLauncher* g_launcher = NULL;
|
|||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
JNIEnv * mJNIEnv = NULL;
|
JNIEnv * mJNIEnv = NULL;
|
||||||
jclass * mJNIClass = NULL;
|
jclass * mJNIClass = NULL;
|
||||||
int SDL_ResumeSyncTime = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class SdlApp;
|
class SdlApp;
|
||||||
@@ -84,21 +78,7 @@ extern "C" void Java_org_libsdl_app_SDLActivity_nativeResume(
|
|||||||
{
|
{
|
||||||
if (!g_engine)
|
if (!g_engine)
|
||||||
return;
|
return;
|
||||||
SDL_ResumeSyncTime = 100000;
|
g_engine->Resume();
|
||||||
g_engine->Resume();
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "Wagic_Version.h"
|
|
||||||
extern "C" jstring Java_org_libsdl_app_SDLActivity_getResourceName(
|
|
||||||
JNIEnv* env, jclass cls)
|
|
||||||
{
|
|
||||||
return env->NewStringUTF (WAGIC_RESOURCE_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" jstring Java_org_libsdl_app_SDLActivity_getResourceUrl(
|
|
||||||
JNIEnv* env, jclass cls)
|
|
||||||
{
|
|
||||||
return env->NewStringUTF (WAGIC_RESOURCE_URL);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -143,16 +123,8 @@ public:
|
|||||||
if(!g_engine->IsPaused())
|
if(!g_engine->IsPaused())
|
||||||
OnEvent(&Event);
|
OnEvent(&Event);
|
||||||
}
|
}
|
||||||
if(!g_engine->IsPaused()){
|
if(!g_engine->IsPaused())
|
||||||
#ifdef ANDROID
|
|
||||||
// Fix for SDL crash on resuming Android app from background.
|
|
||||||
if(SDL_ResumeSyncTime){
|
|
||||||
usleep(SDL_ResumeSyncTime);
|
|
||||||
SDL_ResumeSyncTime = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
OnUpdate();
|
OnUpdate();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,18 +280,17 @@ static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[]
|
|||||||
{ SDLK_DOWN, JGE_BTN_DOWN },
|
{ SDLK_DOWN, JGE_BTN_DOWN },
|
||||||
{ SDLK_LEFT, JGE_BTN_LEFT },
|
{ SDLK_LEFT, JGE_BTN_LEFT },
|
||||||
{ SDLK_RIGHT, JGE_BTN_RIGHT },
|
{ SDLK_RIGHT, JGE_BTN_RIGHT },
|
||||||
{ SDLK_w, JGE_BTN_UP },
|
{ SDLK_z, JGE_BTN_UP },
|
||||||
{ SDLK_s, JGE_BTN_DOWN },
|
|
||||||
{ SDLK_a, JGE_BTN_LEFT },
|
|
||||||
{ SDLK_d, JGE_BTN_RIGHT },
|
{ SDLK_d, JGE_BTN_RIGHT },
|
||||||
{ SDLK_q, JGE_BTN_PREV },
|
{ SDLK_s, JGE_BTN_DOWN },
|
||||||
|
{ SDLK_q, JGE_BTN_LEFT },
|
||||||
|
{ SDLK_a, JGE_BTN_PREV },
|
||||||
{ SDLK_e, JGE_BTN_NEXT },
|
{ SDLK_e, JGE_BTN_NEXT },
|
||||||
{ SDLK_i, JGE_BTN_CANCEL },
|
{ SDLK_i, JGE_BTN_CANCEL },
|
||||||
{ SDLK_l, JGE_BTN_OK },
|
{ SDLK_l, JGE_BTN_OK },
|
||||||
{ SDLK_SPACE, JGE_BTN_OK },
|
{ SDLK_SPACE, JGE_BTN_OK },
|
||||||
{ SDLK_k, JGE_BTN_SEC },
|
{ SDLK_k, JGE_BTN_SEC },
|
||||||
{ SDLK_j, JGE_BTN_PRI },
|
{ SDLK_j, JGE_BTN_PRI },
|
||||||
{ SDLK_b, JGE_BTN_SOUND },
|
|
||||||
{ SDLK_f, JGE_BTN_FULLSCREEN },
|
{ SDLK_f, JGE_BTN_FULLSCREEN },
|
||||||
|
|
||||||
/* old Qt ones, basically modified to comply with the N900 keyboard
|
/* old Qt ones, basically modified to comply with the N900 keyboard
|
||||||
|
|||||||
@@ -185,9 +185,9 @@ static const int doubleBufferAttributes[] = {
|
|||||||
GLX_RED_SIZE, 1, /* the maximum number of bits per component */
|
GLX_RED_SIZE, 1, /* the maximum number of bits per component */
|
||||||
GLX_GREEN_SIZE, 1,
|
GLX_GREEN_SIZE, 1,
|
||||||
GLX_BLUE_SIZE, 1,
|
GLX_BLUE_SIZE, 1,
|
||||||
0L /* None */
|
None
|
||||||
};
|
};
|
||||||
static int WaitForNotify(Display *dpy, XEvent *event, XPointer arg)
|
static Bool WaitForNotify(Display *dpy, XEvent *event, XPointer arg)
|
||||||
{
|
{
|
||||||
return (event->type == MapNotify) && (event->xmap.window == (Window) arg);
|
return (event->type == MapNotify) && (event->xmap.window == (Window) arg);
|
||||||
}
|
}
|
||||||
@@ -387,13 +387,13 @@ int main(int argc, char* argv[])
|
|||||||
if (XCheckWindowEvent(gXDisplay, gXWindow, KeyPressMask | KeyReleaseMask | StructureNotifyMask, &event))
|
if (XCheckWindowEvent(gXDisplay, gXWindow, KeyPressMask | KeyReleaseMask | StructureNotifyMask, &event))
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case 2: /* KeyPress */
|
case KeyPress:
|
||||||
{
|
{
|
||||||
const KeySym sym = XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1);
|
const KeySym sym = XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1);
|
||||||
g_engine->HoldKey_NoRepeat(sym);
|
g_engine->HoldKey_NoRepeat(sym);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3: /* KeyRelease */
|
case KeyRelease:
|
||||||
g_engine->ReleaseKey(XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1));
|
g_engine->ReleaseKey(XKeycodeToKeysym(gXDisplay, event.xkey.keycode, 1));
|
||||||
break;
|
break;
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
|
|||||||
@@ -184,13 +184,7 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
|||||||
const SLboolean req[2] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
|
const SLboolean req[2] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
|
||||||
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &music->playerObject, &audioSrc, &audioSnk, 2, ids, req);
|
result = (*engineEngine)->CreateAudioPlayer(engineEngine, &music->playerObject, &audioSrc, &audioSnk, 2, ids, req);
|
||||||
DebugTrace("result " << result);
|
DebugTrace("result " << result);
|
||||||
|
|
||||||
if(result == SL_RESULT_MEMORY_FAILURE){
|
|
||||||
delete music;
|
|
||||||
mCurrentMusic = NULL;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// realize the player
|
// realize the player
|
||||||
result = (*music->playerObject)->Realize(music->playerObject, SL_BOOLEAN_FALSE);
|
result = (*music->playerObject)->Realize(music->playerObject, SL_BOOLEAN_FALSE);
|
||||||
DebugTrace("result " << result);
|
DebugTrace("result " << result);
|
||||||
@@ -309,12 +303,6 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
|
|||||||
1, ids, req);
|
1, ids, req);
|
||||||
DebugTrace("result " << result);
|
DebugTrace("result " << result);
|
||||||
|
|
||||||
if(result == SL_RESULT_MEMORY_FAILURE){
|
|
||||||
delete sample;
|
|
||||||
mCurrentSample = NULL;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// realize the player
|
// realize the player
|
||||||
result = (*sample->playerObject)->Realize(sample->playerObject, SL_BOOLEAN_FALSE);
|
result = (*sample->playerObject)->Realize(sample->playerObject, SL_BOOLEAN_FALSE);
|
||||||
DebugTrace("result " << result);
|
DebugTrace("result " << result);
|
||||||
|
|||||||
@@ -57,19 +57,20 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap __attribute__((unused)))
|
|||||||
// Load font description
|
// Load font description
|
||||||
|
|
||||||
JFileSystem* fileSys = JFileSystem::GetInstance();
|
JFileSystem* fileSys = JFileSystem::GetInstance();
|
||||||
if (!fileSys->OpenFile(szFont)) return;
|
JFile* jFile = fileSys->OpenFile(szFont);
|
||||||
|
if (!jFile) return;
|
||||||
|
|
||||||
//data=hge->Resource_Load(szFont, &size);
|
//data=hge->Resource_Load(szFont, &size);
|
||||||
//if(!data) return;
|
//if(!data) return;
|
||||||
size = fileSys->GetFileSize();
|
size = fileSys->GetFileSize(jFile);
|
||||||
|
|
||||||
desc = new char[size+1];
|
desc = new char[size+1];
|
||||||
//memcpy(desc,data,size);
|
//memcpy(desc,data,size);
|
||||||
fileSys->ReadFile(desc, size);
|
fileSys->ReadFile(jFile, desc, size);
|
||||||
desc[size]=0;
|
desc[size]=0;
|
||||||
|
|
||||||
//hge->Resource_Free(data);
|
//hge->Resource_Free(data);
|
||||||
fileSys->CloseFile();
|
fileSys->CloseFile(jFile);
|
||||||
|
|
||||||
pdesc=_get_line(desc,linebuf);
|
pdesc=_get_line(desc,linebuf);
|
||||||
if(strcmp(linebuf, FNTHEADERTAG))
|
if(strcmp(linebuf, FNTHEADERTAG))
|
||||||
|
|||||||
@@ -50,54 +50,48 @@ float Random_Float(float min, float max)
|
|||||||
|
|
||||||
hgeParticleSystem::hgeParticleSystem(const char *filename, JQuad *sprite)
|
hgeParticleSystem::hgeParticleSystem(const char *filename, JQuad *sprite)
|
||||||
{
|
{
|
||||||
//void *psi;
|
JFileSystem* fileSys = JFileSystem::GetInstance();
|
||||||
//hgeParticleSystemInfo psi;
|
JFile* jFile = fileSys->OpenFile(filename);
|
||||||
|
if (!jFile) return;
|
||||||
JFileSystem* fileSys = JFileSystem::GetInstance();
|
|
||||||
//hge=hgeCreate(HGE_VERSION);
|
//if(!psi) return;
|
||||||
|
|
||||||
//psi=hge->Resource_Load(filename);
|
//memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
|
||||||
if (!fileSys->OpenFile(filename)) return;
|
//hge->Resource_Free(psi);
|
||||||
|
|
||||||
//if(!psi) return;
|
// Skip reading the pointer as it may be larger than 4 bytes in the structure
|
||||||
|
void *dummyPointer;
|
||||||
//memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
|
fileSys->ReadFile(jFile, &dummyPointer, 4);
|
||||||
//hge->Resource_Free(psi);
|
// we're actually trying to read more than the file size now, but it's no problem.
|
||||||
|
// Note that this fix is only to avoid the largest problems, filling a structure
|
||||||
// Skip reading the pointer as it may be larger than 4 bytes in the structure
|
// by directly reading a file, is really a bad idea ...
|
||||||
void *dummyPointer;
|
fileSys->ReadFile(jFile, &(info.nEmission), sizeof(hgeParticleSystemInfo) - 4);
|
||||||
fileSys->ReadFile(&dummyPointer, 4);
|
fileSys->CloseFile(jFile);
|
||||||
// we're actually trying to read more than the file size now, but it's no problem.
|
|
||||||
// Note that this fix is only to avoid the largest problems, filling a structure
|
info.sprite=sprite;
|
||||||
// by directly reading a file, is really a bad idea ...
|
// info.fGravityMin *= 100;
|
||||||
fileSys->ReadFile(&(info.nEmission), sizeof(hgeParticleSystemInfo) - 4);
|
// info.fGravityMax *= 100;
|
||||||
fileSys->CloseFile();
|
// info.fSpeedMin *= 100;
|
||||||
|
// info.fSpeedMax *= 100;
|
||||||
info.sprite=sprite;
|
|
||||||
// info.fGravityMin *= 100;
|
vecLocation.x=vecPrevLocation.x=0.0f;
|
||||||
// info.fGravityMax *= 100;
|
vecLocation.y=vecPrevLocation.y=0.0f;
|
||||||
// info.fSpeedMin *= 100;
|
fTx=fTy=0;
|
||||||
// info.fSpeedMax *= 100;
|
|
||||||
|
fEmissionResidue=0.0f;
|
||||||
vecLocation.x=vecPrevLocation.x=0.0f;
|
nParticlesAlive=0;
|
||||||
vecLocation.y=vecPrevLocation.y=0.0f;
|
fAge=-2.0;
|
||||||
fTx=fTy=0;
|
mTimer = 0.0f;
|
||||||
|
|
||||||
fEmissionResidue=0.0f;
|
rectBoundingBox.Clear();
|
||||||
nParticlesAlive=0;
|
bUpdateBoundingBox=false;
|
||||||
fAge=-2.0;
|
|
||||||
mTimer = 0.0f;
|
|
||||||
|
|
||||||
rectBoundingBox.Clear();
|
|
||||||
bUpdateBoundingBox=false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hgeParticleSystem::hgeParticleSystem(hgeParticleSystemInfo *psi)
|
hgeParticleSystem::hgeParticleSystem(hgeParticleSystemInfo *psi)
|
||||||
{
|
{
|
||||||
//hge=hgeCreate(HGE_VERSION);
|
//hge=hgeCreate(HGE_VERSION);
|
||||||
|
|
||||||
if (psi)
|
memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
|
||||||
memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
|
|
||||||
|
|
||||||
vecLocation.x=vecPrevLocation.x=0.0f;
|
vecLocation.x=vecPrevLocation.x=0.0f;
|
||||||
vecLocation.y=vecPrevLocation.y=0.0f;
|
vecLocation.y=vecPrevLocation.y=0.0f;
|
||||||
|
|||||||
@@ -10,6 +10,5 @@ void resumeGame();
|
|||||||
@property (nonatomic, retain) id eaglView;
|
@property (nonatomic, retain) id eaglView;
|
||||||
@property (nonatomic, retain) UITextField *inputField;
|
@property (nonatomic, retain) UITextField *inputField;
|
||||||
@property (nonatomic, assign) BOOL bannerIsVisible;
|
@property (nonatomic, assign) BOOL bannerIsVisible;
|
||||||
- (void)toggleKeyboardWithState: (NSString *) initialText;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -53,28 +53,28 @@
|
|||||||
|
|
||||||
- (void)viewWillAppear:(BOOL)animated {
|
- (void)viewWillAppear:(BOOL)animated {
|
||||||
NSLog(@"EAGL ViewController - view Will Appear");
|
NSLog(@"EAGL ViewController - view Will Appear");
|
||||||
[(id)self.view resumeGame];
|
[self.view resumeGame];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)viewWillDisappear:(BOOL)animated
|
- (void)viewWillDisappear:(BOOL)animated
|
||||||
{
|
{
|
||||||
[(id)self.view pauseGame];
|
[self.view pauseGame];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)pauseGame
|
- (void)pauseGame
|
||||||
{
|
{
|
||||||
[(id)self.view pauseGame];
|
[self.view pauseGame];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)resumeGame
|
- (void)resumeGame
|
||||||
{
|
{
|
||||||
[(id)self.view resumeGame];
|
[self.view resumeGame];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)endGame
|
- (void)endGame
|
||||||
{
|
{
|
||||||
[(id)self.view endGame];
|
[self.view endGame];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)viewDidAppear:(BOOL)animated {
|
- (void)viewDidAppear:(BOOL)animated {
|
||||||
|
|||||||
@@ -337,7 +337,7 @@
|
|||||||
|
|
||||||
- (void)applicationWillTerminate:(UIApplication *)application
|
- (void)applicationWillTerminate:(UIApplication *)application
|
||||||
{
|
{
|
||||||
[(id)self.glViewController.view destroyGame];
|
[self.glViewController.view destroyGame];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)initializeKeyboard: (id) initialState
|
- (void)initializeKeyboard: (id) initialState
|
||||||
|
|||||||
@@ -1683,20 +1683,21 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
|
|||||||
int rawsize, i;
|
int rawsize, i;
|
||||||
|
|
||||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
if (!fileSystem->OpenFile(filename)) return;
|
JFile* jFile = fileSystem->OpenFile(filename);
|
||||||
|
if (!jFile) return;
|
||||||
|
|
||||||
rawsize = fileSystem->GetFileSize();
|
rawsize = fileSystem->GetFileSize(jFile);
|
||||||
|
|
||||||
rawdata = new BYTE[rawsize];
|
rawdata = new BYTE[rawsize];
|
||||||
|
|
||||||
if (!rawdata)
|
if (!rawdata)
|
||||||
{
|
{
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSystem->ReadFile(rawdata, rawsize);
|
fileSystem->ReadFile(jFile, rawdata, rawsize);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
|
|
||||||
// Initialize libJpeg Object
|
// Initialize libJpeg Object
|
||||||
cinfo.err = jpeg_std_error(&jerr);
|
cinfo.err = jpeg_std_error(&jerr);
|
||||||
@@ -1804,9 +1805,10 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
|
|||||||
{
|
{
|
||||||
png_size_t check;
|
png_size_t check;
|
||||||
|
|
||||||
JFileSystem *fileSystem = (JFileSystem*)png_get_io_ptr(png_ptr);
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
|
JFile *jFile = (JFile*)png_ptr->io_ptr;
|
||||||
|
|
||||||
check = fileSystem->ReadFile(data, length);
|
check = fileSystem->ReadFile(jFile, data, length);
|
||||||
|
|
||||||
if (check != length)
|
if (check != length)
|
||||||
{
|
{
|
||||||
@@ -1869,13 +1871,14 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
|||||||
DWORD* line;
|
DWORD* line;
|
||||||
|
|
||||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
if (!fileSystem->OpenFile(filename))
|
JFile* jFile = fileSystem->OpenFile(filename);
|
||||||
|
if (!jFile)
|
||||||
return JGE_ERR_CANT_OPEN_FILE;
|
return JGE_ERR_CANT_OPEN_FILE;
|
||||||
|
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
{
|
{
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
|
|
||||||
return JGE_ERR_PNG;
|
return JGE_ERR_PNG;
|
||||||
}
|
}
|
||||||
@@ -1885,26 +1888,22 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
|||||||
if (info_ptr == NULL)
|
if (info_ptr == NULL)
|
||||||
{
|
{
|
||||||
//fclose(fp);
|
//fclose(fp);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
|
|
||||||
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||||
|
|
||||||
return JGE_ERR_PNG;
|
return JGE_ERR_PNG;
|
||||||
}
|
}
|
||||||
png_init_io(png_ptr, NULL);
|
png_init_io(png_ptr, NULL);
|
||||||
png_set_read_fn(png_ptr, (png_voidp)fileSystem, PNGCustomReadDataFn);
|
png_set_read_fn(png_ptr, (png_voidp)jFile, PNGCustomReadDataFn);
|
||||||
|
|
||||||
png_set_sig_bytes(png_ptr, sig_read);
|
png_set_sig_bytes(png_ptr, sig_read);
|
||||||
png_read_info(png_ptr, info_ptr);
|
png_read_info(png_ptr, info_ptr);
|
||||||
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, NULL, NULL);
|
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, int_p_NULL, int_p_NULL);
|
||||||
png_set_strip_16(png_ptr);
|
png_set_strip_16(png_ptr);
|
||||||
png_set_packing(png_ptr);
|
png_set_packing(png_ptr);
|
||||||
if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png_ptr);
|
if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png_ptr);
|
||||||
#if PNG_LIBPNG_VER >= 10400
|
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr);
|
|
||||||
#else
|
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
|
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_gray_1_2_4_to_8(png_ptr);
|
||||||
#endif
|
|
||||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
|
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr);
|
||||||
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
|
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
|
||||||
|
|
||||||
@@ -1912,9 +1911,9 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
|||||||
if (!line)
|
if (!line)
|
||||||
{
|
{
|
||||||
//fclose(fp);
|
//fclose(fp);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
|
|
||||||
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
|
||||||
return JGE_ERR_MALLOC_FAILED;
|
return JGE_ERR_MALLOC_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1936,7 +1935,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
|||||||
|
|
||||||
for (y = 0; y < (int)height; y++)
|
for (y = 0; y < (int)height; y++)
|
||||||
{
|
{
|
||||||
png_read_row(png_ptr, (BYTE*) line, NULL);
|
png_read_row(png_ptr, (BYTE*) line, png_bytep_NULL);
|
||||||
for (x = 0; x < (int)width; x++)
|
for (x = 0; x < (int)width; x++)
|
||||||
{
|
{
|
||||||
DWORD color32 = line[x];
|
DWORD color32 = line[x];
|
||||||
@@ -1959,9 +1958,9 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
|
|||||||
free (line);
|
free (line);
|
||||||
|
|
||||||
png_read_end(png_ptr, info_ptr);
|
png_read_end(png_ptr, info_ptr);
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
|
||||||
|
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
|
|
||||||
|
|
||||||
textureInfo.mBits = buffer;
|
textureInfo.mBits = buffer;
|
||||||
@@ -2002,15 +2001,8 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
|||||||
GifFileType *GifFileIn = NULL;
|
GifFileType *GifFileIn = NULL;
|
||||||
ColorMapObject *palette;
|
ColorMapObject *palette;
|
||||||
int ExtCode;
|
int ExtCode;
|
||||||
|
|
||||||
#if GIFLIB_MAJOR >= 5
|
|
||||||
if ((GifFileIn = DGifOpen(handle, readFunc, NULL)) == NULL)
|
|
||||||
return 1;
|
|
||||||
#else
|
|
||||||
if ((GifFileIn = DGifOpen(handle, readFunc)) == NULL)
|
if ((GifFileIn = DGifOpen(handle, readFunc)) == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
|
||||||
|
|
||||||
*bgcolor = 0;
|
*bgcolor = 0;
|
||||||
textureInfo.mWidth = 0;
|
textureInfo.mWidth = 0;
|
||||||
textureInfo.mHeight = 0;
|
textureInfo.mHeight = 0;
|
||||||
@@ -2019,11 +2011,7 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
|||||||
do {
|
do {
|
||||||
if (DGifGetRecordType(GifFileIn, &RecordType) == GIF_ERROR)
|
if (DGifGetRecordType(GifFileIn, &RecordType) == GIF_ERROR)
|
||||||
{
|
{
|
||||||
#if GIFLIB_MAJOR >= 5
|
|
||||||
DGifCloseFile(GifFileIn, NULL);
|
|
||||||
#else
|
|
||||||
DGifCloseFile(GifFileIn);
|
DGifCloseFile(GifFileIn);
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2032,20 +2020,12 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
|||||||
{
|
{
|
||||||
if (DGifGetImageDesc(GifFileIn) == GIF_ERROR)
|
if (DGifGetImageDesc(GifFileIn) == GIF_ERROR)
|
||||||
{
|
{
|
||||||
#if GIFLIB_MAJOR >= 5
|
|
||||||
DGifCloseFile(GifFileIn, NULL);
|
|
||||||
#else
|
|
||||||
DGifCloseFile(GifFileIn);
|
DGifCloseFile(GifFileIn);
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if((palette = (GifFileIn->SColorMap != NULL) ? GifFileIn->SColorMap : GifFileIn->Image.ColorMap) == NULL)
|
if((palette = (GifFileIn->SColorMap != NULL) ? GifFileIn->SColorMap : GifFileIn->Image.ColorMap) == NULL)
|
||||||
{
|
{
|
||||||
#if GIFLIB_MAJOR >= 5
|
|
||||||
DGifCloseFile(GifFileIn, NULL);
|
|
||||||
#else
|
|
||||||
DGifCloseFile(GifFileIn);
|
DGifCloseFile(GifFileIn);
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
textureInfo.mWidth = GifFileIn->Image.Width;
|
textureInfo.mWidth = GifFileIn->Image.Width;
|
||||||
@@ -2053,11 +2033,7 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
|||||||
*bgcolor = gif_color32(GifFileIn->SBackGroundColor);
|
*bgcolor = gif_color32(GifFileIn->SBackGroundColor);
|
||||||
if((LineIn = (GifRowType) malloc(GifFileIn->Image.Width * sizeof(GifPixelType))) == NULL)
|
if((LineIn = (GifRowType) malloc(GifFileIn->Image.Width * sizeof(GifPixelType))) == NULL)
|
||||||
{
|
{
|
||||||
#if GIFLIB_MAJOR >= 5
|
|
||||||
DGifCloseFile(GifFileIn, NULL);
|
|
||||||
#else
|
|
||||||
DGifCloseFile(GifFileIn);
|
DGifCloseFile(GifFileIn);
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
textureInfo.mTexWidth = getNextPower2(GifFileIn->Image.Width);
|
textureInfo.mTexWidth = getNextPower2(GifFileIn->Image.Width);
|
||||||
@@ -2067,11 +2043,7 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
|||||||
if((p32 = (DWORD *)malloc(sizeof(PIXEL_TYPE) * textureInfo.mTexWidth * textureInfo.mTexHeight)) == NULL)
|
if((p32 = (DWORD *)malloc(sizeof(PIXEL_TYPE) * textureInfo.mTexWidth * textureInfo.mTexHeight)) == NULL)
|
||||||
{
|
{
|
||||||
free((void *)LineIn);
|
free((void *)LineIn);
|
||||||
#if GIFLIB_MAJOR >= 5
|
|
||||||
DGifCloseFile(GifFileIn, NULL);
|
|
||||||
#else
|
|
||||||
DGifCloseFile(GifFileIn);
|
DGifCloseFile(GifFileIn);
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
DWORD * curr = p32;
|
DWORD * curr = p32;
|
||||||
@@ -2083,11 +2055,7 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
|||||||
{
|
{
|
||||||
free((void *)p32);
|
free((void *)p32);
|
||||||
free((void *)LineIn);
|
free((void *)LineIn);
|
||||||
#if GIFLIB_MAJOR >= 5
|
|
||||||
DGifCloseFile(GifFileIn, NULL);
|
|
||||||
#else
|
|
||||||
DGifCloseFile(GifFileIn);
|
DGifCloseFile(GifFileIn);
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
for (GifWord j = 0; j < GifFileIn->Image.Width; j ++)
|
for (GifWord j = 0; j < GifFileIn->Image.Width; j ++)
|
||||||
@@ -2116,11 +2084,7 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
|||||||
}
|
}
|
||||||
if(LineIn != NULL)
|
if(LineIn != NULL)
|
||||||
free((void *)LineIn);
|
free((void *)LineIn);
|
||||||
#if GIFLIB_MAJOR >= 5
|
|
||||||
DGifCloseFile(GifFileIn, NULL);
|
|
||||||
#else
|
|
||||||
DGifCloseFile(GifFileIn);
|
DGifCloseFile(GifFileIn);
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
while (Extension != NULL) {
|
while (Extension != NULL) {
|
||||||
@@ -2133,11 +2097,7 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
|||||||
}
|
}
|
||||||
if(LineIn != NULL)
|
if(LineIn != NULL)
|
||||||
free((void *)LineIn);
|
free((void *)LineIn);
|
||||||
#if GIFLIB_MAJOR >= 5
|
|
||||||
DGifCloseFile(GifFileIn, NULL);
|
|
||||||
#else
|
|
||||||
DGifCloseFile(GifFileIn);
|
DGifCloseFile(GifFileIn);
|
||||||
#endif
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2152,20 +2112,17 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
|
|||||||
|
|
||||||
if(LineIn != NULL)
|
if(LineIn != NULL)
|
||||||
free((void *)LineIn);
|
free((void *)LineIn);
|
||||||
#if GIFLIB_MAJOR >= 5
|
|
||||||
DGifCloseFile(GifFileIn, NULL);
|
|
||||||
#else
|
|
||||||
DGifCloseFile(GifFileIn);
|
DGifCloseFile(GifFileIn);
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
|
int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
|
||||||
{
|
{
|
||||||
JFileSystem *fileSys = (JFileSystem *)ft->UserData;
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
//return fread(buf, 1, size, (FILE *)ft->UserData);
|
JFile* jFile = (JFile*)ft->UserData;
|
||||||
if (fileSys->ReadFile(buf, size))
|
|
||||||
|
if (fileSys->ReadFile(jFile, buf, size))
|
||||||
return size;
|
return size;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
@@ -2177,17 +2134,18 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
|
|||||||
///*
|
///*
|
||||||
//FILE * fp = fopen(filename, "rb");
|
//FILE * fp = fopen(filename, "rb");
|
||||||
JFileSystem *fileSys = JFileSystem::GetInstance();
|
JFileSystem *fileSys = JFileSystem::GetInstance();
|
||||||
if (!fileSys->OpenFile(filename))
|
JFile* jFile = fileSystem->OpenFile(filename);
|
||||||
|
if (!jFile))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//if(fp == NULL)
|
//if(fp == NULL)
|
||||||
// return;
|
// return;
|
||||||
DWORD bkcol;
|
DWORD bkcol;
|
||||||
int result = image_readgif(fileSys, textureInfo, &bkcol, image_gif_read, mode);
|
int result = image_readgif(jFile, textureInfo, &bkcol, image_gif_read, mode);
|
||||||
if(result!=0)
|
if(result!=0)
|
||||||
textureInfo.mBits=NULL;
|
textureInfo.mBits=NULL;
|
||||||
//fclose(fp);
|
//fclose(fp);
|
||||||
fileSys->CloseFile();
|
fileSys->CloseFile(jFile);
|
||||||
return ;//*/
|
return ;//*/
|
||||||
}
|
}
|
||||||
#endif //(!defined IOS) && (!defined QT_CONFIG) && (!defined SDL_CONFIG)
|
#endif //(!defined IOS) && (!defined QT_CONFIG) && (!defined SDL_CONFIG)
|
||||||
@@ -2208,20 +2166,21 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureForm
|
|||||||
UIImage *image = NULL;
|
UIImage *image = NULL;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!fileSystem->OpenFile(filename))
|
JFile* jFile = fileSystem->OpenFile(filename);
|
||||||
|
if (!jFile)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
rawsize = fileSystem->GetFileSize();
|
rawsize = fileSystem->GetFileSize(jFile);
|
||||||
rawdata = new BYTE[rawsize];
|
rawdata = new BYTE[rawsize];
|
||||||
|
|
||||||
if (!rawdata)
|
if (!rawdata)
|
||||||
{
|
{
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSystem->ReadFile(rawdata, rawsize);
|
fileSystem->ReadFile(jFile, rawdata, rawsize);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
|
|
||||||
texData = [[NSData alloc] initWithBytes:rawdata length:rawsize];
|
texData = [[NSData alloc] initWithBytes:rawdata length:rawsize];
|
||||||
image = [[UIImage alloc] initWithData:texData];
|
image = [[UIImage alloc] initWithData:texData];
|
||||||
@@ -2301,20 +2260,21 @@ JTexture* JRenderer::LoadTexture(const char* filename, int, int)
|
|||||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!fileSystem->OpenFile(filename))
|
JFile* jFile = fileSystem->OpenFile(filename);
|
||||||
|
if (!jFile)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
rawsize = fileSystem->GetFileSize();
|
rawsize = fileSystem->GetFileSize(jFile);
|
||||||
rawdata = new BYTE[rawsize];
|
rawdata = new BYTE[rawsize];
|
||||||
|
|
||||||
if (!rawdata)
|
if (!rawdata)
|
||||||
{
|
{
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileSystem->ReadFile(rawdata, rawsize);
|
fileSystem->ReadFile(jFile, rawdata, rawsize);
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
|
|
||||||
QImage tmpImage = QImage::fromData(rawdata, rawsize);
|
QImage tmpImage = QImage::fromData(rawdata, rawsize);
|
||||||
if(tmpImage.isNull())
|
if(tmpImage.isNull())
|
||||||
|
|||||||
@@ -22,8 +22,6 @@
|
|||||||
JMusic::JMusic()
|
JMusic::JMusic()
|
||||||
#ifdef USE_PHONON
|
#ifdef USE_PHONON
|
||||||
: mOutput(0), mMediaObject(0)
|
: mOutput(0), mMediaObject(0)
|
||||||
#elif defined QT_CONFIG
|
|
||||||
: playlist(0), player(0)
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -42,16 +40,11 @@ int JMusic::getPlayTime(){
|
|||||||
|
|
||||||
JMusic::~JMusic()
|
JMusic::~JMusic()
|
||||||
{
|
{
|
||||||
#if defined USE_PHONON
|
#ifdef USE_PHONON
|
||||||
if(mOutput)
|
if(mOutput)
|
||||||
delete mOutput;
|
delete mOutput;
|
||||||
if(mMediaObject)
|
if(mMediaObject)
|
||||||
delete mMediaObject;
|
delete mMediaObject;
|
||||||
#elif defined QT_CONFIG
|
|
||||||
if(player)
|
|
||||||
delete player;
|
|
||||||
if(playlist)
|
|
||||||
delete playlist;
|
|
||||||
#elif defined WITH_FMOD
|
#elif defined WITH_FMOD
|
||||||
JSoundSystem::GetInstance()->StopMusic(this);
|
JSoundSystem::GetInstance()->StopMusic(this);
|
||||||
if (mTrack) FSOUND_Sample_Free(mTrack);
|
if (mTrack) FSOUND_Sample_Free(mTrack);
|
||||||
@@ -76,10 +69,7 @@ JSample::JSample()
|
|||||||
|
|
||||||
JSample::~JSample()
|
JSample::~JSample()
|
||||||
{
|
{
|
||||||
#if (defined QT_CONFIG) && (!defined USE_PHONON)
|
#ifdef USE_PHONON
|
||||||
if(effect)
|
|
||||||
delete effect;
|
|
||||||
#elif USE_PHONON
|
|
||||||
if(mOutput)
|
if(mOutput)
|
||||||
delete mOutput;
|
delete mOutput;
|
||||||
if(mMediaObject)
|
if(mMediaObject)
|
||||||
@@ -154,84 +144,66 @@ void JSoundSystem::DestroySoundSystem()
|
|||||||
|
|
||||||
JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
JMusic *JSoundSystem::LoadMusic(const char *fileName)
|
||||||
{
|
{
|
||||||
JMusic* music = NULL;
|
#ifdef USE_PHONON
|
||||||
#if (defined QT_CONFIG) && (!defined USE_PHONON)
|
JMusic* music = new JMusic();
|
||||||
music = new JMusic();
|
if (music)
|
||||||
if (music)
|
{
|
||||||
{
|
music->mOutput = new Phonon::AudioOutput(Phonon::GameCategory, 0);
|
||||||
music->player = new QMediaPlayer;
|
music->mMediaObject = new Phonon::MediaObject(0);
|
||||||
music->player->setVolume(100);
|
string fullpath = JFileSystem::GetInstance()->GetResourceFile(fileName);
|
||||||
music->playlist = new QMediaPlaylist;
|
music->mMediaObject->setCurrentSource(QString(fullpath.c_str()));
|
||||||
music->fullpath = JFileSystem::GetInstance()->GetResourceFile(fileName);
|
Phonon::Path mediapath = Phonon::createPath(music->mMediaObject, music->mOutput);
|
||||||
music->playlist->addMedia(QUrl::fromLocalFile(music->fullpath.c_str()));
|
Q_ASSERT(mediapath.isValid());
|
||||||
music->playlist->setCurrentIndex(0);
|
}
|
||||||
}
|
return music;
|
||||||
#elif defined USE_PHONON
|
|
||||||
music = new JMusic();
|
|
||||||
if (music)
|
|
||||||
{
|
|
||||||
music->mOutput = new Phonon::AudioOutput(Phonon::GameCategory, 0);
|
|
||||||
music->mMediaObject = new Phonon::MediaObject(0);
|
|
||||||
string fullpath = JFileSystem::GetInstance()->GetResourceFile(fileName);
|
|
||||||
music->mMediaObject->setCurrentSource(QString(fullpath.c_str()));
|
|
||||||
Phonon::Path mediapath = Phonon::createPath(music->mMediaObject, music->mOutput);
|
|
||||||
Q_ASSERT(mediapath.isValid());
|
|
||||||
}
|
|
||||||
#elif (defined WITH_FMOD)
|
#elif (defined WITH_FMOD)
|
||||||
music = new JMusic();
|
JMusic* music = new JMusic();
|
||||||
if (music)
|
if (music)
|
||||||
{
|
{
|
||||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
if (fileSystem->OpenFile(fileName))
|
JFile* jFile = fileSystem->OpenFile(fileName);
|
||||||
{
|
if (jFile)
|
||||||
int size = fileSystem->GetFileSize();
|
{
|
||||||
char *buffer = new char[size];
|
int size = fileSystem->GetFileSize(jFile);
|
||||||
fileSystem->ReadFile(buffer, size);
|
char *buffer = new char[size];
|
||||||
music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
|
fileSystem->ReadFile(jFile, buffer, size);
|
||||||
|
music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
|
||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return music;
|
||||||
#else
|
#else
|
||||||
cerr << fileName << endl;
|
cerr << fileName << endl;
|
||||||
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
return music;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
||||||
{
|
{
|
||||||
#if (defined QT_CONFIG) && (!defined USE_PHONON)
|
#ifdef USE_PHONON
|
||||||
if(music && music->player && music->playlist)
|
if (music && music->mMediaObject && music->mOutput)
|
||||||
|
{
|
||||||
|
if(looping)
|
||||||
{
|
{
|
||||||
if(looping)
|
music->mMediaObject->connect(music->mMediaObject, SIGNAL(aboutToFinish()), music, SLOT(seekAtTheBegining()));
|
||||||
music->playlist->setPlaybackMode(QMediaPlaylist::Loop);
|
|
||||||
|
|
||||||
music->player->setPlaylist(music->playlist);
|
|
||||||
music->player->play();
|
|
||||||
}
|
}
|
||||||
#elif USE_PHONON
|
music->mOutput->setVolume((qreal)mVolume*0.01);
|
||||||
if (music && music->mMediaObject && music->mOutput)
|
music->mMediaObject->play();
|
||||||
{
|
|
||||||
if(looping)
|
|
||||||
{
|
|
||||||
music->mMediaObject->connect(music->mMediaObject, SIGNAL(aboutToFinish()), music, SLOT(seekAtTheBegining()));
|
|
||||||
}
|
|
||||||
music->mOutput->setVolume((qreal)mVolume*0.01);
|
|
||||||
music->mMediaObject->play();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#elif (defined WITH_FMOD)
|
#elif (defined WITH_FMOD)
|
||||||
if (music && music->mTrack)
|
if (music && music->mTrack)
|
||||||
{
|
{
|
||||||
mChannel = FSOUND_PlaySound(mChannel, music->mTrack);
|
mChannel = FSOUND_PlaySound(mChannel, music->mTrack);
|
||||||
SetMusicVolume(mVolume);
|
SetMusicVolume(mVolume);
|
||||||
|
|
||||||
if (looping)
|
if (looping)
|
||||||
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_NORMAL);
|
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_NORMAL);
|
||||||
else
|
else
|
||||||
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_OFF);
|
FSOUND_SetLoopMode(mChannel, FSOUND_LOOP_OFF);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
music = 0;
|
music = 0;
|
||||||
@@ -242,12 +214,7 @@ void JSoundSystem::PlayMusic(JMusic *music, bool looping)
|
|||||||
|
|
||||||
void JSoundSystem::StopMusic(JMusic *music)
|
void JSoundSystem::StopMusic(JMusic *music)
|
||||||
{
|
{
|
||||||
#if (defined QT_CONFIG) && (!defined USE_PHONON)
|
#ifdef USE_PHONON
|
||||||
if (music && music->player && music->playlist)
|
|
||||||
{
|
|
||||||
music->player->stop();
|
|
||||||
}
|
|
||||||
#elif defined USE_PHONON
|
|
||||||
if (music && music->mMediaObject && music->mOutput)
|
if (music && music->mMediaObject && music->mOutput)
|
||||||
{
|
{
|
||||||
music->mMediaObject->stop();
|
music->mMediaObject->stop();
|
||||||
@@ -298,61 +265,48 @@ void JSoundSystem::SetSfxVolume(int volume){
|
|||||||
|
|
||||||
JSample *JSoundSystem::LoadSample(const char *fileName)
|
JSample *JSoundSystem::LoadSample(const char *fileName)
|
||||||
{
|
{
|
||||||
JSample* sample = NULL;
|
#if (defined USE_PHONON)
|
||||||
#if (defined QT_CONFIG) && (!defined USE_PHONON)
|
JSample* sample = new JSample();
|
||||||
sample = new JSample();
|
if (sample)
|
||||||
if (sample)
|
{
|
||||||
{
|
sample->mOutput = new Phonon::AudioOutput(Phonon::GameCategory, 0);
|
||||||
string fullpath = JFileSystem::GetInstance()->GetResourceFile(fileName);
|
sample->mMediaObject = new Phonon::MediaObject(0);
|
||||||
sample->effect = new QMediaPlayer;
|
string fullpath = JFileSystem::GetInstance()->GetResourceFile(fileName);
|
||||||
sample->effect->setMedia(QUrl::fromLocalFile(fullpath.c_str()));
|
sample->mMediaObject->setCurrentSource(QString(fullpath.c_str()));
|
||||||
sample->effect->setVolume(100);
|
Phonon::Path mediapath = Phonon::createPath(sample->mMediaObject, sample->mOutput);
|
||||||
sample->mSample = &(sample->effect);
|
Q_ASSERT(mediapath.isValid());
|
||||||
}
|
}
|
||||||
#elif (defined USE_PHONON)
|
return sample;
|
||||||
sample = new JSample();
|
|
||||||
if (sample)
|
|
||||||
{
|
|
||||||
sample->mOutput = new Phonon::AudioOutput(Phonon::GameCategory, 0);
|
|
||||||
sample->mMediaObject = new Phonon::MediaObject(0);
|
|
||||||
string fullpath = JFileSystem::GetInstance()->GetResourceFile(fileName);
|
|
||||||
sample->mMediaObject->setCurrentSource(QString(fullpath.c_str()));
|
|
||||||
Phonon::Path mediapath = Phonon::createPath(sample->mMediaObject, sample->mOutput);
|
|
||||||
Q_ASSERT(mediapath.isValid());
|
|
||||||
}
|
|
||||||
#elif (defined WITH_FMOD)
|
#elif (defined WITH_FMOD)
|
||||||
sample = new JSample();
|
JSample* sample = new JSample();
|
||||||
if (sample)
|
if (sample)
|
||||||
{
|
{
|
||||||
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
JFileSystem* fileSystem = JFileSystem::GetInstance();
|
||||||
if (fileSystem->OpenFile(fileName))
|
JFile* jFile = fileSystem->OpenFile(fileName);
|
||||||
{
|
if (jFile)
|
||||||
int size = fileSystem->GetFileSize();
|
{
|
||||||
char *buffer = new char[size];
|
int size = fileSystem->GetFileSize(jFile);
|
||||||
fileSystem->ReadFile(buffer, size);
|
char *buffer = new char[size];
|
||||||
sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
|
fileSystem->ReadFile(jFile, buffer, size);
|
||||||
|
sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
|
||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
fileSystem->CloseFile();
|
fileSystem->CloseFile(jFile);
|
||||||
}else
|
}else
|
||||||
sample->mSample = NULL;
|
sample->mSample = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
return sample;
|
||||||
#else
|
#else
|
||||||
cerr << fileName << endl;
|
cerr << fileName << endl;
|
||||||
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
return sample;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JSoundSystem::PlaySample(JSample *sample)
|
void JSoundSystem::PlaySample(JSample *sample)
|
||||||
{
|
{
|
||||||
#if (defined QT_CONFIG) && (!defined USE_PHONON)
|
#ifdef USE_PHONON
|
||||||
if(sample)
|
|
||||||
{
|
|
||||||
sample->effect->play();
|
|
||||||
}
|
|
||||||
#elif defined USE_PHONON
|
|
||||||
if (sample && sample->mMediaObject && sample->mOutput)
|
if (sample && sample->mMediaObject && sample->mOutput)
|
||||||
{
|
{
|
||||||
sample->mOutput->setVolume((qreal)mSampleVolume*0.01);
|
sample->mOutput->setVolume((qreal)mSampleVolume*0.01);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#elif LINUX
|
#elif LINUX
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@@ -48,9 +47,7 @@ JSocket::JSocket(string ipAddr)
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
unsigned int addr_dest = inet_addr(ipAddr.c_str());
|
unsigned int addr_dest = inet_addr(ipAddr.c_str());
|
||||||
hostentptr = gethostbyaddr((char*) &addr_dest, 4, AF_INET);
|
hostentptr=gethostbyaddr((char*) &addr_dest, 4, AF_INET);
|
||||||
if (hostentptr == NULL)
|
|
||||||
hostentptr = gethostbyname(ipAddr.c_str()); // Fix for Windows if IP Address cannot be resolved.
|
|
||||||
#elif LINUX
|
#elif LINUX
|
||||||
hostentptr = gethostbyname(ipAddr.c_str());
|
hostentptr = gethostbyname(ipAddr.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -87,13 +87,13 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned lon
|
|||||||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
static int crypthead(
|
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
|
||||||
const char *passwd, /* password string */
|
const char *passwd; /* password string */
|
||||||
unsigned char *buf, /* where to write header */
|
unsigned char *buf; /* where to write header */
|
||||||
int bufSize,
|
int bufSize;
|
||||||
unsigned long* pkeys,
|
unsigned long* pkeys;
|
||||||
const unsigned long* pcrc_32_tab,
|
const unsigned long* pcrc_32_tab;
|
||||||
unsigned long crcForCrypting)
|
unsigned long crcForCrypting;
|
||||||
{
|
{
|
||||||
int n; /* index in random header */
|
int n; /* index in random header */
|
||||||
int t; /* temporary */
|
int t; /* temporary */
|
||||||
|
|||||||
@@ -65,10 +65,10 @@ int ZCALLBACK ferror_file_func OF((
|
|||||||
voidpf stream));
|
voidpf stream));
|
||||||
|
|
||||||
|
|
||||||
voidpf ZCALLBACK fopen_file_func (
|
voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
|
||||||
voidpf opaque,
|
voidpf opaque;
|
||||||
const char* filename,
|
const char* filename;
|
||||||
int mode)
|
int mode;
|
||||||
{
|
{
|
||||||
FILE* file = NULL;
|
FILE* file = NULL;
|
||||||
const char* mode_fopen = NULL;
|
const char* mode_fopen = NULL;
|
||||||
@@ -87,11 +87,11 @@ voidpf ZCALLBACK fopen_file_func (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uLong ZCALLBACK fread_file_func (
|
uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
|
||||||
voidpf opaque,
|
voidpf opaque;
|
||||||
voidpf stream,
|
voidpf stream;
|
||||||
void* buf,
|
void* buf;
|
||||||
uLong size)
|
uLong size;
|
||||||
{
|
{
|
||||||
uLong ret;
|
uLong ret;
|
||||||
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
||||||
@@ -99,31 +99,31 @@ uLong ZCALLBACK fread_file_func (
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uLong ZCALLBACK fwrite_file_func (
|
uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
|
||||||
voidpf opaque,
|
voidpf opaque;
|
||||||
voidpf stream,
|
voidpf stream;
|
||||||
const void* buf,
|
const void* buf;
|
||||||
uLong size)
|
uLong size;
|
||||||
{
|
{
|
||||||
uLong ret;
|
uLong ret;
|
||||||
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
long ZCALLBACK ftell_file_func (
|
long ZCALLBACK ftell_file_func (opaque, stream)
|
||||||
voidpf opaque,
|
voidpf opaque;
|
||||||
voidpf stream)
|
voidpf stream;
|
||||||
{
|
{
|
||||||
long ret;
|
long ret;
|
||||||
ret = ftell((FILE *)stream);
|
ret = ftell((FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
long ZCALLBACK fseek_file_func (
|
long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
|
||||||
voidpf opaque,
|
voidpf opaque;
|
||||||
voidpf stream,
|
voidpf stream;
|
||||||
uLong offset,
|
uLong offset;
|
||||||
int origin)
|
int origin;
|
||||||
{
|
{
|
||||||
int fseek_origin=0;
|
int fseek_origin=0;
|
||||||
long ret;
|
long ret;
|
||||||
@@ -145,26 +145,26 @@ long ZCALLBACK fseek_file_func (
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZCALLBACK fclose_file_func (
|
int ZCALLBACK fclose_file_func (opaque, stream)
|
||||||
voidpf opaque,
|
voidpf opaque;
|
||||||
voidpf stream)
|
voidpf stream;
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = fclose((FILE *)stream);
|
ret = fclose((FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZCALLBACK ferror_file_func (
|
int ZCALLBACK ferror_file_func (opaque, stream)
|
||||||
voidpf opaque,
|
voidpf opaque;
|
||||||
voidpf stream)
|
voidpf stream;
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = ferror((FILE *)stream);
|
ret = ferror((FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_fopen_filefunc (
|
void fill_fopen_filefunc (pzlib_filefunc_def)
|
||||||
zlib_filefunc_def* pzlib_filefunc_def)
|
zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
{
|
{
|
||||||
pzlib_filefunc_def->zopen_file = fopen_file_func;
|
pzlib_filefunc_def->zopen_file = fopen_file_func;
|
||||||
pzlib_filefunc_def->zread_file = fread_file_func;
|
pzlib_filefunc_def->zread_file = fread_file_func;
|
||||||
|
|||||||
@@ -168,7 +168,10 @@ local int unzlocal_getByte OF((
|
|||||||
voidpf filestream,
|
voidpf filestream,
|
||||||
int *pi));
|
int *pi));
|
||||||
|
|
||||||
local int unzlocal_getByte(const zlib_filefunc_def* pzlib_filefunc_def,voidpf filestream,int *pi)
|
local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi)
|
||||||
|
const zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
|
voidpf filestream;
|
||||||
|
int *pi;
|
||||||
{
|
{
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
|
int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
|
||||||
@@ -195,7 +198,10 @@ local int unzlocal_getShort OF((
|
|||||||
voidpf filestream,
|
voidpf filestream,
|
||||||
uLong *pX));
|
uLong *pX));
|
||||||
|
|
||||||
local int unzlocal_getShort (const zlib_filefunc_def* pzlib_filefunc_def,voidpf filestream,uLong *pX)
|
local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX)
|
||||||
|
const zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
|
voidpf filestream;
|
||||||
|
uLong *pX;
|
||||||
{
|
{
|
||||||
uLong x ;
|
uLong x ;
|
||||||
int i;
|
int i;
|
||||||
@@ -220,7 +226,10 @@ local int unzlocal_getLong OF((
|
|||||||
voidpf filestream,
|
voidpf filestream,
|
||||||
uLong *pX));
|
uLong *pX));
|
||||||
|
|
||||||
local int unzlocal_getLong (const zlib_filefunc_def* pzlib_filefunc_def,voidpf filestream,uLong *pX)
|
local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX)
|
||||||
|
const zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
|
voidpf filestream;
|
||||||
|
uLong *pX;
|
||||||
{
|
{
|
||||||
uLong x ;
|
uLong x ;
|
||||||
int i;
|
int i;
|
||||||
@@ -250,7 +259,9 @@ local int unzlocal_getLong (const zlib_filefunc_def* pzlib_filefunc_def,voidpf f
|
|||||||
|
|
||||||
|
|
||||||
/* My own strcmpi / strcasecmp */
|
/* My own strcmpi / strcasecmp */
|
||||||
local int strcmpcasenosensitive_internal (const char* fileName1,const char* fileName2)
|
local int strcmpcasenosensitive_internal (fileName1,fileName2)
|
||||||
|
const char* fileName1;
|
||||||
|
const char* fileName2;
|
||||||
{
|
{
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@@ -291,7 +302,10 @@ local int strcmpcasenosensitive_internal (const char* fileName1,const char* file
|
|||||||
(like 1 on Unix, 2 on Windows)
|
(like 1 on Unix, 2 on Windows)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,const char* fileName2,int iCaseSensitivity)
|
extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
|
||||||
|
const char* fileName1;
|
||||||
|
const char* fileName2;
|
||||||
|
int iCaseSensitivity;
|
||||||
{
|
{
|
||||||
if (iCaseSensitivity==0)
|
if (iCaseSensitivity==0)
|
||||||
iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
|
iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
|
||||||
@@ -314,7 +328,9 @@ local uLong unzlocal_SearchCentralDir OF((
|
|||||||
const zlib_filefunc_def* pzlib_filefunc_def,
|
const zlib_filefunc_def* pzlib_filefunc_def,
|
||||||
voidpf filestream));
|
voidpf filestream));
|
||||||
|
|
||||||
local uLong unzlocal_SearchCentralDir(const zlib_filefunc_def* pzlib_filefunc_def,voidpf filestream)
|
local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
|
||||||
|
const zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
|
voidpf filestream;
|
||||||
{
|
{
|
||||||
unsigned char* buf;
|
unsigned char* buf;
|
||||||
uLong uSizeFile;
|
uLong uSizeFile;
|
||||||
@@ -378,7 +394,9 @@ local uLong unzlocal_SearchCentralDir(const zlib_filefunc_def* pzlib_filefunc_de
|
|||||||
Else, the return value is a unzFile Handle, usable with other function
|
Else, the return value is a unzFile Handle, usable with other function
|
||||||
of this unzip package.
|
of this unzip package.
|
||||||
*/
|
*/
|
||||||
extern unzFile ZEXPORT unzOpen2 (const char *path, zlib_filefunc_def* pzlib_filefunc_def)
|
extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
|
||||||
|
const char *path;
|
||||||
|
zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
{
|
{
|
||||||
unz_s us;
|
unz_s us;
|
||||||
unz_s *s;
|
unz_s *s;
|
||||||
@@ -479,7 +497,8 @@ extern unzFile ZEXPORT unzOpen2 (const char *path, zlib_filefunc_def* pzlib_file
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern unzFile ZEXPORT unzOpen (const char *path)
|
extern unzFile ZEXPORT unzOpen (path)
|
||||||
|
const char *path;
|
||||||
{
|
{
|
||||||
return unzOpen2(path, NULL);
|
return unzOpen2(path, NULL);
|
||||||
}
|
}
|
||||||
@@ -489,7 +508,8 @@ extern unzFile ZEXPORT unzOpen (const char *path)
|
|||||||
If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
|
If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
|
||||||
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||||
return UNZ_OK if there is no problem. */
|
return UNZ_OK if there is no problem. */
|
||||||
extern int ZEXPORT unzClose (unzFile file)
|
extern int ZEXPORT unzClose (file)
|
||||||
|
unzFile file;
|
||||||
{
|
{
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
if (file==NULL)
|
if (file==NULL)
|
||||||
@@ -509,7 +529,9 @@ extern int ZEXPORT unzClose (unzFile file)
|
|||||||
Write info about the ZipFile in the *pglobal_info structure.
|
Write info about the ZipFile in the *pglobal_info structure.
|
||||||
No preparation of the structure is needed
|
No preparation of the structure is needed
|
||||||
return UNZ_OK if there is no problem. */
|
return UNZ_OK if there is no problem. */
|
||||||
extern int ZEXPORT unzGetGlobalInfo (unzFile file,unz_global_info *pglobal_info)
|
extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
|
||||||
|
unzFile file;
|
||||||
|
unz_global_info *pglobal_info;
|
||||||
{
|
{
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
if (file==NULL)
|
if (file==NULL)
|
||||||
@@ -523,7 +545,9 @@ extern int ZEXPORT unzGetGlobalInfo (unzFile file,unz_global_info *pglobal_info)
|
|||||||
/*
|
/*
|
||||||
Translate date/time from Dos format to tm_unz (readable more easilty)
|
Translate date/time from Dos format to tm_unz (readable more easilty)
|
||||||
*/
|
*/
|
||||||
local void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz* ptm)
|
local void unzlocal_DosDateToTmuDate (ulDosDate, ptm)
|
||||||
|
uLong ulDosDate;
|
||||||
|
tm_unz* ptm;
|
||||||
{
|
{
|
||||||
uLong uDate;
|
uLong uDate;
|
||||||
uDate = (uLong)(ulDosDate>>16);
|
uDate = (uLong)(ulDosDate>>16);
|
||||||
@@ -550,16 +574,21 @@ local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
|
|||||||
char *szComment,
|
char *szComment,
|
||||||
uLong commentBufferSize));
|
uLong commentBufferSize));
|
||||||
|
|
||||||
local int unzlocal_GetCurrentFileInfoInternal (
|
local int unzlocal_GetCurrentFileInfoInternal (file,
|
||||||
unzFile file,
|
pfile_info,
|
||||||
unz_file_info *pfile_info,
|
pfile_info_internal,
|
||||||
unz_file_info_internal *pfile_info_internal,
|
szFileName, fileNameBufferSize,
|
||||||
char *szFileName,
|
extraField, extraFieldBufferSize,
|
||||||
uLong fileNameBufferSize,
|
szComment, commentBufferSize)
|
||||||
void *extraField,
|
unzFile file;
|
||||||
uLong extraFieldBufferSize,
|
unz_file_info *pfile_info;
|
||||||
char *szComment,
|
unz_file_info_internal *pfile_info_internal;
|
||||||
uLong commentBufferSize)
|
char *szFileName;
|
||||||
|
uLong fileNameBufferSize;
|
||||||
|
void *extraField;
|
||||||
|
uLong extraFieldBufferSize;
|
||||||
|
char *szComment;
|
||||||
|
uLong commentBufferSize;
|
||||||
{
|
{
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
unz_file_info file_info;
|
unz_file_info file_info;
|
||||||
@@ -717,15 +746,19 @@ local int unzlocal_GetCurrentFileInfoInternal (
|
|||||||
No preparation of the structure is needed
|
No preparation of the structure is needed
|
||||||
return UNZ_OK if there is no problem.
|
return UNZ_OK if there is no problem.
|
||||||
*/
|
*/
|
||||||
extern int ZEXPORT unzGetCurrentFileInfo (
|
extern int ZEXPORT unzGetCurrentFileInfo (file,
|
||||||
unzFile file,
|
pfile_info,
|
||||||
unz_file_info *pfile_info,
|
szFileName, fileNameBufferSize,
|
||||||
char *szFileName,
|
extraField, extraFieldBufferSize,
|
||||||
uLong fileNameBufferSize,
|
szComment, commentBufferSize)
|
||||||
void *extraField,
|
unzFile file;
|
||||||
uLong extraFieldBufferSize,
|
unz_file_info *pfile_info;
|
||||||
char *szComment,
|
char *szFileName;
|
||||||
uLong commentBufferSize)
|
uLong fileNameBufferSize;
|
||||||
|
void *extraField;
|
||||||
|
uLong extraFieldBufferSize;
|
||||||
|
char *szComment;
|
||||||
|
uLong commentBufferSize;
|
||||||
{
|
{
|
||||||
return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
|
return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
|
||||||
szFileName,fileNameBufferSize,
|
szFileName,fileNameBufferSize,
|
||||||
@@ -737,7 +770,8 @@ extern int ZEXPORT unzGetCurrentFileInfo (
|
|||||||
Set the current file of the zipfile to the first file.
|
Set the current file of the zipfile to the first file.
|
||||||
return UNZ_OK if there is no problem
|
return UNZ_OK if there is no problem
|
||||||
*/
|
*/
|
||||||
extern int ZEXPORT unzGoToFirstFile (unzFile file)
|
extern int ZEXPORT unzGoToFirstFile (file)
|
||||||
|
unzFile file;
|
||||||
{
|
{
|
||||||
int err=UNZ_OK;
|
int err=UNZ_OK;
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
@@ -758,7 +792,8 @@ extern int ZEXPORT unzGoToFirstFile (unzFile file)
|
|||||||
return UNZ_OK if there is no problem
|
return UNZ_OK if there is no problem
|
||||||
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||||
*/
|
*/
|
||||||
extern int ZEXPORT unzGoToNextFile (unzFile file)
|
extern int ZEXPORT unzGoToNextFile (file)
|
||||||
|
unzFile file;
|
||||||
{
|
{
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
int err;
|
int err;
|
||||||
@@ -791,7 +826,10 @@ extern int ZEXPORT unzGoToNextFile (unzFile file)
|
|||||||
UNZ_OK if the file is found. It becomes the current file.
|
UNZ_OK if the file is found. It becomes the current file.
|
||||||
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||||
*/
|
*/
|
||||||
extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
|
extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
|
||||||
|
unzFile file;
|
||||||
|
const char *szFileName;
|
||||||
|
int iCaseSensitivity;
|
||||||
{
|
{
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
int err;
|
int err;
|
||||||
@@ -867,7 +905,9 @@ typedef struct unz_file_pos_s
|
|||||||
} unz_file_pos;
|
} unz_file_pos;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos* file_pos)
|
extern int ZEXPORT unzGetFilePos(file, file_pos)
|
||||||
|
unzFile file;
|
||||||
|
unz_file_pos* file_pos;
|
||||||
{
|
{
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
|
|
||||||
@@ -883,7 +923,9 @@ extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos* file_pos)
|
|||||||
return UNZ_OK;
|
return UNZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos*file_pos)
|
extern int ZEXPORT unzGoToFilePos(file, file_pos)
|
||||||
|
unzFile file;
|
||||||
|
unz_file_pos* file_pos;
|
||||||
{
|
{
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
int err;
|
int err;
|
||||||
@@ -917,11 +959,13 @@ extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos*file_pos)
|
|||||||
store in *piSizeVar the size of extra info in local header
|
store in *piSizeVar the size of extra info in local header
|
||||||
(filename and size of extra field data)
|
(filename and size of extra field data)
|
||||||
*/
|
*/
|
||||||
local int unzlocal_CheckCurrentFileCoherencyHeader (
|
local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
|
||||||
unz_s* s,
|
poffset_local_extrafield,
|
||||||
uInt* piSizeVar,
|
psize_local_extrafield)
|
||||||
uLong *poffset_local_extrafield,
|
unz_s* s;
|
||||||
uInt *psize_local_extrafield)
|
uInt* piSizeVar;
|
||||||
|
uLong *poffset_local_extrafield;
|
||||||
|
uInt *psize_local_extrafield;
|
||||||
{
|
{
|
||||||
uLong uMagic,uData,uFlags;
|
uLong uMagic,uData,uFlags;
|
||||||
uLong size_filename;
|
uLong size_filename;
|
||||||
@@ -1006,12 +1050,12 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (
|
|||||||
Open for reading data the current file in the zipfile.
|
Open for reading data the current file in the zipfile.
|
||||||
If there is no error and the file is opened, the return value is UNZ_OK.
|
If there is no error and the file is opened, the return value is UNZ_OK.
|
||||||
*/
|
*/
|
||||||
extern int ZEXPORT unzOpenCurrentFile3 (
|
extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
|
||||||
unzFile file,
|
unzFile file;
|
||||||
int* method,
|
int* method;
|
||||||
int* level,
|
int* level;
|
||||||
int raw,
|
int raw;
|
||||||
const char* password)
|
const char* password;
|
||||||
{
|
{
|
||||||
int err=UNZ_OK;
|
int err=UNZ_OK;
|
||||||
uInt iSizeVar;
|
uInt iSizeVar;
|
||||||
@@ -1092,7 +1136,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (
|
|||||||
pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
|
pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
|
||||||
pfile_in_zip_read_info->stream.zfree = (free_func)0;
|
pfile_in_zip_read_info->stream.zfree = (free_func)0;
|
||||||
pfile_in_zip_read_info->stream.opaque = (voidpf)0;
|
pfile_in_zip_read_info->stream.opaque = (voidpf)0;
|
||||||
pfile_in_zip_read_info->stream.next_in = (Bytef*)0;
|
pfile_in_zip_read_info->stream.next_in = (voidpf)0;
|
||||||
pfile_in_zip_read_info->stream.avail_in = 0;
|
pfile_in_zip_read_info->stream.avail_in = 0;
|
||||||
|
|
||||||
err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
|
err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
|
||||||
@@ -1151,21 +1195,24 @@ extern int ZEXPORT unzOpenCurrentFile3 (
|
|||||||
return UNZ_OK;
|
return UNZ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ZEXPORT unzOpenCurrentFile (unzFile file)
|
extern int ZEXPORT unzOpenCurrentFile (file)
|
||||||
|
unzFile file;
|
||||||
{
|
{
|
||||||
return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
|
return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char* password)
|
extern int ZEXPORT unzOpenCurrentFilePassword (file, password)
|
||||||
|
unzFile file;
|
||||||
|
const char* password;
|
||||||
{
|
{
|
||||||
return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
|
return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ZEXPORT unzOpenCurrentFile2 (
|
extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw)
|
||||||
unzFile file,
|
unzFile file;
|
||||||
int* method,
|
int* method;
|
||||||
int* level,
|
int* level;
|
||||||
int raw)
|
int raw;
|
||||||
{
|
{
|
||||||
return unzOpenCurrentFile3(file, method, level, raw, NULL);
|
return unzOpenCurrentFile3(file, method, level, raw, NULL);
|
||||||
}
|
}
|
||||||
@@ -1180,10 +1227,10 @@ extern int ZEXPORT unzOpenCurrentFile2 (
|
|||||||
return <0 with error code if there is an error
|
return <0 with error code if there is an error
|
||||||
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||||
*/
|
*/
|
||||||
extern int ZEXPORT unzReadCurrentFile(
|
extern int ZEXPORT unzReadCurrentFile (file, buf, len)
|
||||||
unzFile file,
|
unzFile file;
|
||||||
voidp buf,
|
voidp buf;
|
||||||
unsigned len)
|
unsigned len;
|
||||||
{
|
{
|
||||||
int err=UNZ_OK;
|
int err=UNZ_OK;
|
||||||
uInt iRead = 0;
|
uInt iRead = 0;
|
||||||
@@ -1341,7 +1388,8 @@ extern int ZEXPORT unzReadCurrentFile(
|
|||||||
/*
|
/*
|
||||||
Give the current position in uncompressed data
|
Give the current position in uncompressed data
|
||||||
*/
|
*/
|
||||||
extern z_off_t ZEXPORT unztell (unzFile file)
|
extern z_off_t ZEXPORT unztell (file)
|
||||||
|
unzFile file;
|
||||||
{
|
{
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
file_in_zip_read_info_s* pfile_in_zip_read_info;
|
file_in_zip_read_info_s* pfile_in_zip_read_info;
|
||||||
@@ -1360,7 +1408,8 @@ extern z_off_t ZEXPORT unztell (unzFile file)
|
|||||||
/*
|
/*
|
||||||
return 1 if the end of file was reached, 0 elsewhere
|
return 1 if the end of file was reached, 0 elsewhere
|
||||||
*/
|
*/
|
||||||
extern int ZEXPORT unzeof (unzFile file)
|
extern int ZEXPORT unzeof (file)
|
||||||
|
unzFile file;
|
||||||
{
|
{
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
file_in_zip_read_info_s* pfile_in_zip_read_info;
|
file_in_zip_read_info_s* pfile_in_zip_read_info;
|
||||||
@@ -1392,10 +1441,10 @@ extern int ZEXPORT unzeof (unzFile file)
|
|||||||
the return value is the number of bytes copied in buf, or (if <0)
|
the return value is the number of bytes copied in buf, or (if <0)
|
||||||
the error code
|
the error code
|
||||||
*/
|
*/
|
||||||
extern int ZEXPORT unzGetLocalExtrafield (
|
extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
|
||||||
unzFile file,
|
unzFile file;
|
||||||
voidp buf,
|
voidp buf;
|
||||||
unsigned len)
|
unsigned len;
|
||||||
{
|
{
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
file_in_zip_read_info_s* pfile_in_zip_read_info;
|
file_in_zip_read_info_s* pfile_in_zip_read_info;
|
||||||
@@ -1443,7 +1492,8 @@ extern int ZEXPORT unzGetLocalExtrafield (
|
|||||||
Close the file in zip opened with unzipOpenCurrentFile
|
Close the file in zip opened with unzipOpenCurrentFile
|
||||||
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||||
*/
|
*/
|
||||||
extern int ZEXPORT unzCloseCurrentFile (unzFile file)
|
extern int ZEXPORT unzCloseCurrentFile (file)
|
||||||
|
unzFile file;
|
||||||
{
|
{
|
||||||
int err=UNZ_OK;
|
int err=UNZ_OK;
|
||||||
|
|
||||||
@@ -1485,11 +1535,12 @@ extern int ZEXPORT unzCloseCurrentFile (unzFile file)
|
|||||||
uSizeBuf is the size of the szComment buffer.
|
uSizeBuf is the size of the szComment buffer.
|
||||||
return the number of byte copied or an error code <0
|
return the number of byte copied or an error code <0
|
||||||
*/
|
*/
|
||||||
extern int ZEXPORT unzGetGlobalComment (
|
extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
|
||||||
unzFile file,
|
unzFile file;
|
||||||
char *szComment,
|
char *szComment;
|
||||||
uLong uSizeBuf)
|
uLong uSizeBuf;
|
||||||
{
|
{
|
||||||
|
int err=UNZ_OK;
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
uLong uReadThis ;
|
uLong uReadThis ;
|
||||||
if (file==NULL)
|
if (file==NULL)
|
||||||
@@ -1516,7 +1567,8 @@ extern int ZEXPORT unzGetGlobalComment (
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Additions by RX '2004 */
|
/* Additions by RX '2004 */
|
||||||
extern uLong ZEXPORT unzGetOffset (unzFile file)
|
extern uLong ZEXPORT unzGetOffset (file)
|
||||||
|
unzFile file;
|
||||||
{
|
{
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
|
|
||||||
@@ -1531,9 +1583,9 @@ extern uLong ZEXPORT unzGetOffset (unzFile file)
|
|||||||
return s->pos_in_central_dir;
|
return s->pos_in_central_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ZEXPORT unzSetOffset (
|
extern int ZEXPORT unzSetOffset (file, pos)
|
||||||
unzFile file,
|
unzFile file;
|
||||||
uLong pos)
|
uLong pos;
|
||||||
{
|
{
|
||||||
unz_s* s;
|
unz_s* s;
|
||||||
int err;
|
int err;
|
||||||
|
|||||||
@@ -172,7 +172,8 @@ local linkedlist_datablock_internal* allocate_new_datablock()
|
|||||||
return ldi;
|
return ldi;
|
||||||
}
|
}
|
||||||
|
|
||||||
local void free_datablock(linkedlist_datablock_internal* ldi)
|
local void free_datablock(ldi)
|
||||||
|
linkedlist_datablock_internal* ldi;
|
||||||
{
|
{
|
||||||
while (ldi!=NULL)
|
while (ldi!=NULL)
|
||||||
{
|
{
|
||||||
@@ -182,24 +183,24 @@ local void free_datablock(linkedlist_datablock_internal* ldi)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local void init_linkedlist(
|
local void init_linkedlist(ll)
|
||||||
linkedlist_data* ll)
|
linkedlist_data* ll;
|
||||||
{
|
{
|
||||||
ll->first_block = ll->last_block = NULL;
|
ll->first_block = ll->last_block = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
local void free_linkedlist(
|
local void free_linkedlist(ll)
|
||||||
linkedlist_data* ll)
|
linkedlist_data* ll;
|
||||||
{
|
{
|
||||||
free_datablock(ll->first_block);
|
free_datablock(ll->first_block);
|
||||||
ll->first_block = ll->last_block = NULL;
|
ll->first_block = ll->last_block = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local int add_data_in_datablock(
|
local int add_data_in_datablock(ll,buf,len)
|
||||||
linkedlist_data* ll,
|
linkedlist_data* ll;
|
||||||
const void* buf,
|
const void* buf;
|
||||||
uLong len)
|
uLong len;
|
||||||
{
|
{
|
||||||
linkedlist_datablock_internal* ldi;
|
linkedlist_datablock_internal* ldi;
|
||||||
const unsigned char* from_copy;
|
const unsigned char* from_copy;
|
||||||
@@ -262,11 +263,11 @@ local int add_data_in_datablock(
|
|||||||
|
|
||||||
local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def,
|
local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def,
|
||||||
voidpf filestream, uLong x, int nbByte));
|
voidpf filestream, uLong x, int nbByte));
|
||||||
local int ziplocal_putValue (
|
local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte)
|
||||||
const zlib_filefunc_def* pzlib_filefunc_def,
|
const zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
voidpf filestream,
|
voidpf filestream;
|
||||||
uLong x,
|
uLong x;
|
||||||
int nbByte)
|
int nbByte;
|
||||||
{
|
{
|
||||||
unsigned char buf[4];
|
unsigned char buf[4];
|
||||||
int n;
|
int n;
|
||||||
@@ -290,10 +291,10 @@ local int ziplocal_putValue (
|
|||||||
}
|
}
|
||||||
|
|
||||||
local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte));
|
local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte));
|
||||||
local void ziplocal_putValue_inmemory (
|
local void ziplocal_putValue_inmemory (dest, x, nbByte)
|
||||||
void* dest,
|
void* dest;
|
||||||
uLong x,
|
uLong x;
|
||||||
int nbByte)
|
int nbByte;
|
||||||
{
|
{
|
||||||
unsigned char* buf=(unsigned char*)dest;
|
unsigned char* buf=(unsigned char*)dest;
|
||||||
int n;
|
int n;
|
||||||
@@ -314,9 +315,9 @@ local void ziplocal_putValue_inmemory (
|
|||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
local uLong ziplocal_TmzDateToDosDate(
|
local uLong ziplocal_TmzDateToDosDate(ptm,dosDate)
|
||||||
const tm_zip* ptm,
|
const tm_zip* ptm;
|
||||||
uLong dosDate)
|
uLong dosDate;
|
||||||
{
|
{
|
||||||
uLong year = (uLong)ptm->tm_year;
|
uLong year = (uLong)ptm->tm_year;
|
||||||
if (year>1980)
|
if (year>1980)
|
||||||
@@ -336,10 +337,10 @@ local int ziplocal_getByte OF((
|
|||||||
voidpf filestream,
|
voidpf filestream,
|
||||||
int *pi));
|
int *pi));
|
||||||
|
|
||||||
local int ziplocal_getByte(
|
local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi)
|
||||||
const zlib_filefunc_def* pzlib_filefunc_def,
|
const zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
voidpf filestream,
|
voidpf filestream;
|
||||||
int *pi)
|
int *pi;
|
||||||
{
|
{
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
|
int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
|
||||||
@@ -366,10 +367,10 @@ local int ziplocal_getShort OF((
|
|||||||
voidpf filestream,
|
voidpf filestream,
|
||||||
uLong *pX));
|
uLong *pX));
|
||||||
|
|
||||||
local int ziplocal_getShort (
|
local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX)
|
||||||
const zlib_filefunc_def* pzlib_filefunc_def,
|
const zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
voidpf filestream,
|
voidpf filestream;
|
||||||
uLong *pX)
|
uLong *pX;
|
||||||
{
|
{
|
||||||
uLong x ;
|
uLong x ;
|
||||||
int i;
|
int i;
|
||||||
@@ -394,10 +395,10 @@ local int ziplocal_getLong OF((
|
|||||||
voidpf filestream,
|
voidpf filestream,
|
||||||
uLong *pX));
|
uLong *pX));
|
||||||
|
|
||||||
local int ziplocal_getLong (
|
local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX)
|
||||||
const zlib_filefunc_def* pzlib_filefunc_def,
|
const zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
voidpf filestream,
|
voidpf filestream;
|
||||||
uLong *pX)
|
uLong *pX;
|
||||||
{
|
{
|
||||||
uLong x ;
|
uLong x ;
|
||||||
int i;
|
int i;
|
||||||
@@ -436,9 +437,9 @@ local uLong ziplocal_SearchCentralDir OF((
|
|||||||
const zlib_filefunc_def* pzlib_filefunc_def,
|
const zlib_filefunc_def* pzlib_filefunc_def,
|
||||||
voidpf filestream));
|
voidpf filestream));
|
||||||
|
|
||||||
local uLong ziplocal_SearchCentralDir(
|
local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream)
|
||||||
const zlib_filefunc_def* pzlib_filefunc_def,
|
const zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
voidpf filestream)
|
voidpf filestream;
|
||||||
{
|
{
|
||||||
unsigned char* buf;
|
unsigned char* buf;
|
||||||
uLong uSizeFile;
|
uLong uSizeFile;
|
||||||
@@ -495,11 +496,11 @@ local uLong ziplocal_SearchCentralDir(
|
|||||||
#endif /* !NO_ADDFILEINEXISTINGZIP*/
|
#endif /* !NO_ADDFILEINEXISTINGZIP*/
|
||||||
|
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
extern zipFile ZEXPORT zipOpen2 (
|
extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def)
|
||||||
const char *pathname,
|
const char *pathname;
|
||||||
int append,
|
int append;
|
||||||
zipcharpc* globalcomment,
|
zipcharpc* globalcomment;
|
||||||
zlib_filefunc_def* pzlib_filefunc_def)
|
zlib_filefunc_def* pzlib_filefunc_def;
|
||||||
{
|
{
|
||||||
zip_internal ziinit;
|
zip_internal ziinit;
|
||||||
zip_internal* zi;
|
zip_internal* zi;
|
||||||
@@ -614,7 +615,7 @@ extern zipFile ZEXPORT zipOpen2 (
|
|||||||
|
|
||||||
if (size_comment>0)
|
if (size_comment>0)
|
||||||
{
|
{
|
||||||
ziinit.globalcomment = (char*)ALLOC(size_comment+1);
|
ziinit.globalcomment = ALLOC(size_comment+1);
|
||||||
if (ziinit.globalcomment)
|
if (ziinit.globalcomment)
|
||||||
{
|
{
|
||||||
size_comment = ZREAD(ziinit.z_filefunc, ziinit.filestream,ziinit.globalcomment,size_comment);
|
size_comment = ZREAD(ziinit.z_filefunc, ziinit.filestream,ziinit.globalcomment,size_comment);
|
||||||
@@ -679,30 +680,35 @@ extern zipFile ZEXPORT zipOpen2 (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern zipFile ZEXPORT zipOpen (
|
extern zipFile ZEXPORT zipOpen (pathname, append)
|
||||||
const char *pathname,
|
const char *pathname;
|
||||||
int append)
|
int append;
|
||||||
{
|
{
|
||||||
return zipOpen2(pathname,append,NULL,NULL);
|
return zipOpen2(pathname,append,NULL,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ZEXPORT zipOpenNewFileInZip3 (
|
extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi,
|
||||||
zipFile file,
|
extrafield_local, size_extrafield_local,
|
||||||
const char* filename,
|
extrafield_global, size_extrafield_global,
|
||||||
const zip_fileinfo* zipfi,
|
comment, method, level, raw,
|
||||||
const void* extrafield_local,
|
windowBits, memLevel, strategy,
|
||||||
uInt size_extrafield_local,
|
password, crcForCrypting)
|
||||||
const void* extrafield_global,
|
zipFile file;
|
||||||
uInt size_extrafield_global,
|
const char* filename;
|
||||||
const char* comment,
|
const zip_fileinfo* zipfi;
|
||||||
int method,
|
const void* extrafield_local;
|
||||||
int level,
|
uInt size_extrafield_local;
|
||||||
int raw,
|
const void* extrafield_global;
|
||||||
int windowBits,
|
uInt size_extrafield_global;
|
||||||
int memLevel,
|
const char* comment;
|
||||||
int strategy,
|
int method;
|
||||||
const char* password,
|
int level;
|
||||||
uLong crcForCrypting)
|
int raw;
|
||||||
|
int windowBits;
|
||||||
|
int memLevel;
|
||||||
|
int strategy;
|
||||||
|
const char* password;
|
||||||
|
uLong crcForCrypting;
|
||||||
{
|
{
|
||||||
zip_internal* zi;
|
zip_internal* zi;
|
||||||
uInt size_filename;
|
uInt size_filename;
|
||||||
@@ -890,18 +896,21 @@ extern int ZEXPORT zipOpenNewFileInZip3 (
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ZEXPORT zipOpenNewFileInZip2(
|
extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi,
|
||||||
zipFile file,
|
extrafield_local, size_extrafield_local,
|
||||||
const char* filename,
|
extrafield_global, size_extrafield_global,
|
||||||
const zip_fileinfo* zipfi,
|
comment, method, level, raw)
|
||||||
const void* extrafield_local,
|
zipFile file;
|
||||||
uInt size_extrafield_local,
|
const char* filename;
|
||||||
const void* extrafield_global,
|
const zip_fileinfo* zipfi;
|
||||||
uInt size_extrafield_global,
|
const void* extrafield_local;
|
||||||
const char* comment,
|
uInt size_extrafield_local;
|
||||||
int method,
|
const void* extrafield_global;
|
||||||
int level,
|
uInt size_extrafield_global;
|
||||||
int raw)
|
const char* comment;
|
||||||
|
int method;
|
||||||
|
int level;
|
||||||
|
int raw;
|
||||||
{
|
{
|
||||||
return zipOpenNewFileInZip3 (file, filename, zipfi,
|
return zipOpenNewFileInZip3 (file, filename, zipfi,
|
||||||
extrafield_local, size_extrafield_local,
|
extrafield_local, size_extrafield_local,
|
||||||
@@ -911,17 +920,20 @@ extern int ZEXPORT zipOpenNewFileInZip2(
|
|||||||
NULL, 0);
|
NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ZEXPORT zipOpenNewFileInZip (
|
extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
|
||||||
zipFile file,
|
extrafield_local, size_extrafield_local,
|
||||||
const char* filename,
|
extrafield_global, size_extrafield_global,
|
||||||
const zip_fileinfo* zipfi,
|
comment, method, level)
|
||||||
const void* extrafield_local,
|
zipFile file;
|
||||||
uInt size_extrafield_local,
|
const char* filename;
|
||||||
const void* extrafield_global,
|
const zip_fileinfo* zipfi;
|
||||||
uInt size_extrafield_global,
|
const void* extrafield_local;
|
||||||
const char* comment,
|
uInt size_extrafield_local;
|
||||||
int method,
|
const void* extrafield_global;
|
||||||
int level)
|
uInt size_extrafield_global;
|
||||||
|
const char* comment;
|
||||||
|
int method;
|
||||||
|
int level;
|
||||||
{
|
{
|
||||||
return zipOpenNewFileInZip2 (file, filename, zipfi,
|
return zipOpenNewFileInZip2 (file, filename, zipfi,
|
||||||
extrafield_local, size_extrafield_local,
|
extrafield_local, size_extrafield_local,
|
||||||
@@ -929,8 +941,8 @@ extern int ZEXPORT zipOpenNewFileInZip (
|
|||||||
comment, method, level, 0);
|
comment, method, level, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
local int zipFlushWriteBuffer(
|
local int zipFlushWriteBuffer(zi)
|
||||||
zip_internal* zi)
|
zip_internal* zi;
|
||||||
{
|
{
|
||||||
int err=ZIP_OK;
|
int err=ZIP_OK;
|
||||||
|
|
||||||
@@ -951,10 +963,10 @@ local int zipFlushWriteBuffer(
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ZEXPORT zipWriteInFileInZip (
|
extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
|
||||||
zipFile file,
|
zipFile file;
|
||||||
const void* buf,
|
const void* buf;
|
||||||
unsigned len)
|
unsigned len;
|
||||||
{
|
{
|
||||||
zip_internal* zi;
|
zip_internal* zi;
|
||||||
int err=ZIP_OK;
|
int err=ZIP_OK;
|
||||||
@@ -966,9 +978,9 @@ extern int ZEXPORT zipWriteInFileInZip (
|
|||||||
if (zi->in_opened_file_inzip == 0)
|
if (zi->in_opened_file_inzip == 0)
|
||||||
return ZIP_PARAMERROR;
|
return ZIP_PARAMERROR;
|
||||||
|
|
||||||
zi->ci.stream.next_in = (Bytef*)buf;
|
zi->ci.stream.next_in = (void*)buf;
|
||||||
zi->ci.stream.avail_in = len;
|
zi->ci.stream.avail_in = len;
|
||||||
zi->ci.crc32 = crc32(zi->ci.crc32,(const Bytef*)buf,len);
|
zi->ci.crc32 = crc32(zi->ci.crc32,buf,len);
|
||||||
|
|
||||||
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
|
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
|
||||||
{
|
{
|
||||||
@@ -1016,10 +1028,10 @@ extern int ZEXPORT zipWriteInFileInZip (
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ZEXPORT zipCloseFileInZipRaw (
|
extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32)
|
||||||
zipFile file,
|
zipFile file;
|
||||||
uLong uncompressed_size,
|
uLong uncompressed_size;
|
||||||
uLong crc32)
|
uLong crc32;
|
||||||
{
|
{
|
||||||
zip_internal* zi;
|
zip_internal* zi;
|
||||||
uLong compressed_size;
|
uLong compressed_size;
|
||||||
@@ -1112,15 +1124,15 @@ extern int ZEXPORT zipCloseFileInZipRaw (
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ZEXPORT zipCloseFileInZip (
|
extern int ZEXPORT zipCloseFileInZip (file)
|
||||||
zipFile file)
|
zipFile file;
|
||||||
{
|
{
|
||||||
return zipCloseFileInZipRaw (file,0,0);
|
return zipCloseFileInZipRaw (file,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int ZEXPORT zipClose (
|
extern int ZEXPORT zipClose (file, global_comment)
|
||||||
zipFile file,
|
zipFile file;
|
||||||
const char* global_comment)
|
const char* global_comment;
|
||||||
{
|
{
|
||||||
zip_internal* zi;
|
zip_internal* zi;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ filesystem * filesystem::pCurrentFS = NULL;
|
|||||||
std::vector<filesystem::pooledBuffer *> filesystem::m_Buffers;
|
std::vector<filesystem::pooledBuffer *> filesystem::m_Buffers;
|
||||||
|
|
||||||
static const int STORED = 0;
|
static const int STORED = 0;
|
||||||
|
static const int DEFLATED = 8;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
@@ -631,8 +632,8 @@ streamoff filesystem::CentralDirZipped(std::istream & File, std::streamoff begin
|
|||||||
std::streamoff eof = begin + size;
|
std::streamoff eof = begin + size;
|
||||||
|
|
||||||
// Look for the "end of central dir" header. Start minimum 22 bytes before end.
|
// Look for the "end of central dir" header. Start minimum 22 bytes before end.
|
||||||
if (! File.seekg(eof - 22, ios::beg))
|
if (! File.seekg(eof - 22, ios::beg))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
streamoff EndPos;
|
streamoff EndPos;
|
||||||
streamoff StartPos = File.tellg();
|
streamoff StartPos = File.tellg();
|
||||||
|
|||||||
@@ -258,8 +258,8 @@ inline void izfstream::open(const char * FilePath, filesystem * pFS) {
|
|||||||
if (pFS)
|
if (pFS)
|
||||||
m_pFS = pFS;
|
m_pFS = pFS;
|
||||||
|
|
||||||
if (m_pFS != NULL)
|
if (m_pFS != NULL)
|
||||||
m_pFS->Open(* this, FilePath);
|
m_pFS->Open(* this, FilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void izfstream::close() {
|
inline void izfstream::close() {
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ bool zbuffer::use(std::streamoff Offset, std::streamoff Size)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
//Don't use a buffer already used;
|
//Don't use a buffer already used;
|
||||||
if (m_Used)
|
if (m_Used)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// adjust file position
|
// adjust file position
|
||||||
if (! m_ZipFile.seekg(Offset, ios::beg))
|
if (! m_ZipFile.seekg(Offset, ios::beg))
|
||||||
|
|||||||
11
README.md
@@ -1,9 +1,7 @@
|
|||||||
#Wagic the Homebrew
|
#Wagic the Homebrew
|
||||||
|
|
||||||
|
|
||||||
[](https://travis-ci.com/WagicProject/wagic)
|
[](https://travis-ci.org/WagicProject/wagic)
|
||||||
[](https://ci.appveyor.com/project/xawotihs/wagic/branch/master)
|
|
||||||
[](https://coveralls.io/r/WagicProject/wagic?branch=master)
|
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
@@ -20,9 +18,4 @@ It is highly customizable and allows the player to tweak the rules / create thei
|
|||||||
|
|
||||||
Info, downloads, discussions and more at http://wololo.net/forum/index.php
|
Info, downloads, discussions and more at http://wololo.net/forum/index.php
|
||||||
|
|
||||||

|
-
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Sample round play-through video
|
|
||||||
[](http://www.youtube.com/watch?v=WUFSAPZuDIk)
|
|
||||||
|
|||||||
76
appveyor.yml
@@ -1,76 +0,0 @@
|
|||||||
# Notes:
|
|
||||||
# - Minimal appveyor.yml file is an empty file. All sections are optional.
|
|
||||||
# - Indent each level of configuration with 2 spaces. Do not use tabs!
|
|
||||||
# - All section names are case-sensitive.
|
|
||||||
# - Section names should be unique on each level.
|
|
||||||
|
|
||||||
# branches to build
|
|
||||||
branches:
|
|
||||||
# blacklist
|
|
||||||
except:
|
|
||||||
- travis_mac_osx
|
|
||||||
# Do not build on tags (GitHub only)
|
|
||||||
skip_tags: true
|
|
||||||
|
|
||||||
#---------------------------------#
|
|
||||||
# environment configuration #
|
|
||||||
#---------------------------------#
|
|
||||||
|
|
||||||
environment:
|
|
||||||
GH_TOKEN:
|
|
||||||
secure: dYnBDQkiY5oVjIlswzBX9BJigNtBGXgGlp1tK3XbHzrDEDrs2vaKD5m+Oz5OSz1C
|
|
||||||
|
|
||||||
# scripts that run after cloning repository
|
|
||||||
install:
|
|
||||||
- ps: (new-object net.webclient).DownloadFile('https://bootstrap.pypa.io/pip/2.7/get-pip.py', 'C:/get-pip.py')
|
|
||||||
- "C:/Python27/python.exe C:/get-pip.py"
|
|
||||||
- "C:/Python27/Scripts/pip.exe install pyjavaproperties"
|
|
||||||
- "C:/Python27/Scripts/pip.exe install github3.py"
|
|
||||||
|
|
||||||
#---------------------------------#
|
|
||||||
# build configuration #
|
|
||||||
#---------------------------------#
|
|
||||||
|
|
||||||
# build Configuration, i.e. Debug, Release, etc.
|
|
||||||
configuration: Release
|
|
||||||
|
|
||||||
build:
|
|
||||||
project: projects/mtg/mtg_vs2010.sln # path to Visual Studio solution or project
|
|
||||||
|
|
||||||
#---------------------------------#
|
|
||||||
# tests configuration #
|
|
||||||
#---------------------------------#
|
|
||||||
|
|
||||||
# to disable automatic tests
|
|
||||||
test: off
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------#
|
|
||||||
# artifacts configuration #
|
|
||||||
#---------------------------------#
|
|
||||||
|
|
||||||
artifacts:
|
|
||||||
# pushing windows package
|
|
||||||
- path: projects\mtg\bin\Wagic-windows*.zip
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------#
|
|
||||||
# deployment configuration #
|
|
||||||
#---------------------------------#
|
|
||||||
|
|
||||||
# scripts to run before deployment
|
|
||||||
before_deploy:
|
|
||||||
- cd projects/mtg/bin
|
|
||||||
- "C:/Python27/python.exe createWindowsZip.py"
|
|
||||||
- cd ../../..
|
|
||||||
|
|
||||||
# scripts to run after deployment
|
|
||||||
after_deploy:
|
|
||||||
|
|
||||||
# to run your custom scripts instead of provider deployments
|
|
||||||
deploy_script:
|
|
||||||
- "C:/Python27/python.exe tools/upload-binaries.py -t %GH_TOKEN% -s %APPVEYOR_REPO_COMMIT% -l projects/mtg/bin/Wagic-windows.zip -r Wagic-windows.zip -b %APPVEYOR_REPO_BRANCH%"
|
|
||||||
|
|
||||||
# to disable deployment
|
|
||||||
#deploy: off
|
|
||||||
|
|
||||||
1
projects/mtg/Android/.gitignore
vendored
@@ -1,4 +1,3 @@
|
|||||||
/gen
|
/gen
|
||||||
/bin
|
/bin
|
||||||
/libs
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="0192" android:versionName="@string/app_version" package="net.wagic.app">
|
||||||
android:versionCode="0231"
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
|
||||||
android:installLocation="preferExternal"
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
android:versionName="@string/app_version"
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
package="net.wagic.app">
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
<application android:debuggable="true" android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<activity android:configChanges="keyboard|keyboardHidden|orientation" android:label="@string/app_name" android:name="org.libsdl.app.SDLActivity" android:screenOrientation="sensorLandscape">
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<intent-filter>
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<application android:icon="@drawable/icon"
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
android:label="@string/app_name"
|
</intent-filter>
|
||||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
|
</activity>
|
||||||
|
|
||||||
<activity android:debuggable="false"
|
<activity android:configChanges="keyboard|keyboardHidden|orientation" android:name="com.google.ads.AdActivity" android:screenOrientation="sensorLandscape"/>
|
||||||
android:configChanges="keyboard|keyboardHidden|orientation"
|
</application>
|
||||||
android:label="@string/app_name"
|
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="10"/>
|
||||||
android:name="org.libsdl.app.SDLActivity"
|
</manifest>
|
||||||
android:screenOrientation="sensorLandscape">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN" />
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
</application>
|
|
||||||
<uses-sdk android:minSdkVersion="10"
|
|
||||||
android:targetSdkVersion="29" />
|
|
||||||
</manifest>
|
|
||||||
|
|||||||
@@ -8,4 +8,4 @@
|
|||||||
# project structure.
|
# project structure.
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-23
|
target=android-10
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ SDL_PATH := $(JGE_PATH)/Dependencies/SDL
|
|||||||
BOOST_PATH := $(MY_WAGIC_ROOT)/Boost
|
BOOST_PATH := $(MY_WAGIC_ROOT)/Boost
|
||||||
JPEG_PATH := $(JGE_PATH)/Dependencies/libjpeg
|
JPEG_PATH := $(JGE_PATH)/Dependencies/libjpeg
|
||||||
PNG_PATH := $(JGE_PATH)/Dependencies/libpng
|
PNG_PATH := $(JGE_PATH)/Dependencies/libpng
|
||||||
|
DEBUG ?= DEBUG
|
||||||
|
|
||||||
LOCAL_CFLAGS += -DLINUX -DANDROID -DSDL_CONFIG -DNETWORK_SUPPORT
|
LOCAL_CFLAGS += -DLINUX -DANDROID -DSDL_CONFIG -D_$(DEBUG)
|
||||||
LOCAL_CFLAGS += -D_STLP_USE_SIMPLE_NODE_ALLOC -DTIXML_USE_STL
|
LOCAL_CFLAGS += -D_STLP_USE_SIMPLE_NODE_ALLOC -DTIXML_USE_STL
|
||||||
LOCAL_CFLAGS += -D__arm__ -D_REENTRANT -D_GLIBCXX__PTHREADS
|
LOCAL_CFLAGS += -D__arm__ -D_REENTRANT -D_GLIBCXX__PTHREADS
|
||||||
LOCAL_STATIC_LIBRARIES := libpng libjpeg
|
LOCAL_STATIC_LIBRARIES := libpng libjpeg
|
||||||
@@ -56,6 +57,7 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.cpp \
|
|||||||
$(MTG_PATH)/src/DeckMetaData.cpp \
|
$(MTG_PATH)/src/DeckMetaData.cpp \
|
||||||
$(MTG_PATH)/src/DeckStats.cpp \
|
$(MTG_PATH)/src/DeckStats.cpp \
|
||||||
$(MTG_PATH)/src/DuelLayers.cpp \
|
$(MTG_PATH)/src/DuelLayers.cpp \
|
||||||
|
$(MTG_PATH)/src/Effects.cpp \
|
||||||
$(MTG_PATH)/src/ExtraCost.cpp \
|
$(MTG_PATH)/src/ExtraCost.cpp \
|
||||||
$(MTG_PATH)/src/GameApp.cpp \
|
$(MTG_PATH)/src/GameApp.cpp \
|
||||||
$(MTG_PATH)/src/GameLauncher.cpp \
|
$(MTG_PATH)/src/GameLauncher.cpp \
|
||||||
@@ -133,7 +135,6 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.cpp \
|
|||||||
$(MTG_PATH)/src/WFilter.cpp \
|
$(MTG_PATH)/src/WFilter.cpp \
|
||||||
$(MTG_PATH)/src/WFont.cpp \
|
$(MTG_PATH)/src/WFont.cpp \
|
||||||
$(MTG_PATH)/src/WGui.cpp \
|
$(MTG_PATH)/src/WGui.cpp \
|
||||||
$(MTG_PATH)/src/WParsedInt.cpp \
|
|
||||||
$(MTG_PATH)/src/WResourceManager.cpp \
|
$(MTG_PATH)/src/WResourceManager.cpp \
|
||||||
$(MTG_PATH)/src/DeckView.cpp \
|
$(MTG_PATH)/src/DeckView.cpp \
|
||||||
$(MTG_PATH)/src/CarouselDeckView.cpp \
|
$(MTG_PATH)/src/CarouselDeckView.cpp \
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
APP_PROJECT_PATH := $(call my-dir)/..
|
APP_PROJECT_PATH := $(call my-dir)/..
|
||||||
APP_CPPFLAGS += -frtti -fexceptions
|
APP_CPPFLAGS += -frtti -fexceptions
|
||||||
APP_ABI := armeabi-v7a
|
APP_ABI := armeabi armeabi-v7a
|
||||||
#APP_ABI := x86 # mainly for emulators
|
APP_STL := gnustl_static
|
||||||
APP_STL := c++_static
|
|
||||||
APP_MODULES := libpng libjpeg main SDL
|
APP_MODULES := libpng libjpeg main SDL
|
||||||
|
|
||||||
#APP_OPTIM is 'release' by default
|
#APP_OPTIM is 'release' by default
|
||||||
|
|||||||
@@ -11,4 +11,4 @@
|
|||||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||||
|
|
||||||
# Project target.
|
# Project target.
|
||||||
target=android-23
|
target=android-10
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 8.5 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 60 KiB |
@@ -4,7 +4,6 @@
|
|||||||
android:id="@+id/mainLayout"
|
android:id="@+id/mainLayout"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:keepScreenOn="true"
|
|
||||||
>
|
>
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Wagic</string>
|
<string name="app_name">Wagic</string>
|
||||||
<string name="app_version">0.23.1</string>
|
<string name="app_version">0.19.2</string>
|
||||||
<string name="info_text">All Rights Reserved.</string>
|
<string name="info_text">Wagic v0.19.2\\nAll Rights Reserved.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1,279 +0,0 @@
|
|||||||
package net.wagic.utils;
|
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class DeckImporter
|
|
||||||
{
|
|
||||||
public static String importDeck( File f, String mypath, String activePath )
|
|
||||||
{
|
|
||||||
String message = "";
|
|
||||||
String deck = "";
|
|
||||||
String deckname = "";
|
|
||||||
String prefix = "";
|
|
||||||
int cardcount = 0;
|
|
||||||
if(f.exists() && !f.isDirectory())
|
|
||||||
{
|
|
||||||
deckname = f.getName();
|
|
||||||
int pos = deckname.lastIndexOf(".");
|
|
||||||
if (pos > 0)
|
|
||||||
{
|
|
||||||
deckname = deckname.substring(0, pos);
|
|
||||||
}
|
|
||||||
deck += "#NAME:"+deckname+"\n";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Scanner scanner = new Scanner(new File(mypath));
|
|
||||||
if (scanner.hasNext())
|
|
||||||
{
|
|
||||||
while (scanner.hasNext())
|
|
||||||
{
|
|
||||||
String line = scanner.nextLine();
|
|
||||||
line = line.trim();
|
|
||||||
if (line.equals("")) {
|
|
||||||
line = scanner.nextLine();
|
|
||||||
prefix = "#SB:"; // Sideboard started from next card.
|
|
||||||
if (line.equals("")) {
|
|
||||||
line = scanner.nextLine(); // Sometimes there are 2 blank lines from main deck and sideboard.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!line.equals("")) // don't write out blank lines
|
|
||||||
{
|
|
||||||
String[] slines = line.split("\\s+");
|
|
||||||
String arranged = "";
|
|
||||||
for (int idx = 1; idx < slines.length; idx++)
|
|
||||||
{
|
|
||||||
arranged += slines[idx] + " ";
|
|
||||||
}
|
|
||||||
if ((isNumeric(slines[0])) && arranged != null)
|
|
||||||
{
|
|
||||||
if (slines[1] != null && slines[1].startsWith("["))
|
|
||||||
{
|
|
||||||
arranged = arranged.substring(5);
|
|
||||||
slines[1] = slines[1].replaceAll("\\[", "").replaceAll("\\]", "");
|
|
||||||
deck += prefix + arranged + " (" + renameSet(slines[1]) + ") * " + slines[0] + "\n";
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
deck += prefix + arranged + "(*) * " + slines[0] + "\n";
|
|
||||||
}
|
|
||||||
cardcount += Integer.parseInt(slines[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File profile = new File(activePath + "/User/settings/options.txt");
|
|
||||||
String profileName = "Default";
|
|
||||||
if (profile.exists() && !profile.isDirectory())
|
|
||||||
profileName = getActiveProfile(profile);
|
|
||||||
File rootDecks = null;
|
|
||||||
if (!profileName.equalsIgnoreCase("Default"))
|
|
||||||
rootDecks = new File(activePath + "/User/profiles/" + profileName);
|
|
||||||
else
|
|
||||||
rootDecks = new File(activePath + "/User/player/");
|
|
||||||
if (rootDecks.exists() && rootDecks.isDirectory())
|
|
||||||
{
|
|
||||||
//save deck
|
|
||||||
int countdeck = 1;
|
|
||||||
File[] files = rootDecks.listFiles();
|
|
||||||
for (int i = 0; i < files.length; i++)
|
|
||||||
{//check if there is available deck...
|
|
||||||
if (files[i].getName().startsWith("deck"))
|
|
||||||
countdeck++;
|
|
||||||
}
|
|
||||||
File toSave = new File(rootDecks + "/deck" + countdeck + ".txt");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
FileOutputStream fop = new FileOutputStream(toSave);
|
|
||||||
|
|
||||||
// if file doesn't exists, then create it
|
|
||||||
if (!toSave.exists())
|
|
||||||
{
|
|
||||||
toSave.createNewFile();
|
|
||||||
}
|
|
||||||
// get the content in bytes
|
|
||||||
byte[] contentInBytes = deck.getBytes();
|
|
||||||
fop.write(contentInBytes);
|
|
||||||
fop.flush();
|
|
||||||
fop.close();
|
|
||||||
message = "The deck has been successfully imported as: " + toSave.getName() + "\n" + cardcount + " total cards in this deck\n\n" + deck;
|
|
||||||
} catch (IOException e)
|
|
||||||
{
|
|
||||||
message = e.getMessage();
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
message = "Problem opening decks folder: " + rootDecks.getAbsolutePath();
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
message = "No errors, and file EMPTY";
|
|
||||||
}
|
|
||||||
} catch (IOException e)
|
|
||||||
{
|
|
||||||
message = e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isNumeric(String input)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Integer.parseInt(input);
|
|
||||||
}
|
|
||||||
catch(NumberFormatException ex)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getActiveProfile(File mypath)
|
|
||||||
{
|
|
||||||
String name = "";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Scanner scanner = new Scanner(new File(mypath.toString()));
|
|
||||||
if (scanner.hasNext())
|
|
||||||
{
|
|
||||||
String line = scanner.nextLine();
|
|
||||||
name = line.substring(8);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "Default";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(IOException e)
|
|
||||||
{
|
|
||||||
return "Default";
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String renameSet(String set)
|
|
||||||
{
|
|
||||||
if (set == "")
|
|
||||||
return "*";
|
|
||||||
if (set == "AL")
|
|
||||||
return "ALL";
|
|
||||||
if (set == "AQ")
|
|
||||||
return "ATQ";
|
|
||||||
if (set == "AP")
|
|
||||||
return "APC";
|
|
||||||
if (set == "AN")
|
|
||||||
return "ARN";
|
|
||||||
if (set == "AE")
|
|
||||||
return "ARC";
|
|
||||||
if (set == "BR")
|
|
||||||
return "BRB";
|
|
||||||
if (set == "BD")
|
|
||||||
return "BTD";
|
|
||||||
if (set == "CH")
|
|
||||||
return "CHR";
|
|
||||||
if (set == "6E")
|
|
||||||
return "6ED";
|
|
||||||
if (set == "CS")
|
|
||||||
return "CSP";
|
|
||||||
if (set == "DS")
|
|
||||||
return "DST";
|
|
||||||
if (set == "D2")
|
|
||||||
return "DD2";
|
|
||||||
if (set == "8E")
|
|
||||||
return "8ED";
|
|
||||||
if (set == "EX")
|
|
||||||
return "EXO";
|
|
||||||
if (set == "FE")
|
|
||||||
return "FEM";
|
|
||||||
if (set == "FD")
|
|
||||||
return "5DN";
|
|
||||||
if (set == "5E")
|
|
||||||
return "5ED";
|
|
||||||
if (set == "4E")
|
|
||||||
return "4ED";
|
|
||||||
if (set == "GP")
|
|
||||||
return "GPT";
|
|
||||||
if (set == "HL")
|
|
||||||
return "HML";
|
|
||||||
if (set == "IA")
|
|
||||||
return "ICE";
|
|
||||||
if (set == "IN")
|
|
||||||
return "INV";
|
|
||||||
if (set == "JU")
|
|
||||||
return "JUD";
|
|
||||||
if (set == "LG")
|
|
||||||
return "LEG";
|
|
||||||
if (set == "LE")
|
|
||||||
return "LGN";
|
|
||||||
if (set == "A")
|
|
||||||
return "LEA";
|
|
||||||
if (set == "B")
|
|
||||||
return "LEB";
|
|
||||||
if (set == "MM")
|
|
||||||
return "MMQ";
|
|
||||||
if (set == "MI")
|
|
||||||
return "MIR";
|
|
||||||
if (set == "MR")
|
|
||||||
return "MRD";
|
|
||||||
if (set == "NE")
|
|
||||||
return "NEM";
|
|
||||||
if (set == "9E")
|
|
||||||
return "9ED";
|
|
||||||
if (set == "OD")
|
|
||||||
return "ODY";
|
|
||||||
if (set == "ON")
|
|
||||||
return "ONS";
|
|
||||||
if (set == "PS")
|
|
||||||
return "PLS";
|
|
||||||
if (set == "PT")
|
|
||||||
return "POR";
|
|
||||||
if (set == "P2")
|
|
||||||
return "P02";
|
|
||||||
if (set == "P3")
|
|
||||||
return "PTK";
|
|
||||||
if (set == "PR")
|
|
||||||
return "PPR";
|
|
||||||
if (set == "PY")
|
|
||||||
return "PCY";
|
|
||||||
if (set == "R")
|
|
||||||
return "RV";
|
|
||||||
if (set == "SC")
|
|
||||||
return "SCG";
|
|
||||||
if (set == "7E")
|
|
||||||
return "7ED";
|
|
||||||
if (set == "ST")
|
|
||||||
return "S99";
|
|
||||||
if (set == "ST2K")
|
|
||||||
return "S00";
|
|
||||||
if (set == "SH")
|
|
||||||
return "STH";
|
|
||||||
if (set == "TE")
|
|
||||||
return "TMP";
|
|
||||||
if (set == "DK")
|
|
||||||
return "DRK";
|
|
||||||
if (set == "TO")
|
|
||||||
return "TOR";
|
|
||||||
if (set == "UG")
|
|
||||||
return "UGL";
|
|
||||||
if (set == "U")
|
|
||||||
return "2ED";
|
|
||||||
if (set == "UD")
|
|
||||||
return "UDS";
|
|
||||||
if (set == "UL")
|
|
||||||
return "ULG";
|
|
||||||
if (set == "US")
|
|
||||||
return "USG";
|
|
||||||
if (set == "VI")
|
|
||||||
return "VIS";
|
|
||||||
if (set == "WL")
|
|
||||||
return "WTH";
|
|
||||||
else
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,16 +5,11 @@ import java.io.FileNotFoundException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class StorageOptions
|
public class StorageOptions
|
||||||
{
|
{
|
||||||
private static final String TAG = StorageOptions.class.getCanonicalName();
|
|
||||||
private static ArrayList<String> mMounts = new ArrayList<String>();
|
private static ArrayList<String> mMounts = new ArrayList<String>();
|
||||||
private static ArrayList<String> mVold = new ArrayList<String>();
|
private static ArrayList<String> mVold = new ArrayList<String>();
|
||||||
|
|
||||||
@@ -23,29 +18,13 @@ public class StorageOptions
|
|||||||
public static int count = 0;
|
public static int count = 0;
|
||||||
public static String defaultMountPoint;
|
public static String defaultMountPoint;
|
||||||
|
|
||||||
public static void determineStorageOptions(android.content.Context mContext)
|
public static void determineStorageOptions()
|
||||||
{
|
{
|
||||||
initializeMountPoints();
|
initializeMountPoints();
|
||||||
if (findForcemount()){
|
|
||||||
readMountsFileTest();
|
|
||||||
}
|
|
||||||
readMountsFile();
|
readMountsFile();
|
||||||
readVoldFile();
|
readVoldFile();
|
||||||
if (findForcemount()){
|
|
||||||
removeDuplicates(mMounts);
|
|
||||||
}
|
|
||||||
compareMountsWithVold();
|
compareMountsWithVold();
|
||||||
testAndCleanMountsList();
|
testAndCleanMountsList();
|
||||||
File[] externalStorageVolumes = mContext.getExternalFilesDirs("");
|
|
||||||
for(int i = 0; i < externalStorageVolumes.length; i++){
|
|
||||||
mMounts.add(externalStorageVolumes[i].getAbsolutePath());
|
|
||||||
}
|
|
||||||
for(int i = 0; i < mMounts.size(); i++){
|
|
||||||
for(int j = 0; j < mMounts.size(); j++){
|
|
||||||
if(i!=j && mMounts.get(i).startsWith(mMounts.get(j)))
|
|
||||||
mMounts.remove(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setProperties();
|
setProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,42 +40,6 @@ public class StorageOptions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void readMountsFileTest()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Test mountpoints storage -kevlahnota
|
|
||||||
*/
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Scanner scanner = new Scanner(new File("/proc/mounts"));
|
|
||||||
while (scanner.hasNext())
|
|
||||||
{
|
|
||||||
String line = scanner.nextLine();
|
|
||||||
if (line.startsWith("/"))
|
|
||||||
{
|
|
||||||
String[] lineElements = line.split("\\s+");
|
|
||||||
if ("vfat".equals(lineElements[2]) || "fuse".equals(lineElements[2]) || "sdcardfs".equals(lineElements[2]))
|
|
||||||
{
|
|
||||||
File mountPoint = new File(lineElements[1]);
|
|
||||||
if (!lineElements[1].equals(defaultMountPoint))
|
|
||||||
if (mountPoint.isDirectory() && mountPoint.canRead())
|
|
||||||
mMounts.add(lineElements[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException fnfex)
|
|
||||||
{
|
|
||||||
// if proc/mount doesn't exist we just use
|
|
||||||
Log.i(TAG, fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point");
|
|
||||||
mMounts.add(defaultMountPoint);
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.e(TAG, e.getMessage() + ": unknown exception while reading mounts file");
|
|
||||||
mMounts.add(defaultMountPoint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void readMountsFile()
|
private static void readMountsFile()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -122,11 +65,11 @@ public class StorageOptions
|
|||||||
} catch (FileNotFoundException fnfex)
|
} catch (FileNotFoundException fnfex)
|
||||||
{
|
{
|
||||||
// if proc/mount doesn't exist we just use
|
// if proc/mount doesn't exist we just use
|
||||||
Log.i(TAG, fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point");
|
Log.i(StorageOptions.class.getCanonicalName(), fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point");
|
||||||
mMounts.add(defaultMountPoint);
|
mMounts.add(defaultMountPoint);
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.e(TAG, e.getMessage() + ": unknown exception while reading mounts file");
|
Log.e(StorageOptions.class.getCanonicalName(), e.getMessage() + ": unknown exception while reading mounts file");
|
||||||
mMounts.add(defaultMountPoint);
|
mMounts.add(defaultMountPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,48 +98,28 @@ public class StorageOptions
|
|||||||
} catch (FileNotFoundException fnfex)
|
} catch (FileNotFoundException fnfex)
|
||||||
{
|
{
|
||||||
// if vold.fstab doesn't exist we use the value gathered from the Environment
|
// if vold.fstab doesn't exist we use the value gathered from the Environment
|
||||||
Log.i(TAG, fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point");
|
Log.i(StorageOptions.class.getCanonicalName(), fnfex.getMessage() + ": assuming " + defaultMountPoint + " is the only mount point");
|
||||||
mMounts.add(defaultMountPoint);
|
mMounts.add(defaultMountPoint);
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.e(TAG, e.getMessage() + ": unknown exception while reading vold.fstab file");
|
Log.e(StorageOptions.class.getCanonicalName(), e.getMessage() + ": unknown exception while reading mounts file");
|
||||||
mMounts.add(defaultMountPoint);
|
mMounts.add(defaultMountPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<String> removeDuplicates(ArrayList<String> list)
|
|
||||||
{
|
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
|
||||||
|
|
||||||
HashSet<String> set = new HashSet<String>();
|
|
||||||
|
|
||||||
for (String item : list)
|
|
||||||
{
|
|
||||||
if (!set.contains(item))
|
|
||||||
{
|
|
||||||
result.add(item);
|
|
||||||
set.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void compareMountsWithVold()
|
private static void compareMountsWithVold()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Sometimes the two lists of mount points will be different. We only want those mount points that are in both list.
|
* Sometimes the two lists of mount points will be different. We only want those mount points that are in both list.
|
||||||
*
|
*
|
||||||
* Compare the two lists together and remove items that are not in both lists.
|
* Compare the two lists together and remove items that are not in both lists.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (mVold.size() > 0)
|
for (int i = 0; i < mMounts.size(); i++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mMounts.size(); i++)
|
String mount = mMounts.get(i);
|
||||||
{
|
if (!mVold.contains(mount))
|
||||||
String mount = mMounts.get(i);
|
mMounts.remove(i--);
|
||||||
if (!mVold.contains(mount))
|
|
||||||
mMounts.remove(i--);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't need this anymore, clear the vold list to reduce memory
|
// don't need this anymore, clear the vold list to reduce memory
|
||||||
@@ -209,60 +132,18 @@ public class StorageOptions
|
|||||||
/*
|
/*
|
||||||
* Now that we have a cleaned list of mount paths Test each one to make sure it's a valid and available path. If it is not, remove it from the list.
|
* Now that we have a cleaned list of mount paths Test each one to make sure it's a valid and available path. If it is not, remove it from the list.
|
||||||
*/
|
*/
|
||||||
int t = 0;
|
|
||||||
for (int i = 0; i < mMounts.size(); i++)
|
for (int i = 0; i < mMounts.size(); i++)
|
||||||
{
|
{
|
||||||
t++;
|
|
||||||
String mount = mMounts.get(i);
|
String mount = mMounts.get(i);
|
||||||
File root = new File(mount);
|
File root = new File(mount);
|
||||||
if (!root.exists() || !root.isDirectory() || !root.canWrite())
|
if (!root.exists() || !root.isDirectory() || !root.canWrite())
|
||||||
mMounts.remove(i--);
|
mMounts.remove(i--);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t == 0 && Build.VERSION.SDK_INT >= 16 && findForcemount())
|
|
||||||
{
|
|
||||||
//if none is found lets force it for Jellybean and above...
|
|
||||||
if (System.getenv("EXTERNAL_STORAGE") != null)
|
|
||||||
{
|
|
||||||
File root = new File(System.getenv("EXTERNAL_STORAGE"));
|
|
||||||
if (root.exists() && root.isDirectory() && root.canWrite())
|
|
||||||
{
|
|
||||||
if(!isRooted())
|
|
||||||
{
|
|
||||||
File folder = new File(System.getenv("EXTERNAL_STORAGE")+"/Android/data/net.wagic.app/files");
|
|
||||||
folder.mkdirs();
|
|
||||||
mMounts.add(folder.toString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mMounts.add(System.getenv("EXTERNAL_STORAGE"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (System.getenv("SECONDARY_STORAGE") != null)
|
|
||||||
{
|
|
||||||
File root = new File(System.getenv("SECONDARY_STORAGE"));
|
|
||||||
if (root.exists() && root.isDirectory() && root.canWrite())
|
|
||||||
{
|
|
||||||
if(!isRooted())
|
|
||||||
{
|
|
||||||
File folder = new File(System.getenv("SECONDARY_STORAGE")+"/Android/data/net.wagic.app/files");
|
|
||||||
folder.mkdirs();
|
|
||||||
mMounts.add(folder.toString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mMounts.add(System.getenv("SECONDARY_STORAGE"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setProperties()
|
private static void setProperties()
|
||||||
{
|
{
|
||||||
Log.d(TAG, "setProperties()");
|
|
||||||
/*
|
/*
|
||||||
* At this point all the paths in the list should be valid. Build the public properties.
|
* At this point all the paths in the list should be valid. Build the public properties.
|
||||||
*/
|
*/
|
||||||
@@ -270,29 +151,14 @@ public class StorageOptions
|
|||||||
ArrayList<String> mLabels = new ArrayList<String>();
|
ArrayList<String> mLabels = new ArrayList<String>();
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
if(findForcemount()){
|
for (String path : mMounts)
|
||||||
for (String path : mMounts)
|
{ // TODO: /mnt/sdcard is assumed to always mean internal storage. Use this comparison until there is a better way to do this
|
||||||
{//with forcemount menu
|
if ("/mnt/sdcard".equalsIgnoreCase(path))
|
||||||
if ("/mnt/sdcard".equalsIgnoreCase(path) || "/storage/sdcard0".equalsIgnoreCase(path))
|
mLabels.add("Built-in Storage");
|
||||||
mLabels.add("Internal SD " + "[" + path + "/]");
|
else
|
||||||
else if (path.contains("emulated"))
|
mLabels.add("External SD Card " + i++);
|
||||||
mLabels.add("Emulated SD " + " [" + path + "/]");
|
|
||||||
else
|
|
||||||
mLabels.add("External SD " + " [" + path + "/]");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
for (String path : mMounts)
|
|
||||||
{
|
|
||||||
// TODO: /mnt/sdcard and emulated are assumed to always mean internal storage. Use this comparison until there is a better way to do this
|
|
||||||
if ("/mnt/sdcard".equalsIgnoreCase(path) || path.contains("emulated"))
|
|
||||||
mLabels.add("Built-in Storage " + "[" + path + "/]");
|
|
||||||
else
|
|
||||||
mLabels.add("External SD Card " + "[" + path + "/]");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
labels = new String[mLabels.size()];
|
labels = new String[mLabels.size()];
|
||||||
mLabels.toArray(labels);
|
mLabels.toArray(labels);
|
||||||
|
|
||||||
@@ -305,119 +171,4 @@ public class StorageOptions
|
|||||||
// use and to prepare it for the next time it's needed.
|
// use and to prepare it for the next time it's needed.
|
||||||
mMounts.clear();
|
mMounts.clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private static boolean isExternalStorageReadOnly() {
|
|
||||||
String extStorageState = Environment.getExternalStorageState();
|
|
||||||
if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(extStorageState)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isExternalStorageAvailable() {
|
|
||||||
String extStorageState = Environment.getExternalStorageState();
|
|
||||||
if (Environment.MEDIA_MOUNTED.equals(extStorageState)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the device is rooted.
|
|
||||||
*
|
|
||||||
* @return <code>true</code> if the device is rooted, <code>false</code> otherwise.
|
|
||||||
*/
|
|
||||||
public static boolean isRooted()
|
|
||||||
{
|
|
||||||
// get from build info
|
|
||||||
String buildTags = android.os.Build.TAGS;
|
|
||||||
if (buildTags != null && buildTags.contains("test-keys"))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if /system/app/Superuser.apk is present
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File file = new File("/system/app/Superuser.apk");
|
|
||||||
if (file.exists())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (Exception e1)
|
|
||||||
{
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File file = new File("/system/app/Superuser/Superuser.apk");
|
|
||||||
if (file.exists())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (Exception e1)
|
|
||||||
{
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
//SuperSU
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File file = new File("/system/app/SuperSU.apk");
|
|
||||||
if (file.exists())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (Exception e1)
|
|
||||||
{
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File file = new File("/system/app/SuperSU/SuperSU.apk");
|
|
||||||
if (file.exists())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (Exception e1)
|
|
||||||
{
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
// try executing commands
|
|
||||||
return canExecuteCommand("/system/xbin/which su")
|
|
||||||
|| canExecuteCommand("/system/bin/which su") || canExecuteCommand("which su");
|
|
||||||
}
|
|
||||||
|
|
||||||
// executes a command on the system
|
|
||||||
private static boolean canExecuteCommand(String command)
|
|
||||||
{
|
|
||||||
boolean executedSuccesfully;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Runtime.getRuntime().exec(command);
|
|
||||||
executedSuccesfully = true;
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
executedSuccesfully = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return executedSuccesfully;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean findForcemount()
|
|
||||||
{
|
|
||||||
Log.d(TAG, "findForcemount()");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File file = new File(System.getenv("EXTERNAL_STORAGE") + "/forcemount");
|
|
||||||
if (file.exists())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
Log.w(TAG, e.getMessage());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 820 KiB After Width: | Height: | Size: 820 KiB |
|
Before Width: | Height: | Size: 235 KiB After Width: | Height: | Size: 235 KiB |
|
Before Width: | Height: | Size: 630 KiB After Width: | Height: | Size: 630 KiB |
|
Before Width: | Height: | Size: 233 KiB After Width: | Height: | Size: 233 KiB |
|
Before Width: | Height: | Size: 417 KiB After Width: | Height: | Size: 417 KiB |
|
Before Width: | Height: | Size: 235 KiB After Width: | Height: | Size: 235 KiB |
|
Before Width: | Height: | Size: 235 KiB After Width: | Height: | Size: 235 KiB |
@@ -1,20 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>NSPrincipalClass</key>
|
|
||||||
<string>NSApplication</string>
|
|
||||||
<key>CFBundlePackageType</key>
|
|
||||||
<string>APPL</string>
|
|
||||||
<key>CFBundleGetInfoString</key>
|
|
||||||
<string>Created by Qt/QMake</string>
|
|
||||||
<key>CFBundleSignature</key>
|
|
||||||
<string>????</string>
|
|
||||||
<key>CFBundleExecutable</key>
|
|
||||||
<string>wagic.launcher</string>
|
|
||||||
<key>CFBundleIdentifier</key>
|
|
||||||
<string>wagic.wagic</string>
|
|
||||||
<key>NOTE</key>
|
|
||||||
<string>This file was generated by Qt/QMake.</string>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cd ${0%/*/*}/Resources
|
|
||||||
#cd ../Resources
|
|
||||||
exec ../MacOS/wagic -platformpluginpath ../PlugIns >> ../logs/out.log 2> ../logs/err.log
|
|
||||||
@@ -6,7 +6,7 @@ OBJS = objs/InteractiveButton.o objs/AbilityParser.o objs/ActionElement.o\
|
|||||||
objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o\
|
objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o\
|
||||||
objs/DeckDataWrapper.o objs/DeckEditorMenu.o objs/DeckMenu.o\
|
objs/DeckDataWrapper.o objs/DeckEditorMenu.o objs/DeckMenu.o\
|
||||||
objs/DeckMenuItem.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o\
|
objs/DeckMenuItem.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o\
|
||||||
objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o\
|
objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o\
|
||||||
objs/GameObserver.o objs/GameOptions.o objs/GameState.o\
|
objs/GameObserver.o objs/GameOptions.o objs/GameState.o\
|
||||||
objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o\
|
objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o\
|
||||||
objs/DeckManager.o objs/GameStateMenu.o objs/GameStateOptions.o\
|
objs/DeckManager.o objs/GameStateMenu.o objs/GameStateOptions.o\
|
||||||
@@ -27,7 +27,7 @@ OBJS = objs/InteractiveButton.o objs/AbilityParser.o objs/ActionElement.o\
|
|||||||
objs/ThisDescriptor.o objs/Token.o objs/Translate.o objs/TranslateKeys.o\
|
objs/ThisDescriptor.o objs/Token.o objs/Translate.o objs/TranslateKeys.o\
|
||||||
objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o\
|
objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o\
|
||||||
objs/WCachedResource.o objs/WDataSrc.o objs/WGui.o objs/WFilter.o objs/Tasks.o\
|
objs/WCachedResource.o objs/WDataSrc.o objs/WGui.o objs/WFilter.o objs/Tasks.o\
|
||||||
objs/WFont.o objs/WParsedInt.o objs/CarouselDeckView.o objs/GridDeckView.o objs/DeckView.o
|
objs/WFont.o objs/CarouselDeckView.o objs/GridDeckView.o objs/DeckView.o
|
||||||
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
|
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
|
||||||
|
|
||||||
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
|
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
|
||||||
@@ -59,6 +59,7 @@ endif
|
|||||||
|
|
||||||
ifeq ($(TARGET_ARCHITECTURE),psp)
|
ifeq ($(TARGET_ARCHITECTURE),psp)
|
||||||
DEFAULT_RULE = 3xx
|
DEFAULT_RULE = 3xx
|
||||||
|
TARGET_ARCHITECTURE = psp
|
||||||
PSP_FW_VERSION=371
|
PSP_FW_VERSION=371
|
||||||
BUILD_PRX = 1
|
BUILD_PRX = 1
|
||||||
SIGN_PRX = 1
|
SIGN_PRX = 1
|
||||||
@@ -68,42 +69,24 @@ EXTRA_TARGETS = EBOOT.PBP
|
|||||||
PSP_EBOOT_TITLE = Wagic, the Homebrew?!
|
PSP_EBOOT_TITLE = Wagic, the Homebrew?!
|
||||||
PSP_EBOOT_ICON = icon.png
|
PSP_EBOOT_ICON = icon.png
|
||||||
#PSP_EBOOT_ICON1 = icon1.pmf
|
#PSP_EBOOT_ICON1 = icon1.pmf
|
||||||
PSP_LARGE_MEMORY = 1
|
|
||||||
PSP_EBOOT_UNKPNG = pic0.png
|
PSP_EBOOT_UNKPNG = pic0.png
|
||||||
PSP_EBOOT_PIC1 = pic1.png
|
PSP_EBOOT_PIC1 = pic1.png
|
||||||
INCDIR = ../../JGE/include ../../JGE/src/zipFS ../../JGE/include/psp ../../JGE/include/psp/freetype2 ../../JGE/src ../../projects/mtg/include ../../Boost
|
INCDIR = ../../JGE/include ../../JGE/src/zipFS ../../JGE/include/psp ../../JGE/include/psp/freetype2 ../../JGE/src ../../projects/mtg/include ../../Boost
|
||||||
LIBDIR = ../../JGE/lib/psp
|
LIBDIR = ../../JGE/lib/psp
|
||||||
CFLAGS = -O2 -G0 -DPSPFW3XX -DDEVHOOK -DUSE_PRECOMPILED_HEADERS=1 -DPSP -DTIXML_USE_STL
|
CFLAGS = -O2 -G0 -DPSPFW3XX -DDEVHOOK -DUSE_PRECOMPILED_HEADERS=1 -DPSP -DTIXML_USE_STL
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
ifeq ($(MAKECMDGOALS),x11)
|
|
||||||
|
|
||||||
OBJS += objs/TestSuiteAI.o
|
|
||||||
INCDIR = -I../../JGE/include -I../../JGE/src -I/usr/X11/include -I../../projects/mtg/include -I/usr/include/boost -I../../JGE/src/zipFS
|
|
||||||
LIBDIR = -L../../JGE/lib/linux -L../../JGE -L/usr/X11/lib
|
|
||||||
LIBS = -ljge -lfreetype -ljpeg -lgif -lpng -lz -lm -lstdc++ -lhgetools -lGL -lGLU -lX11 -lpthread $(FMOD)
|
|
||||||
CFLAGS = $(INCDIR) -DLINUX -DNETWORK_SUPPORT -DUSE_PRECOMPILED_HEADERS=1 -DTIXML_USE_STL -Wno-nonnull-compare
|
|
||||||
|
|
||||||
ASFLAGS = $(CXXFLAGS)
|
|
||||||
|
|
||||||
all: $(DEFAULT_RULE)
|
|
||||||
else
|
|
||||||
|
|
||||||
OBJS += objs/TestSuiteAI.o
|
OBJS += objs/TestSuiteAI.o
|
||||||
INCDIR = -I../../JGE/include -I../../JGE/src -I/usr/X11/include -I../../projects/mtg/include -I../../Boost -I../../JGE/src/zipFS
|
INCDIR = -I../../JGE/include -I../../JGE/src -I/usr/X11/include -I../../projects/mtg/include -I../../Boost -I../../JGE/src/zipFS
|
||||||
LIBDIR = -L../../JGE/lib/linux -L../../JGE -L/usr/X11/lib -L../../Boost/lib
|
LIBDIR = -L../../JGE/lib/linux -L../../JGE -L/usr/X11/lib -L../../Boost/lib
|
||||||
LIBS = -ljge -lfreetype -ljpeg -lgif -lpng -lz -lm -lstdc++ -lhgetools -lGL -lGLU -lX11 -lboost_thread $(FMOD)
|
LIBS = -ljge -lfreetype -ljpeg -lgif -lpng -lz -lm -lstdc++ -lhgetools -lGL -lGLU -lX11 -lboost_thread $(FMOD)
|
||||||
CFLAGS = $(INCDIR) -DLINUX -DNETWORK_SUPPORT -DUSE_PRECOMPILED_HEADERS=1 -Wno-nonnull-compare
|
CFLAGS = $(INCDIR) -DLINUX -DUSE_PRECOMPILED_HEADERS=1
|
||||||
|
|
||||||
ASFLAGS = $(CXXFLAGS)
|
ASFLAGS = $(CXXFLAGS)
|
||||||
|
|
||||||
all: $(DEFAULT_RULE)
|
all: $(DEFAULT_RULE)
|
||||||
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS := -Wall -W -Werror -Wno-unused -Wno-deprecated-declarations $(CFLAGS)
|
CFLAGS := -Wall -W -Werror -Wno-unused $(CFLAGS)
|
||||||
CXXFLAGS += $(CFLAGS)
|
CXXFLAGS += $(CFLAGS)
|
||||||
# -fno-exceptions
|
# -fno-exceptions
|
||||||
|
|
||||||
@@ -127,6 +110,8 @@ debug: all
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(TARGET): Makefile.$(TARGET_ARCHITECTURE) $(OBJS) ../../JGE/lib/linux/libjge.a
|
$(TARGET): Makefile.$(TARGET_ARCHITECTURE) $(OBJS) ../../JGE/lib/linux/libjge.a
|
||||||
$(CXX) -o $(TARGET) $(OBJS) $(LIBS) $(LIBDIR)
|
$(CXX) -o $(TARGET) $(OBJS) $(LIBS) $(LIBDIR)
|
||||||
|
|
||||||
@@ -143,7 +128,7 @@ clean:
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
define compile
|
define compile
|
||||||
$(CXX) -c $(CXXFLAGS) $< -o $@
|
$(CXX) -c $(CXXFLAGS) $< -o $@
|
||||||
endef
|
endef
|
||||||
|
|
||||||
PrecompiledHeader.h.gch: ../../projects/mtg/include/PrecompiledHeader.h
|
PrecompiledHeader.h.gch: ../../projects/mtg/include/PrecompiledHeader.h
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |