Warn when no graphics is detected at startup

Add script for building otclient snaphots
This commit is contained in:
Eduardo Bart 2012-08-19 11:30:57 -03:00
parent 6d039ade67
commit 779f298055
6 changed files with 225 additions and 108 deletions

View File

@ -9,6 +9,30 @@ function Client.reloadScripts()
print(message)
end
function Client.startup()
-- Play startup music (The Silver Tree, by Mattias Westlund)
g_sounds.playMusic("startup.ogg", 3)
connect(g_game, { onGameStart = function() g_sounds.stopMusic(3) end })
connect(g_game, { onGameEnd = function() g_sounds.playMusic("startup.ogg", 3) end })
-- Check for startup errors
local errtitle = nil
local errmsg = nil
if g_graphics.getRenderer():lower():match('gdi generic') then
errtitle = tr('Graphics card driver not detected')
errmsg = tr('No graphics card detected, everything will be drawn using the CPU,\nthus the performance will be really bad.\nPlease update your graphics driver to have a better performance.')
end
-- Show entergame
if errmsg or errtitle then
local msgbox = displayErrorBox(errtitle, errmsg)
msgbox.onOk = function() EnterGame.firstShow() end
else
EnterGame.firstShow()
end
end
function Client.init()
g_window.setMinimumSize({ width = 600, height = 480 })
@ -37,15 +61,7 @@ function Client.init()
g_window.setIcon(resolvepath('clienticon.png'))
g_keyboard.bindKeyDown('Ctrl+Shift+R', Client.reloadScripts)
connect(g_app, { onRun =
function()
-- Play startup music (The Silver Tree, by Mattias Westlund)
g_sounds.playMusic("startup.ogg", 3)
connect(g_game, { onGameStart = function() g_sounds.stopMusic(3) end })
connect(g_game, { onGameEnd = function() g_sounds.playMusic("startup.ogg", 3) end })
end
})
connect(g_app, { onRun = Client.startup })
end
function Client.terminate()

View File

@ -88,16 +88,23 @@ function EnterGame.init()
protocolBox:setCurrentOption(clientVersion)
end
-- only open entergame when app starts
if not g_app.isRunning() then
enterGame:hide()
if g_app.isRunning() and not g_game.isOnline() then
enterGame:show()
end
end
function EnterGame.firstShow()
enterGame:show()
local account = g_crypt.decrypt(g_settings.get('account'))
local password = g_crypt.decrypt(g_settings.get('password'))
local host = g_settings.get('host')
local autologin = g_settings.getBoolean('autologin')
if #host > 0 and #password > 0 and #account > 0 and autologin then
addEvent(EnterGame.doLogin)
end
else
if g_game.isOnline() then
enterGame:hide()
end
end
end
function EnterGame.terminate()

View File

@ -125,11 +125,11 @@ function tryExit()
local logoutFunc = function() logout() exitWindow:destroy() exitWindow = nil end
local cancelFunc = function() exitWindow:destroy() exitWindow = nil end
exitWindow = displayGeneralBox('Exit', tr("If you shut down the program, your character might stay in the game.\nClick on 'Logout' to ensure that you character leaves the game properly.\nClick on 'Exit' if you want to exit the program without logging out your character."), {
{ text='Force Exit', callback=exitFunc },
exitWindow = displayGeneralBox('Exit', tr("If you shut down the program, your character might stay in the game.\nClick on 'Logout' to ensure that you character leaves the game properly.\nClick on 'Exit' if you want to exit the program without logging out your character."),
{ { text='Force Exit', callback=exitFunc },
{ text='Logout', callback=logoutFunc },
{ text='Cancel', callback=cancelFunc },
anchor=AnchorHorizontalCenter}, logoutFunc, cancelFunc)
anchor=AnchorHorizontalCenter }, logoutFunc, cancelFunc)
return true
end

181
tools/make_snapshot.sh Executable file
View File

@ -0,0 +1,181 @@
#!/bin/bash
# generates otclient zip package for win32
# by edubart :)
gitroot="git://github.com/edubart/otclient.git"
name="otclient"
workdir="$HOME/$name-builds"
mingwplatform="i486-mingw32"
makejobs=4
[ "$1" == "--replace" ] && replace=true || replace=false
# setup work directory
mkdir -p $workdir
cd $workdir
# update otclient
if [ -d otclient ]; then
cd otclient
git pull || exit
else
git clone $gitroot otclient || exit
fi
# get spr and dat
cd $workdir
if [ ! -d Tibia ]; then
wget http://tibiaclient.com/files/tibia860.tar
tar xf tibia860.tar
fi
cd $workdir/otclient
revision=`git rev-list --all | wc -l`
commit=`git describe --dirty --always`
# compile for win32
rm -rf build.win32
mkdir build.win32
cd build.win32
cmake -DCMAKE_TOOLCHAIN_FILE=$workdir/otclient/src/framework/cmake/${mingwplatform}_toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBOT_PROTECTION=OFF \
-DBUILD_REVISION=$revision \
-DBUILD_COMMIT=$commit \
.. || exit
make -j$makejobs || exit
cd ..
# compile for win32
rm -rf build.win32dx9
mkdir build.win32dx9
cd build.win32dx9
cmake -DCMAKE_TOOLCHAIN_FILE=$workdir/otclient/src/framework/cmake/${mingwplatform}_toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBOT_PROTECTION=OFF \
-DOPENGLES=2.0 \
-DBUILD_REVISION=$revision \
-DBUILD_COMMIT=$commit \
.. || exit
make -j$makejobs || exit
cd ..
# compile for linux 64
rm -rf build.linux64
mkdir build.linux64
cd build.linux64
export CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"
export LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
cmake -DCMAKE_BUILD_TYPE=Release \
-DBOT_PROTECTION=OFF \
-DBUILD_REVISION=$revision \
-DBUILD_COMMIT=$commit \
.. || exit
make -j$makejobs || exit
cd ..
##################################################
# create win32 package
pkg_suffix="-snapshot-linux64-`date +%Y%m%d`"
pkgname="$name$pkg_suffix"
pkgzip="$pkgname.tgz"
cd $workdir
rm -rf $pkgname
mkdir $pkgname
cd $pkgname
# copy otclient files
cp -R $workdir/otclient/mods .
cp -R $workdir/otclient/modules .
cp $workdir/otclient/build.linux64/otclient .
cp $workdir/otclient/build.linux64/otclient.map .
cp $workdir/otclient/init.lua .
cp $workdir/otclient/otclientrc.lua .
cp $workdir/otclient/BUGS .
cp $workdir/otclient/AUTHORS .
cp $workdir/otclient/LICENSE .
cp $workdir/otclient/README.md README
# remove git files
find -name '.git*' -exec rm -rf {} \;
find -name '*.spr' -exec rm -f {} \;
find -name '*.dat' -exec rm -f {} \;
cd $workdir
# determine zip name
if ! $replace; then
let i=1
while [ -e $pkgzip ]; do
pkgzip="$pkgname-$i.zip"
let i=i+1
done
fi
# compress to a zip file
rm -f $pkgzip
tar czf $pkgzip $pkgname
echo "Package generated to $pkgzip"
mkdir $pkgname/modules/game_tibiafiles/860/
cp $workdir/Tibia/*.spr $pkgname/modules/game_tibiafiles/860/
cp $workdir/Tibia/*.dat $pkgname/modules/game_tibiafiles/860/
##################################################
# create win32 package
pkg_suffix="-snapshot-win32-`date +%Y%m%d`"
pkgname="$name$pkg_suffix"
pkgzip="$pkgname.zip"
cd $workdir
rm -rf $pkgname
mkdir $pkgname
cd $pkgname
# copy otclient files
cp -R $workdir/otclient/mods .
cp -R $workdir/otclient/modules .
cp $workdir/otclient/build.win32/otclient.exe .
cp $workdir/otclient/build.win32/otclient.map .
cp $workdir/otclient/build.win32dx9/otclient.exe otclient_dx9.exe
cp $workdir/otclient/build.win32dx9/otclient.map otclient_dx9.map
cp $workdir/otclient/init.lua .
cp $workdir/otclient/otclientrc.lua .
cp $workdir/otclient/AUTHORS AUTHORS.txt
cp $workdir/otclient/BUGS BUGS.txt
cp $workdir/otclient/LICENSE LICENSE.txt
cp $workdir/otclient/README.md README.txt
unix2dos LICENSE.txt README.txt BUGS.txt AUTHORS.txt
# remove git files
find -name '.git*' -exec rm -rf {} \;
find -name '*.spr' -exec rm -f {} \;
find -name '*.dat' -exec rm -f {} \;
cd $workdir
# determine zip name
if [ ! $replace ]; then
let i=1
while [ -e $pkgzip ]; do
pkgzip="$pkgname-$i.zip"
let i=i+1
done
fi
# compress to a zip file
rm -f $pkgzip
zip -9 -qr $pkgzip $pkgname
echo "Package generated to $pkgzip"
# test win32 otclient
mkdir otclient/modules/game_tibiafiles/860/
cp $workdir/Tibia/*.spr otclient/modules/game_tibiafiles/860/
cp $workdir/Tibia/*.dat otclient/modules/game_tibiafiles/860/
cd otclient
wine build.win32/otclient.exe
rm -f *.log

View File

@ -1,3 +0,0 @@
*
!makeotc
!.gitignore

View File

@ -1,84 +0,0 @@
#!/bin/bash
# generates otclient zip package for win32
# by edubart :)
# TODO: the following options
# --gitroot <giturl> - clone a different url, the default is git://github.com/edubart/otclient.git
# --platform <platform> - compile for i486-mingw32, i586-msvc-mingw32 or linux
# --branch <branch> - use sources from a specific branch, the default is master
# --name <name> - change .exe and folder name, the default is otclient
# --protocol <proto> - game protocol, the default is 860
# --suffix <suffix> - override suffix, the default is the date
# --copy-tibiafiles <folder> - copy Tibia.spr and Tibia.dat from folder
# --github-upload <url> - upload the zip to github
# --scp-upload <url> - upload the zip to a shell via scp
gitroot="git://github.com/edubart/otclient.git"
name="otclient"
protocol=860
platform="i486-mingw32"
tibiafiles_folder="$HOME/projects/otclient/modules/game_tibiafiles"
upload_to="root@myserver.com:/var/www/downloads/"
pkg_suffix="-snapshot-`date +%Y%m%d`-protocol${protocol}-win32"
use_spr=false
upload=false
make_jobs=8
srcdir=`pwd`
if [ -d $name ]; then
cd $name
git pull || exit
else
git clone $gitroot $name || exit
cd $name
fi
gitdir=`pwd`
revision=`git rev-list --all | wc -l`
commit=`git describe --dirty --always`
rm -rf build
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$gitdir/src/framework/cmake/${platform}_toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_REVISION=$revision \
-DBUILD_COMMIT=$commit \
-DBOT_PROTECTION=OFF \
-DPROTOCOL=$protocol \
.. || exit
make "-j${make_jobs}" || exit
pkgdir="$name$pkg_suffix"
pkgzip="$pkgdir.zip"
cd $srcdir
rm -rf $pkgdir
mkdir $pkgdir
cd $pkgdir
cp -R $gitdir/modules .
cp $gitdir/build/*.exe .
cp $gitdir/build/*.map .
cp $gitdir/LICENSE .
cp $gitdir/README.rdoc .
if $use_spr; then
cp $dat_folder/*.spr modules/game_tibiafiles/
cp $dat_folder/*.dat modules/game_tibiafiles/
fi
cd $srcdir
rm -f $pkgzip
zip -9 -qr $pkgzip $pkgdir
echo "Package generated to $pkgzip"
if $upload; then
scp $srcdir/$pkgzip $upload_to
fi