attal-src-1.0-rc2/0000755000175000017500000000000011016115066011451 5ustar aaaaattal-src-1.0-rc2/admin/0000755000175000017500000000000011016113670012540 5ustar aaaaattal-src-1.0-rc2/admin/debian/0000755000175000017500000000000011016113667013770 5ustar aaaaattal-src-1.0-rc2/admin/debian/attal.desktop0000644000175000017500000000033110762554454016477 0ustar aaaa[Desktop Entry] Encoding=UTF-8 Name=Attal Comment=Turn based strategy game Comment[it]=Gioco strategico a turni Exec=attal-client Icon= StartupNotify=true Terminal=false Type=Application Categories=Game;StrategyGame; attal-src-1.0-rc2/admin/debian/attalscenario.desktop0000644000175000017500000000036010762554455020226 0ustar aaaa[Desktop Entry] Encoding=UTF-8 Name=AttalScenarioEditor Comment=Turn based strategy game Comment[it]=Gioco strategico a turni Exec=attal-scenario-editor Icon= StartupNotify=true Terminal=false Type=Application Categories=Game;StrategyGame; attal-src-1.0-rc2/admin/debian/attalserver.desktop0000644000175000017500000000033710762554455017735 0ustar aaaa[Desktop Entry] Encoding=UTF-8 Name=AttalServer Comment=Turn based strategy game Comment[it]=Gioco strategico a turni Exec=attal-server Icon= StartupNotify=true Terminal=false Type=Application Categories=Game;StrategyGame; attal-src-1.0-rc2/admin/debian/attaltheme.desktop0000644000175000017500000000035210762554456017527 0ustar aaaa[Desktop Entry] Encoding=UTF-8 Name=AttalThemeEditor Comment=Turn based strategy game Comment[it]=Gioco strategico a turni Exec=attal-theme-editor Icon= StartupNotify=true Terminal=false Type=Application Categories=Game;StrategyGame; attal-src-1.0-rc2/admin/attal-qt-4.2.patch0000644000175000017500000000072410462075762015631 0ustar aaaa--- attal-src/config.pro.ark 2006-07-26 22:55:50.000000000 +0200 +++ attal-src/config.pro 2006-07-26 22:55:56.000000000 +0200 @@ -32,7 +32,7 @@ isEmpty( ATT_DATA_PREFIX ) { ATT_DATA_PREFIX = ATT_PREFIX #Change it if data final directory is different from installation dir } - DEFINES += ATT_PREFIX=\"$$ATT_DATA_PREFIX\" + DEFINES += ATT_PREFIX=\\\"$$ATT_DATA_PREFIX\\\" } # For sound under windows, enter here the path to SDL root dir and uncomment line attal-src-1.0-rc2/admin/attal.iss0000755000175000017500000001136310631635655014412 0ustar aaaa; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! [Setup] AppName=Attal Lords of Doom AppVerName=Attal 1.0-rc1 AppPublisher=AttalDevelopers AppPublisherURL=sourceforge.net/projects/attal AppSupportURL=sourceforge.net/projects/attal AppUpdatesURL=sourceforge.net/projects/attal DefaultDirName={pf}\Attal DefaultGroupName=Attal Lords of Doom OutputBaseFilename=attalsetup Compression=lzma SolidCompression=yes LicenseFile=C:\Documenti\attal\Copying.txt SetupIconFile= AppCopyright=GPL [Languages] Name: english; MessagesFile: compiler:Default.isl Name: french; MessagesFile: compiler:Languages\French.isl Name: german; MessagesFile: compiler:Languages\German.isl Name: italian; MessagesFile: compiler:Languages\Italian.isl Name: russian; MessagesFile: compiler:Languages\Russian.isl Name: spanish; MessagesFile: compiler:Languages\Spanish.isl [Tasks] Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked [Files] Source: C:\Documenti\attal\attal-client.exe; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\attal-ai.exe; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\AttalAi2.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\attal-campaign-editor.exe; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\AttalClient9.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\AttalCommon9.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\AttalFight8.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\attal-scenario-editor.exe; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\attal-server.exe; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\AttalServer9.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\attal-theme-editor.exe; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\mingwm10.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\ogg.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\QtCore4.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\QtGui4.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\QtNetwork4.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\QtXml4.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\SDL.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\SDL_mixer.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\vorbis.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\vorbisfile.dll; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\Readme; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\Copying.txt; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\HOWTOPLAY.html; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\INSTALL; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\News; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\Authors; DestDir: {app}; Flags: ignoreversion Source: C:\Documenti\attal\themes\*; DestDir: {app}\themes; Flags: recursesubdirs Source: C:\Documenti\attal\i18n\*; DestDir: {app}\i18n; Flags: recursesubdirs ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] Name: {group}\Attal; Filename: {app}\attal-client.exe; WorkingDir: {app}; IconFilename: {app}\themes\medieval\images\misc\ico_attal-client.ico; Languages: english italian german russian french Name: {group}\Attal-scenario-editor; Filename: {app}\attal-scenario-editor.exe; WorkingDir: {app}; IconFilename: {app}\themes\medieval\images\misc\ico_attal-scenario-editor.ico Name: {group}\Attal-theme-editor; Filename: {app}\attal-theme-editor.exe; WorkingDir: {app}; IconFilename: {app}\themes\medieval\images\misc\ico_attal-theme-editor.ico Name: {group}\Attal-campaign-editor; Filename: {app}\attal-campaign-editor.exe; WorkingDir: {app}; IconFilename: {app}\themes\medieval\images\misc\ico_attal-campaign-editor.ico Name: {group}\Attal-server; Filename: {app}\attal-server.exe; WorkingDir: {app}; IconFilename: {app}\themes\medieval\images\misc\ico_attal-server.ico Name: {group}\Attal-ai; Filename: {app}\attal-ai.exe; WorkingDir: {app}; IconFilename: {app}\themes\medieval\images\misc\ico_attal-ai.ico Name: {group}\{cm:UninstallProgram,Attal}; Filename: {uninstallexe} Name: {commondesktop}\Attal; Filename: {app}\attal-client.exe; WorkingDir: {app}; IconFilename: {app}\themes\medieval\images\misc\ico_attal-client.ico; Tasks: desktopicon [Run] Filename: {app}\attal-client.exe; Description: {cm:LaunchProgram,Attal}; Flags: nowait postinstall skipifsilent attal-src-1.0-rc2/admin/attal.spec0000644000175000017500000000321610761565761014545 0ustar aaaa%define cvs 1.0-rc1 Summary: A turn based strategy game Name: attal Version: 1.0-rc1 Release: 0.%cvs.1ark License: GPL Group: Amusement/Games Source: %name-src-%cvs.tar.lz Source1: %name-themes-%cvs.tar.lz #Patch: attal-qt-4.2.patch BuildRoot: /tmp/%{name}-buildroot %description Attal is a turn based strategy game %prep %setup -q -n %name-src -a 1 #%patch -p1 -b .qt42~ mv %name-themes themes export QTDIR=/usr/lib/qt4 export ATT_PREFIX=%_prefix ./autogen.sh %build export LD_LIBRARY_PATH=`pwd` make %?_smp_mflags %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT%_bindir mkdir -p $RPM_BUILD_ROOT%_libdir mkdir -p $RPM_BUILD_ROOT%_datadir/games/attal/ install -m 755 attal-server $RPM_BUILD_ROOT%_bindir/attal-server install -m 755 attal-ai $RPM_BUILD_ROOT%_bindir/attal-ai install -m 755 attal-client $RPM_BUILD_ROOT%_bindir/attal-client install -m 755 attal-scenario-editor $RPM_BUILD_ROOT%_bindir/attal-scenario-editor install -m 755 attal-theme-editor $RPM_BUILD_ROOT%_bindir/attal-theme-editor install -m 755 attal-campaign-editor $RPM_BUILD_ROOT%_bindir/attal-campaign-editor install -m 755 *.so* $RPM_BUILD_ROOT%_libdir cp -r themes $RPM_BUILD_ROOT%_datadir/games/attal/ %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %doc README TODO COPYING %_bindir/attal-server %_bindir/attal-ai %_bindir/attal-client %_bindir/attal-scenario-editor %_bindir/attal-theme-editor %_bindir/attal-campaign-editor %_libdir/* %_datadir/games/attal/* %changelog * Sun May 21 2006 Lusum First try attal-src-1.0-rc2/admin/create_debs.sh0000755000175000017500000001720310762554453015361 0ustar aaaa#!/bin/bash cd .. echo PREPARE ENVIRONMENT VARIABLES export QTDIR=/usr/share/qt4 export QMAKESPEC=/usr/share/qt4/mkspecs/linux-g++ export VERSION=$(grep -m 1 ATTAL_VERSION= config.pro | tr -d [[:alpha:]] | tr -d [[:blank:]] | tr -d = | tr -d _ | tr -d -) export CURDIR=$(dirs -l) export ATT_PREFIX=/usr #echo PREPARE SRC-ROOT # make clean 1> /dev/null echo MAKE SURE WE HARDCODE EVERYTHING WITH /usr PREFIX - DEBIAN STANDARD #cat config.pro | sed 's#/usr/local#/usr#g' | tee config-mod.pro #mv -f config-mod.pro config.pro ./autogen.sh 1> /dev/null make echo MAKE SURE WE INSTALL IN A SUBDIRECTORY OF SRC-ROOT, SO WE CAN PACK UP LATER make INSTALL_ROOT="$CURDIR"/debian/attal/ install echo PREPARE attal DEBIAN PACKAGE FOLDERS following debian naming mkdir -p debian/attal/usr/share/doc/attal 1> /dev/null cp HOWTOPLAY.html debian/attal/usr/share/doc/attal/HOWTOPLAY.html 1> /dev/null cp AUTHORS debian/attal/usr/share/doc/attal/AUTHORS 1> /dev/null cp INSTALL debian/attal/usr/share/doc/attal/INSTALL 1> /dev/null cp COPYING debian/attal/usr/share/doc/attal/copyright 1> /dev/null cp NEWS debian/attal/usr/share/doc/attal/changelog.Debian 1> /dev/null gzip -9 debian/attal/usr/share/doc/attal/changelog.Debian 1> /dev/null mkdir -p debian/attal/usr/share/applications cp admin/debian/attal.desktop debian/attal/usr/share/applications/attal.desktop 1> /dev/null cp admin/debian/attalscenario.desktop debian/attal/usr/share/applications/attalscenario.desktop 1> /dev/null cp admin/debian/attalserver.desktop debian/attal/usr/share/applications/attalserver.desktop 1> /dev/null cp admin/debian/attaltheme.desktop debian/attal/usr/share/applications/attaltheme.desktop 1> /dev/null mkdir -p debian/attal/usr/share/menu echo '?package(attal):needs="X11" section="Games/Strategy" \' > debian/attal/usr/share/menu/attal echo 'title="Attal" command="/usr/bin/attal-client" ' >> debian/attal/usr/share/menu/attal echo '?package(attal):needs="X11" section="Games/Strategy" \' > debian/attal/usr/share/menu/attalserver echo 'title="Attal-server" command="/usr/bin/attal-server" ' >> debian/attal/usr/share/menu/attalserver echo '?package(attal):needs="X11" section="Games/Strategy" \' > debian/attal/usr/share/menu/attalscenario echo 'title="Attal-scenario-editor" command="/usr/bin/attal-scenario-editor" ' >> debian/attal/usr/share/menu/attalscenario echo '?package(attal):needs="X11" section="Games/Strategy" \' > debian/attal/usr/share/menu/attaltheme echo 'title="Attal-theme-editor="/usr/bin/attal-theme-editor" ' >> debian/attal/usr/share/menu/attaltheme echo '?package(attal):needs="X11" section="Games/Strategy" \' > debian/attal/usr/share/menu/attalcampaign echo 'title="Attal-campaign-editor command="/usr/bin/attal-campaign-editor" ' >> debian/attal/usr/share/menu/attalcampaign echo PREPARE attal-themes-medieval DEBIAN PACKAGE FOLDERS following debian naming mkdir -p debian/attal-themes-medieval/usr/share/games/attal/themes mv debian/attal/usr/share/games/attal/themes/medieval debian/attal-themes-medieval/usr/share/games/attal/themes/ mkdir -p debian/attal-themes-medieval/usr/share/doc/attal-themes-medieval 1> /dev/null mkdir debian/attal-themes-medieval/DEBIAN export SIZE=$(du -s debian/attal-themes-medieval/ | tr -d [[:alpha:]] | tr -d [[:blank:]]) echo Package: attal-themes-medieval > debian/attal-themes-medieval/DEBIAN/control echo Version: $VERSION >> debian/attal-themes-medieval/DEBIAN/control echo Section: contrib >> debian/attal-themes-medieval/DEBIAN/control echo Priority: optional >> debian/attal-themes-medieval/DEBIAN/control echo Architecture: i386 >> debian/attal-themes-medieval/DEBIAN/control echo Depends: libqt4-core,libqt4-gui,libsdl-mixer1.2 >> debian/attal-themes-medieval/DEBIAN/control echo Installed-Size: $SIZE >> debian/attal-themes-medieval/DEBIAN/control echo Maintainer: Lusum \(lusum@sourceforge.net\) >> debian/attal-themes-medieval/DEBIAN/control echo Description: Attal - Lords of Doom >> debian/attal-themes-medieval/DEBIAN/control echo " Attal is an turn-based strategy game " >> debian/attal-themes-medieval/DEBIAN/control echo " that can be played alone (against AI) " >> debian/attal-themes-medieval/DEBIAN/control echo " or against other through a network. " >> debian/attal-themes-medieval/DEBIAN/control echo " " >> debian/attal-themes-medieval/DEBIAN/control echo " This package provides the medieval theme for Attal" >> debian/attal-themes-medieval/DEBIAN/control echo PREPARE attal-themes-cyberpunk DEBIAN PACKAGE FOLDERS following debian naming mkdir -p debian/attal-themes-cyberpunk/usr/share/games/attal/themes mv debian/attal/usr/share/games/attal/themes/cyberpunk debian/attal-themes-cyberpunk/usr/share/games/attal/themes/ cp -Rf debian/attal-themes-medieval/usr/share/doc/ debian/attal-themes-cyberpunk/usr/share/ mv debian/attal-themes-cyberpunk/usr/share/doc/attal-themes-medieval debian/attal-themes-cyberpunk/usr/share/doc/attal-themes-cyberpunk mkdir debian/attal-themes-cyberpunk/DEBIAN export SIZE=$(du -s debian/attal-themes-cyberpunk/ | tr -d [[:alpha:]] | tr -d [[:blank:]]) echo Package: attal-themes-cyberpunk > debian/attal-themes-cyberpunk/DEBIAN/control echo Version: $VERSION >> debian/attal-themes-cyberpunk/DEBIAN/control echo Section: contrib >> debian/attal-themes-cyberpunk/DEBIAN/control echo Priority: optional >> debian/attal-themes-cyberpunk/DEBIAN/control echo Architecture: i386 >> debian/attal-themes-cyberpunk/DEBIAN/control echo Depends: libqt4-core, libsdl-mixer1.2 >> debian/attal-themes-cyberpunk/DEBIAN/control echo Installed-Size: $SIZE >> debian/attal-themes-cyberpunk/DEBIAN/control echo Maintainer: Lusum \(lusum@sourceforge.net\) >> debian/attal-themes-cyberpunk/DEBIAN/control echo Description: Attal - Lords of Doom >> debian/attal-themes-cyberpunk/DEBIAN/control echo " Attal is an turn-based strategy game " >> debian/attal-themes-cyberpunk/DEBIAN/control echo " that can be played alone (against AI) " >> debian/attal-themes-cyberpunk/DEBIAN/control echo " or against other through a network. " >> debian/attal-themes-cyberpunk/DEBIAN/control echo " " >> debian/attal-themes-cyberpunk/DEBIAN/control echo " This package provides the cyberpunk theme for Attal (unusable)" >> debian/attal-themes-cyberpunk/DEBIAN/control rm -Rf debian/attal/usr/share/games/attal/themes/ echo PREPARE attal DEBIAN PACKAGE FOLDERS cp -Rf debian/attal-themes-medieval/usr/share/doc/ debian/attal/usr/share/ mv debian/attal/usr/share/doc/attal-themes-medieval debian/attal/usr/share/doc/attal mkdir debian/attal/DEBIAN export SIZE=$(du -s debian/attal | tr -d [[:alpha:]] | tr -d [[:blank:]]) echo Package: attal > debian/attal/DEBIAN/control echo Version: $VERSION >> debian/attal/DEBIAN/control echo Section: contrib >> debian/attal/DEBIAN/control echo Priority: optional >> debian/attal/DEBIAN/control echo Architecture: i386 >> debian/attal/DEBIAN/control echo Depends: libqt4-core, libsdl-mixer1.2 >> debian/attal/DEBIAN/control echo Installed-Size: $SIZE >> debian/attal/DEBIAN/control echo Maintainer: Lusum \(lusum@sourceforge.net\) >> debian/attal/DEBIAN/control echo Description: Attal - Lords of Doom >> debian/attal/DEBIAN/control echo " Attal is an turn-based strategy game " >> debian/attal/DEBIAN/control echo " that can be played alone (against AI) " >> debian/attal/DEBIAN/control echo " or against other through a network. " >> debian/attal/DEBIAN/control echo BUILD THE PACKAGES dpkg-deb -b debian/attal/ attal_"$VERSION"_i386.deb dpkg-deb -b debian/attal-themes-medieval/ attal-themes-medieval_"$VERSION"_i386.deb dpkg-deb -b debian/attal-themes-cyberpunk/ attal-themes-cyberpunk_"$VERSION"_i386.deb echo CLEAN UP rm -Rf debian 1> /dev/null make clean 1> /dev/null attal-src-1.0-rc2/admin/macx-bundle/0000755000175000017500000000000011016113670014737 5ustar aaaaattal-src-1.0-rc2/admin/macx-bundle/attal.icns0000644000175000017500000012334110646510063016733 0ustar aaaaicnsit32f  *>HVbekQ^~QatO3 '1RxnqsR.* +c»rkddrqzzvv~|< .(nƼz^G=66?DGYo{{|pd[VSPPVa~Ƽ;6rʀ+eA) "+467ELUfqq~si\WL@5)#'6UѢY# 7>rķoD$"#(,04769CIVer|~zqhZUPG;2, $;iɟc!:'t̵Y5  ##&*-3854:CWuyoh^XOF<2($  3VŐ@ <GX* !$',011+6Qzuia]YNB6-(! ,Yӯh#hǛ^-+##&*($,YtZ]YWND7,%  !$*9hÙC:Ǵl+#!!6u<5??<72) "))-3?lн^(UėEFO%-00-,O͋; H'rDZp-/i6%+/4665Ir׮V+ɩZ&7 P½u  %*0357324UڻU K˜H .vK$(,035540.HҷHŖ38 !Yğ4  $*-23542-$9ߺLx0 EÀʆ#  &,21.,-/%2zشL iĽ4  *þ\  !+--.++*"0sϯL fþ4 "¿+֦>   %+-//,& -nЫJ  _ž7   EÁ Ҋ  !+/.-'%#*{˲DTɰ?  )^Łb  .1-))& 4͛3ɯJ ,nɀتC &**& "!Aw ž_    6ρʀъ" &(&%% "R׹K Oľ"  !Jϼd $&)'&(-n̟--¿=  $fтˀЭD "&+&,-:t nW  (~ˀʀ͏+!',,.1FϼLHǁ%  [ˀ q (,254iѳ1%°B   $ʀ"L   &,267H͂ gz     `̀؜*  "/0696_0)?   :́ n   )/4:8;j b|  -  "ٴK   *06=1WЪ)@  ^ɁɀЙ4 +5729] ϧ6;ˀ.Վ+ )9>;F> qB  '|ʾ]kˀֽk  4<<;X.%\ǽĄ%0Lj ɬF -<=3}z(' =¿ɠ<Uˇ ѕ(  ':=3`Μ E` & &üÿѵX sɈ { 6>;P [C ' hĽ{#8͇ ǻW .=;FC - r,  <½ʜ9Y͆ˬ7 '<9Bl L ĿŻĻS (ʀƀ ˊ$  !99=z͔ f.+ SŃ"Kπŀ˿f 6<;mͰ |@ 2Ơ6  rʀӰI 2A:a‘ O}ǯT1ʀÁ ʝ2-@:Y‘ T XĀ! 3Uǂ ';;Vż Tw$9›: $|ʂ̾b "8=TƼ Rm !W   8ĀǶ7 7=Q˾ Pi   hz  ^ÀĀÁ ˑ 4;NϽ Ol ? ''a|öƒÀľu48Nɽ Pu(ƽ IʯYB€Ăŀ ϹW 66Mƽ P k'lGg¿ĂÁ ͥ>76PǾ P 5 H4_D-ƒÁ ûɊ%66Wɾ P (Y  V/ X¿ƒÁ ½k  /6^ŽF1wtT0¿S25iǻr6-\)1C+?ýł¿ɡ-24sƳ UC +P 2%h} /5Ʀ7 qY{)y/ûy*ĿƒÀɻ^,<ʍXpY.*Ļt U‚>+Mi B, ?]&Ļržā‚ƽǑ$ ,bE+?#'yb<¼q !+y* xZe;tY ]ÂŀɽW (ʹgo* EYgT &ÿƒĀ¦6":ʙ (R:  zaH \þāŀ Č% ]{%9Qf8^-&}¿ûĀÀ {1!M !os. LO dq 6ŽĀ ˾T@ě"3[A-tXh`ÿĀ¿ͼ9i»h 8` k- Ne*ôb,4;k|5 L[) Wı[ HɽÃƿĢHZƿDT6z" Mɯ_ y×>(ĹWI|y>r<  qԪn):)ye=# $ &2Hj}dP>3,*(&$  3WןM,Oɛ^0 (EpvUA2,*&" &Uy+ rѡd10#M^>6++)&# -_֧K;ֿu00.lu, "# #3hk VѢM1 ?F DܗC )uͼ{6 *e ,  6o\ 1ѱa*)  Mýt   'S] 1%ئQ!   -u¿°N   ;S1ҡ:  Z͢5   /V Oɑ6    DЈ#   ,yW oŌ7# &^   *rY mĊ6  ݀ݪ@    (nTjɢ9    B؁ُ!    &~I ^ҶB    ![܃ހ߀j 3ڤ!:ӶM   &jނ߀H  @˿f      .݂ޔ&   IU Uɉ%    Aj  _٫32ˤC    _ ޴E   &~ wʽ^ "݀ؓ)    @T R̓%   \ހt   [7 -˱>   #߀ݹM    .ߍ  q{     `݁߀߂)   O4/Ǯ>    :ހ߃n    (r k  !܀߀J     Jݸ.˭@  `݀ހ߁ ٞ2   (h C~   E݁߂}  Qܣ$}̴L   'ـ߁߀U   1U0ő+  g܂ހ߀߁ު8     a^Ϳi   >؁ڽف׃    4D ʰF  ցke Z t FNJ& ^܁~"">   X$ jg  Bڀ5 9ހ +  6@ żC  ,׀_ gށ݂ s   #` ħ,    gЋ% (އ ٸM  r ,lj  $ Aө@  Nއ ߟ,S Lf  (׀ڼ[  sى ׂ   B# cE$ l~"  6ވ ] 6F 0 {.  ?Ӂآ9 Z܈ ٵ; .p OĻ   րX &ڂހב( (qޚ k0í   [ր֋$ I߁ހm  #a޶ CØ ':׭; nځ݀P  !!Sȑ Sŋ "ֻ[   *ކ ٨8  Gɑ XǾdž  eπφ#  UـڀՌ  CÑ Xž} CϢ> !فl >Ñ Wv #ͷ]    @׀ڀ @   =Ǒ Uv  ĺ̈́  h׀ڀ ޝ&   ?ȑ V~ B՟.,b "؃ـ~ AǑ WľÇ*ʁR $ҴZHقځ^ BǑ W¼q͊!v̭Jm؁ځ܀ ݯB   Eȑ W O̤7iͨI/׃قՏ& LǑ X .Ѐ[ ^Ϩ6[׃قo  UǑN } ]Ѣ7ւ؂݀܀X   bđ |>/   hˀǟ6 KҀ˖1Bց؃׭1 !oּ ^#F 4̀ ̷W  9ς͊,nق؂ق݇ %֯ @[ !}6уɂ$+ӂ؅h-ٖ$gr  ^ǂˮ0/у} Uӂ؅ـҵG=q N' @ǁǷb.πuق؂ـ؀ڠ-SM2>$*Æ(̀ i=Ӏف؁}o1 \ qŀ < $ς͂Ђӿe bـ؀؂a   'rq& O¿[$ẑπӂѻ^&؃մ:5֥ ' \8'¿ qЀςӀѲO YրӒ!Z܃.@Onß= bсӀ ӥ- ځ v+U,&yr+ QT hсҀ|6؂иO?ا%+b@0zbуҿsfӀ؀؂~6jr ;` o1 Yρ̀ ͷp,ф׃׾g,3غCn~4 P^_́ ϼb JււװN\ՓDT8|# T͂ ӹe|ււѤB*bz@v=   Aˁ ƬU 2ӂ؀Ʉ* Rխ,[j~T  6ǀ ɦL  ^Ӂվk)y+ylu! 2̀ǢM'ӁҲ\^տD ^nr; 1ʟD  IѤM-֕5r|vlW+}̠; qђ<  kSSzt|}qtv! #r˕?4~-@ґ*fuu|yrv~7 dǒ8Ye /ѳ3;lwy{wn{Ka1  %{Ӫ^  !uо]Kqsywuq_! F) @˟FYɆ!`ossyqvn1  n? EҪ<5knrrwpG  2^- 7` FkpustU  6ы SkmuqtH  4ѯ5 *_mtnupP 1` 8^mpstvV 5q FhlprpuW  >p1klorvq]%  UѼh 0]mor|ye6%nս`0[omty~qL 4̾h .Zlpot{wZ,Pмi%Xsmprw}jG#  /yھd Rgjssr{|kF,jЮVI_mmnuu|{h@  .m~5 1Qgkorvw}iJ( CmV7Zkkouwv|~qV7! 6WȪo4 $Jhmqtvy{}}mT<&9XzřK71Xlrqtyyw|~wjUB3(!  ,>Soľj'38\jlpvz}~{upiilr{y6 /AYfouz|ĻV3+-H_pty}~ſoB' 9Oboz~uP$ !%9Odsy{Z4 $+3?LQZelq{~wog^RD7.   -ALXddiM7S}{|uqoheZK4 !&DhsFY[;$ ' 7[}]f§Z3*4nǾzhZMM[]iwuk[ORapԻF.4ĴtV>/'#'(,?Vhik^F2(),06EW|АD4@׽h>$$,8K[_g^J6& $7]`& 8D|ͪyH&$.?SadYE0!'CtԪn):/~Öf?% ,Eh}aI2""5ZןM*W̞^/!?ksM6!(Vw*)$}٧e1 J~W4(0dեI Ew2/0os%&6ikbӥN  @C BܗD.-׽y5  (bķ( 2l_ 4׵a*- PǾr  $Qb '٦O!"  1}ʮD  9U1֢: \͜. 1U 3і9    @φ ,zV 4sϔ>  ] (qY sϒ= ~ = %kUoҪ? A  !}MgھF   _ d 0%@ܾR  %n B  @k    .   M[  ]Ҏ'  >h d7:֬F  [ C ( eޒ" F[ Z܌)  ] q ^>5ؿF )I,}ӄ % _$P; 8ҷD  5j (|x҆  FP2ܸD \ ݜ,  ,n Gڈ . Az Z& T #S 7W 3ؠ1 g6  %k fv  ?Ľ؁ 8H "Q pjS  | Nח. d&&&3Y( tr 0 Fܦ1 :܊"3G L  ,U dt  h"ڸ5  iٌ% Q  o 2ݙ!  ?گ? M - P Vs &[sއ  @$ nR l}  6 _ 3I 9 9 >ߢ4[>  ,s Y * !T  %ߖ,  &u靑 t7ֽ"  ]܌ It!g뻑 Lզ =߯7 mT   X͑ ]֙ %Z   (9 Mϑ eؓ k؈   X܎" Gɑ d׊Fܩ=% n Dɑ e؃)&b HB ?ϑf܆  sޏo ' ;ԑfݎ  F6+]  &ׁ :Ցfڗ/[  'ضX M^ <ԑ eڢzܔ'״NtB @Ց dٮ4 Uޮ=sܲP4ܓ&IՑdص .d  hݲ<  ap TԑX*5؈ dܬ= WbёF<  k)٭<M՜5Fݮ1!pɑi(T 9` <֏-s & Im 'րև;Ӊ(-l .- xЇ jڸ6 8Ո YݽL  @{ \̡.Hj "61UV=ͷJ=2Ў *oA%t7$p"!֥B"ijp  Ɖ3Xр׿d%~b(? 5 . mʥG,̊$ w޻Q Z ! \-M˴dwدC i߂ި- z+`3Ǽ6!Z^mހҀ5SC-/{þN 8Ҋ k{j ˆ=r~'Os$ &~ַ:^ؾs  .o3;K&¹>aѼn`bMS g" ]d'IǍ, Vg ݮF0j 'NǡE  Fո_  5ъ- X4|е] =ֱUhn *߅DŇ& :խU,ܸ]^MwžB  8بI N٩N1$D½^0ڬAwٖ>  uYj&+}١F8҄/Fژ;B mћ> ^k 4ܼ7S]g6 (f &e"fw-  F(EبK bՏ!2}D sǛE KݴA Fg$ 5f5  ;i by0  9ݕ 'pd& 8ڀ߻= :~g( 7j Nm& =| fr+ Ez Mu+ ^kIq;+ydEyY! 8n?tp= Wo 6u]05k 0oW$0r߹[/dP)4uы; Gp`1  !Hv׵c &NxkG.  7\޽}= 2bkL2! $>^֨U7BsfO=1'" #5I_{r) 3L{{|~Ç= / -Usc< 7[w؀ ҽsF' 'HbzʭV& "3Lf~»b9 09CP`foyxm^OA4! t8mk@    #&&%&'''''&#  %())**.5;>>>>?????>;5.**))(%  $*.6<@BBBCFMSVVVWWWWWWVSMFCBBB@<6/-,("  $+3;AFMTXZ[[[]djnonopppponjd][[[ZXTMGED@90)! %-3>ELU[afmrtuuvw}}wvuutrmfb`^ZRJB:/$ &1.  -;HVdpyǻ}vl`P>, 0@P]jxösaN=0$,@Qbr~q_QF8*%;Pcutj]O>+/F[pŵ~p`O<*&:Oe{óq_K7" $7I[oƼnXC.#5HZk}ô{dN7#%6HZl~ñnXE7+&7HZl~λziZMB5( &7HZk~ı{obWI;+#7HZk|xl\M;(#5HZk|n\J6 #5FZk}Ĺ~kWA+ 3GYl~´waJ3+?Th}iQ:" (:L`uʶqZC* "8J[mѾybL5 /FYl~ƮmYB, #:Sh|Ϸ|gP:'*B\rİs]I5 2JczϼkVA+&Sg|̷q[D-0G]sӿ{eP8 7Nf|ȱqZC+)@WmҼ{fO6  5LbxDZrZC-'@WmѼ{eM63KawűnU=& $;Tkιt\E.*B\t}dM6 5IbzȳkT<$ +AVl͸nV>&3J`xкoW?' ":QhѻpW?' %=UmѻpW?&'>VoѻpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?''?WpһpW?'&>VnһpW?' %=UlһpW?' "9PgһpW?'2I_wѻpW?')?TjкoV?'1F]u˶mV>% %TjílU<% 2I_uϹxbK3'>TjǯnW@(2I_vӾycM5 '=SjθpYB*1H^vɵkS;! &SezĵzeR?(0CUhzòlXB/ 2CVi|Ŵo]J6 !2G[oȶo]M<(#9Nbuɸq_K;+-ATewȹraO:)  1CTfzƸr`O>* 0BTjĵp_N=+ 2G^qͿq_N=+&:Pbr̽q_N=+ ,@Q_kuɻ~p`N;+  />KV_k|ĸwj]O>+  '3. !/;FQ]iu·xhZNC8*  ".9FR_pû|nbSE6*  "00"  +;JVbnxĿ}ui^SF7( (6AMXahq{xnf^TI>2$  +7BIQZepw~{ulbWNG>3(  *19CNX_gouwurme]UK@6/& !+6>FNV]glnopppppppppppppppppppppppponlg^ZXSLB;3( '.7>FOTVWWWWWWWWWWWWWWWWWWWWWWWWWWVTOGC@<5+%   &/8<>>?????????????????????????><80*($  $&&'''''''''''''''''''''''''&$    attal-src-1.0-rc2/admin/macx-bundle/config.pro0000644000175000017500000000552510643113341016735 0ustar aaaa# # config.pro # File included by any Makefile.pro # # if you are a developper (using cvs), don't change this file but # create a devel.pro file with your options. # # Otherwise: # # Uncomment 'CONFIG += staticlib' if you want static libs and static link # Uncomment 'CONFIG += debug' if you do want debugging symbols to be added (may be add next line "CONFIG += debug") # export ATT_CROSS_COMPILE if you do a cross compilation from unix to win32) # Comment 'DEFINES += WITH_SOUND' if you want to enable sound support (need SDL and SDL_mixer installed) # If you are using a version of qt with windows-style as plugin, you may # try to add these 2 lines 'DEFINES += QT_PLUGIN' and 'LIBS += -lqwindowsstyle' (maybe it is not enough, I do not know exists( devel.pro ) { include( devel.pro ) } else { CONFIG += qt CONFIG += warn_on #CONFIG += debug #CONFIG += staticlib !isEmpty( ATT_CROSS_COMPILE ) { CONFIG += crosslinwin } isEmpty( ATTAL_VERSION ) { ATTAL_VERSION=1.0-rc1 } DEFINES += ATTAL_VERSION=\\\"$$ATTAL_VERSION\\\" #DEFINES += WITH_SOUND unix:!macx { isEmpty( ATT_PREFIX ) { ATT_PREFIX = /usr } isEmpty( ATT_THEMES_PREFIX ) { ATT_THEMES_PREFIX = $${ATT_PREFIX}/share/games/attal/themes/ #Themes final directory } isEmpty( ATT_TRANSL_PREFIX ) { ATT_TRANSL_PREFIX = $${ATT_PREFIX}/share/games/attal/translations/ #Traslations final directory } isEmpty( ATT_TEMP_THEMES_PREFIX ) { ATT_TEMP_THEMES_PREFIX = $${ATT_THEMES_PREFIX} #Change it if themes final directory is different from installation dir } isEmpty( ATT_TEMP_TRANSL_PREFIX ) { ATT_TEMP_TRANSL_PREFIX = $${ATT_TRANSL_PREFIX} #Change it if translations final directory is different from installation dir } DEFINES += ATT_THEMES_DIR=\\\"$$ATT_THEMES_PREFIX\\\" DEFINES += ATT_TRANSL_DIR=\\\"$$ATT_TRANSL_PREFIX\\\" } macx { CONFIG -= app_bundle #We don't want multiple bundles - we create one for all binaries ATT_PREFIX = . ATT_THEMES_PREFIX = $${ATT_PREFIX}/themes/ ATT_TRANSL_PREFIX = $${ATT_PREFIX}/i18n/ ATT_TEMP_THEMES_PREFIX = $${ATT_THEMES_PREFIX} ATT_TEMP_TRANSL_PREFIX = $${ATT_TRANSL_PREFIX} DEFINES += ATT_THEMES_DIR=\\\"$$ATT_THEMES_PREFIX\\\" DEFINES += ATT_TRANSL_DIR=\\\"$$ATT_TRANSL_PREFIX\\\" #INCPATH += /Library/Frameworks/SDL.framework/Headers/ #Enable these, if you want to try to compile with sound, but for me sound doesn't work anyway, so I disabled it for now #LIBS += -L/Library/Frameworks/SDL.framework/SDL -L/Library/Frameworks/SDL_mixer.framework/SDL_mixer -framework SDL -framework SDL_mixer -framework QtNetwork LIBS += -framework QtNetwork #Don't know if it's my Qt, but there seems to be a problem if that is missing } # For sound under windows, enter here the path to SDL root dir and uncomment line #win32:SDL_DIR = # For compilers different from gcc and mingw, uncomment line (not tested) #DEFINES +=WIN32VC6 } attal-src-1.0-rc2/admin/macx-bundle/mac-make-script.command0000755000175000017500000001333610664407722021301 0ustar aaaa#!/bin/sh cd ../.. mv config.pro config.pro.bak cp admin/macx-bundle/config.pro ./ # These are the appropriate lines for the default Trolltech package of Qt 4.3 export QTDIR=/usr/ export QMAKESPEC=/usr/local/Qt4.3/mkspecs/macx-g++/ # Do not modify below this line ./autogen.sh make mkdir -p Attal.app/Contents/MacOS/ mkdir Attal.app/Contents/Resources/ #mkdir Attal.app/Contents/SharedFrameWorks/ cp attal-client attal-theme-editor attal-ai attal-server attal-scenario-editor attal-campaign-editor Attal.app/Contents/MacOS/ #cp admin/macx-bundle/*.xpm Attal.app/Contents/MacOS/ cp admin/macx-bundle/starter Attal.app/Contents/MacOS/ cp -r themes Attal.app/Contents/Resources/ cp -r i18n Attal.app/Contents/Resources/ cp admin/macx-bundle/attal.icns Attal.app/Contents/Resources/ #cp /Library/Frameworks/QtGui.framework/Versions/Current/QtGui echo "APPL????" > Attal.app/Contents/PkgInfo echo " CFBundleIconFile attal.icns CFBundlePackageType APPL CFBundleGetInfoString Created by Qt/QMake CFBundleSignature ???? CFBundleExecutable starter NOTE Please, do NOT change this file -- It was generated by Qt/QMake. " > Attal.app/Contents/Info.plist mkdir Attal.app/Contents/Frameworks/ cp -R /Library/Frameworks/QtCore.framework Attal.app/Contents/Frameworks/ cp -R /Library/Frameworks/QtGui.framework Attal.app/Contents/Frameworks/ cp -R /Library/Frameworks/QtNetwork.framework Attal.app/Contents/Frameworks/ cp -R /Library/Frameworks/QtXml.framework Attal.app/Contents/Frameworks/ install_name_tool -id @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore Attal.app/Contents/Frameworks/QtCore.framework/Versions/4.0/QtCore install_name_tool -id @executable_path/../Frameworks/QtGui.framework/Versions/4.0/QtGui Attal.app/Contents/Frameworks/QtGui.framework/Versions/4.0/QtGui install_name_tool -id @executable_path/../Frameworks/QtNetwork.framework/Versions/4.0/QtNetwork Attal.app/Contents/Frameworks/QtNetwork.framework/Versions/4.0/QtNetwork install_name_tool -id @executable_path/../Frameworks/QtXml.framework/Versions/4.0/QtXml Attal.app/Contents/Frameworks/QtXml.framework/Versions/4.0/QtXml install_name_tool -change QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore Attal.app/Contents/Frameworks/QtGui.framework/Versions/4.0/QtGui install_name_tool -change QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore Attal.app/Contents/Frameworks/QtNetwork.framework/Versions/4.0/QtNetwork install_name_tool -change QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore Attal.app/Contents/Frameworks/QtXml.framework/Versions/4.0/QtXml for i in Attal.app/Contents/MacOS/*; do install_name_tool -change QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore $i; done for i in Attal.app/Contents/MacOS/*; do install_name_tool -change QtGui.framework/Versions/4/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/4.0/QtGui $i; done for i in Attal.app/Contents/MacOS/*; do install_name_tool -change QtNetwork.framework/Versions/4/QtNetwork @executable_path/../Frameworks/QtNetwork.framework//Versions/4.0/QtNetwork $i; done for i in Attal.app/Contents/MacOS/*; do install_name_tool -change QtXml.framework/Versions/4/QtXml @executable_path/../Frameworks/QtXml.framework/Versions/4.0/QtXml $i; done cp *.dylib Attal.app/Contents/Frameworks/ for j in Attal.app/Contents/MacOS/*; do for i in *.dylib; do install_name_tool -change $i @executable_path/../Frameworks/$i $j; done; done for i in *.dylib; do install_name_tool -id @executable_path/../$i Attal.app/Contents/Frameworks/$i; done for i in *.dylib; do for j in Attal.app/Contents/Frameworks/*.dylib; do install_name_tool -change $i @executable_path/../Frameworks/$i $j; done; done for i in Attal.app/Contents/Frameworks/*.dylib; do install_name_tool -change QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4.0/QtCore $i; done for i in Attal.app/Contents/Frameworks/*.dylib; do install_name_tool -change QtGui.framework/Versions/4/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/4.0/QtGui $i; done for i in Attal.app/Contents/Frameworks/*.dylib; do install_name_tool -change QtNetwork.framework/Versions/4/QtNetwork @executable_path/../Frameworks/QtNetwork.framework//Versions/4.0/QtNetwork $i; done for i in Attal.app/Contents/Frameworks/*.dylib; do install_name_tool -change QtXml.framework/Versions/4/QtXml @executable_path/../Frameworks/QtXml.framework/Versions/4.0/QtXml $i; done strip -u -r Attal.app/Contents/MacOS/attal-* strip -S -X -x Attal.app/Contents/Frameworks/libAttal* rm Attal.app/Contents/Frameworks/libAttal*.*.dylib cd Attal.app/Contents/Frameworks/ ln -s libAttalAi.dylib libAttalAi.2.0.0.dylib ln -s libAttalAi.dylib libAttalAi.2.0.dylib ln -s libAttalAi.dylib libAttalAi.2.dylib ln -s libAttalClient.dylib libAttalClient.9.0.0.dylib ln -s libAttalClient.dylib libAttalClient.9.0.dylib ln -s libAttalClient.dylib libAttalClient.9.dylib ln -s libAttalFight.dylib libAttalFight.8.0.0.dylib ln -s libAttalFight.dylib libAttalFight.8.0.dylib ln -s libAttalFight.dylib libAttalFight.8.dylib ln -s libAttalServer.dylib libAttalServer.9.0.0.dylib ln -s libAttalServer.dylib libAttalServer.9.0.dylib ln -s libAttalServer.dylib libAttalServer.9.dylib attal-src-1.0-rc2/admin/macx-bundle/starter0000755000175000017500000126341010664020731016363 0ustar aaaa` 8__PAGEZERO$__TEXT   __text__TEXT\&g\__cstring__TEXT __textcoal_nt__TEXTdd __StaticInit__TEXT&&__eh_frame__TEXT\ h__constructor__TEXT@ @__destructor__TEXT@ @__const_coal__TEXT@ @ __literal8__TEXT (__literal4__TEXT D__const__TEXT` "`X__DATA0p @__data__DATA0% __dyld__DATAUE__mod_init_func__DATAUE __gcc_except_tab__DATAUE__const_coal__DATA[lK __const__DATA@a@Q__bss__DATA`hD__common__DATAt__IMPORT`__pointers__IMPORT`__jump_table__IMPORT|a`8__LINKEDITp /usr/lib/dyld 8 F/opt/local/lib/libpng.3.dylib 4F/opt/local/lib/libz.1.dylib 4}.F X/usr/lib/libSystem.B.dylib XF/System/Library/Frameworks/Carbon.framework/Versions/A/Carbon pF/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices 4F/usr/lib/libstdc++.6.dylib 46E/usr/lib/libgcc_s.1.dylibp P1l4'p1P\&j]\$ML$ˉ\$UWVS,} ]E 0=00urT$$sEЋuЋE$suЋEЉ$IsE<[^_]UWVS$G{$-&|E D$kq$rwqD$$r$rDD$ D$D$OD$DEkED$E$ED$$PrE$$\rHD$D$0D$ 0D$D$H$.<Ƌp$>uj<uxp$>Ƌp$>p $>p$>~EЈp $<<‰D$M L$w$Y?<,Gp$ >p $=p$=p$=p $=Ƌp$=p$=Ƌp$=p$q=ȉ`yT1Bp $@=5p$+=5p$=59|p $<ȍA9x}dDžӥwT$U T$w$X1&p$<9u닕p$<1ߋDžӥd$V<p$;p$;DžDž1Dž0h~Pp$ ;p$: h~Pp $:p$: !Љhy 99tE9~ NjPuwM L$ x$]?UBJB l$9t=}9~ B9`u tWt th9sDžDž]9HDžDž29DžDž9|Dž1 Ƌ9P9fE9 #ui~dL~"J9uBu ~J9r~*dЉLdʉL19LBƄ9r逽tt !11<t 09捵D$؉D$L$ D$-xD$4$I6$*6tt$$%6$6‹tA15t&BBB9ËLBB9rDžTt@T$^5FL$|$$^5F׋9|tEPlH@t$ 5p$49[^_]ÐUWVS9詇D$E$4y2U9jD$M $apuE D$=jwpT$ D$D$L $84wp$6 GuIu Ft+p$ 4M L$aj$u2 8u9 at5D$D$ ‰D$E D$j$q2p$t3p $f3p$X3p$J3p $<3ƃxDžӥp$3p$3yP1Bp$25p$25p $25;|rE D$j$q211\7\DDD;|ƅ~ƅq2Xp $2l4$\L$4$D$4$VƅDžDžDž4$AEPMAA QQ ${%UBB 4$}+MAED$|$4$8;rǍl4$4$d$$`$$\ $$ļ[^_]ÐUWVSwD$D$D$ D$D$E$$"UB BEZD$E $b$\W$.l $@#`$.#d` E$$`B`~EPtl$'dB~l$\$#UBBB Bt$#MAA d$`"`$R"1D$D$>l4$\L$4$8D$4$pƅDžDžDž4$[EPMAA QQ $"UBB 4$}+MAED$|$4$R;rǍl4$4$d$8!`$*!\ $"ļ[^_]ÐUWVSLtD$D$D$ D$D$E$!UbWD$M $jEЅD$ D$D$zX$!E$!EE$u!tE D$X$wUЉT$E$V!ED$E$S!Exu E$+!uVЃɃuf~t}GUBGO B<wE$!E$ <u E$ GGG $s MAA G$X EԉE1GG MAMԉ;W|E$ $GD$ D$EԉD$E$F ؋E̅t Uԉ$ ED$E$ D$ED$E$ MЉ $L[^_]UWVSLrD$D$D$ D$D$E$X`UUD$M $EЅD$ D$D$,V$hE$?EE$'tE D$4V$LwUЉT$E$ED$E$Exu E$uVЃɃuf~t}GUBGO B<wE$E$<u E$jGGG $%MAA G$ EԉE1GG MAMԉ;W|E$1$GD$ D$EԉD$E$؋U̅t Uԉ$ED$E$D$ED$E$MЉ $gL[^_]UWVS|3p} D$D$D$ D$D$E$URD$<$D$D$4$4‰Eu($|$T$uU$U=D5U܍O <#u!T$D$4$‰U@ȁD5D$ ED$$fUBUtExunu<#u!T$D$4$kȁYD5HD$ ED$$UBUEHzy|t<#u!T$D$4$~‰E@ȁD5D$ ED$$EUtt Džvt u E@  UB UBBB $hUBB DžEpp p/OO%ExU'TBT$D$$3uE)șExU'TT$D$$uE)șD$T$$uE)șD$T$$JuE)ș8 Ex$}3…tv$KT$ UB D$BD$4$Exy$)Ѹ$I)ʈV)Ѹ$I)ʈVЈFU;B7$zNeUB‰EDžW|[^_]UWVS|i} D$D$D$ D$D$E$ULD$<$D$D$4$‰Eu($y|$M$uU$U=D5U܍SI <#u!T$D$4$_‰U@ȁD5D$ ED$$&UBUtE@unu<#u!T$D$4$kȁYD5HD$ ED$$UBUE@zy|t<#u!T$D$4$>‰E@ȁD5D$ ED$$Utt Džvt u E@  UB UBBB $(UBB DžEpp p/OO%ExUMBT$D$$uE)șExUMT$D$$uE)șD$T$$IuE)șD$T$$ uE)ș8 Ex$=3…tv$ T$ UB D$BD$4$Exy$)Ѹ$I)ʈV)Ѹ$I)ʈVЈFU;B7$:NeUB‰EDžW|[^_]UWVPEUMEEU U܋u}EE؉€Ut#E܉D$ UT$ED$U$濉uUBD$B$j 1E؃Ec;}}FUB$D$D$ED$U܉T$ED$ EFD$ED$U$. ;}|}t P^_]4P^_]ÐUWVSbEU Muu}Equuu} [^_]UWVS rbEU Muu}ENuuu} [^_]wUWVS ,bEU Muu}Ehuuu} [^_]1USaD$(D$$[]ÐUSaD$2D$$[]ÐUS|aD$BD$$Z[]ÐUc]Ucڜ]UVS%a9Ŝ|[$Ƌt1D$ɜD$4$ɜt$ ɜ MŜɜ ŜŜ~$ D$ D$T$ɜ$[^]ÐUVS]`uAFt$| F,tV(t$Pu[^]UVS`uFt$0 V,tV(t$Pu[^]驣UVS_uFt$ N,tV(t$P4$cu[^]T UWVS}ut FO)ȅu/$(PƋMAD$4$.  ;>}ut FO)ȅt1L$(ƋMAD$4$D$@}|$UB$ӕDžu;ϕ|MA,tQ(t$PE@,GU;BtBuGM;At=At6MAD$AD$<$RƋ<$P}w(E$ Uz(Ĝ[^_]ÐUWVSlEED$E$.]E6lYFlX,D$ t$|$ ED$E$]Et$|$ 6lYFlX,D$t$|$ ED$E$]Et$|$ 6lYFlX,D$E܃ $E}l[^_]USSƃED$ E D$ED$$W[]ÐUSFSƃED$ E D$ED$$D$$)$E E[]kUWVS#D1уVUUU)σt2 t#1tu7777E܉D$ED$ ED$L$4$ ut3tKu`}<8}M MU܉}}MMUU#}}MMU}MU܉u Eu<[^_]UWVSlQj1D$$1t-ji6D$$ bJED$ ED$ED$$1EEЍ6Uԍ6u}EE =<:M}EE =mE<MEȸ =M։T$|$UȉT$ uD$}|$E$EE Euԃ}LU$fu=  $$Eĉ|$ t$ut$$T}ĉf7D$$6D$$6D$$6D$$ 6D$$6D$$6D$$i6D$$vQ6D$$^96D$$FVf'ft$Pǃf4D$$4D$$4D$$4D$$ 4D$$4D$$l4D$$mT4D$$U<4D$$=$4 D$$%$5$PǃfD$D$D$ D$D$$D$D$D$ D$D$$UD$D$D$ D$D$$D$D$D$ D$D$$ D$D$D$ D$D$$D$D$D$ D$D$$}D$D$D$ D$D$$GD$D$D$ D$D$$D$D$D$ D$D$$ D$D$D$ D$D$$ $=S)fF,FKPfF$4$-94$ƅuѸl[^_]UWVS\Kuu0$ƅt30D$4$t0D$4$t>uq1t$,ǃFLTKǃ_SCHǃEME=ƃľtD$t$<$x<$z[^_]4$C념ULE]YUSnJGuD$D$$u+ƃD$ D$D$$uD$D$$+D$ D$D$$[]ÐU&L݁T`]UL+U +Ex;E}x ;U}1]ÐUSnIJt BJ$ ‹EE BBBF;BD‰FB[]UWVSI}E)9:u"E 9Bu;Uu E@EBrJuщE[^_]USHUM s9u 9Hu u[]ÐUVSgHt.1t$P;|ǃ[^]UJt@]ÐUSH$UP[]USGE1ыRt#9utBA BU[]q[]ÐUIE]ÐU]ÐUWVSpG}E tNt+;~tGFt9tDD$<$u:vuDt$<$uvu1GFGF[^_]ÐU^IE]ÐU]ÐU]ÐU]ÐU]ÐUWV0EEEURЉEMσE fU؋EE؃UD‹MEMQtA D$E$QEMU; p0^_]ÐUS4ED$D$D$D$ D$$Y4[]UVS0ESED$D$D$ D$D$D$ktlf$udD$t$$E$;O0[^]UVƋ@t5$MF $nFFF F^]ÐUWVSDM} <@1(9Nu9~uF<$~up 9|ԃ[^_]UG%U _ÐUSvDE@$Rt$D$$[]UVS /DuEuE$&u%$D$$RHCKt#ED$E f ED$$[ƃ [^]US$CE\t8P$ D$D$ D$D$codo$tvea7.P$D$ D$D$codo$tvea}$[]ÐUWVSCƃD$$ ;$uD$D$ D$D$tiuq$tvea4$yy$-D$RVRD$}މ<$fu։4$fED$|$4$=f} tz$,$ED$$$t6t$<$t$$JfE $$ uD$<$,fu<$[^_]ÐU]ÐU(E$#EÐU(E$ EU(E$EU)ÐU(E$EU)ЃUV$u4$O4$UEUE $^]ÐU CUAn~ft]UWV`׍ut$${D$|$4$1эA`^_]ÐUWVS;@/}Љ|$ D$D$$llun|$ D$tsilD$----E$ft<$D}ED$<$fEE؉E܉|tE䉅xnEFD$D$FD$|D$xD$ D$ ssft$<$tt$;u~}<$f1Ĭ[^_]ÐUWVS>93u ?37t$ǃ7ǃ;ED$4$MfE1fEE܉tED$ED$4$tD$ D$TXETED$4$fu!E؉D$ D$TXETED$4$ }؋tD$ D$ sfhED$4$bfEf}DfEEf9E\ufǃ?P;$lj7fEE܉xE؉|.ED$ED$4$xD$ D$TXETED$4$fuY|D$ D$TXETED$4$D$|D$|$ D$TXETED$4$E xxD$ D$ sfhED$4$4fEfuiEPD$|D$ED$ D$ sfhED$4$EE؍~E=dloft=ksidu/ zfEEf;EG+7G;Ef?EĬ[^_]ÐUS$<UƂEEBx*EBz*EEEB|fu S*EB~fu S*EBhttED$ED$$$[]ÐUEt1&:uQy:uA/tQQЉu]ÐUS$;xt#$ UT$$zUE) $*R\D$L$x$D$D$?x$I@$I<$ |c$[]UST:wt$w$[]US":Et @(;wuewt[$@t?$wT$$t!D$rD$>$nǃw[]ÐUWVS9+w$:U+wD$$EEEEEEEEEEEEU}EP@@ EUCQ\E\M؋E؉D$E܉D$ED$ ED$+w$x$xU}EEEuuċ}}ȋMM̋UUЋEEԋED$t$|$ L$T$ML$+w$!*M E\*MxCQX\P\*EXP*E@H e[^_]ÐUS 8u$@[]UWVS<7}Eu E FU;~4VEt$u d4$UE4 VUUU T$UT$$UU NtR~6$vt ǃ6/ZD$E D$ D$D$TXET6$<[^_]US6M UE EU M[]UWVS<6}u EEE$E;UUԉT$D$TXET$U92B (t $kUB $:(U BE(D$ EԉD$D$TXETE$!( 1(8 u ;U|苔$dtu dtD$<$P <[^_]ÐUD$E$ÐUWVSlR5EEȋu1U;u U;Vn9|U1EMԋBEAEԃEt 9 9E$ƋD$D$4$D$D$4$uĉt$EG Uč4H$EOUT$UT$|$D$ D$ED$$nu2EUVEF~ ED$F$FEt$t<$l[^_]ÐU] UWVS_3u} 190u9xu xt 9|1[^_]UWVS 311&XU9uU 9Ptu;T|҃ [^_]UWVS2u9|[($Njt1D$D$<$t$ 4[^_]UWVS(2PT1 u;4td9|11<<uED9|9Xu&XD$ $TPUP[^_]UWVS1ª11 2MM; u E9|݃[^_]ÐUWVSM1}t(uy1t ;8u9|[^_]ÐUWVS 1UB=29"2t/$o1 4$oƅuҋE‰ǃ־&ǃ&D$<$P ־u㉳&^[^_]UWVS,80}udh9tZhTE䀻Tt|$4$Y]t E䉃TTD$4$R vʃ,[^_]ÐUS/Mͽɽ+Q+Ax;A}x ;Q}1[]UWVSE؋UB+EԋM EP+U؋ME EMIEԍAEEE4wMq42uM4U<. A$9|A(9A"9| A&9$…u8 E 0A$9|!A(9E0A"9| A&9$…u5 A$9E|"A(9EE0A"9| A&9$i…uW1 E 0A$9|A(9A"9E| A&9E~T$+…u. A$9E|A(9EA"9E| A&9E~$…u…tQED$$oE9E~ )EMU ) E9E~ )EEu)EU 9}EM9}uԋE 0M؋U E܃p^_]UWV0Ɖ$DžE$4$$GhE@ ItUB t(D$4$UB t$[E@ UrFWIPI4$F@Ivu݀OIE$GIE$_0^_]UWVS,(E8Eu1qIxHv+p+H@u틻47400@ M8L$$ЋU䉓804,[^_]ÐUWVS'jfrtd~vǃ~vFufED$4$Tu4$Yu4$~ $nfED$<$5TuH@ ǃD$<$ЉD$<$Suq<$9gn+B+B@ ǃ D$ <$Љ$$*e[^_]UWVS&u,D$4$WS1D,,|cD$4$2SD|c|c0D$4$SD00(D$4$RD((;E ;0u $X;E4$c[^_]UWVS<%uED$F D$F$f9EEȅ+D$b$\UȋBt*ЃD$F D$F$UȋBF EЋ}ȃ$EȉE̋Ùzx@$Űt4Gt-ЃD$EЉD$F$6E$뷋Eȃ$EF x:Uԋt5Bx.t*t[D$ljD$F$m$‹UȋBЃD$F D$F$1 n1$<[^_]UWV E1EЉEWMQE ;u B#Et7fB9}}*UBMTTTTT T EM;9|E΃4$EtU M M!DGF9|5DFVu $D$$FFMLFML FM FMfL~<$EtU M  DurD$4$XTD$ PL$X|$4$,v5TD$ PL$|$4$|$E$1Y[^_]UWVSPuD$4$~<$L$jE <$t$ D$D$ 4$j[^_]UWVS\EE̓uOȓEЉ$'EU҉D$T$ D$T$ȓ$a$Dƃ̓ēē$ D$D$XD$ D$t$ē$D$D$XT$ D$t$$ǃ8DtD$4$8tD$4$G`WED$D$ED$D$$ǃēD$E$Fft#}Љ|$E$f}u <$fnuE$,=suomumE$4u]EЉD$D$D$D$ D$tpDQD$colmE$&ED$EЉ$8fu EЉ$1E$gdWE\[^_]USrE$y؋6[]ÐUWVSFftcǃfMN t ǃf7~<$|Gt(It 4$xGIF t$F vuTt$q[^_]ÐUWVS<}E EHw.GD$GD$GD$ GD$ED$<$8.wht'F t$3F EGIǃФ<[^_]UWVS\.EE܋UU؋EEԋUUu }GIHvWhUwE܅y EEEM؅y UUEG+E9ENEԉEԋG+E9ENEЉEЋUԅ$E܅E؅E;GU;W‰E }\[^_]E@ tqfEUMEfEEƉD$EfEEƉD$ ҉T$ɉL$U$UB D$D$E$U$GI=UB t$EЉD$ UԉT$E؉D$U܉$UB GIǃN I+뫃\[^_]ÐUWVPE$RUzJuxB E EPUE@ E UBEUrz$>Rt$|$UT$ UT$D$$ExKt@Ku$R@huD$U$3EEED$ED$E $EEȉEUỦUUBKt#BEЋrrz$QỦT$U+t5E@EԋUr+űz$VQỦT$UԉT$t$ |$bt*ExPU؋p+uȉ$ Q|$UȉT$U,tBExPU܋pp$P|$UȉT$U܉T$ t$D$$@E$PD$$P^_]UD$E$ÐUWVS,.EEH<PhUL <P9EuMAD$ $fEHu D$ D$8D$$<=UBh~<$O9Eu<$Pg<vuՋM; u)u@<@u@h@t@u鉃 E$6UD$$P M $U;u1MQEUB t$MD$E$fUU,[^_]韽,[^_]UVSuɻ4$c4$q6u[^]^UVS{u4$)u[^]16UVSIu]4$u[^]5UWVS,}E E܉2t ,[^_]U܉UL>}&}}}}JJVnt 9EE܉$辿U܉$lBE܉$ZAtUt 9EU䉓B$AM܋UU܋$Pwƃމ'ƃމ$g6FEU܉Bt"EȉMǃ2t 9EDMM䋃DEE䋃FEUt$M܋Ut FF19E$MtUǃB,BtǃBUt 9ERM܋Uq?EE܉ut">M܉ +vu$MU܉t">M܉vuE܉D$$ M€uD4D$$4C€uD4D$$t $臼 $ǃ2 tUFuuBu^4$ZJu1J9tAu1RѸ t&4$J bvuۋ$ Bvu聻 'DE$޻fU܉F$MBu$$ME;ǃhU܉t;t9UtMܸuutMܸ\M܉ʸxuIutM܋U[uƃމƃމ<$u vu1,[^_]UWVS,8 u }G4$D$ED$<$E扃HU䉓D+FP+VLt$$f$GTh@ ǃTD$$ЉTt$薵ǃǃǃGǃ$ǃGW1,[^_]UWVS, }uE$lhFftsffZD$ED$<$虸U打 E䉃M+Q(+A$FL$$vD$ED$<$:U;uE;u E䉓 M+Q(+A$FL$$tD$D$8$D$D$8$4@D$D$8$4FtD$$VǃF1,[^_]ÐUVSSD'tFD$$ ;'uD1[^]ÐUWVS\ }E $4Ɖ<$DH)2PPPPPPPPPPPPPPPPPPPPPVPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPFPPLP E܉D$D$D$D$ D$trdqD$tcrcU $EԉD$D$D$D$ D$trdqD$tcroE $詴Gh;dE܉D$D$D$D$ D$trdqD$tcrcU $[EԉD$D$D$D$ D$trdqD$tcroE $!Mu)EU)‰UĉZT$t$ D$L$<$PEU)9uEU)9EGhGhWGED$Gh$} t|$$|$$ҁс@EщсHEщсfEщс"EщсEы % Љ G|$$E;ED$Gh$} |$$h;u`|$$ǃD|$$ ޔuD$D$$h1O<gt&U܃SF;D$D$$͋M܉ȃCF;։z~Lt4uE f=vftf tf uE爃wǃvƃwǃvw6;n=M1u Etǃ~t ǃ~}t ǃ~l@t ǃ~[t ǃ~Jfy ǃ~9t ǃ~( t ǃ~%%~~u E 9 Eǃvƃw=%%@E‰HE‰fE‰"E‰E‹ ‰ <$7NjwuMąt|$Eĉ$;1\[^_]ÐUS$EE胰r;ru+@rB$r…u㋃rrކt,ruƃrƃrކt fE/E$*rEE$[]USP$D$*1$[]USu1"$@xD$D1[]US$@xD$D؋u1[]UVSwD$F$vu[^]UWVSiE@$ $,@@ @)F$F(U$a5PhtqBFFrAhMNqhF =F=@ ǃD$ $ЉD$u4$ƃ$M XE@Uzt'BxDž;B| EMA\q\NdeMȋVeMD$D$D$D$D$ E@F)T$UB+FL$$ DžCD$D$D$MQT$AD$ T$D$ $ǤDž u}EԉD$E؉D$E܉D$ ED$ED$E$u&MQ<@u9u4DžDž2uV<Ѓ@Dž DžuWu4$菤E7UB4$w7EDMA7~*ǃ7dQD$$hD$ ẺD$EΉD$$&MQ<`t/@u*D$$ءD$$uV<u@=t@t D$ `t D$D$D$$芡EGxhG =G=$Ƌ$D$UT$7T$ D$t$$薢$諢Ƌ$赠D$ML$7T$ D$t$$O$dƋ$nD$UT$e7T$ D$t$$Q$Ƌ$'D$ML$7T$ D$ t$$ut$D$K$t$D$#$ =@uu4$+fu4$Et$讴 t $ 5Ut$脴$@tƃD$$\MaFd^]UVEu H`PTPT194t9^]ÐU0E@x]UWVSEx`11ҋM;y`֋ڕD$AT0$VűMAT4} Q} R~(} TE;x`|$URul11u MAuXy`MAT9tC} Rt } TuFF9B}BB;Fs$c1[^_]UWVS,E܉׀xHw‹|$$P EBwԔD$E܉$UЋU+Bؔ0U+BؔU܋|$$P E䋃ؔ0Etu&ԔD$U܉$Gu E܉$膸E,[^_]ÐUVu ~It`D$4$ t 4$WEM9MuE$UR`UԋM\;8u4X2@ D$<$ЋX1${G<uUT$<$P EM9MuqM9t9E9x`NUB`"M@<t}tU|"E;p`M9u|[^_]UVS uED$ED$ED$ ED$E D$4$HFKF`FTFXv\Fd#j [^]ÐUVS {uED$ED$ED$ ED$E D$4$aGFKF`FTFXv\Fdi [^]ÐUWV }`GTGTEG`EG`GX\Gdt$ Gd1E;zu t$P9uu}~EE ^_] ^_]UVS}uF4$V4$d u[^])UVSGu[F4$ u[^]( UVSu-F4$u[^] UWV}u G`WTWT1;4t 9v9~r;wXuGXFG`G`uGT҃4$赅wT ~4WTB;O`|Gdt$芆Gd^_]ÐUWV }E PtXPUJ`ЃTuFT1 u ;4t9|E9EuG9O9U T$M $Eu FP`upTu6UrT$ۄMATt 0u p U pMQ`ZBuD$uFT$貇FTV`֍ ʋEPTB9|UBTM uV`BUB`Bdt$IMAd ^_]ÐUEP`T$U T$$ÐUVS uED$ED$ED$ ED$E D$4$ DFJFZFYFXFTN<@ [^]ÐUVS iuED$ED$ED$ ED$E D$4$O CFJFZFYFXFTN<@ [^]ÐUM1҃} ˆQYa<AX9u1 QXyJt $ $iUWV D$E$Ur4$1E~`1$U9EtxHfuD$$b9u؃ ^_]UWVS}HXtwDw@XtZtGZGJ~ GJt$D$<$,uBXtE FEFEFEFEF F$F(F,F0$F4F8FPhFF FHF<FIFJF@1FD1FKFLFtu E[^])[^]ÐUUE BEBEBEB]UWV uM }U9Nu;~uE;Fu ;Vu1(T$UT$ |$L$4$P4$X ^_]UWVS<U} EE܋MM؋EEԋMMЋ{ w੨tEEB@D$$8Z$}D$D$$<$薑Ɖ<$tE<$QE<$.)uЋUЃT$ U)UԋUԃT$UUT$E܉$^EE E<[^_]+<[^_]ÐUE @<t1 @u]ÐUWVu} F<tF ${Fu?tME tMtU؋Et E܋M1(^_]ÐUWVS|ƃXBUM u uI:-uz}B<-tu ƃYBHEZtEt|$E D$4$Uuމ|$E D$4$Tuǀ?t[^_]ÐUVS uD$ ED$E D$4$d9~}0$n [^]UWVSLuE tJ>uUT$$)yL>F>FEFEFE܋FE؍E؉D$E܉D$ ED$ED$$zǨt +FE t +FEF\Eԅuv\t#FE؉D$E܉D$ ED$EE؉D$E܉D$ FD$FD$4$RUԉV\B>tFpǃB>NpuU$:Fp>>tD$4$Cǃ>>V uFpD$4$!L>uƃL>:o$v4$PL[^_]ÐUWVu~t!M@ @>P $t!U@@p$M1y D$D$ $CE0x @$c'UBBкǀuEǀǀuMǁ  $< E$UB^_]U]/U].UWVS,ޔuF- ;"Nj4;;;;;;O;4$PF4$PF4$F$t%+F(F,&t4 t^,@r BD$bPTU䋸u u uCRu}GuBu F(1PHEBz@oD$4$PF(F,dt= t2<t%@r BD$4$PF(F(F,F(F,F0F4F8F<?F@FAFDFHFIFJFLFPFTFtFXFYFZF.u,[^_]@FB4$1,[^_]UWV }E EG-v@GB<$<$Bƃt#u}t@3<$<$+ ^_]UVuF- v@FB4$@^]UVuF-v@FB4$@^]UVuV3w?~@u9Fx;F`s@C4$4$PFxt,5tt@FB4$ȉ4$uF4$P4$*^]ÐUVxHup ugx(uax$u[x,uUxduOzuCJTyu:~u.z (y u"~ uR$;u;Q$u ;V$u1^]UWVS#Ƌ5 t't$T$4$$P#Ɖ$^$55 Em$9[^]6USrDŽll$[]USrL~$Lt$9"l$P[]UWVS,6rMu }9~PU~Fu0fMfu9fEMfET$E$#1,[^_]UWVSLqUEU EUE UE$Z!U MEfEE։D$EfEE։D$ ҉T$ɉL$4$t$t$<$"ED$4$"EUEUEU+U EU+U$4$ E$u1L[^_]ÐUWVSLpEEԋE EЋ}uzJ.uzD$:$!F*EG*E*EE*EE؋E؉D$E܉D$ED$ ED$:$i!zJ.uzE EL[^_]K!L[^_]UWVSoutt$4[^_]UWVSloEEE EEǃ^E EȉEЋ}}fE7t t u~9}sMU$tFEЉEE+ED$U$]EXE؋M 9Mv f.EEȉEE؅u UȉU uMȉM+E_GEԋU9Uw uVE+E D$E $7%y ‹Eȋũ@ 9uWM&uQUGO&uM&M}Eȉ^~uU^4@BUuM MȍWV@u?E(t8WGt<@t EȉEM@MȀ:tWWEGMȈMȉ‰#EЉEȋ}1D$UЉ$C]EXEE EU )UEMl[^_]ÐUWVS#mƅƅE({}pE8@@<@MtC€uD4D$@$*u 9r/u€t4D$@$t.(UUnD4҃EM9MNEuuDž DžD$@u4$ …ti9v`z@tZD$T$$/E9ENE‰6DžDžDžDžMuDžuE+*EDžU؉}䍍@u x@tU(uOU(T$ t$L$|$D$ D$T$$uu"uDž\tRt:uE$u1E$HE€t"uu))Ή=Et E&U))ʉEE$E U$B Dž M$IEt U >EtUU u$+V+$UE$+P+E +D$T$u$4$mF DžEUUE+*EE LOM(L$ E%D$E؉D$ED$D$ D$D$$uM*f.vf(X,Љt u NEtX,)+,X,U)+E 4+|$ t$ED$$U tZ9wRE9sE+T$$ݝ|$ ,D$D$gg$U t!<@uy@uU}$t|E tvE$;P} HEtE 5EtEE u$+F+!UE$+P+E T$D$M$ $EtM 7EtMM ++U++M tUU+"EtUU+U‹GD$t$t$ T$L$$zEtE >EtMM +*U++E  0tUU+#EtUU+u0GD$D$D$ T$L$$yĬ[^_]ÐUWVS\d}E EUU܋uEE؋UUԋE EЋU$U̅t?u EЅt.E؅t'E؉D$ t$U܉T$E$uEuE€UtE؉D$ t$U܉T$E$ỦT$ EЉD$<D$UԉT$E؉D$t$ U܉T$ED$<$}t \[^_]%\[^_]ÐUWVS|cut>uE UY UƅƅEuDžDž1G>@F<@tC€uD4D$@$su 9w,€t.D$@$?t'"zD4؃EuDžpDžD$@4$x…tD$1E$[]UWVSPE Et} UuE )4))ƍPѿQUM )U4))UƍPщE)Ѓc +EcE8€MEEE[^_]UWVSlOEE} uMuu u8  6*g^*^*M^ȿ?|$L$ T$\$R$MU]|$ML$ UT$]\$$l[^_]USNE UUU;t[]ÐUWVSNU} u uBu[^_]B uEu} U[^_]U]ÐUV$uFD$F$kF$D$FD$ED$ED$ED$ ED$E D$$T$^]UjPEU U]ÐUWVSMUE EMM}uMuBt,B Mu}MMMM U[^_][^_]ÐUWVu} FD$F$sD$ ED$|$$VtB;~VMB^_]USD MUB<@t B E܋B$EB(EB,EB0EB4EB8E$}uE$EEDEEE܅uEt4UED$ED$ED$ ED$E D$E܉$ȚD[]ÐU(UBKtt(D$ED$ED$ ED$E D$$ÐUWV0Ep@J$@ ƉuE@EUBJ$S )E} ~UBK tEmEx@J$= EEp@J$ +}|$UT$ Ɖt$ED$U$ 0^_]ÐUWVSL_KD$ D$D$E$%U-D$E $DžFu܋T$D$ $?ot$ T$|$ $N~uFT$D$ $t FO)ȅuU܋MQEAЃyBE$ NjExDž9L$D$$0tE$ZED$FD$4$7~Et<,u>t9|$VL[^_]UWVSLID$ D$D$E$U+D$E $ǰDžoDu܋T$D$ $ot$ T$|$ $~uDT$D$ $t FO)ȅuU܋MQEAЃyBE$NjExDž9L$D$$tE$ZED$DD$4$~Et<,u>t9|$L[^_]UWVSF=D5tsFwD4D$4$)tFDuD4 D$4$uF t뛃[^_]UWVSl3FD$E$TU(D$E $$DžDž."!\yQ€ t0"yPЉ txu(D$)D$<$yDžDžƒ‰uCDž$Ѓtϋy"t E99~b$@D$D$$.t$ <+F$t$T$$0D$D$$$oUBBB$zl[^_]ÐUWVSlCD$E$4U%D$E $˪$DžDž."!\yQ€ t0"yPЉ txu(D$)D$<$yDžDžƒ‰uCDž$Ѓtϋy"t E99~b$ D$D$$t$<+F$t$T$$0D$D$$$OUBBB$Zl[^_]ÐUjB]UZBtÙ]U]ÐUWVS,?EEE EEE܋}ut8 $8$!|$ E܉D$ED$E$u 4$LƉ4$GEE܃EEE EE,[^_]UWVS, ?EEE E}uEu$$}u}EE EE,[^_]U$AE@]U AE@]U@E@]U@E@q]USU>EQ@LuM D[]ÐU@E@ ]ÐUS >E@U DUTUTUTUT[]ÐUVS=UE R@ 0 2L0L2D0D2[^]UWVS=EU UUU}uUt,@tUu}EE UU[^_][^_]UVS '=u E$m#4vE D$ED$ ED$ED$E$#ǃ# [^]U(UED$BD$BD$BD$ BD$E D$$gÐU(UBJȄt/B@D$BD$BD$BD$ BD$L$$!ÐUWVS,D<@t E UE)EEU |EUDEU$|$ED$U $蜻EEUBU$DuED$t$U $RE EUBU$|$t$E $mE~PUBUE$ED$UT$<$ܽmmu~U,[^_]UP=EEEEE EEE R6E]iU =EEEEE EEE .6E]9UWVS,|:xt SE ;UM,U!EU|EU DEU$ut$GD$E $ιEUBU$zED$|$4$葼EUBU$CED$UT$E $ZEmE~TUBUE$ED$|$U $E mmE~U,[^_]ÐU;EEEEE EEE 4E]eUT;EEEEE EEE z4E]5U$;EEEEE EEE V4E]U:EEEEE EEE .4E]UWVSẺD$$PEE؃E܍FEE܉D$ED$<$:D$L>ẺD$$>E܉D$FD$<$D$=ẺD$$E܉D$FD$<$ΩEEЃD$ EԃD$FD$<$蹨D$ẺD$$8XE܉D$t$E$VEE} E؃E<[^_]2UWVS<}u EEEE܋EE؉D$E܉D$ ED$t$<$D$>E؉D$$EDED$FD$<$蹤D$L>E؉D$$ED$FD$<$胤D$=E؉D$$LED$FD$<$MEiE܃D$ ED$FD$<$8D$D$$8#^EEЉE؃E܋EԃEE܉D$|$E$ 47FED$|$Eԉ$D$?ẺD$$E܉D$t$E$财EE} E؃E<[^_]鐥UWV0EEE E}uEED$t$ |$ED$E$Etu}EE EE0^_]=U]1wUWVSL>"Eԉ׉MЋMu E9|Q9V<8}EЉE)щM܉)9OS}u E}U9}f888D$L$t$ t$ML$EE܉E)$U9}8889D$L$t$ t$UUȉ)D$M $U؃}]9}Mԅ9} 88D$D$D$F@t$ t$ED$UU܉Ủ)$N9} 88D$D$ l@D$t$ t$MMȉ)D$E9} 89D$D$D$ l@t$ t$UUȉ)D$M $9} 89D$D$Py@D$t$ t$ED$UU܉Ủ)$`9}}")lj|$ M܉L$ED$E'|$ )E܋U܉T$ML$E$AUԅt)E)ЃD$MDD$Ẽ$})EȋUȃUUDE MML[^_]麡~bEԅt)E)ЃD$EȃD$MD$莞}t,)E̋ŨUUU MDEL[^_]\L[^_]UWVSEԉD$$?zD$t$E؉$U1D$t$E$U1D$>EԉD$$D$t$E؉$U1D$t$E$U1D$?EԉD$$D$t$E؉$U1dD$t$E$U1FD$?EԉD$$8+fEu E؉EUܸ<[^_]UWVSUVSujN tVt$P4$>u[^]飧UWV}E 9GuE;Gt-$$EƋED$ E D$GD$4$^_]ÐUVuF uF$NFF FEJ^]UWV uE E}F uF$ FF F}MM EJ ^_]UWVPEEu }UUEE܋UU؋E EԋUBP@EutEE܅u胸E܋E܉D$ UT$|$4$u؉uċEԍ4UzEęE)ЉE)ЋUUUU‰UE'ED$t$<$讪Uzw;u|ߋGEU9U}uP^_]dP^_]ÐUWVS uE}F~F FFFhU VF uiFu{F [^_]ÐUR]UER]ÐUUM t9ut9uE U][E UWV Eu‹$PME@hEMQl9Et9E/U$PEt(EMUT$ $P(ZM+QxUߋEǀ@x@l UML$$PƅtRUt$$P()EuM9MTE1UML$$PƅuEEUt$$P(ljuMM}}9}}UML$$P E9E|?UML$$PƅkUt$$P()EEMAhuE맋E+EMUBxEBlD$U$ ^_]UWVu} |$4$;u E;u E;udžF|^_]UWVu} |$4$dED$4$U9u E 9Eu9u E 9Eu^_]UEJ ]UWVux(4$PD$4$׃^_]UWV }<$PEt$<$P(Et$<$PƅuߋE ^_]ÐUE@|]ÐU]ÐUUE 9]ÐUWVS,uED$ED$ED$ ED$E D$4$dD$D$D$ D$D$$YD$D$D$ D$D$4<$rYFJFKFlFhFtFpFxdžFLdžF@FD:GGHdž`džƆF|dždždžu,[^_]UWVS<UBJuMq<$]ƋE 0Ur<$`ƋM1Ep<$c)ƋU2Mq<$f)ƋE0U¤B<u M+lMBKt M lME8yMpu M+lMBKt UlMM1y[^_]UWV0E$1ED$ED$ ED$ED$U$}E+xx5Ut$$P ~;} }EE9}Ut$$Pƅulj0^_]ÐUWV0ED$ED$ ED$ED$E$MUzx}苲.;u u,Ut$$P )NjUt$$Pƅt10^_]ÐUWVu} |$4$ftD$4$Z;u E^_]UWVS,ED$ED$ ED$E D$E$ED$ED$ ED$E D$E$ZM"K}uƤFKtE )E EL$T$ |$D$4$B"KMFKtE)EET$L$ D$E D$E4$,[^_]ÐU8ED$ED$ ED$ED$E$EUWVS,uED$ED$ED$ ED$E D$4$_D$D$D$ D$D$$TD$D$D$ D$D$4<$TFJFKFlFhFtFpFxdžFLdžF@FDb GGHdždžƆF|dždždžu,[^_]UWVSaE$FU$P0EȋM $P4E̍E؉ED$U܉UT$ MML$EED$U$EEMME4E EUzIyMzJuMQJMA@D$AD$AD$AD$ AD$T$ $QEUtSuBhuM;M~@UB<tlBEpLEȅuUMȉL$$P@t$ D$|$E$U|$$P M|$ $PDžuuƊt>EpLEȅuUMȉL$$P@t$ D$|$E$"U|$$P M|$ $PDžuUt D$$M|$ $|$E$E؉D$E܉D$ ED$ED$U$x>E؉D$ E܉D$ED$E$輒֊8tM $5E$ZƃZMQHtMD$ $D$D$E$ZUBLJ<$D$M $[ƃZƊtE`U|$$P@ZD$ D$|$M $!;U;tt|$$P@t1Zt(M9tMT$ $PE6UBLD$ ZD$t$$Mt$ $P9u?UBLD$ ZD$t$$K;utMt$ $PƅuƃZ)UBLD$ ZD$|$$D$|$M $ZE@LH<L8U9});Z}!MAl)Љ¸H;Qht]Qh;QlCE9~L;Z~DUrl)Ƌ$P4+E9OHM;qhtqh;qltD$ $UBHRD<|$$E;Z~IMu1MT$ $PƋEЅu E}UMЉL$$PEfEEԋuUD$ ZD$t$U$uZtMALtI< $Ut$$Pƅt;uuEЅtfEЋMXUʊM;Q|AA9|$ $9ZMALD$T$ $ZExHuD$$UZtMI<AL $ E@Ltu$kUzHv֊0t $%L1MMM̋U|$$MALD$|$ $UBLD$|$$L[^_]UE,PTHҸH;QhtQh;QltE M]/]ÐUVS1D$U$Ԉ%RD$$豈!RD$$袈RD$ RD$D$$聈[^]UWVS`MU u*00Q 0Qt>t7QO*Au牻Q)򉓜QB΁ t,E RUt/utNQQ Q*QE*QGQ*QE*Q*QQGOQ*QE*Q*QQQQG)QQǃQǃQ[^_]UWVSp}U u,0B_0 $ #`/1?Mtn)EDFtWL3Ptw Nt@OuyaQtTujb.`$$蕅G$p161.0&P0//4/0/$EGhtp$[^_]UVEu MUUMu E^]eU诊t"覊UT$ U T$UT$$3ÐUƁN]ÐUNu#ƁNT~6h~U EPP]ÐUVS OulD$FD$FD$D$ D$D$4$/$lD$/${D$D$D$FD$FD$ D$D$/N$l [^]ÐUWVS\ lD$.$zED$ ED$ED$nM$mEEV}8~MzMp. p$iuR}D$V}D$EЉD$ EԉD$E؉D$E܉$W[MME܉EEԍ+M9O;}L}ĉ}ċzMU~&R}1 }>M؉E9~%)p}>M؉E9~ E)ƍv9LU|$ML$ t$UĉT$M $P\[^_]UVS)LƃL Lt8u Ltr$Ph Lu"$z|Ɖ$ L LD$ L$D L$ L$@ L$RD${$RƃLƃL[^]ÐUVSQ,E95Kǃ,D$$D$4$ܛ5KtB<u$P9Kt5zt ƃ9KD$ t$Z,$H[^]ÐUWVS,}EEEEuJ+t>t+E,[^_];rJD$\E܉$D$$+E䉃JE~JrJzJt)vJt$PEE܉EZ,TZ,f.szE,[^_]avJtB<u$PZ,EE܉EE,[^_]9+,[^_]UVS3u$tPPu@*[^]ÐUS$MX*ȅuE$[]z9t8xPu@܋@PD$AD$AD$ D$D$ $$[]UWVS\E`xUEȋwEܩ@t }*3wth\PD8g,} u&UĉT$$'dx}}<U}]9uJ JB9uC9 u.EĉD$+U$'dx*udxUE<`u}ȫt} u@&}'u}`Uǃ*^딋Eǃ* <uU9uEE:uE;UuLE9uDUĉT$+<$&`xdxE}yAuw=t= uǃ*E@t)}xEEȋ<B*dxtEȨt<tǃ*s1\[^_]UVS uED$ED$ED$ ED$E D$4${ :N<@FJFLFTFXF\FDF`AuFdFhF] [^]ÐUE@Tt E]T1]UVS uED$ED$ED$ ED$E D$4$a9N<@FJFLFTFXF\FDF`tFdFhF] [^]ÐUEU `<9PXu1PX]ÐUVuN V4yx$Bt $uV܋t JBxubŃ$^]UWV}u tsFtu O<4$|tO<v<$S ;wXtO<wXGLt'<xtVtF D$<$<$w^_]UWV0u }u E@XEEEEUBT)MATUB`tb>t%EE9E1fD1/1ыEDE9E~]T$4$x tc9UU;U}21fD1/M M}эL9M }ED$4${x1jD$/4$cwt1уMEMATUBTEE$t$Q9E0^_]ÐUWVS<%D$D$$sDžDžEpTEpTG@tst(D$D$$r D$D$$rE D$$ruGD$/$ut$EpT$ƅ܍D$$qt D$D$$rD$D$$qE D$$q\14$O91<[^_]UWVS,UB\<vLBTu E $OEUҍ41UBT0t$o$9}uE;Z!u ǃZ!UBTt$pE@T@X@\,[^_]ÐUVS+u34$,4$u[^]oUVSui34$u[^]UVSu;34$u[^]UWVu} 4$~T~X^_]ÐUWV E $CNE<<$toƉ|$U T$$xoE$RUrTrXB\Mt1VtUV $9Eu ^_]ÐUWVS<}uƃ==%E!]v EwKfǀulUD4D$M $pt%Eu=U܉U)=Mǃ=Shiffǃ=t+ƃ=AE@tUCmd+BUtMOptiAon+MtECtrlf@+EM#w\UFփ}~!gfff)€0EPƃgfff))эA0F1EU؋UMU; uM9Mw>DoEp9uʋE-=w4EKP_E$UBЃ1M؋DD$E$m%$|nUЃE܃<[^_]UVUtatZ<#t1:+u :^u t ztD$D$$l 1^]ÐUVSFMk0t6u0t'A&uQt&uA݉8u1[^]UE@<@t @ E]1]UVS;uB߃]vBw~ _@9t1j9u˃[^]ÐUWVS,u }9D$9D$|$ t$D$E$ek~!~~9w1,[^_]ÐUWVS,ju }v9D$z9D$|$ t$vD$E$j~!~~v9w1,[^_]ÐUWVSu8D$8D$D$ T$D$$Tj8BN8؉8~? u@HJT$ IT$D$E$jƅK881.H VP FAFAA;|~D$D$$iDžg|O0~8~8u$;h‹F~D ptC€ugD4D$@$%iuwu€ugD4D$@$huugD4D$@$hutbcu]멉u|D4D$@$6hȄuGD$ |$T$4$[fu'L$ |$|$E$gG;8$eDžz8~1I1;|*rH;|փ;tiD$ D$D$$hƋD$(D$$D$ D$D$|$D$D$ D$D$$h<$[h4$bh*E E*EE̋*EЋ*EԉD$T$ UT$M L$Eȉ$}uȉu؋M̉M܋UЉUEԉE䋽|$t$L$T$ D$ah$g~$f<$g$c8~#1D t$cu߸1Ĭ[^_]ÐU]U]U]UWV0uD$E Ɖ$bE%gD$D$D$D$ E D$t$E$`hƉ<$f0^_]ÐUWV0uD$E Ɖ$,bEfD$D$D$D$ E D$t$E$gƉ<$\f0^_]ÐUWVS|肵u4$gE4$flj4$cE4$g&fED$ ED$ED$$fED$(D$$D$ D$t$ED$D$D$ D$ED$<$eE*EE*E E*EE*EEԋED$|$ E D$ED$Eȉ$zuȉu؋M̉M܋UЉUEԉE}ĉ|$t$L$T$ D$`$e&|<$eE$d}<$d|[^_]UWVut$4$?flj4$+ft}^_]`^_]UWVSгul0 H_,0\_/?^D$ D$$D$$el0H_\_Bl074$a[^_]xUS2$x/~ /-N^D$ D$%D$r$'e//^N/^[]ÐUVuFht@t$|u^]KUVSyu#4$u[^]UVSKu"4$u[^]ԡUVSu"4$V4$謡u[^]^UWV0u4$]~hWu"tFD$F$DGFIFItDG $AG Gt#$$A4$P54$PE t $pAED$ED$ED$ED$FD$ FD$D$$L?Gt,UMT$L$D$ED$ ED$T$ $U0^_]UD$E$ÐUWV0}GEWUED$ED$ ED$E D$<$gwht&FtU;WuU;Wt$IF0^_]ÐUWVSx!ML$ED$4$u=;ur͉0^_]UWV0E} MuEEEE9sPxUMED$|$4$uUMEE9EuUD3ME(>xED$|$4$DuE9r؋E0^_]UWV0E} uuEEEE9s]xED$|$4$quE9r؋E0^_]UWV}E uE1.E1E9EsuEuwq9u wD7wq9u vn $? D9링vHw;q9u v@  $? D9$? D9$? D9\q9u wMEY 9$? D9$? D9Ew =w-=wM9Mrʼnȃ^_]UWVEU‰UU u1v}7r1;MsxE09u wD0E~}9} v+ }>?ʀT>uxE0u;Mr݉^_]UVSΞǃ6$sLƅt8u2B$ZLƅt8uJ$ALƅt<8t7RD$4$PuVD$4$Pt[^]UWV } :D$ D$|$U$k=w5$IFD$ T$|$E$Mty+ED$|$4$E~9EULЉU9rɋE0^_]UWV0U$uh(A8A <A4A8A<A$A@ADy A 1EyHMǁ@ǁD8v'u@$B@4$UD$B$4M8D$A $4u<dž@uEE(qq4y y8Q4UQ<A$A@A1D։QDA 1D׉QHEM@ ~@  $Uu@M䉌D@݃EEEu;$U}E(UJLuxJMwuuU@4MH$uFD$D$4$ƋUMD$D$4$FEpLEMU;$_$u4$@0^_]UE]UWV }Ex<$Pƃt<My   ~@)@<$t@B<$$ ~!@G$B@ <$LJLJE^FEFw F ~~@<$M9L‰F 9L‰ETE;G$|LJEF$D$GF$1FD$G F $l1F D$GF$P1F(D$G F $41F,F0FLETM;O$eD$G $0$;G$| t @ @E@fMyu@#<$<$CE@xtx t%@;<$G|9~ ^_]UVS裕u,@@@4$P4$dž[^]UVSUuFD$D$4$P,PP @@@[^]UWV0E@E0@}舗u<$UR H}7G>NƒuE$UR uVǃuE$UR uVu艆u4$UR uVuF u4$UR uVuF u4$UR ouVuFu4$UR BuVuFЃu4$UR uFEUB$qEJ|BUBAB AB$A @dD$$PU苂x t@:$EH tPtH$U@ $UB$@9t@ $}苗u&OG$T$D$<$E苸EUWEuu4$UR E0PUVMuu4$UR uNrWG ȃuE$UR E0@EGEJBGAG AGA U@eD$$PETUE;P$@ E0UP10^_]UWV Ɖ׋EȉE k:JzF]zISzFIz?ƆBBBRG fW G ft1@wBBD$4$PJBAAA A@WD$4$PG G t+@ZG BG BD$4$PMG W @9@XHvj?JueFu_XuYXuSuMG<t<t<u!@l;@m0@n%@YGBUP@MUPD$4$P ^_]UWV ǃ :Azdzozbu}zeuwJBMJ B B E7BRЋBEFNEF @LD$<$PƇU #@NEBD$<$P ^_]UWV0E@E܋@uE$Q *M܋A2uE$UR M܋AEzDE ~ EEOEE17EuU$MQ E܋8PUmD59uwċu+u؋M|=t3=t?@D|B $E܉8UP(6U4$M؋E܍U4$M؋EɋMAt$ $P10^_]UWV@EE؋U܋MIM9}AEu"U$Q M M}}E0ƒEuU$MQ j}GEUDEyE1E5U|=uM؋q\ }؋;uGuUBVT$D$M $PE}|U܈BMJr U}܉WE؉ǀu1U؋M܋I ME܋PUE~EMUQM؉u%E$UR MM ME@Eu1ҋ})ω}#}}}E9Ut9Uu؉u;}yE܅t>E u U܉ tM܉ }܋}E܋@U)ЉEMǁ}|=tM=t\@[|BEEBD$<$PUEMHE.?}<$MUEӋE$MUE뽋UBML$$P1@^_]UWV ExWuU$W W0EUuM $W tpEWUMtU@[M|BpD$ $PEEG~UBt$$P1 ^_]UWV E@E8pu:U$MU싂@M9qu$Q E8p=uuU$MQ E8pЉU $u.u4$dR p d hdph:уuM $dV * V4Au"E$dR  dQ`M@gPD$ $P`D9u ~~M@  $`u$Dž\(L)u4U$dQ Dd6d@:ЃuM $dV VMQ$1 ;>t"T9|U@x$L1FFUPxFBFBM@hD$ $P\L`9\u4E$dR  d dvulu4$dR dVqMp׃u $dV }d0xMtxJElBUpAtAxA @iD$$PM@A|FdGFǁ|U@UD$$PMǁ|u.u4$xR x x~pU@PpHD$$PEDžt1E׉Pu.U$xQ xxzPD2tuluQE؉AEىBEډBEۉB E܉BE݉BEމBE߉B@VD$4$PQEAEBEBEB EBEBEBEB@VD$4$Ptt9}U@$1Qu.M $xR x xx5;t|+tlptppUpEpvU@pH$u E$sE׉EۉBE߉BEB EBD$D$$'lu.U$Q 6x|ƃU@QpHD$$P~M@p $Eu$FUM3|u.E$R  ~0ƒu"U$Q Y@x 3Mu4u4$R  ~3f F9Eyh~yDžU QAFBFBFB FBF BF BFBM@]D$ $PuA|u e1[^_]UVu|u ttP9|u3@b@BD$4$Pdž|FT$4$PtBB1^]UWV u E|‹@yxpD$$PFEFEFEu~&0w";}t;}t;}t ;}t U@axpD$$PttuEǀ|EtU|c1 ^_]UEǀ@|ǀ|B B Bǂ]UWVSuuM UF@09LЅt0u wYRt, w= 6tt1ҍEuMOW\?E w MLT`@DHu[^_][^_]UWVMU }u~+ w|@DPM^_]^_]UWVSt}GD$D$<$AAqA\Ⱥp@`uYAATLJG|LJ|@ @ @ǀ[^_]UWV@EֈMBEBEER(U+UF9OЋMNF)9N‹V)9NЅ~q}}t)|$ED$ UD$ED$U$V,'|$ED$ UD$ED$U$V(}FEF9Ed@^_]UWV@EֈMBEBEER(U+UF9OЋMNF)9N‹V)9NЅ~q}}t)|$ED$ UD$ED$U$V,'|$ED$ UD$ED$U$V(}FEF9Ed@^_]UWV }EUUuƋM ;qw ;A wu@<$U B9ErB9vcM y"u@E<$E x!t‰U B!ME ;HvH1M +QI‰A1ɋU E H9vw9Mv }uM!@<$M}tU rE x tEPU@))Ɖu4ML$U $ ;}rހ}u}u@<$M A!E @)EU M ^_]UWV }EUUuƋM ;qw ;A wu@<$U B9ErB9vcM y"u@E<$E x!t‰7U B!ME ;HvH1M +QI‰A1ɋU E H9vz9Mv }uM!@<$M}tU rE x tHPU@))Ɖu4ML$U $ ;}rހ}u}u@<$M A!E @)EU M ^_]UWV E@E} vU@M H$} ucEpD~"tF"F(D$U$V0v$uߋMADqH~"tF"F(D$E$V0v$uߋUBHM UDȃE9M|EM;}|}uUzdu;PMHuF BF$BF(B }@^D$<$!U@_MHD$$PuVFdD$ }|$D$4$REEE܉}EU܋R UE}EUUȉEEPEؙ}ȉEUUU#ЋMЋuMu 0;U|}}E9E}1EEU9U|EEMMuЋ};wdZUEPMHLu@G\DEԋ1!UBMԉL$D$$PF@E;xd|ԃ|[^_]UWVSLrZEEċFUĉBtFBpBLtCr"h@0UL[^_]Măydu{FEăxdu)FF0~uEv4UċUUE8Mq U1>B 9u1E̋L4MЅt+MЋUJ4EUUԋE;Pd|'9MMċAD$D$ $E EEEM4эB@E )к)‰y ؙ;MuуE}K뫍@FFTNDuLMċA\DE܋E"UċBM܉L$D$$PG@EUE;Pd|ЋMċA\DE1EȉD$F@$U;zd|L[^_]UWV U@ER\UEYEU 41CVF‹E Q fEf9}uEU9U| ^_]UWV`U@EERUE@EUR UE@EċURUȋE9EUEUuEEĉE}EE&U Ufu%;U~E@E9E~҃E9u} U29u~]uEUE}U҉Uu+UEMf(;M~E@;u~Ѓm;}}uU9UEEEuEUE}UU$MUfu%;U~EE9E}ԃE@9u}Ur9u~]uEEE܋uEE؋}+U܋EMfA;M~E9}}Ѓm@;u}uU9UEEEEEԋuċUEUE}!MU f9u$@9U}9}}ڃE9u}Ep9u~MuċEEEЋ}ȋEu!MU f9ur@9U}9u}ڃm;}}uċU+UE+E M+MʋEPUEŰEE1XUz}몋Ep uUz}U U f99U}@9E}׃EEE9E|EEč<EڋUr`^_]UWV@tp@tp}tHprMqvp  $Dž,Dž(TNt(49~++9}++<69|++<61ҋq(49~+@"9}+@9 |++vNjA(49~+9}+9$|++7(x9,N,,( 9(1Dž(,;x| x; |Ѝ||@9uDž0xx0x4Qt40)Ǎ ?ɋB)ƍvR4)‹8<44@@Dx`ddX`\8h@lDžH\XhD9~4uϋlh lX\Ht<8<`d `9090$ttTPpMp LPDžϋLT2fu샅L@uP TM;Pu@^_]UWV@U@E܋J\MEEu <UEEkEGEGȃEȉEԋuE܋Eԍ4Bf>u $MUE,UM Uu9uuEE9E_@^_]UWVEEPUMI\Mȋu űx(}ЋUBtMԋpu؋@E܋}ȍ<|xEEU UMEu~$t:||:}UȍTUxF EF$EEMI MuF$EE}}1EEEEEEEEEEEEuL}G}t}G|EEЋ M MMQE̋MEuVEE}}uȉtEtuTUUU؉BM5UUU؉B MU܉U؉BMԉU؋EgUċE\EE E E9Ea}EcUUMIME@EUR UMIME@EU@MEEEEE}E8MUUE|42ЃftUEE|EU;M~ɃEE@M9M~EEE9EEEEUUҋuMAt8E}MUBtxM}MUBtxMЙ}UUE M9MEHpU@`HD$$PMAĐ^_]U]UWVS,0FuE WUNLtFLtG GG~Lu=lGGFp@8@=~@9@4$~LuSF\@D EW uFUT$D$4$PG ED$G $G(uaG$t(D$UD$e!uG,[^_]UE@]UWVS,DEE‹@D$,D$$EMUB B B(ydt@/ $MAD$D$ $UB1MqUBD$D$$PuϋMAExZtrpT‹@8@$"~M@9@ $UBD$ t$D$$PMAq E@UrLtBLMyLu4AQ\RT T$D$ $PUB E,[^_]u,[^_]UWV Ƌ@D$D$4$GFD$D$4$G FD$D$4$GFD$D$4$G1E MEEi[,WE W E GUG4EfEҶUXu ^_]UWVuFD$D$4$lj~(w:F(?kW]]cc~$ ~$~$u F$@ 4$F,tStwFdF(t GTD0T;N$|wFdF(u'uD>$FdF(uG-u ;F(uF$FdG@4$~Jt FhFdFh[^_]UWVSLt=EEԋxWUzI>1#Hpu%BыR$RT$D$ $}ԉGpEԋ@pEUUEEMALf8fxfxfx fxfx}}ċElj}ċxf1}č :A}DAUEЈUۃu̓}EET}܋M;y$B}tUԉB #MԉA }LJL[^_]UWV`EEU8Mċuȋ@EURUM@D$uF $E D$M $RtuuEE-U܋EPMH1u(u~0u F<EUJuDEE9EvR4U uvDuU܋EP$u UUEP@UEuȋM;wEE܋U9BH~MM̋Et }E,|$UT$ FD$ML$E$UUz$EM9Mɋuv4űUB$M MEE؋u;F8lEEMЋU;$Eu9u[E@EM܋U;J0u9sQ$~ A$9sU(@ u(@HAAAU$P `^_]U1]UWVPEUЋM9A||u%;wU$uSMMuEEx0@ MQD$D$ D$MAHD$E$R EMЋU;v E@ EUR U܋MA 1u܅DU܉U܋UMԋDEE EE]U؋M4E11ED$UT$ t$ML$E$UUR$UM;yrNjA$UUEM9MEETEEԋU;B$;P^_]UWVPEUuV|9?yu>9u1l򋶈9w%u4$uE UM(tDž DžpxZ(y0.9vA ljƅ3-(J ϋB 1uƅ3tJEPD$9D$ FljD$tAHD$u4$R (Q ƅ26uVD$L$ D$tAHD$4$R ƅ2pFp(VL24r8r@r HrDR/u UBD$tD$$E؋MpU؉BBpEUEW MuUREMA@EԉT$G $TƋGD$G$@UT$t$D$ D$D$M $UԋUBHETUE܋M;A$mU؉BB ЃHBNMAD$D$ $PUع B 考uU؉BMB BL[^_]UEǀ$~ B t (@ (@HBBB]UWVĀEEċu1J$B MIMD$D$ MD$BUċDHD$ $MQ DE;$|UċRUUMċIMu܋(uԋ}~4}EEEUUM4 <}D=UME1PEꀃ};O4|EEŰE;P8|EEMu;$dUă T$4$PEEȋ};8s}EE뫋UBEEMЋu;N}9sd$~ A$9sU(@ u(@HAAA'}ЋEĉxUȉP1M $P ^_]UWVS<8+EEċE UċUȅt%Mċ@M<[^_]uċx_v}ȉGE̋UԋM؉EEUuԃu}؋O O$ȋuęEU}̋G8EG<EE@E܋uu1}܋}}9|EEUU}׋EEuƋMUEGFABEE9E|܋EU)1 uB;M|EETE}ЋE;x$UB@BDBL MȉAuF0F4 }ȉG<[^_]UWV0E0u#WUT$U$P t[G0GEUED$ED$E D$t$ G4D$ED$E$R;w4w G0G40^_]UWVEEȀx0u,MƋ@@D8D$ $R F0FL}ȋGDOt tpEML$ut$} |$MȋAHD$ 4ML$uȋF@D8D$}<$RF4;FHFDUE;wxMȃ4MuF4}FHFL;E̋UEsuԋN N$ȋ}ƋUԋB,1EʋEЅuA}̉GH<6ŰB@D8uЋp1B9|EET}ЋE;x$|UBD Mȃ4Mu}|$ED$M L$uȋFHD$ }|$F@D8D$E$RF4;FHJ~LUU؋MuEx}EEH H$ȋuEċU}؋G8EG<EMMUUEЉEE؋uƉu}׋uE=UBUBGFEEUEUEEEEEU9U|EETM܋u;N$#}ȃw@G0UG4GHGDĐ^_]U(UED$ED$E D$D$ D$D$$QUWVS\%u UBD$PD$$EȋMUȉtu@4$Ux@/$MM܋EP@$D$D$ $U܉B8MQ$E܉P< Uԍ4uE]w w$MƋQEƉD$D$ $ME܋@8EE܋@u } uE}7}܋E<}7ÜM1B}}7BuVuüFFFũEE}9}^EЍ4xEUB\tS}}}}U6U܋}2M̈E0A}}7A8^_]UWV@u M}U UPUPUPU@EEEԋETUVFE܋7ű}Ћ}G\ MEUUMM}4M4}EEE}E}̈uG}}ÜBMQMԋMM̈AAAM̋EMMЈAAEPE؋MMЈAAAMЋu9u }G\tyEu } uE}7}E<}7ÜM1B}}7BuuuЈFF@^_]UWVS,P }GD$0D$<$Ɖ6FW\WdV(u,NFF GT$D$<$PF FbF F GD$D$<$FGD$D$<$FGD$D$<$FGD$D$<$F1E܀ MEEi[,VE VE FUF<EfEҶUXu,[^_]UWVS<EE̋UlEӀ}tpu+1,Mp9 ?1E$tMtt9xEЋEx tBU@MlBpBtB xB$ $EEEU(@E؉M}u0>y*@sU؉P@D$ $PMl4NH‹U;tt&@sM؉HxD$$PUxM;p~EEUԋE;$,tu}tV}taM̉A _ ỦBM̉M܋}E(}t4UtuVPM̍D,D$ T$D$E$F/pU̍D,D$ t$D$M $ŰD,B1 @;$|GG(|uG^_]UWVS|rEEUxUMt@(u7ExUUыREԋBE؋E@ EUzBEBEċBEȋB E̋B$EEDMHME MEEM(@Ut,7D$ |$ML$EԉE${SU܉U}~1OE%u MԉM)06D$t$ |$ED$U$>ƅM܉M}tX9}+t$ |$ED$Uԉ$M܉M})U!;?}N?։UDĉDMUfEEME;@PEԉMQE؉BUEP xEMAEĉAEȉAẺA EЉA$Eh(1|[^_]UWVS|EEUpUMxMEtUr(u JMy/AtHEEPEԋBE؋UR UMqE EQDD$ L$D$$M܉Et4…u&fx  f x93t6FfA9]DžF<4Af>AD$ D$T$Eԉ$PM܉Et)…ufx  f9AMQEԉQE؉BP HPi(%BfA1Č[^_]UWVSU}GD$@D$<$q@,uGW$T$D$<$1@u;w$|ރ[^_]UEQ\@`A`]UWV0EEx\U;|mEH M:UM D$ MF`M  D$|$E$V0ETUM;Q$|1E@\ U UM)UB`9GME )9GEt$ET$ |$UT$E$QU2M)q`q\q\E;|U0^_]UUE]UE]UWV`EEEE @MEuuEEMu Mԉϋu~\$EǃEMNjuԈuԃ9}r׃}~4UB\D$ED$ED$ ML$ut$ $莑EEEUM;f`^_]UWV EEE6EEM֋}w\}  AB9rEEU;| ^_]UWV0EEZET֋Ep\ELx AB9rUB\D$D$|$ ED$UT$$虐GEU90^_]UWVEEEEMu r@RDAyU B(4'RADATW9u@IT GEMu;k^_]UWV,EEEU؋MQ0uЋU܅uxxE0U IRRG‹EЃE}IDFuu ~(}ԉ։E=EMRM ʍ vD}D G}E֋E9EuvD8UBEE} EEM؋u;}}}E,^_]UWVSLUBD$D$$EЋu}ЉGG t@4$ExHt~EEUU؋uЉuuEl}؋O$EEĉϋUz}ĉƋ}O ș}ĉ}EHdE؀x0u,UB4EETEE}ԋu;~$|9u 9uʍ699}t\u؃~(vS}G4UBxD$B\$t$ D$D$u4$׋}G [ *}tu؃~(v}G4E@덍oUB4|Йƅu-u"#UB4U䈂Du@&4$, 9uoL[^_]UWVS,bE8u1tUJt;rt)ɉ)‰ ‰) ȸ}c)ƍvƍF)ƉuZEHtЍR@ э R}c)ǍǍG)DžDnMvU| t>ML$$t( >}c)ƍvƍF)벉,[^_]USMPi~1:El@M M LD MLP[]UWVSPvƃPvǃOD$|t$$VD$t$L$@,~#t E ~E<-u%wG<0~L<9H0E E)E)E,<+tw)wG<0~<90)E )EEEw} ~M +U)E } ~E +U)E ME?$t ENE>%t ʉEQE0 ,fT]E܄sEjAQQP/E܍Q7E.E܌ %EN EEF EǍgEЍ4UЀ| A|u%ED$ UT$ED$U $gAEEE*D$EEE *$%DEЀ|EԅtU9U}EEUU*EdYD$*EY$NC*E^$ D}t$D$D$ ?$D$ C}t$D$D$ $D$?BU$UT A1<[^_]ÐUSD$+?D$8$$[]ÐUV4EMU]؉Ɖ$הDED$E$LED$E$KED$E$KED$E$KmG4DED$E$KED$E$KED$E$kKED$E$QK4^]HUVSu4$ӓKD$D$ $D$ KD$D$ $D$JD$3333D$ 33ӿ$D$JD$3333D$ 33ӿ$D$JD$D$ $D$zJD$D$ $3333D$33VJD$D$ ?$3333D$332JD$D$ ?$D$JD$D$ ?$D$ID$D$ ?$D$IFID$D$ $D$ID$D$ $D$tID$3333D$ 33?$D$PID$3333D$ 33?$D$,ID$D$ ?$D$ID$D$ ?$D$HEHD$D$ $D$HD$D$ $D$?HD$3333D$ 33ӿ$D$?nHD$3333D$ 33ӿ$3333D$33?JHD$D$ ?$3333D$33?&HD$D$ ?$D$?HD$3333D$ 33ӿ$D$?GD$3333D$ 33ӿ$D$GDGD$D$ $D$?GD$D$ $D$?hGD$3333D$ 33ÿ$D$?DGD$D$ $3333D$33? GD$D$ $D$@FD$D$ $zD$G?FD$D$ ?$D$@FD$D$ ?$3333D$33?FD$3333D$ 33?$D$?lFD$D$ ?$D$?HFD$D$ ?$D$?$F#Co>D$D$ $D$ED$D$ $D$ED$3333D$ 33ӿ$D$ED$3333D$ 33ӿ$D$ED$D$ $D$_ED$D$ $3333D$33;ED$D$ ?$3333D$33ED$D$ ?$D$DD$D$ ?$D$DD$D$ ?$D$DJB<D$D$ $D$}DD$D$ $D$YDD$3333D$ 33?$D$5DD$3333D$ 33?$D$DD$D$ ?$D$CD$D$ ?$D$ChA<D$D$ $D$CD$D$ $D$?wCD$3333D$ 33ӿ$D$?SCD$3333D$ 33ӿ$3333D$33?/CD$D$ ?$3333D$33? CD$D$ ?$D$?BD$3333D$ 33ӿ$D$?BD$3333D$ 33ӿ$D$B>@:D$D$ $D$?qBD$D$ $D$?MBD$3333D$ 33ÿ$D$?)BD$D$ $3333D$33?BD$D$ $D$@AD$D$ $zD$G?AD$D$ ?$D$@AD$D$ ?$3333D$33?uAD$3333D$ 33?$D$?QAD$D$ ?$D$?-AD$D$ ?$D$? A[^]>UVS u4$苉`9D$p= D$ ף?$D$ٿ@D$\D$ (\?$D$@D$D$ ?$\D$(\z@D$D$ ?$p= D$ףV@;D$D$$8D$3333D$33?D$D$ ɿ$D$?==D$D$$f+8D$p= D$ ף?$D$ٿ?D$\D$ (\?$D$?D$D$ ?$\D$(\c?D$D$ ?$p= D$ף?? [^]<UVSu4$7D$D$ ٿ$D$>D$D$ ?$D$>D$D$ ?$D$>D$D$ ٿ$D$>/:6D$D$ ?$D$^>D$D$ $D$?:>D$D$ $D$>D$D$ ٿ$D$=D$D$ ?$D$=q986D$D$ ٿ$D$=D$D$ ?$D$u=D$D$ ?$D$Q=D$D$ ?$D$-=D$D$ $D$? =D$D$ $D$<D$D$ ٿ$D$<[^]Z:UVSu4$j[^]UVSu4$4D$D$ ?$3333D$33ӿ4<D$D$ $D$?<D$D$ $3333D$33ӿ;7V74D$D$ ?$3333D$33ӿ;D$D$ $D$?;D$D$ $3333D$33ӿo;[^]9UVSu4$3D$D$ ?$D$?(;D$D$ $D$?;D$D$ $D$?:6P3D$D$ ?$ffffD$ff:D$D$ $D$?:D$D$ $ffffD$ffj: 62D$D$ ?$D$?5:D$D$ $D$?:D$D$ $D$?97?2D$D$ ?$ffffD$ff9D$D$ $D$?9D$D$ $ffffD$ffw9[^]7UVSu4$1D$D$ ?$D$?09D$D$ ?$3333D$33? 9D$D$ $3333D$33?8D$D$ $D$?8g441D$D$ ?$3333D$338D$D$ $D$?r8D$D$ $3333D$33N830D$D$ ?$D$?8D$D$ ?$3333D$33?7D$D$ $3333D$33?7D$D$ $D$?7L5/D$D$ ?$3333D$337D$D$ $D$?[7D$D$ $3333D$3377[^]4UVSu4$/D$D$ ?$3333D$336D$D$ $D$?6D$D$ $3333D$336K2.D$D$ ?$D$?z6D$D$ ?$3333D$33?V6D$D$ $3333D$33?26D$D$ $D$?63xY.D$D$ ?$D$?5D$D$ ?$3333D$33?5D$D$ $3333D$33?5D$D$ $D$?m5 3-D$D$ ?$3333D$33?5D$D$ $D$?5D$D$ $3333D$334[^]2UVSu4$y}N-D$D$ ?$D$?4D$D$ $D$?4D$D$ $D$?h4 0,D$D$ ?$D$:4D$D$ ?$D$4D$D$ $D$3D$D$ $D$3q/8,D$D$ ?$D$?3D$D$ $D$?u3D$D$ $D$?Q30+D$D$ ?$D$#3D$D$ ?$D$2D$D$ $D$2D$D$ $D$2[^]P0UVSu  [^]UVSu$D$f@+)u[^]UVSu$D$f@(u[^]{UVSu$D$f@(u[^]YUVSu$D$f@(u[^]#UVSu$D$f@s(u[^]5UVSu$D$f@E(u[^]GUVSu4$y)D$D$ ٿ$ffffD$ffֿ0D$D$ ?$ffffD$ffֿ0D$D$ ?$ffffD$ff?0D$D$ ٿ$ffffD$ff?0-,(D$D$ ?$3333D$33?\0D$D$ $ffffD$ff?80D$D$ $3333D$33?0+(D$D$ ?$3333D$33ÿ/D$D$ $ffffD$ff/D$D$ $3333D$33ÿ/A+'D$D$ ?$3333D$33ÿi/D$D$ ?$3333D$33?E/D$D$ ?$3333D$33?!/D$D$ $ffffD$ff?.D$D$ $3333D$33?.D$D$ ٿ$3333D$33?.D$D$ ٿ$3333D$33ÿ.D$D$ $3333D$33ÿm.D$D$ $ffffD$ffI.D$D$ ?$3333D$33ÿ%.[^]+UVSu4$v|&D$D$ ?$D$?-D$D$ $D$?-D$D$ $D$?-9)%D$D$ $D$h-D$D$ $D$?D-W(q%D$D$ $D$-D$D$ $D$?,'=%D$D$ ?$D$?,D$D$ $D$?,D$D$ $D$?u,[^]*UEf(f(]UVS u4$t$D$D$?D$D$ $D$)'^?$D$D$?D$D$ $D$) [^]H)USE$2t#D$D$ $D$i+D$D$ $D$?E+[]S&UVSu4$s#D$3333D$ 33ÿ$D$*D$3333D$ 33?$D$*D$3333D$ 33?$D$?*D$3333D$ 33ÿ$D$?*5&#D$D$ $3333D$33ÿd*D$D$ ?$3333D$33ÿ@*D$D$ ?$3333D$33?*D$D$ $3333D$33?)%bC"D$3333D$ 33ÿ$D$)D$3333D$ 33?$D$)D$3333D$ 33?$3333D$33ÿ{)D$D$ ?$3333D$33ÿW)D$D$ ?$3333D$33?3)D$3333D$ 33?$3333D$33?)D$3333D$ 33?$D$?(D$3333D$ 33ÿ$D$?(D$3333D$ 33ÿ$3333D$33?(D$D$ $3333D$33?(D$D$ $3333D$33ÿ[(D$3333D$ 33ÿ$3333D$33ÿ7([^]%US$6pR D$D$ ?$D$'D$D$ $D$'D$D$ $D$?'"$'7pD$D$ ?$D$n'D$D$ $D$?J'[]X"US$'ofD$D$ ?$D$'D$D$ $D$&D$D$ $D$?&!$6KoD$D$ ?$D$&D$D$ $D$?^&[]l!UVSJu~v[^]UWVS\EZE1$EtEȉ$^nE, Eȉ$Dnw%D$D$ $D${%D$D$ $D$W%D$D$ ?$D$3%DEEؾE^YL$E[r]MYML$E$4r]EYE$$E\EEE\TE؃yE^YL$Eq]MYML$E$q]EYE$+$EXEEE\\E؃y}t! \[^_]ÐUVS;u$D$f@$D$f[^]ÐUSl$D$`\@EZ$D$`@8[]US"D$D$ ?$D$D$D$ $D$? ED$D$ $D$?D$D$ ɿ$D$6[]USD$D$ ?$D$E$D$D$ ?$D$T[]UWVSu4$j!D$D$ $ffffD$ff!D$D$ $D$?!D$D$ ٿ$D$?!D$D$ ٿ$ffffD$ff?s!D$D$ ?$ffffD$ff?O!D$D$ ?$ffffD$ff+!*+?|$D$4$h$izD$D$ $D$? D$D$ ٿ$D$? D$D$ ٿ$ffffD$ff? 7|$D$84$/h$iD$D$ $ffffD$ffJ D$D$ $D$?& D$D$ ٿ$D$? D$D$ ٿ$ffffD$ff?D$D$ ?$ffffD$ff?D$D$ ?$ffffD$ff5D$D$ $D$?hD$D$ ٿ$ffffD$ff?D[^_]PUWVS}<$gD$ffffD$ ff$D$D$D$ $D$D$D$ $D$ٿD$ffffD$ ff$3333D$33ӿD$ffffD$ ff$3333D$33?kD$ffffD$ ff?$3333D$33?GD$ffffD$ ff?$D$#+?t$D$8<$e$fTD$ffffD$ ff$D$D$D$ $D$D$D$ $D$ٿD$ffffD$ ff$3333D$33ӿhD$ffffD$ ff$3333D$33?DD$ffffD$ ff?$3333D$33? D$ffffD$ ff?$D$t$D$<$d${ePD$ffffD$ ff?$D$D$3333D$ 33ӿ$3333D$33D$3333D$ 33ӿ$D$?jD$ffffD$ ff?$3333D$33?Ft$D$8<$c$d|D$ffffD$ ff?$D$D$3333D$ 33ӿ$3333D$33D$3333D$ 33ӿ$D$?D$ffffD$ ff?$3333D$33?[^_](UWVSu4$dD$D$ $D$GD$D$ $D$?#D$D$ $D$?D$D$ ?$D$?D$D$ ?$D$?D$D$ ?$D$D$D$ ?$D$oD$D$ $D$K+?|$D$4$a$bD$D$ $ffffD$ffD$D$ $ffffD$ff?D$D$ ٿ$ffffD$ff?D$D$ ٿ$ffffD$ff3D$D$ $ffffD$ffbD$D$ $ffffD$ff?>D$D$ ?$ffffD$ff?D$D$ ?$ffffD$ff4$a^D$D$ $D$D$D$ $3333D$33ӿD$D$ $3333D$33ӿxD$D$ $D$T|$D$84$_$`D$D$ $D$ D$D$ $D$?D$D$ $D$?D$D$ ?$D$?D$D$ ?$D$?zD$D$ ?$D$VD$D$ ?$D$2D$D$ $D$[^_]UVSu4$kD$>D$4$^$o_DD$D$ $3333D$33?D$D$ ٿ$D$?D$3333D$ 33?$D$^D$3333D$ 33?$D$ٿ:D$D$ ?$D$ٿD$+?D$84$]$^HD$D$ $3333D$33?D$D$ ٿ$D$?D$3333D$ 33?$D$D$3333D$ 33?$D$ٿ\D$D$ ?$D$ٿ8 D$3333D$ 33?$D$ D$3333D$ 33?$D$ٿD$3333D$ 33?$D$ٿ[^]_UWVS}<$B] D$D$ $D$yD$D$ $D$?UD$D$ ?$D$?1D$D$ ?$D$? D$D$ ?$D$D$D$ ?$D$hD$>D$<$\[$@\ D$D$ $3333D$33wD$D$ $3333D$33SD$D$ $3333D$33?/D$D$ $3333D$33? +?t$D$<$Z$[Z D$3333D$ 33?$3333D$33D$3333D$ 33?$3333D$33?D$D$ ?$3333D$33?tD$D$ ?$3333D$33P t$D$8<$Y$Z D$D$ $D$D$D$ $3333D$33D$D$ $3333D$33D$D$ $3333D$33?D$D$ $3333D$33?vD$D$ $D$?RD$D$ ?$D$?.D$D$ ?$D$? D$D$ ?$D$D$D$ ?$D$a D$3333D$ 33?$3333D$33D$3333D$ 33?$3333D$33?pD$D$ ?$3333D$33?LD$D$ ?$3333D$33([^_] UVS`Mu EUEU ^E{]Y]^YE*E*эYX\*E*YX\ 9V$MUYML$UT$$nXM\L$]\\$$YD$ZED$ZML$D$ ?1D$D$$A\$ XXD$Z]\$ZED$*Y\D$ L$T$V$[VE`[^]Z`[^]UWVSLBMu EUEU ^E]Y]^YE*E*ٍYXE\E*E*YXE\E9T$9WED$]\$$VED$]\$$XD$ZED$Z]\$D$ ?1t$t$$zZt$t$$PY$-Y$&VD$ZED$Z]\$*YD$ ED$]\$T$YED$]\$$X$XTEL[^_]XL[^_]UVS1 4 uŦ$Q .vM QD UD YD ]D aD eD iD mD qD $uD (yD ,F 4[^]ÐUSpL3u0$%D9~?@.uz.Fzt܉>%N>%B% E䉃>%[^_]ÐUWVSa$ [^_]$BD$D$fI$O#$BD$D$$N;$|ՋfI$N$N[^_]ÐUVSR$$D$[^]B.Puz.Fzt͉$N(rUWVSlUMuf(YEf(YXEX&EYYXX.Mff.ztYYXQ f(fTVYMf.ztYYXQ f(fTVYED$D$@D$EXE$bN],}E\E$FN],E)EXE$(N],uE\E$ N],E)*YƴD$ ZML$ZED$bH$M#uHHbHEl[^_]U莝ǁ!ǁ!ǁ!]UfE]f(Yf(Y,XX<YY$XX4ZZ]UVS 蓚uED$ED$ED$ ED$E D$4$Y FJF@-ƆdždžFtFx?F| [^]ÐUWVS }Iy<$`]wGJ$+[ƉuwGJ$/[ƋGEGJ$3[)EWUGJ$6[)EGHUҋM 9E}L$ED$ ML$E)ЉD$ t$EȉD$<$rIWDu~ T$UT$T$t$ ML$D$<$[ODEE+Eu~ L$ML$L$t$ D$T$<$[<$tG8 G8$G$2FMVUUU)‰UEEMɉM܋U+UEEċU+U܃EȋyEEE5}ƹt FO)ȅuUUċ}}ȋuuȋMȉL$T$t$BD$|$ T$t$Eĉ$^!U)UUUt$EЉD$|$T$t$ BD$MȉL$$#!1}}ȋEEċuuȋUȉT$D$|$ D$t$Mĉ $F E)EUUt$EЉD$|$ T$MȉL$UҋM 9E}#ED$L$ t$UT$<$E)ЉD$ML$ D$ED$<$ImWDu~ T$UT$T$t$ ML$D$<$*YODU+Eu~ L$ML$L$D$ ED$T$<$X<$tG8 G8$D$CMVUUU)‰U̅EEMɉM؋U+U؃EEЋU+ŨEԋyEEE5}ƹt FO)ȅMMЉMUUԋ}}ЋEԉD$|$T$L$BD$ |$T$UЉ$M)MuuEEVUD$|$T$ |$t$MЉ $ED$|$t$ UT$ML$<$_}}ЋuuЋEEԋUԉT$|$D$ t$D$MЉ $yE)EUUT$t$EЉD$ |$T$UЉ$IĜ[^_]UVS #uED$ED$ED$ ED$E D$4$GFJF@-ƆdždžFtFx?F| [^]ÐUVS蝓uVlf.Vdrًtt@ufb\VdZY٪\^,‰)‰9~1-\VdZY٪\^,)9~,FT*D$4$\$4$[^]UVSǒu4$t$ D$$D$?:][^]ÐUWVS\脒E@E؋URU܋MIMEx@Ht?:9|})щMUҋM 9|M)׋E@Ht=+M؋u =+M܉y  9| *ƋUYZX,EBHt  EEURHUĀt}u;ENEEEPlf(\@dff.u)z'f(+u*YX,ы=8u7PU,BT*\Jd\Rd^f.r+Uf.r19}E9|} +M G~~*D$E$yUtT$$8]MǁE$LMtEtO@T@\D$ D$$D$?ZU$3D$M $ y/|$ED$U܉T$ M؉L$D$E$8U|$ML$E܉D$ U؉T$D$M $E@Ht>>t}M,AT*D$ $\$E$IpU,JTRlf.Rdr EڋE@Ht==QtK=St1(=-Pw狄C HxE.<s\PdZY\^,) NE.<d\PdZY\^,)U,Bd,*D$M $],UЋM,AT9t/*D$ $U$PMI< $>\[^_]ÐUEǀƀ]ÐUԏEE f.szff.v Z.ztE E]Sv]ÐUWV }ut$ ED$UT$E $e<$CPB<$貽҃GH<u+T$t$D$UT$ EEU D.<u>T$D$ED$UDD$ E D$D$<$O ^_]UEE Mf.@du z f.Hlzt@dHlE E]Pu]UVS uED$ED$ED$ ED$E D$4$UcFJdžƆ [^]ÐUVS 蟋uED$ED$ED$ ED$E D$4$FJdžƆ [^]ÐUWVS,>}u E D$ED$ED$ ED$ED$<$GH<$GJLJƇ,[^_]UWVS,Ȋ}u E D$ED$ED$ ED$ED$<$,GH<$GJLJƇ,[^_]UWVS\Ru >sED$ UT$ML$E$D@{UBTB\MAdf.Alu z 5EHT\Hd@l\@d^f.wf_f(ȋUBHMDMMt5U) 5M)ȉEUBH<t<+t*U8*UYX,M)ȉ2 Dǃ2EE@Ht EE EEMQHtu;ENEEt )E*UDE)E*UYX,ËU)‰2y ǃ29UM䉋2}+2EEEԋE+E܉E؅yU2y ǃ21f)9}|*M؉29M} E䉃2f(ʋ}܋UBl\BdY^XJdL$$UI UUEMf.AT؋Eԉ2fI5=Rt(=Q1=S=Tu MAHuATA\D$ E@Hu@T@\D$ D$$= \$U$ \$M $-E$UBHfBTB\D$ D$$ \$M $ \$E$U$QMAHATA\D$ D$ $ \$E$; \$U$M $Ep5E$sS*E܋UYZX,ȉM9M{\$E$ \$U$\[^_]UWVSL讅} u"1tE$yTU$.sE@EԋUBJ$FE؋E@E܋UBJ$FEEx@J$FEEp@J$kFU)UԋUԉT$U)U܋U܉T$}|$ Ɖt$E D$U$L[^_]UWVSׄEEU U}MMEEURdf.Rluzkf(GMIT\IdAl\Ad^f.vf(f.kszfkUBHuDu<t<*YX,ӋMf.Qlw1T)Љ‰)HEE EEMIHMt}u9O)*YX,ËMAHtEEUĉ}EEEMMEEĉUȋUT$ML$ |$}|$E$bUȉM̄uzJEljE̋UBH<D$1MȉL$}ĉ|$ED$ UT$M̉L$}<$EUȃWDT$M)щL$UăT$ED$ ED$D$<$<D$1}ȉ|$EĉD$UT$ ML$}̉|$E$DEUăMQDT$UȃT$})׉|$UT$ ED$D$ $DXuą~?Mȅ~8UBDD$MȉL$}ĉ|$ED$ UT$M̉L$}<$DUBH<<G0EEjωƹt FO)ȅM9MOEȃ9E@}ȃ}ԋE+EȃuEED$+?D$8UBD$-$.}MMЉMEЉD$ |$L$4$UЉT$ GD$ML$F$EЉD$ |$UT$F $~D$+?D$MAD$G-$+.EE؋UЉT$ D$ML$<$7}Љ|$ E؃D$ED$F$|$ E؃ D$UT$ 4$VM9MOEă9E@}}܋EăEE+EăuD$+?D$8UBD$z,$^-}}}t$ ML$|$E܉$gFD$ UT$GD$M܉ $GF D$ ED$ |$U܉$'~D$+?D$MAD$+$,EE|$ UT$D$M܉ $FD$ }|$ED$E܉$ t$ |$E D$U܉$MȉL$}ĉ|$ ED$UT$M $L2 0};8uwGH<t<u=EEĬ[^_]3/*ƋUYZX,ЅFLMȉL$}ĉ|$ED$ UT$M̉L$}<$|Ĭ[^_]ÐUWV@ExIy$cAURUUBJ$m?EE@EUBJ$:?EEx@J$ ?EEp@J$>U)UUT$U)UUT$ }|$Ɖt$E$@^_]ÐUWVS$EEu,[^_]USuuK[]ÐUWVSxu}\u\~dM 1ҋA9EA9}>A;E69E}/M MMD M MD MMD -9u3M3U 3M3U[^_]ÐUVStuub~3x/9~+X uD u D uD #3u3U #3u73U[^]U]oU]FUVu1ɋu t B@$))ʉщ)ЍD^]ÐUVSsuo4$t$Pu[^]"UVSsu/4$t$Pu[^]UVSKsu4$Tt$P4$u[^]UEU 9tE E]+\]ÐUWVSD$D$E؉D$ E܉D$ED$E$E9)H U+u)Ɖx,؍HuFD$FD$ NL$FD$4$R<[^_]ÐUVu4$訰;E 44$蛰F9E }$4$_;E4$RF9E}1^]ÐUWVEx\t )ED$U T$$}t y1^_]ÐUWVSLvq}U MEEEGEЀuwtG u1A`EGutAd "EEEEEDЉT$ED$Eĉ$"G t EEEL[^_]UWVS,pu}D$ED$ED$ ED$E D$4$"4$蠅Vu;uF`t@tF$F $D$4$5Ƌu^_]UWVS,nE䋓EEE| ;Bur;| :t$$@uыUPp1,[^_]ÐUWVS,>nE䋃:U| ;Pupyx2t$$O@uዃ:UPp1,[^_]ÐUWVSm}UEEEBE؀zuJtMA u1G`E܋uFutGd mEUB u uGhEMAt $.Eu E1w@uU uEEGDEG]ЉUuEML$u4$;E} u"uuEJ}uD$7}G $E7t$ED$ED$ ED$E D$E$.UJ RD$MA $IE} ut$ut$}|$ ED$U T$M $a.E }띋mu+0})lj}UU_>D$|$|$ UĉT$U T$$-MA!>$,)‰p)DƉE=$x,p1tUERpƹt FO)ȅ$smuMMMM} }}D$D$v@D$D$t$ t$L$<$*D$D$v@D$D$t$ t$ED$<$'D$L>D$$$;UB $MMMu u}G $EEu u}w,U  \D$D$v@D$D$ML$ L$ut$}x<$D$ D$ED$E$&D$ D$ED$E$D$ D$E6uML$ t$}|$E$t$ ED$D$Ux$!ML$ L$ut$}x<$u1tERtǹt FO)ȅD$?D$$$ED$D$f@D$D$N@D$ D$ML$x4$DUUD$}|$|$ T$E D$$*E@1tgDž|RƉ׹t FO)ȅ2$M MuVUUU)‰)׋ME)ЃEMщMEt0uM4 )xEt$ ED$UT$M $|$ ED$t$U$uEE}uM uL1M E)EY8u}1ED$}|$D$ ED$E D$Ẻ$LY[^_]ËUB $US$fUD$D$BD$BD$ D$D$$$[]ÐUWVS\e}E EȋuUUąvGJ$&EO)M̃M܋EƋUJMEЃEEątw;toEЃD$ ẼD$T$E؃$t@@G@D$GD$GD$D$ D$GJD$<$'?1;D$D$UT$M܉L$ ED$U؉T$Mȉ $UȋB`t\uЃ U)EUU)J $ 8L$T:T$Ɖt$ $T$D$FMȋAUȋzBurtMȋQut tP`@d 1ҋVD$$ UȋB$踡D$D$D$ML$ŨT$ UT$M؉L$$UȋBy[$' }̃uuM؃Mԉ|$FD$ $$6}u EԉE\[^_]\[^_]UWV u}t)AD$AD$ A+FD$E D$ $RVT$VT$ |$U T$4$P ^_]ÐUWVS|b} D$ED$UT$ ML$ED$U$>M^D$bD$E؉D$ E܉D$ED$E$E$PwUJ@`4} uAd*@@"aMąuBUȅt;*EȃEy1ỦT$D $&~M̉N5*Eȅy1EȉD$D $~UȉV} MtB`tyD M;tjBucE@da:tUzdtB`tEt?@`t6Mt@u&E@d1UBd MAdL[^_]ÐUWVS,O}E D$<$E~dun<$PVht$PFht$PF\Ǎt u0E4t4$Pt$Pm̋E,[^_]UWVS/Ou $c/t4$PU HM$Mu&w+E k+ED$(D$$E(D$ E$D$UT$ML$ED$UT$ M L$ED$$$I-|+EEU(UEEEt1px't$x$`|EuDž|EEE(D$ $uj$,1pED$$UƉI@@|ME(| +Bhut  $P$P;u|Ћ|T};|tUt$PE|u E؋DEED$ED$E|MLBƃt'ǁD$ $U;tD$ $X5B9MEuu`/@t $@ Eu E܅rJ񉍬ERЉ}i$t$(D$$D$ D$ML$ED$UT$ML$ E D$T$ $E؋TE؋J)z+DžMT By1By ؉1ɉL$t$$};U~E؃+y1|$D $N~|DžMA9ED9utBE؋Tt $PMU؍A9݋DǀD$$2aE؋Tt $PME؉A9͋r$ljt$(M(L$$D$ D$D$D$D$T$ L$D$<$[|ЃEBE؋Tt $PMU؍A9݅vM܅kyED$ $Xpp$D$(D$$D$ T$D$D$D$t$ |$D$$zM䋁$R|$&U E؋Tt$PE؃⋅$$ Ĝ[^_]US4GE1҅ED$ T$ED$ED$D$D$ ED$E D$E$4[]UE E]SUE E]?UE E]5UE E]!UE]UEB1E ]U1]U]UWVE 耉@E @P4E0Dždx`0Iff1du00 0f t5`0pP0PT00X00X0f0t&`0pP0PT0PT0fzPt׃`pP0`0fy`tpP0pP0fypud4`B B@B`0 0`0pP0PT00X0241A@)) 4R)Љ)t)ΉpPllT1X?h4x`hx эR҉ )) ) )щ )׋hhhA)ȉ)‹ыlllF))֍Wh)ǍG֋t2 `) G`p  G )ʉ G@04`dd8Dž\U\ET<8I *88Wt1D8H8 L"8 L8r t"փD8H8H8JtփD88ytD8D8Juu%@<GGG 89888D8H8 L8: ))‹I)ȉ) $)׋D(H2L ,@҉ )) ) )щ  + Ћ,,,A)ȉ)‹ы(((F))֋ P,R+,,B֋$2%@<)$$%@EpUfzpu.MUB EpMPU0UU:U:ЍҍM4@4΍4p)֋EMQ` )ȍB)UEP )Ѝ)Ѝ M)ǁ y EEEmEEEEEUMDEUru] UMy t ȃXMEPtCEUzu3%MUEMU UUU A  Ġ^_]UWVE 耉E @PtEp0xDžpIfVfp pf~ t@`@pppPp0p0pfx0t5`p@pppP[p@pfy@t"ȃ`ppPpPpfxPt`ppp`pf~`tppppfyptxG G@G`ptxp p`p@pppPp02tw@)Љ)Ǎ))ȍȉ)v)Wp8t>t4 )lj <2)։)ȉ1tW`Vtx ʉω)׍‰P)L4 )׉ <0\)Ɖh`)ʉd2XȉXȉll)׍‰@)<%B)%Bh%|A)׉%A  ^_]UWVPM;MENƒyPUEux *)‰UEEEE)+MA}UUuuu $6EEԉD$ UT$t$<$+EE؋UUUUUD$T$ ED$EԉD$U$}+EEU؉T$D$E$若$ UU؉T$ ED$t$<$i$'/UT$E؉D$ U܉T$ED$E$P^_]ÐUWVS=Y=mudtSgPipiS a dgOmaeo/? ! !!v-f ~~Dt<<>>.. `A~A~OOEoe- --''``"'"`:-^V:y:Y//E=< > fifl++..,,_"%%^A^E'A:E`E'I^I:I`I'O^Omc`O'U^U`U||^ ~^_ u . * , ~-; v /SpaceBackspaceTabClearEnterPauseScroll_LockEscapeHomeLeftUpRightDownPage_UpPage_DownEndPrintInsertMenuNum_LockKP_EnterShift_LShift_RControl_LControl_RCaps_LockMeta_LMeta_RAlt_LAlt_RDelete%d%d%d%dFLTK CGContext Stack overflow error FLTK CGContext Stack underflow error LC_CTYPELC_ALLLANGutfUTFJPEGMEM%ld%c->>>>>|>[]|><-<<<|<[]<<|<->-->+->|arrowreturnarrowsquarecirclelineplusmenuUpArrowDnArrow||searchFLTKfilenewfileopenfilesavefilesaveasfileprintrefreshreloadundoredofl_push_matrix(): matrix stack overflow.fl_pop_matrix(): matrix stack underflow.%g%.12f%.*f$UWEE}Ѓ_]UE@UE@UE EUEBKUE ‹EPJÐUE ‹EP,ÐUE EUEB4UUE B$ÐUUE BUEB UUE B\ÐUS$UED$ED$ED$ ED$E D$$2ĩ@U$[]UE@UE@UV4UE D$$脫UED$$EuE$nuE$ԪE4^]UEUPUPUP @@@U P@ @$@(PP@UP]UJUU]UKUVSu{4$1Ku[^]h $UVSu=FFF FFFUFF F$E D$4$Tu[^]VQUrUԧU]QUVSu4$Pu[^]鐩U UU]+JUVSue4$Ju[^]>UU<U]IUVS;u4$Iu[^]U|UU]IUVSuɦ4$cIu[^]隨UVSusFFF FFFFF F$E D$4$*Su[^]OUVS5uF D$4$Va9Ftf<[^]UV$1U MfED$fED$ ҉T$ɉL$4$螨$^]UVuFFF D$F$rF}]UUvdU]}UVSuUd4$}u[^]ŠUVEUPUP@ @dU P@ @$PP@]UVSud4$}u[^]GUUdU]IUVSIud4$)u[^]UUdU]$UVSud4$#u[^]鳟UDUdU]lUVSud4$Lu[^]iUVS uED$ED$ED$ ED$E D$4$2W [^]ÐUVS 9uED$ED$ED$ ED$E D$4$蔤F$ [^]UXUNdU]`{UVSu-d4$@{u[^]}UUU]"UULdU]UVS_u+d4$ڣu[^]US$2EU}u6}u0.d$距ڛD$D$`?$($[]ÐUÐUSu=u8,D$c$XjD$D$0$([]ÐU]USVu3u.g$(D$D$$$([]ÐU]Ufuu`\ 0~]U]U,uuǁ>j:]ÐU]zPLR|! ($\* $PZ $x@ $& $ $ $ $@ $h $ (P $ $  ,4%M (ddWM ,&aM  ,N4P ,85P , "6P ,P 7:Q ,7vQ ,8Q (9  ( 2W $8^ 12Fl_BMP_Image12Fl_GIF_Image13Fl_JPEG_Image12Fl_PNG_Image12Fl_PNM_Image15Fl_Shared_Image8Fl_Group9Fl_Button9Fl_Widget9Fl_Window6Fl_Box8Fl_Image12Fl_RGB_Image9Fl_Pixmap12Fl_XBM_Image12Fl_XPM_Image14Fl_Tiled_Image11Fl_Browser_13Fl_TooltipBox8Fl_Menu_16Fl_Double_Window9Fl_Bitmap12Fl_Scrollbar9Fl_Slider11Fl_Valuator14Fl_Menu_Window16Fl_Single_Window9menutitle10menuwindow16Fl_Return_Buttono@7@?<,?f@VV@v@p@`@F@s@Py@ l@?$@??333333?333333?п?333333?a@-DT! @{Gzt?Q?f ʒ>Y@F??C?GC@ A@>?^?u='ԋ?OOOO !"#*0+0,0-0.0/000 1456789:GHIJKLMN579qrstuvwxyz{|}~  < A B C D E F G H M Q R S T b c  < A B G H K L M p q  < ? A B C M V > ? @ F G H J K L M U V A B C M prtvxz|~p`^>     !"#$%&)*+,-./01_ 456789:;<=>?@ACDz`aABCDEFGHIJKLMNOPQRSTUVWXYZ$$$$$$$$$$$$$$$$$$$$$$$$$$!/!   !#%')+-/13579;=?ACEGIKMOQSUWY[]_acegikmoqsuwy{} !"#$%&'01234567@ABCDEQSUW`abcdefgpqrstuvwz{xy|}QRSTUVWXYZ[\^_0123456789:;<=>?@ABCDEFGHIJKLMNOacegikmoqsuwy{}abcdefghijklmnopqrstuvwxyz{|}~abcdefghijklmnopqrstuvwxyz   !#%')+-/357:<>@BDFHKMOQSUWY[]_acegikmoqsuwz|~STWXY[`cihor   @>     !(0)" #*1892+$%,3:;4-&'.5<=6/7>?????????????????0 <3?@pL|CsO ,#/ߠ`Pl\cSo_84 ;7HxDtK{Gw($+'רhXdTk[gW2>1 =BrN~AqM}".!-ݢbRn^aQm] :6 95JzFvIyEu*&)%ժjZfViYeU @ @?aHP1?oM?lb??;i$? {zQ?]rU?@XSBK@I2"X!{sbhXE 0~SsAmTbSAA-BKbhTb~XBK!;(@XSBK@I2"I2EA!;I2'7 " 0A-("7 ~  @ @'666'''666'''p`222||||||||||||||||||||||||||||||||O c #FFFFFFo c #EFEFEF. c #E8E8E8asdfhgzxcv^bqweryt123465=97-80]ou[ip lj'k;\,/nm. `SQTRaghPUWVQSTRsdmcdniwdniwdniwdniwdniwHbyekbyekbyekbyeksuomsuomsuomsuom suom suomktlfktlfdniwdniwdniwdniwdniwdniwHdniwCdniwFdniwdniwbyekbyekbyekbyeksuomsuomsuomsuomsuom dh3G`GF60@Xp?UUUqqqq8qq88XhhhhXh\\\h\PPP &&&111===HHHUUU___jjjuuu$Hm?$?H?m?????$Hm$Hmڿ$Hm??$?H?m???????$??H??m???????????$?H?m??????$?H?m???ڿ???$?H?m????$Hm?$?H?m?????$Hm$Hmڿ$Hm$Hm?$?H?m?????$Hm$Hmڿ$Hm$Hm?$?H?m?????$Hm$Hmڿ$HmVvF.ּֿ¾zJJJVVJVvFVVVvFvFVVVVVV++,,,--...//000111223344 !"#$%&'()*+,-./01234567?O@`px|~|lFq@P~|x|nGP88 08<<<<8 0QGn|x|~`Q99??Q 8i&H  o?? R@`px<|~~f|lF<~<<<R8L>? dl x | PQRSTUVWacg$0<HPX`hD"fU3w (" *@`HhBbJj082:pPxXrRzZ ,$.&LlDdNnFf<4>6|\tT~^vV# +! )CcKkAaIi3;19sS{[qQyY/' -%OoGgMmEe?7=5_wW}]uU   & ! 0 `9 R}    "   "!a: S~x??~P':LJ'&Bj'&-GV-/&V"v |v3PoA(s,x'Aq|@ ;A& |& T   O A :  |:  h  3  c A 7  |7  %0 u ` n % ENh9Xmx)h9Xmx)h9Xmx)h9Xmx)h9Xmx)h9Xmx)\C?;99&=9@ ^`\XxMPUjHxHI.HO ^\C?;99&=9^ ^ ]C?;99&=9n ^]NnC?;99&=9} ^ `^ ^ ^  ] ^  `^ `^_(H&I99GG^GFK  ``_zMPUjHxHI.H ^ `^$ ]2 `B ^L  ^_ `^j ``y ` ^ `  ^ ` ` ]]Fz<BB$].N]"B$^&&v#B$ ^6 D(@^h9&9B$`^P9f9:99BB:9^HCCC?;99&=9^BIIMPUjHxHI.HD`,lLdHd0Xp<`(Pd(Tt$T @x(<`p Lt<t,Hp<x$@,@X4X_R BBl9_dx._*F# Dp~~\_b2,2v#B$` C:C6 DD>B `KL&I99GG^GFK@`pJ[bB$Fz:|``PwoB$Fz:|`<Xv#B$Fz:|`~~6 Dp~f~~`6 D.$(`rX Dp~f~~á ܜ|Dp~f~~ a B$b@bb[55 \b\\@]0FLvּV. 1aRR?"x0d|X 3,1R013(1$1܂2;:~O2T@f^ _L5gff$3pt@gg33P+T6hl\a2D t'3&Dh'Otz'ct'wt'tD(t)tJ*t+t+-Qm-_dt~t`htUuUu"V)uMV;u7YMuY_uZqu{ZuZuS[uCu&uu u +v >vCYv|ErvEvF vzvzvv 0-wZw @0ww 0w*$xGx @1Qx `2\xhbxhmxhxxhx 2xhxҪxxyyPznRznbz$okz(owz,oz0oz4oz8oz|o|x|n|:|& } @4.} `4W}Low}Po}To}z} ~XoK~\o~F~`o"Ljdoho loW 4: 4po 5  `5: 5d 5 5 ˂ׂoooao$o*o4o@oJ<*^do5AdG`GσF߃oYdg/&iClVpbpr9q}qCrrrqs҄s߄p(p,p 60p4p" ?Eb ?k@pt C{t `C `O dO |OÅtӅX n&^Gf҆ 0Jdv4և:j8.YzBňpp p/pLpdpzpp OΉ O O O $Pq (P( @P2 P= PE PR Q\ DQi `Qs Q Q R R dR R؊Dq݊HqLqPqTqXq"YqBs.%e SZqpqϋtq؋qqr T  TI Y i y     Ɍ ٌ      ) 9 "I "Y &iru U} `U;Z\\_Սf`ލcffMhIk-l:;mHe}]r + +HĎd؎܅ (=RTg ,{ѐmǏ2ۏ- -*>!P\7oq@!&Ӑ^y1C&V^i|s ͑ߑ 3L&^ r| . @.ђݒ . .2J*b>3Rvh~ @/ /ɓEޓ \0>Q`n}/p r dUɔՔ| 0&@Z v8#x%(ɕL(z(((9)V2)uJ,*/–-ܖ$.. 4$82?$3\'yfH8ŗ,;>bCE86S6m677 ֘v4 | U$|(|,| 0|@|@S<Dd mHz`d= 5  0  0 GjLG}MddNFHLlfLIr~JCVRҷg|UUXO^QPЂoMavxSp/SgQjgHgRURFhTN>gN ?*4~J΁Dj8 b> M g VLhO: zg&N1VhRh8S5iRNSJpS¾SֿzPa5RB.JDJhh0'itS>iSSXhRMAD&B.UUD?4dEEESzS:En7.b7PLa^3[EAVCּxUPdF^b>ELAS UiT6hhWShUSpsܓo7v5z D@40 E`?K>az-*? <^A ` 3UHJriVDUL&xB> MMơ.MTL0K &A52~oA2{ZJ|lJ|~J}e> UjO|2TJi DJJtFT~iPrhPMh@M@M,MM$w hlX[5"`TںQMFuThhQYUdZJ4uJvJwJ.xJy Kz\&\ R\ R  3  3 ]&.] RF]^]w] R]`(5$(5 R? R o~+oTLo(oo(oܜo|o.oRo,p>Jp̗{pp ṕp)WTIWlWWW OWW Xd(X.FX"cX0XlXXhXXY5YWY.yYYzYYMMNT.Nij}jFzjn}mlyjJ{lzj8}k:|l{ m z>mbz\mxl}xmXm<Y0 \F| S   `mxX_- K҂d{  `nN4 ;U ? C &= 9 9 9A ACBHC'BibiaiJ[ib[Z j4a*jYpQ4*QHAQ(, oR@RRz+ z} ]#]]#^^F7^*_~_f~mz~8_p~O^|pm~m~U_~UU %VBVltlcVtVRVVVz"E > 1 1< 0>x 02z<[zB 1$ 0&@~fLFbBb>bpCbDcD5c:CPc CkcBls sss&n$Dn.l^ qnn^\  \ԡ4 1 T!I$!T8:!{nn_PY!|!!,<!Nn5 R!! 3b`<6"2"BT". Zw" 3?h3T`"l""T"HRT4 ##"# M#.x#A?~-#|#x~T?B1f?0#l#l#hSsF?#<#R $<$b 5D 5*$:$LT$Dc$}$$ $f$u>>ֶ>>$ 3$$@%@+%̭F%  ? 5_(W%h%dy%{ $1%q 5%`%X%P%%t%p&`| $&r<&/=>#X&l&&rb&L&&@&'6='X'8i'{'A9A&9YDoAAh8F 8 88f  84  9P%985.;9"]9l5N62 ~9 92p99h99!6>,B9HBZ:eB9B:VL|E:_BBB;B9B:Cf9%CP9:9`2A`2_x1e`,36t-`/`+`j,`,2`b2`2'''B(7(LY(t(((Q&IQ^GQGRG#RFKpdtXQdLdKMWD|KrDDIBIxI~kg[xkg k|pkPwkiko9kklVhlj6liOljUkXiil|l$ZPC=%b=@'=<,Y66(("(=b$a6<n6v6"6'6(-Gg 6'()(=v# :B$^"=)H8=~#c x)=&>&;f&@F4@83)`V)Rt)R\L"=@3?6)(| 1)) $4)P6 )  *Dd@3%*܂}@43 4@F5@.6@5>*Q*d*+qGqX]q0qqqr7ZxXZ.zZZZZ[H,[qqrDra8_r̭rr$: ): R:F :l : cvP7 a.>aP,<$P -;LW;LX0,73>H&E7"<T0u;̸c7%@3@3 h-DraL[_l` \&`\ ]]>^Aj@`oQ_R`_8\^__`V_]c`s acn`A@^:]`^Ta_OR `Z<]^nk``;^A ^r`s _[$ m  @ :O n } 7C Ujj Q R M^ ^2 n V  cL  t n A : KC caB d_ j< D ly .> %A !s 1shr[@e[g [N \\@]Rb[fQ^R _b\^e_@gWe@acf#t(h_g b:paf@brae_R@fz<ab[f>>a7aCsgw 0 &@[x $(,; 0E] ,1 (1w* 2Ep]K 57Pă*$** 2L* Ef] 01DN 5NN 57 ?R] 2E]E]**4* 2FR^F^Nba R-F]+7F\+0FF] +؂OL OOF]ZF]-+,8+ЂM+i+Ȃ~+ 2+XN 5dF]+ 2mF\]+(xF[F[F]+ 2F]dPdPCGNRG(QdX eUeT&e6PFVZ2eVAeYOQNeGo`e؏eeGx`@Hf`f[cI:pfdfF$fU4f7Gcf gg6(g7gTHgYgGicfDfsXfgfe +gHRivf{bIo|nI~eZe6mIo]rIc*sff:.8p@0nA 0]\&,,-,<,I,Y,p,,bNwNNNNNNNO"O5OLOaOrOO,,,,,O,ccd-4KZCwChMK-fK3-CzKKG-W-Kdh---[\%\;\P5PKKK-CCCdC---K-.L$.4.A.R.[.u........../B/X/p//\//////00&090I0Z0i0{000000000L1 141H1b1s1111111112*2;2K2[2n2222222223)313C3S3e3u3.L33339L33\BL344.4;4F4O4b4;tn4y4444444"F      + > O ] h s       @ R>u   ? c7777,G6`M4G7? ;G! D<7(DC,daG:'ue7iGpG7$2AP`|77 88/8C8Y8m8vGi~Gv8Chm!G)a5=fMGeK G/De~8  "( ;R_')+-Vmqrtz{ % 3&n&-/3AFUWX !"#'(-MNQ : K M X \ r  5 L \H         F H S T V X _ ` a          5               ~ R U  #5    r   ] ^w f         vxz| DZ~VZ 1M{"#'C,N_$*.56ADb~Pb !6 #! H X d m n q H u  \O `\O \O ]O ]O ]O ]O ]O aT ^N ^O @^O ^O `^N ^O _O `_O _O teT leT heT deT `eT \eT _O _O eT _O `O `O @`O ``O gT `O `O `O aO `O aO |i[HUI~a7Y &8Xmp*TzS{Cn:|Ds9:72edombgecdfZY$ekVg\s}^h]bv)J8KG>@;t=S+F<?EBh'Qj:AD9CLwroRluP{n`tazy-  # (+"0/WZ,5*e )2&34 4p' 6Y1mq_xjd%!c $v~f!._NXArgc_NXArgv___progname__dyld_func_lookup__start_environdyld_stub_binding_helperstart___keymgr_dwarf2_register_sections__cthread_init_routine__mh_execute_header_atexit_catch_exception_raise_catch_exception_raise_state_catch_exception_raise_state_identity_clock_alarm_reply_do_mach_notify_dead_name_do_mach_notify_no_senders_do_mach_notify_port_deleted_do_mach_notify_send_once_do_seqnos_mach_notify_dead_name_do_seqnos_mach_notify_no_senders_do_seqnos_mach_notify_port_deleted_do_seqnos_mach_notify_send_once_errno_exit_mach_init_routine_main_receive_samples___cxa_atexit___i686.get_pc_thunk.bx___dso_handle__keymgr_get_and_lock_processwide_ptr__keymgr_get_and_lock_processwide_ptr_2__keymgr_set_and_unlock_processwide_ptr_calloc_dlopen_dlsym_free_malloc__Z2aiP9Fl_WidgetPv__Z2aiP9Fl_WidgetPv.eh__Z4campP9Fl_WidgetPv__Z4campP9Fl_WidgetPv.eh__Z4pfadPv__Z4pfadPv.eh__Z4scenP9Fl_WidgetPv__Z4scenP9Fl_WidgetPv.eh__Z5themeP9Fl_WidgetPv__Z5themeP9Fl_WidgetPv.eh__Z6clientP9Fl_WidgetPv__Z6clientP9Fl_WidgetPv.eh__Z6serverP9Fl_WidgetPv__Z6serverP9Fl_WidgetPv.eh__ZN6Fl_BoxC1EiiiiPKc__ZN6Fl_BoxC1EiiiiPKc.eh__ZN8Fl_Group9resizableEP9Fl_Widget__ZN8Fl_Group9resizableEP9Fl_Widget.eh__ZN9Fl_Widget3boxE10Fl_Boxtype__ZN9Fl_Widget3boxE10Fl_Boxtype.eh__ZN9Fl_Widget5alignEh__ZN9Fl_Widget5alignEh.eh__ZN9Fl_Widget5imageEP8Fl_Image__ZN9Fl_Widget5imageEP8Fl_Image.eh__ZN9Fl_Widget8callbackEPFvPS_PvES1___ZN9Fl_Widget8callbackEPFvPS_PvES1_.eh__ZN9Fl_Widget9labelsizeEh__ZN9Fl_Widget9labelsizeEh.eh__ZN9Fl_Widget9labeltypeE12Fl_Labeltype__ZN9Fl_Widget9labeltypeE12Fl_Labeltype.eh__ZNK8Fl_Image1hEv__ZNK8Fl_Image1hEv.eh__ZNK8Fl_Image1wEv__ZNK8Fl_Image1wEv.eh__ZNK9Fl_Widget1hEv__ZNK9Fl_Widget1hEv.eh__ZNK9Fl_Widget1wEv__ZNK9Fl_Widget1wEv.eh__ZNSt11char_traitsIcE6lengthEPKc__ZNSt11char_traitsIcE6lengthEPKc.eh__ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6___ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_EPKS3_RKS6_.eh__ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_ERKS6_PKS3___ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_ERKS6_PKS3_.eh_main.eh_win__Unwind_Resume__Z18fl_register_imagesv__Z27fl_define_FL_ENGRAVED_LABELv__ZN15Fl_Shared_Image3getEPKcii__ZN15Fl_Shared_Image7releaseEv__ZN2Fl17get_system_colorsEv__ZN2Fl3runEv__ZN2Fl6schemeEPKc__ZN2Fl6visualEi__ZN8Fl_Group3endEv__ZN8Fl_Group5beginEv__ZN9Fl_ButtonC1EiiiiPKc__ZN9Fl_WidgetC2EiiiiPKc__ZN9Fl_Window4showEiPPc__ZN9Fl_Window5labelEPKc__ZN9Fl_WindowC1EiiPKc__ZNKSs4sizeEv__ZNKSs5c_strEv__ZNSolsEPFRSoS_E__ZNSs5eraseEmm__ZNSs6appendEPKc__ZNSs6appendEPKcm__ZNSs6appendERKSs__ZNSs7reserveEm__ZNSsC1ERKSs__ZNSsC1Ev__ZNSsD1Ev__ZNSsaSEPKc__ZNSspLERKSs__ZNSt8ios_base4InitC1Ev__ZNSt8ios_base4InitD1Ev__ZSt4cout__ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6___ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc__ZStlsIcSt11char_traitsIcESaIcEERSt13basic_ostreamIT_T0_ES7_RKSbIS4_S5_T1_E__ZTV6Fl_Box__ZdlPv__Znwm___gxx_personality_v0_system__ZN12Fl_BMP_ImageC1EPKc__ZN12Fl_GIF_ImageC1EPKc__ZN12Fl_PNG_ImageC1EPKc__ZN12Fl_PNM_ImageC1EPKc__ZN13Fl_JPEG_ImageC1EPKc__ZN15Fl_Shared_Image11add_handlerEPFP8Fl_ImagePKcPhiE__ZN12Fl_BMP_ImageC2EPKc__ZN12Fl_BMP_ImageD0Ev__ZN12Fl_BMP_ImageD1Ev__ZN12Fl_RGB_ImageC2EPKhiiii__ZTI12Fl_BMP_Image__ZTS12Fl_BMP_Image__ZTV12Fl_BMP_Image___i686.get_pc_thunk.cx__ZN12Fl_RGB_Image10desaturateEv__ZN12Fl_RGB_Image13color_averageE8Fl_Colorf__ZN12Fl_RGB_Image4copyEii__ZN12Fl_RGB_Image4drawEiiiiii__ZN12Fl_RGB_Image5labelEP12Fl_Menu_Item__ZN12Fl_RGB_Image5labelEP9Fl_Widget__ZN12Fl_RGB_Image7uncacheEv__ZN12Fl_RGB_ImageD2Ev__ZTI12Fl_RGB_Image__ZTV12Fl_RGB_Image__ZTV8Fl_Image__ZTVN10__cxxabiv120__si_class_type_infoE__Znam_fclose_fopen_fread_fseek_getc__ZN12Fl_GIF_ImageC2EPKc__ZN12Fl_GIF_ImageD0Ev__ZN12Fl_GIF_ImageD1Ev__ZN9Fl_PixmapC2EPKPc__ZTI12Fl_GIF_Image__ZTS12Fl_GIF_Image__ZTV12Fl_GIF_Image__ZN2Fl5errorE__ZN2Fl7warningE__ZN9Fl_Pixmap10desaturateEv__ZN9Fl_Pixmap13color_averageE8Fl_Colorf__ZN9Fl_Pixmap4copyEii__ZN9Fl_Pixmap4drawEiiiiii__ZN9Fl_Pixmap5labelEP12Fl_Menu_Item__ZN9Fl_Pixmap5labelEP9Fl_Widget__ZN9Fl_Pixmap7measureEv__ZN9Fl_Pixmap7uncacheEv__ZN9Fl_Pixmap8set_dataEPKPKc__ZN9Fl_PixmapD2Ev__ZTI9Fl_Pixmap__ZTV9Fl_Pixmap__ZdaPv_fl_fopen_memcpy_sprintf_strcpy__ZN13Fl_JPEG_ImageC2EPKc__ZN13Fl_JPEG_ImageD0Ev__ZN13Fl_JPEG_ImageD1Ev__ZTI13Fl_JPEG_Image__ZTS13Fl_JPEG_Image__ZTV13Fl_JPEG_Image_jpeg_CreateDecompress_jpeg_calc_output_dimensions_jpeg_destroy_decompress_jpeg_finish_decompress_jpeg_read_header_jpeg_read_scanlines_jpeg_start_decompress_jpeg_std_error_jpeg_stdio_src_longjmp_setjmp__ZN12Fl_PNG_ImageC2EPKc__ZN12Fl_PNG_ImageD0Ev__ZN12Fl_PNG_ImageD1Ev__ZTI12Fl_PNG_Image__ZTS12Fl_PNG_Image__ZTV12Fl_PNG_Image_png_create_info_struct_png_create_read_struct_png_destroy_read_struct_png_init_io_png_read_end_png_read_info_png_read_rows_png_set_expand_png_set_interlace_handling_png_set_packing_png_set_strip_16__ZN12Fl_PNM_ImageC2EPKc__ZN12Fl_PNM_ImageD0Ev__ZN12Fl_PNM_ImageD1Ev__ZTI12Fl_PNM_Image__ZTS12Fl_PNM_Image__ZTV12Fl_PNM_Image__DefaultRuneLocale_atoi_fgets_fscanf_strtol__Z25fl_define_FL_SHADOW_LABELv__Z27fl_define_FL_EMBOSSED_LABELv__Z11fl_pop_clipv__Z12fl_push_clipiiii__Z7fl_drawPKciiii8Fl_AlignP8Fl_Imagei__Z7fl_fontii__Z8fl_color8Fl_Color__ZN2Fl13set_labeltypeE12Fl_LabeltypePFvPK8Fl_Labeliiii8Fl_AlignEPFvS3_RiS7_E__ZN15Fl_Shared_Image10desaturateEv__ZN15Fl_Shared_Image10num_imagesEv__ZN15Fl_Shared_Image11num_images_E__ZN15Fl_Shared_Image13alloc_images_E__ZN15Fl_Shared_Image13color_averageE8Fl_Colorf__ZN15Fl_Shared_Image13num_handlers_E__ZN15Fl_Shared_Image14remove_handlerEPFP8Fl_ImagePKcPhiE__ZN15Fl_Shared_Image15alloc_handlers_E__ZN15Fl_Shared_Image3addEv__ZN15Fl_Shared_Image4copyEii__ZN15Fl_Shared_Image4drawEiiiiii__ZN15Fl_Shared_Image4findEPKcii__ZN15Fl_Shared_Image6imagesEv__ZN15Fl_Shared_Image6reloadEv__ZN15Fl_Shared_Image6updateEv__ZN15Fl_Shared_Image7compareEPPS_S1___ZN15Fl_Shared_Image7images_E__ZN15Fl_Shared_Image7uncacheEv__ZN15Fl_Shared_Image9handlers_E__ZN15Fl_Shared_ImageC1EPKcP8Fl_Image__ZN15Fl_Shared_ImageC1Ev__ZN15Fl_Shared_ImageC2EPKcP8Fl_Image__ZN15Fl_Shared_ImageC2Ev__ZN15Fl_Shared_ImageD0Ev__ZN15Fl_Shared_ImageD1Ev__ZN15Fl_Shared_ImageD2Ev__ZTI15Fl_Shared_Image__ZTS15Fl_Shared_Image__ZTV15Fl_Shared_Image__ZN12Fl_XBM_ImageC1EPKc__ZN12Fl_XPM_ImageC1EPKc__ZN8Fl_Image4drawEiiiiii__ZN8Fl_Image5labelEP12Fl_Menu_Item__ZN8Fl_Image5labelEP9Fl_Widget__ZN8Fl_ImageD2Ev__ZTI8Fl_Image_bsearch_memmove_qsort_strcmp__Z14fl_parse_colorPKcRhS1_S1___ZN2Fl10backgroundEhhh__ZN2Fl10foregroundEhhh__ZN2Fl10scheme_bg_E__ZN2Fl11background2Ehhh__ZN2Fl13reload_schemeEv__ZN2Fl7scheme_E__ZN9Fl_PixmapC1EPKPKc_fl_bg_fl_bg2_fl_fg__Z11fl_contrast8Fl_ColorS___Z11fl_down_boxiiii8Fl_Color__Z11fl_up_frameiiii8Fl_Color__Z13fl_down_frameiiii8Fl_Color__Z14fl_thin_up_boxiiii8Fl_Color__Z15fl_open_displayv__Z15fl_round_up_boxiiii8Fl_Color__Z16fl_thin_down_boxiiii8Fl_Color__Z16fl_thin_up_frameiiii8Fl_Color__Z17fl_round_down_boxiiii8Fl_Color__Z18fl_thin_down_frameiiii8Fl_Color__Z23fl_define_FL_GTK_UP_BOXv__Z27fl_define_FL_PLASTIC_UP_BOXv__Z9fl_up_boxiiii8Fl_Color__ZN14Fl_Tiled_ImageC1EP8Fl_Imageii__ZN2Fl11next_windowEPK9Fl_Window__ZN2Fl11set_boxtypeE10Fl_BoxtypePFviiii8Fl_ColorEhhhh__ZN2Fl11set_boxtypeE10Fl_BoxtypeS0___ZN2Fl12first_windowEv__ZN2Fl14scrollbar_sizeEi__ZN2Fl1hEv__ZN2Fl1wEv__ZN2Fl9get_colorE8Fl_Color__ZN2Fl9get_colorE8Fl_ColorRhS1_S1___ZN2Fl9set_colorE8Fl_Colorhhh__ZN2Fl9set_colorE8Fl_Colorj__ZN9Fl_PixmapD1Ev__ZN9Fl_Widget6redrawEv_getenv_log_pow_putenv_sscanf_strcasecmp_strdup_strlcat__Z10HandleMenuP9HICommand__Z11fl_set_spotiiiiii__Z12MacMapWindowP9Fl_WindowP15OpaqueWindowPtr__Z12fl_fix_focusv__Z13fl_reset_spotv__Z13fl_set_statusiiii__Z14MacUnmapWindowP9Fl_WindowP15OpaqueWindowPtr__Z14fl_throw_focusP9Fl_Widget__Z15MacUnlinkWindowP4Fl_XS0___Z16MacDestroyWindowP9Fl_WindowP15OpaqueWindowPtr__Z16XRectangleRegioniiii__Z16fl_close_displayv__Z16fl_filename_namePKc__Z16fl_open_callbackPFvPKcE__Z7fl_waitd_fl_gc__Z21carbonKeyboardHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv__Z7fl_findP15OpaqueWindowPtr__Z8fl_readyv__Z8mac2fltkm__ZN10Fl_Tooltip4exitE__ZN10Fl_Tooltip5enterE__ZN2Fl10belowmouseEP9Fl_Widget__ZN2Fl10e_is_clickE__ZN2Fl11add_handlerEPFiiE__ZN2Fl11add_timeoutEdPFvPvES0___ZN2Fl11belowmouse_E__ZN2Fl11has_timeoutEPFvPvES0___ZN2Fl12event_insideEPK9Fl_Widget__ZN2Fl12event_insideEiiii__ZN2Fl12first_windowEP9Fl_Window__ZN2Fl12remove_checkEPFvPvES0___ZN2Fl13delete_widgetEP9Fl_Widget__ZN2Fl13dnd_text_ops_E__ZN2Fl14remove_handlerEPFiiE__ZN2Fl14remove_timeoutEPFvPvES0___ZN2Fl14repeat_timeoutEdPFvPvES0___ZN2Fl14visible_focus_E__ZN2Fl15selection_ownerEP9Fl_Widget__ZN2Fl16selection_owner_E__ZN2Fl17e_original_keysymE__ZN2Fl18do_widget_deletionEv__ZN2Fl1xEv__ZN2Fl1yEv__ZN2Fl20clear_widget_pointerEPK9Fl_Widget__ZN2Fl20watch_widget_pointerERP9Fl_Widget__ZN2Fl22release_widget_pointerERP9Fl_Widget__ZN2Fl3e_xE__ZN2Fl3e_yE__ZN2Fl4copyEPKcii__ZN2Fl4e_dxE__ZN2Fl4e_dyE__ZN2Fl4idleE__ZN2Fl4waitEd__ZN2Fl4waitEv__ZN2Fl5checkEv__ZN2Fl5flushEv__ZN2Fl5focusEP9Fl_Widget__ZN2Fl5grab_E__ZN2Fl5pasteER9Fl_Widget__ZN2Fl5pasteER9Fl_Widgeti__ZN2Fl5readyEv__ZN2Fl6add_fdEiPFviPvES0___ZN2Fl6add_fdEiiPFviPvES0___ZN2Fl6e_textE__ZN2Fl6focus_E__ZN2Fl6handleEiP9Fl_Window__ZN2Fl6modal_E__ZN2Fl6pushedEP9Fl_Widget__ZN2Fl6redrawEv__ZN2Fl7damage_E__ZN2Fl7e_stateE__ZN2Fl7pushed_E__ZN2Fl7versionEv__ZN2Fl8e_clicksE__ZN2Fl8e_keysymE__ZN2Fl8e_lengthE__ZN2Fl8e_numberE__ZN2Fl8e_x_rootE__ZN2Fl8e_y_rootE__ZN2Fl9add_checkEPFvPvES0___ZN2Fl9get_mouseERiS0___ZN2Fl9has_checkEPFvPvES0___ZN2Fl9remove_fdEi__ZN2Fl9remove_fdEii__ZN2Fl9selectionER9Fl_WidgetPKci__ZN4Fl_X11q_end_imageEv__ZN4Fl_X13q_begin_imageER6CGRectiiii__ZN4Fl_X14q_fill_contextEv__ZN4Fl_X16q_clear_clippingEv__ZN4Fl_X17q_release_contextEPS___ZN4Fl_X4makeEP9Fl_Window__ZN4Fl_X5firstE__ZN4Fl_X5flushEv__ZN4Fl_X9fake_X_wmEPK9Fl_WindowRiS3_S3_S3_S3___ZN9DataReady10HandleDataER6fd_setS1_S1___ZN9DataReady11StartThreadEPv__ZN9DataReady12CancelThreadEPKc__ZN9DataReady15DataReadyThreadEPv__ZN9DataReady5AddFDEiiPFviPvES0___ZN9DataReady8RemoveFDEii__ZN9DataReady9CheckDataER6fd_setS1_S1___ZN9DataReadyC1Ev__ZN9DataReadyD1Ev__ZN9Fl_Widget11do_callbackEv__ZN9Fl_Widget12redraw_labelEv__ZN9Fl_Widget6damageEh__ZN9Fl_Widget6damageEhiiii__ZN9Fl_Window10size_rangeEiiiiiii__ZN9Fl_Window11size_range_Ev__ZN9Fl_Window12make_currentEv__ZN9Fl_Window4hideEv__ZN9Fl_Window4showEv__ZN9Fl_Window5flushEv__ZN9Fl_Window5labelEPKcS1___ZN9Fl_Window6handleEi__ZN9Fl_Window6resizeEiiii__ZN9Fl_Window8current_E__ZN9Fl_WindowD0Ev__ZN9Fl_WindowD1Ev__ZN9Fl_WindowD2Ev_fl_capture_fl_default_cursor_fl_disable_transient_for_fl_dnd_target_window_fl_event_time_fl_key_vector_fl_local_grab_fl_lock_function_fl_modal_for_fl_oldfocus_fl_os_event_fl_screen_fl_selection_buffer_fl_selection_buffer_length_fl_selection_length_fl_selection_requestor_fl_show_iconic_fl_sys_menu_bar_fl_system_menu_fl_unlock_function_fl_window_fl_window_region_fl_xfocus_fl_xmousewin_AECountItems_AECreateDesc_AEDisposeDesc_AEGetNthPtr_AEGetParamDesc_AEInstallEventHandler_AEProcessAppleEvent_AERemoveEventHandler_AppendResMenu_BringToFront_CFBundleCopyExecutableURL_CFBundleGetMainBundle_CFRelease_CFURLGetFSRef_CGBitmapContextGetHeight_CGContextClipToRect_CGContextConcatCTM_CGContextFlush_CGContextGetCTM_CGContextRestoreGState_CGContextSaveGState_CGContextScaleCTM_CGContextTranslateCTM_CallNextEventHandler_ClearCurrentScrap_ClearMenuBar_CollapseWindow_ConvertEventRefToEventRecord_CountDragItems_CreateEvent_CreateNewWindow_DiffRgn_DisposeEventLoopTimerUPP_DisposeRgn_DisposeWindow_DrawMenuBar_FSCompareFSRefs_FSRefMakePath_FSpMakeFSRef_FindWindow_FlushEvents_GetApplicationEventTarget_GetAvailableWindowAttributes_GetAvailableWindowPositioningBounds_GetCurrentEventQueue_GetCurrentKeyModifiers_GetCurrentProcess_GetCurrentScrap_GetDeviceList_GetDragItemReferenceNumber_GetDragMouse_GetEventClass_GetEventDispatcherTarget_GetEventKind_GetEventParameter_GetFlavorData_GetFlavorDataSize_GetFlavorFlags_GetFrontProcess_GetMainDevice_GetMainEventLoop_GetMenuHandle_GetMenuItemRefCon_GetMouse_GetNextDevice_GetPort_GetPortBounds_GetProcessBundleLocation_GetQDGlobalsArrow_GetQDGlobalsScreenBits_GetResource_GetScrapFlavorData_GetScrapFlavorSize_GetScriptManagerVariable_GetWindowBounds_GetWindowClass_GetWindowEventTarget_GetWindowPort_GlobalToLocal_HideWindow_HiliteMenu_InstallEventHandler_InstallEventLoopTimer_InstallReceiveHandler_InstallTrackingHandler_InvalWindowRect_InvalWindowRgn_IsWindowActive_IsWindowCollapsed_KLGetCurrentKeyboardLayout_KLGetKeyboardLayoutProperty_KeyTranslate_LocalToGlobal_MenuSelect_MoreMasters_MoveWindow_NewAEEventHandlerUPP_NewEventHandlerUPP_NewEventLoopTimerUPP_NewRgn_PostEventToQueue_PutScrapFlavor_QDBeginCGContext_QDEndCGContext_ReceiveNextEvent_ReleaseEvent_RemoveEventLoopTimer_RepositionWindow_SameProcess_SelectWindow_SendEventToEventTarget_SetEventLoopTimerNextFireTime_SetEventMask_SetFrontProcess_SetItemMark_SetOrigin_SetPort_SetPortClipRegion_SetRectRgn_SetWTitle_SetWindowActivationScope_SetWindowBounds_SetWindowClass_SetWindowResizeLimits_ShowWindow_TransformProcessType_UnionRgn__Z14fl_clip_regionP15OpaqueRgnHandle__Z29fl_quartz_restore_line_style_v__Z7fl_fontP11Fl_FontSize__Z9fl_cursor9Fl_Cursor8Fl_ColorS0___ZN10Fl_Tooltip7currentEP9Fl_Widget__ZN10Fl_Tooltip7widget_E__ZN2Fl13compose_stateE__ZN8Fl_Group6handleEi__ZN8Fl_Group6resizeEiiii__ZN8Fl_Group7currentEPS___ZN8Fl_GroupD2Ev__ZN8Fl_Menu_6pickedEPK12Fl_Menu_Item__ZN9Fl_Widget10take_focusEv__ZN9Fl_Widget16default_callbackEPS_Pv__ZN9Fl_Widget4hideEv__ZN9Fl_Widget4showEv__ZN9Fl_Widget5labelEPKc__ZN9Fl_Window6cursorE9Fl_Cursor8Fl_ColorS1___ZNK8Fl_Label7measureERiS0___ZNK9Fl_Widget6windowEv__ZNK9Fl_Widget8containsEPKS___ZNK9Fl_Widget9visible_rEv__ZTV9Fl_Window___maskrune___sF___tolower___toupper_close_fl_color__fl_fontsize_fprintf_memset_pipe_pthread_cancel_pthread_create_pthread_join_pthread_mutex_init_pthread_mutex_lock_pthread_mutex_unlock_pthread_testcancel_realloc_select_write__ZN8Fl_Group10init_sizesEv__ZN8Fl_Group10navigationEi__ZN8Fl_Group13draw_childrenEv__ZN8Fl_Group3addER9Fl_Widget__ZN8Fl_Group4drawEv__ZN8Fl_Group5clearEv__ZN8Fl_Group5sizesEv__ZN8Fl_Group6insertER9Fl_Widgeti__ZN8Fl_Group6removeER9Fl_Widget__ZN8Fl_Group7currentEv__ZN8Fl_Group8current_E__ZN8Fl_GroupC1EiiiiPKc__ZN8Fl_GroupC2EiiiiPKc__ZN8Fl_GroupD0Ev__ZN8Fl_GroupD1Ev__ZNK8Fl_Group10draw_childER9Fl_Widget__ZNK8Fl_Group12update_childER9Fl_Widget__ZNK8Fl_Group18draw_outside_labelERK9Fl_Widget__ZNK8Fl_Group4findEPK9Fl_Widget__ZNK8Fl_Group5arrayEv__ZTI8Fl_Group__ZTS8Fl_Group__ZTV8Fl_Group__Z14fl_not_clippediiii__ZN9Fl_Widget6resizeEiiii__ZN9Fl_WidgetD2Ev__ZNK9Fl_Widget10draw_labelEiiii8Fl_Align__ZNK9Fl_Widget10draw_labelEv__ZNK9Fl_Widget8draw_boxEv__ZTI9Fl_Widget__ZN9Fl_Button4drawEv__ZN9Fl_Button5valueEi__ZN9Fl_Button6handleEi__ZN9Fl_Button7setonlyEv__ZN9Fl_ButtonC2EiiiiPKc__ZN9Fl_ButtonD0Ev__ZN9Fl_ButtonD1Ev__ZN9Fl_Widget10draw_focusEv__ZTI9Fl_Button__ZTS9Fl_Button__ZTV9Fl_Button__ZN2Fl13test_shortcutEi__ZN9Fl_Widget13test_shortcutEv__ZNK9Fl_Widget10draw_focusE10Fl_Boxtypeiiii__ZNK9Fl_Widget8draw_boxE10Fl_Boxtype8Fl_Color_FL_NORMAL_SIZE__ZN2Fl9readqueueEv__ZN9Fl_Widget10copy_labelEPKc__ZN9Fl_Widget10deactivateEv__ZN9Fl_Widget13damage_resizeEiiii__ZN9Fl_Widget6handleEi__ZN9Fl_Widget8activateEv__ZN9Fl_WidgetC1EiiiiPKc__ZN9Fl_WidgetD0Ev__ZN9Fl_WidgetD1Ev__ZNK9Fl_Widget8active_rEv__ZTS9Fl_Widget__ZTV9Fl_Widget__Z13fl_line_styleiiPc__Z7fl_rectiiii__ZN2Fl6box_dhE10Fl_Boxtype__ZN2Fl6box_dwE10Fl_Boxtype__ZN2Fl6box_dxE10Fl_Boxtype__ZN2Fl6box_dyE10Fl_Boxtype__ZTVN10__cxxabiv117__class_type_infoE___cxa_pure_virtual__Z14XParseGeometryPKcPiS1_PjS2___ZN2Fl3argEiPPcRi__ZN2Fl4argsEiPPc__ZN2Fl4argsEiPPcRiPFiiS1_S2_E__ZN2Fl4helpE__ZN10Fl_Tooltip8enabled_E__ZN2Fl15default_atcloseEP9Fl_WindowPv__ZN2Fl7atcloseE__ZN9Fl_Window4drawEv_cos__ZN9Fl_Window10_Fl_WindowEv__ZN9Fl_Window10copy_labelEPKc__ZN9Fl_Window16default_callbackEPS_Pv__ZN9Fl_Window7currentEv__ZN9Fl_Window9iconlabelEPKc__ZN9Fl_WindowC1EiiiiPKc__ZN9Fl_WindowC2EiiPKc__ZN9Fl_WindowC2EiiiiPKc__ZNK9Fl_Window6x_rootEv__ZNK9Fl_Window6y_rootEv__ZTI9Fl_Window__ZTS9Fl_Window___i686.get_pc_thunk.dx__Z16fl_color_average8Fl_ColorS_f__Z7fl_lineiiii__ZN6Fl_Box4drawEv__ZN6Fl_Box6handleEi__ZN6Fl_BoxD0Ev__ZN6Fl_BoxD1Ev__ZTI6Fl_Box__ZTS6Fl_Box__ZN12Fl_RGB_ImageC1EPKhiiii__ZN12Fl_RGB_ImageD0Ev__ZN12Fl_RGB_ImageD1Ev__ZN8Fl_Image10desaturateEv__ZN8Fl_Image10draw_emptyEii__ZN8Fl_Image13color_averageE8Fl_Colorf__ZN8Fl_Image4copyEii__ZN8Fl_Image7measureEPK8Fl_LabelRiS3___ZN8Fl_Image7uncacheEv__ZN8Fl_Image9labeltypeEPK8Fl_Labeliiii8Fl_Align__ZN8Fl_ImageD0Ev__ZN8Fl_ImageD1Ev__ZTS12Fl_RGB_Image__ZTS8Fl_Image_CGColorSpaceCreateDeviceRGB_CGColorSpaceRelease_CGContextDrawImage_CGDataProviderCreateWithData_CGDataProviderRelease_CGImageCreate_CGImageRelease__Z11fl_clip_boxiiiiRiS_S_S___ZN2Fl5fatalE_fflush_fputc_vfprintf__ZN9Fl_Pixmap11delete_dataEv__ZN9Fl_Pixmap9copy_dataEv__ZN9Fl_PixmapC1EPKPc__ZN9Fl_PixmapD0Ev__ZTS9Fl_Pixmap__Z14fl_draw_pixmapPKPKcii8Fl_Color__Z16fl_end_offscreenv__Z17fl_copy_offscreeniiiiP13OpaqueGrafPtrii__Z17fl_delete_bitmaskP13OpaqueGrafPtr__Z17fl_measure_pixmapPKPKcRiS3___Z18fl_begin_offscreenP13OpaqueGrafPtr__Z19fl_delete_offscreenP13OpaqueGrafPtr__Z30fl_create_offscreen_with_alphaii_fl_access_fl_chmod_fl_execvp_fl_getcwd_fl_getenv_fl_make_path_fl_make_path_for_file_fl_mkdir_fl_nonspacing_fl_open_fl_rename_fl_rmdir_fl_stat_fl_system_fl_tolower_fl_toupper_fl_unlink_fl_utf2mbcs_fl_utf8len_fl_utf_nb_char_fl_utf_strcasecmp_fl_utf_strncasecmp_fl_utf_tolower_fl_utf_toupper_XUtf8IsNonSpacing_XUtf8Tolower_access_chmod_execvp_fl_utf8decode_fl_utf8encode_getcwd_mkdir_open_rename_rmdir_stat_strrchr_unlink_jpeg_abort_decompress_jpeg_consume_input_jpeg_has_multiple_scans_jpeg_input_complete_jinit_input_controller_jinit_marker_reader_jinit_memory_mgr_jpeg_abort_jpeg_destroy_jinit_master_decompress_jpeg_new_colormap_jdiv_round_up_jinit_1pass_quantizer_jinit_2pass_quantizer_jinit_color_deconverter_jinit_d_coef_controller_jinit_d_main_controller_jinit_d_post_controller_jinit_huff_decoder_jinit_inverse_dct_jinit_merged_upsampler_jinit_phuff_decoder_jinit_upsampler_jpeg_finish_output_jpeg_read_raw_data_jpeg_start_output_jpeg_std_message_table_jpeg_resync_to_restart__Z10fl_polygoniiiiii__Z10fl_polygoniiiiiiii__Z14fl_clip_regionv__Z15fl_push_no_clipv__Z15fl_restore_clipv__Z7fl_lineiiiiii__Z7fl_loopiiiiii__Z7fl_loopiiiiiiii__Z8fl_pointii__Z8fl_rectfiiii__Z9fl_xylineiii__Z9fl_xylineiiii__Z9fl_xylineiiiii__Z9fl_yxlineiii__Z9fl_yxlineiiii__Z9fl_yxlineiiiii_fl_clip_state_number_CGBitmapContextGetWidth_CGContextAddLineToPoint_CGContextClosePath_CGContextFillPath_CGContextFillRect_CGContextMoveToPoint_CGContextSetShouldAntialias_CGContextStrokePath_CGContextStrokeRect_ClipCGContextToRegion_CopyRgn_GetRegionBounds_RectInRgn_SectRgn_SetEmptyRgn_fl_quartz_line_width___Z10fl_measurePKcRiS1_i__Z14fl_expand_textPKcPcidRiRdii__Z7fl_drawPKciiii8Fl_AlignPFvS0_iiiEP8Fl_Imagei__ZN8Fl_Image4drawEii_fl_draw_shortcut__Z10fl_descentv__Z14fl_draw_symbolPKciiii8Fl_Color__Z7fl_drawPKciii__Z8fl_widthPKci__Z9fl_heightv_ceil_strlcpy__Z11fl_rtl_drawPKciii__Z7fl_drawPKciff__Z7fl_drawPKcii__Z8fl_widthPKc__Z8fl_widthPKti__Z8fl_widthh__Z8fl_widthj__ZN11Fl_FontSizeC1EPKci__ZN11Fl_FontSizeC2EPKci__ZN11Fl_FontSizeD1Ev__ZN11Fl_FontSizeD2Ev_fl_font__fl_fonts_fl_size__ATSFontFindFromName_ATSFontGetHorizontalMetrics_ATSUCreateStyle_ATSUCreateTextLayout_ATSUDisposeStyle_ATSUDisposeTextLayout_ATSUDrawText_ATSUFindFontFromName_ATSUGetUnjustifiedBounds_ATSUSetAttributes_ATSUSetLayoutControls_ATSUSetLineControls_ATSUSetRunStyle_ATSUSetTextPointerLocation_ATSUSetTransientFontMatching_CFStringCreateWithCString_fl_utf8toUtf16__Z11fl_inactive8Fl_Color__Z8fl_colorhhh_fl_current_xmap_fl_xmap_CGContextSetRGBFillColor_CGContextSetRGBStrokeColor__Z11fl_no_labelPK8Fl_Labeliiii8Fl_Align__Z15fl_normal_labelPK8Fl_Labeliiii8Fl_Align__Z17fl_normal_measurePK8Fl_LabelRiS2___ZNK8Fl_Label4drawEiiii8Fl_Align__ZNK9Fl_Widget10draw_labelEiiii__ZN12Fl_XBM_ImageC2EPKc__ZN12Fl_XBM_ImageD0Ev__ZN12Fl_XBM_ImageD1Ev__ZN9Fl_BitmapC2EPKcii__ZTI12Fl_XBM_Image__ZTS12Fl_XBM_Image__ZTV12Fl_XBM_Image__ZN9Fl_Bitmap4copyEii__ZN9Fl_Bitmap4drawEiiiiii__ZN9Fl_Bitmap5labelEP12Fl_Menu_Item__ZN9Fl_Bitmap5labelEP9Fl_Widget__ZN9Fl_Bitmap7uncacheEv__ZN9Fl_BitmapD2Ev__ZTI9Fl_Bitmap__ZTV9Fl_Bitmap__ZN12Fl_XPM_ImageC2EPKc__ZN12Fl_XPM_ImageD0Ev__ZN12Fl_XPM_ImageD1Ev__ZTI12Fl_XPM_Image__ZTS12Fl_XPM_Image__ZTV12Fl_XPM_Image__Z11fl_draw_box10Fl_Boxtypeiiii8Fl_Color__Z12fl_gray_rampv__Z12fl_rectboundiiii8Fl_Color__Z15fl_border_frameiiii8Fl_Color__Z15fl_embossed_boxiiii8Fl_Color__Z15fl_engraved_boxiiii8Fl_Color__Z17fl_embossed_frameiiii8Fl_Color__Z17fl_engraved_frameiiii8Fl_Color__Z19fl_internal_boxtype10Fl_BoxtypePFviiii8Fl_ColorE__Z8fl_framePKciiii__Z8fl_rectfiiii8Fl_Color__Z9fl_frame2PKciiii__Z9fl_no_boxiiii8Fl_Color__ZN2Fl11get_boxtypeE10Fl_Boxtype__ZN2Fl15draw_box_activeEv__ZNK9Fl_Widget8draw_boxE10Fl_Boxtypeiiii8Fl_Color__Z25fl_define_FL_ROUND_UP_BOXv__Z8fl_arc_iiiiidd__Z6fl_arciiiidd__Z6fl_pieiiiidd__Z16gtk_round_up_boxiiii8Fl_Color__Z18gtk_round_down_boxiiii8Fl_Color__Z11fl_end_loopv__Z13fl_begin_loopv__Z9fl_vertexdd__ZN14Fl_Tiled_Image10desaturateEv__ZN14Fl_Tiled_Image13color_averageE8Fl_Colorf__ZN14Fl_Tiled_Image4copyEii__ZN14Fl_Tiled_Image4drawEiiiiii__ZN14Fl_Tiled_ImageC2EP8Fl_Imageii__ZN14Fl_Tiled_ImageD0Ev__ZN14Fl_Tiled_ImageD1Ev__ZN14Fl_Tiled_ImageD2Ev__ZN8Fl_Image4copyEv__ZTI14Fl_Tiled_Image__ZTS14Fl_Tiled_Image__ZTV14Fl_Tiled_Image__ZN11Fl_Browser_10update_topEv__ZN11Fl_Browser_11item_selectEPvi__ZN11Fl_Browser_11redraw_lineEPv__ZN11Fl_Browser_11select_onlyEPvi__ZN11Fl_Browser_16scrollbar_width_E__ZN11Fl_Browser_4drawEv__ZN11Fl_Browser_6handleEi__ZN11Fl_Browser_6resizeEiiii__ZN11Fl_Browser_6selectEPvii__ZN11Fl_Browser_7displayEPv__ZN11Fl_Browser_8deletingEPv__ZN11Fl_Browser_8deselectEi__ZN11Fl_Browser_8new_listEv__ZN11Fl_Browser_8positionEi__ZN11Fl_Browser_8swappingEPvS0___ZN11Fl_Browser_9find_itemEi__ZN11Fl_Browser_9hpositionEi__ZN11Fl_Browser_9insertingEPvS0___ZN11Fl_Browser_9replacingEPvS0___ZN11Fl_Browser_C1EiiiiPKc__ZN11Fl_Browser_C2EiiiiPKc__ZN11Fl_Browser_D0Ev__ZN11Fl_Browser_D1Ev__ZN11Fl_ValuatorD2Ev__ZN12Fl_ScrollbarD1Ev__ZN2Fl14scrollbar_sizeEv__ZN9Fl_SliderD2Ev__ZNK11Fl_Browser_10full_widthEv__ZNK11Fl_Browser_11full_heightEv__ZNK11Fl_Browser_11incr_heightEv__ZNK11Fl_Browser_13item_selectedEPv__ZNK11Fl_Browser_17item_quick_heightEPv__ZNK11Fl_Browser_4bboxERiS0_S0_S0___ZNK11Fl_Browser_8leftedgeEv__ZNK11Fl_Browser_9displayedEPv__ZTI11Fl_Browser___ZTS11Fl_Browser___ZTV11Fl_Browser___ZN12Fl_ScrollbarC1EiiiiPKc__ZN9Fl_Slider11scrollvalueEiiii__ZTV11Fl_Valuator__ZTV12Fl_Scrollbar__ZTV9Fl_Slider_CGContextSetLineCap_CGContextSetLineDash_CGContextSetLineJoin_CGContextSetLineWidth__ZN9Fl_Window14default_cursorE9Fl_Cursor8Fl_ColorS1__GetCursor_SetCursor__ZN10Fl_Tooltip10enter_areaEP9Fl_WidgetiiiiPKc__ZN10Fl_Tooltip10textcolor_E__ZN10Fl_Tooltip11hoverdelay_E__ZN10Fl_Tooltip5exit_EP9Fl_Widget__ZN10Fl_Tooltip5font_E__ZN10Fl_Tooltip5size_E__ZN10Fl_Tooltip6color_E__ZN10Fl_Tooltip6delay_E__ZN10Fl_Tooltip6enter_EP9Fl_Widget__ZN13Fl_TooltipBox4drawEv__ZN13Fl_TooltipBox4showEv__ZN13Fl_TooltipBox6layoutEv__ZN13Fl_TooltipBoxC1Ev__ZN13Fl_TooltipBoxD0Ev__ZN13Fl_TooltipBoxD1Ev__ZN14Fl_Menu_WindowC2EiiPKc__ZN16Fl_Single_WindowC2EiiPKc__ZN16Fl_Single_WindowD2Ev__ZN9Fl_Widget7tooltipEPKc__ZTI13Fl_TooltipBox__ZTS13Fl_TooltipBox__ZTV13Fl_TooltipBox__ZN14Fl_Menu_Window4hideEv__ZN14Fl_Menu_Window4showEv__ZN14Fl_Menu_Window5flushEv__ZN14Fl_Menu_WindowD2Ev__ZN2Fl11screen_xywhERiS0_S0_S0_ii__ZTI14Fl_Menu_Window__ZTV14Fl_Menu_Window__ZTV16Fl_Single_Window__ZN2Fl7composeERi__ZN8Fl_Menu_5clearEv__ZN12Fl_Menu_Item7setonlyEv__ZN8Fl_Menu_4copyEPK12Fl_Menu_ItemPv__ZN8Fl_Menu_4menuEPK12Fl_Menu_Item__ZN8Fl_Menu_5valueEPK12Fl_Menu_Item__ZN8Fl_Menu_9find_itemEPKc__ZN8Fl_Menu_C1EiiiiPKc__ZN8Fl_Menu_C2EiiiiPKc__ZN8Fl_Menu_D0Ev__ZN8Fl_Menu_D1Ev__ZN8Fl_Menu_D2Ev__ZNK8Fl_Menu_13item_pathnameEPciPK12Fl_Menu_Item__ZNK8Fl_Menu_4sizeEv__ZTI8Fl_Menu___ZTS8Fl_Menu___ZTV8Fl_Menu__fl_menu_array_owner__ZNK12Fl_Menu_Item4sizeEv_strcat__Z15fl_old_shortcutPKc__Z17fl_shortcut_labeli__ZN9Fl_Widget13test_shortcutEPKc__Z14fl_draw_pixmapPKPcii8Fl_Color__Z17fl_measure_pixmapPKPcRiS2__fl_mask_bitmap__Z19fl_create_offscreenii__Z24fl_can_do_alpha_blendingv__ZN16Fl_Double_Window4hideEv__ZN16Fl_Double_Window4showEv__ZN16Fl_Double_Window5flushEi__ZN16Fl_Double_Window5flushEv__ZN16Fl_Double_Window6resizeEiiii__ZN16Fl_Double_WindowD0Ev__ZN16Fl_Double_WindowD1Ev__ZN16Fl_Double_WindowD2Ev__ZTI16Fl_Double_Window__ZTS16Fl_Double_Window__ZTV16Fl_Double_Window_CGBitmapContextCreate_CGBitmapContextGetAlphaInfo_CGBitmapContextGetData_CGContextRelease_fwrite__Z17fl_create_bitmaskiiPKh__Z19fl_create_alphamaskiiiiPKh__ZN9Fl_BitmapC1EPKhii__ZN9Fl_BitmapD0Ev__ZN9Fl_BitmapD1Ev__ZTS9Fl_Bitmap_CGImageMaskCreate_XUtf8Toupper_fl_utf8back_fl_utf8bytes_fl_utf8from_mb_fl_utf8froma_fl_utf8fromwc_fl_utf8fwd_fl_utf8locale_fl_utf8test_fl_utf8to_mb_fl_utf8toa_fl_utf8towc_mbstowcs_strstr_wcstombs_jpeg_save_markers_jpeg_set_marker_processor_jpeg_alloc_huff_table_jpeg_alloc_quant_table_jpeg_natural_order_jpeg_free_large_jpeg_free_small_jpeg_get_large_jpeg_get_small_jpeg_mem_available_jpeg_mem_init_jpeg_mem_term_jpeg_open_backing_store_jzero_far_jcopy_block_row_jcopy_sample_rows_jround_up_jpeg_fill_bit_buffer_jpeg_huff_decode_jpeg_make_d_derived_tbl_jpeg_idct_1x1_jpeg_idct_2x2_jpeg_idct_4x4_jpeg_idct_float_jpeg_idct_ifast_jpeg_idct_islow__Z13fl_add_symbolPKcPFv8Fl_ColorEi__Z11fl_end_linev__Z12fl_translatedd__Z13fl_begin_linev__Z13fl_pop_matrixv__Z14fl_end_polygonv__Z14fl_push_matrixv__Z15fl_return_arrowiiii__Z16fl_begin_polygonv__Z22fl_end_complex_polygonv__Z24fl_begin_complex_polygonv__Z8fl_scaledd__Z9fl_circleddd__Z9fl_rotated_sin_CGContextAddArc__Z13fl_end_pointsv__Z14fl_mult_matrixdddddd__Z14fl_transform_xdd__Z14fl_transform_ydd__Z15fl_begin_pointsv__Z15fl_transform_dxdd__Z15fl_transform_dydd__Z21fl_transformed_vertexdd__Z6fl_gapv__Z8fl_scaled_rint__ZN12Fl_Scrollbar10timeout_cbEPv__ZN12Fl_Scrollbar12increment_cbEv__ZN12Fl_Scrollbar4drawEv__ZN12Fl_Scrollbar6handleEi__ZN12Fl_ScrollbarC2EiiiiPKc__ZN12Fl_ScrollbarD0Ev__ZTI12Fl_Scrollbar__ZTS12Fl_Scrollbar__ZN11Fl_Valuator11handle_dragEd__ZN11Fl_Valuator12value_damageEv__ZN11Fl_Valuator14handle_releaseEv__ZN11Fl_Valuator5clampEd__ZN11Fl_Valuator5valueEd__ZN11Fl_Valuator6formatEPc__ZN9Fl_Slider4drawEiiii__ZN9Fl_Slider6handleEiiiii__ZN9Fl_SliderC2EiiiiPKc__ZTI9Fl_Slider__ZN9Fl_Slider10_Fl_SliderEv__ZN9Fl_Slider11slider_sizeEd__ZN9Fl_Slider4drawEv__ZN9Fl_Slider6boundsEdd__ZN9Fl_Slider6handleEi__ZN9Fl_Slider7draw_bgEiiii__ZN9Fl_SliderC1EhiiiiPKc__ZN9Fl_SliderC1EiiiiPKc__ZN9Fl_SliderC2EhiiiiPKc__ZN9Fl_SliderD0Ev__ZN9Fl_SliderD1Ev__ZTS9Fl_Slider__ZN11Fl_Valuator5roundEd__ZN11Fl_Valuator9incrementEdi__ZN11Fl_ValuatorC2EiiiiPKc__ZTI11Fl_Valuator__ZN11Fl_Valuator4stepEd__ZN11Fl_Valuator9precisionEi__ZN11Fl_Valuator9softclampEd__ZN11Fl_ValuatorC1EiiiiPKc__ZN11Fl_ValuatorD0Ev__ZN11Fl_ValuatorD1Ev__ZTS11Fl_Valuator_snprintf__ZN14Fl_Menu_Window5eraseEv__ZN14Fl_Menu_WindowD0Ev__ZN14Fl_Menu_WindowD1Ev__ZTS14Fl_Menu_Window__ZN16Fl_Single_Window4showEv__ZN16Fl_Single_Window5flushEv__ZTI16Fl_Single_Window__ZN2Fl11screen_xywhERiS0_S0_S0_i__ZN2Fl12screen_countEv_screens__ZN16Fl_Single_WindowD0Ev__ZN16Fl_Single_WindowD1Ev__ZTS16Fl_Single_Window__ZN10menuwindow10autoscrollEi__ZN10menuwindow12set_selectedEi__ZN10menuwindow13find_selectedEii__ZN10menuwindow17early_hide_handleEi__ZN10menuwindow4drawEv__ZN10menuwindow6handleEi__ZN10menuwindow6titlexEi__ZN10menuwindow8positionEii__ZN10menuwindow9drawentryEPK12Fl_Menu_Itemii__ZN10menuwindow9is_insideEii__ZN10menuwindowC1EPK12Fl_Menu_ItemiiiiS2_S2_iii__ZN10menuwindowC2EPK12Fl_Menu_ItemiiiiS2_S2_iii__ZN10menuwindowD0Ev__ZN10menuwindowD1Ev__ZN10menuwindowD2Ev__ZN14Fl_Menu_WindowC2EiiiiPKc__ZN16Fl_Single_WindowC2EiiiiPKc__ZN9menustate9is_insideEii__ZN9menutitle4drawEv__ZN9menutitleC1EiiiiPK12Fl_Menu_Item__ZN9menutitleC2EiiiiPK12Fl_Menu_Item__ZN9menutitleD0Ev__ZN9menutitleD1Ev__ZNK12Fl_Menu_Item13find_shortcutEPi__ZNK12Fl_Menu_Item13test_shortcutEv__ZNK12Fl_Menu_Item4drawEiiiiPK8Fl_Menu_i__ZNK12Fl_Menu_Item4nextEi__ZNK12Fl_Menu_Item5popupEiiPKcPKS_PK8Fl_Menu___ZNK12Fl_Menu_Item7measureEPiPK8Fl_Menu___ZNK12Fl_Menu_Item8pulldownEiiiiPKS_PK8Fl_Menu_S1_i__ZTI10menuwindow__ZTI9menutitle__ZTS10menuwindow__ZTS9menutitle__ZTV10menuwindow__ZTV9menutitle__ZN2Fl4grabEP9Fl_Window__ZN16Fl_Return_Button4drawEv__ZN16Fl_Return_Button6handleEi__ZN16Fl_Return_ButtonD0Ev__ZN16Fl_Return_ButtonD1Ev__ZN9Fl_ButtonD2Ev__ZTI16Fl_Return_Button__ZTS16Fl_Return_Button__ZTV16Fl_Return_Button_SetUserFocusWindow_cxa_atexit_check_2_cxa_atexit_check_1_check_cxa_atexit_get_globals_add_routine_run_routines_cxa_atexit_wrapper_atexit_common__GLOBAL__I_win__ZSt8__ioinitGCC_except_table0GCC_except_table1GCC_except_table2GCC_except_table3GCC_except_table4GCC_except_table5GCC_except_table6GCC_except_table7GCC_except_table8GCC_except_table9___tcf_0__Z41__static_initialization_and_destruction_0iiEH_frame1___tcf_0.eh__Z41__static_initialization_and_destruction_0ii.eh__GLOBAL__I_win.eh__Z15fl_check_imagesPKcPhi__Z10read_dwordP7__sFILE__Z9read_wordP7__sFILE__Z9read_longP7__sFILE_fl_jpeg_error_handler_fl_jpeg_output_handler__Z7innardsPK8Fl_Labeliiii8Fl_AlignPA3_ii__ZZ15fl_shadow_labelPK8Fl_Labeliiii8Fl_AlignE4data__Z15fl_shadow_labelPK8Fl_Labeliiii8Fl_Align__ZZ17fl_engraved_labelPK8Fl_Labeliiii8Fl_AlignE4data__Z17fl_engraved_labelPK8Fl_Labeliiii8Fl_Align__ZZ17fl_embossed_labelPK8Fl_Labeliiii8Fl_AlignE4data__Z17fl_embossed_labelPK8Fl_Labeliiii8Fl_Align__GLOBAL__I__ZN2Fl10backgroundEhhh_tile_xpm_tile_cmap_tile_fl_bg_set_fl_fg_set_fl_bg2_set__ZZN2Fl13reload_schemeEvE6levels__ZZN2Fl6schemeEPKcE1e___tcf_0__Z41__static_initialization_and_destruction_0ii__Z7nothingv__Z7nothingP9Fl_Widget__GLOBAL__I__ZN2Fl11belowmouse_E_dataready_num_widget_watch_widget_watch_max_widget_watch_dwidgets_num_dwidgets_alloc_dwidgets_mac_timer_used_mac_timers_mac_timer_alloc_myScrap_resize_from_system_currDragRef_currDragData_currDragSize_currDragErr_fl_os_capture_macKeyLookUp_default_cursor_ptr_default_cursor_open_cb_got_events_dnd_flag_handlers_in_idle_first_check_next_check_free_check__Z17breakMacEventLoopv__Z12delete_timerR10MacTimeout__Z8do_timerP16__EventLoopTimerPv__ZZ16chord_to_e_statemE5state__Z16chord_to_e_statem__ZZ14keycode_to_symmmtE3map__Z14keycode_to_symmmt__Z21OpenAppleEventHandlerPK6AEDescPS_m__ZZ15fl_open_displayvE16beenHereDoneThat__Z21QuitAppleEventHandlerPK6AEDescPS_m__Z15FSSpec2UnixPathP6FSSpecPc__Z19fillCurrentDragDataP13OpaqueDragRef__Z41__static_initialization_and_destruction_0ii___tcf_0__Z17handleUpdateEventP15OpaqueWindowPtr__Z4sendiP9Fl_WidgetP9Fl_Window__Z21carbonDispatchHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv__ZZ16do_queued_eventsdE9appEvents__ZZ16do_queued_eventsdE14dispatchEvents__ZZ16do_queued_eventsdE6target__ZZ16do_queued_eventsdE3rgn__ZZ16do_queued_eventsdE9been_here__Z16do_queued_eventsd__Z17dndReceiveHandlerP15OpaqueWindowPtrPvP13OpaqueDragRef__ZZ18dndTrackingHandlersP15OpaqueWindowPtrPvP13OpaqueDragRefE2py__ZZ18dndTrackingHandlersP15OpaqueWindowPtrPvP13OpaqueDragRefE2px__Z18dndTrackingHandlersP15OpaqueWindowPtrPvP13OpaqueDragRef__ZZ19carbonWindowHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvE12activeWindow__Z19carbonWindowHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv__ZZ18carbonMouseHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvE10suppressed__ZZ18carbonMouseHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvE2py__ZZ18carbonMouseHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvE2px__ZZ18carbonMouseHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvE6keysym__Z18carbonMouseHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv__Z23carbonMousewheelHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv__ZZ21carbonKeyboardHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvE8prevMods__ZZ21carbonKeyboardHandlerP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvE6buffer__ZZN4Fl_X4makeEP9Fl_WindowE12windowEvents__ZZN4Fl_X4makeEP9Fl_WindowE14keyboardEvents__ZZN4Fl_X4makeEP9Fl_WindowE11mouseEvents__ZZN4Fl_X4makeEP9Fl_WindowE16mousewheelEvents__ZZN4Fl_X4makeEP9Fl_WindowE5xyPos__Z4sendP9Fl_Widgeti__Z6navkeyv_obj_queue_obj_head_obj_tail__GLOBAL__I__ZN2Fl3argEiPPcRi_helpmsg_title_name_geometry_arg_called_return_i__Z8fl_matchPKcS0_i__Z41__static_initialization_and_destruction_0ii__ZZN9Fl_Window4showEiPPcE8beenhere__Z5fatalPKcz__Z5errorPKcz__Z7warningPKcz__ZZ7ToupperiE5table__Z7Toupperi_use_merged_upsample_prepare_for_output_pass_finish_output_pass_output_pass_setup_error_exit_output_message_emit_message_format_message_reset_error_mgr_init_source_fill_input_buffer_skip_input_data_term_source_rstack_rstackptr_underline_at_built_in_table_utfWbuf_utfWlen__ZZN11Fl_FontSizeC4EPKciE7font_mx__Z17mac_Utf8_to_Utf16PKciPi_fl_cmap_measure_table__Z8hexdigiti_fl_box_table_draw_it_active_inactive_ramp_active_ramp__Z4drawiiiiiih__Z9gtk_color8Fl_Color__Z12gtk_up_frameiiii8Fl_Color__Z10gtk_up_boxiiii8Fl_Color__Z14gtk_down_frameiiii8Fl_Color__Z12gtk_down_boxiiii8Fl_Color__Z17gtk_thin_up_frameiiii8Fl_Color__Z15gtk_thin_up_boxiiii8Fl_Color__Z19gtk_thin_down_frameiiii8Fl_Color__Z17gtk_thin_down_boxiiii8Fl_Color__Z8fl_arc_iiiiidd__Z4drawiiiiii__Z6up_boxiiii8Fl_Color__Z8down_boxiiii8Fl_Color__Z8up_frameiiii8Fl_Color__Z10down_frameiiii8Fl_Color__Z11thin_up_boxiiii8Fl_Color__Z8up_roundiiii8Fl_Color__Z10down_roundiiii8Fl_Color__Z15narrow_thin_boxiiii8Fl_Color__Z10frame_rectiiiiPKc8Fl_Color__Z10shade_rectiiiiPKc8Fl_Color__Z11frame_roundiiiiPKc8Fl_Color__Z11shade_roundiiiiPKc8Fl_Color__Z18scrollbar_callbackP9Fl_WidgetPv__Z19hscrollbar_callbackP9Fl_WidgetPv__ZZN11Fl_Browser_6handleEiE2py__ZZN11Fl_Browser_6handleEiE8whichway__ZZN11Fl_Browser_6handleEiE6change_fl_quartz_line_pattern_size_fl_quartz_line_pattern_fl_quartz_line_join__fl_quartz_line_cap___ZZ13fl_line_styleiiPcE7pattern__ZZ13fl_line_styleiiPcE4Join__ZZ13fl_line_styleiiPcE3Cap_crsrARROWptr_crsrARROW_crsrNONEptr_crsrNONE_crsrNWSEptr_crsrNWSE_crsrWEptr_crsrWE_crsrNESWptr_crsrNESW_crsrMOVEptr_crsrMOVE_crsrHANDptr_crsrHAND_crsrHELPptr_crsrHELP_crsrNSptr_crsrNS__GLOBAL__I__ZN10Fl_Tooltip6delay_E_tip_window_recent_tooltip_H_Y_recursion__Z14recent_timeoutPv__ZZN9Fl_Widget7tooltipEPKcE8beenhere__Z41__static_initialization_and_destruction_0ii__Z15tooltip_timeoutPv_compose_pairs_table__ZZ17fl_shortcut_labeliE3buf_chars_per_pixel_ncolors_stack_window_stack_gc_stack_ix__ZZ17fl_create_bitmaskiiPKhE7reverse__ZZ19fl_create_alphamaskiiiiPKhE6dither_ucs_table_FE20_ucs_table_FB1E_ucs_table_302A_ucs_table_20D0_ucs_table_0E31_ucs_table_0901_ucs_table_064B_ucs_table_0591_ucs_table_0483_ucs_table_0300_ucs_table_FF21_ucs_table_33CE_ucs_table_24B6_ucs_table_2102_ucs_table_1E00_ucs_table_10A0_ucs_table_0386_ucs_table_0041_table.2285_cp1252_ret.3710_start_input_pass_finish_input_pass_consume_markers_reset_input_controller_get_sof_examine_app0_examine_app14_get_interesting_appn_save_marker_skip_variable_next_marker_read_markers_read_restart_marker_reset_marker_reader_extra_pool_slop_first_pool_slop_do_sarray_io_do_barray_io_access_virt_sarray_access_virt_barray_free_pool_self_destruct_alloc_small_alloc_large_alloc_sarray_alloc_barray_request_virt_sarray_request_virt_barray_realize_virt_arrays_base_dither_matrix_color_quantize_color_quantize3_quantize_ord_dither_quantize3_ord_dither_quantize_fs_dither_finish_pass_1_quant_new_color_map_1_quant_create_colorindex_RGB_order.2951_start_pass_1_quant_prescan_quantize_update_box_fill_inverse_cmap_pass2_no_dither_pass2_fs_dither_init_error_limit_finish_pass1_finish_pass2_start_pass_2_quant_new_color_map_2_quant_build_ycc_rgb_table_ycc_rgb_convert_null_convert_grayscale_convert_gray_rgb_convert_ycck_cmyk_convert_start_pass_dcolor_start_output_pass_decompress_smooth_data_decompress_data_decompress_onepass_dummy_consume_data_start_input_pass_consume_data_start_pass_main_process_data_context_main_process_data_simple_main_process_data_crank_post_start_pass_dpost_post_process_1pass_post_process_prepass_post_process_2pass_extend_offset_extend_test_start_pass_huff_decoder_decode_mcu_aanscalefactor.3018_aanscales.3010_start_pass_start_pass_merged_upsample_merged_2v_upsample_merged_1v_upsample_h2v1_merged_upsample_h2v2_merged_upsample_extend_offset_extend_test_start_pass_phuff_decoder_decode_mcu_DC_first_decode_mcu_AC_first_decode_mcu_DC_refine_decode_mcu_AC_refine_process_restart_start_pass_upsample_sep_upsample_fullsize_upsample_noop_upsample_int_upsample_h2v1_upsample_h2v2_upsample_h2v1_fancy_upsample_h2v2_fancy_upsample_symbols_symbnumb__Z4findPKc__Z15fl_init_symbolsv__ZZ15fl_init_symbolsvE8beenhere__Z11draw_arrow18Fl_Color__Z11draw_arrow28Fl_Color__Z11draw_arrow38Fl_Color__Z13draw_arrowbar8Fl_Color__Z13draw_arrowbox8Fl_Color__Z13draw_bararrow8Fl_Color__Z12draw_arrow018Fl_Color__Z12draw_arrow028Fl_Color__Z12draw_arrow038Fl_Color__Z14draw_0arrowbar8Fl_Color__Z14draw_0arrowbox8Fl_Color__Z14draw_0bararrow8Fl_Color__Z16draw_doublearrow8Fl_Color__Z10draw_arrow8Fl_Color__Z9draw_plus8Fl_Color__Z14draw_arrow1bar8Fl_Color__Z11draw_square8Fl_Color__Z11draw_circle8Fl_Color__Z9draw_line8Fl_Color__Z9draw_menu8Fl_Color__Z12draw_uparrow8Fl_Color__Z14draw_downarrow8Fl_Color__Z14draw_doublebar8Fl_Color__Z11draw_search8Fl_Color__Z9draw_fltk8Fl_Color__Z12draw_filenew8Fl_Color__Z13draw_fileopen8Fl_Color__Z13draw_filesave8Fl_Color__Z15draw_filesaveas8Fl_Color__Z14draw_fileprint8Fl_Color__Z12draw_refresh8Fl_Color__Z11draw_reload8Fl_Color__Z9draw_undo8Fl_Color__Z9draw_redo8Fl_Color__Z17set_outline_color8Fl_Color__Z9rectangledddd8Fl_Color__Z16draw_round_arrow8Fl_Colorf_what_m_p_n_gap_p_size_stack_sptr__Z21fl_transformed_vertexff__ZZN9Fl_Slider6handleEiiiiiE9offcenter_epsilon_num_screens__Z11screen_initv_p_button__Z7forwardi__Z8backwardi__ZZNK12Fl_Menu_Item5popupEiiPKcPKS_PK8Fl_Menu_E5dummyattal-src-1.0-rc2/admin/macx-bundle/starter.cxx0000644000175000017500000001211410664020732017152 0ustar aaaa // generated by Fast Light User Interface Designer (fluid) version 2.1000 //#include "starter.h" /*#include "ai.xpm" #include "client.xpm" #include "server.xpm" #include "scen.xpm" #include "camp.xpm" #include "theme.xpm"*/ #include #include #include #include using namespace std; #include #include #include #include #include #include #include #include Fl_Window* win = (Fl_Window*)0; string pfad(void* data) { int i = strlen((char*)data); i = i - 7; string help; help = (char*)data; help.erase(i, 7); cout << help << endl; return help; } void server(Fl_Widget* w, void* data){ string path = pfad(data); path += "attal-server --themepath "+path+"../Resources/themes/ &"; system(path.c_str()); win->hide(); } void client(Fl_Widget* w, void* data){ string path = pfad(data); path += "attal-client --themepath "+path+"../Resources/themes/ &"; system(path.c_str()); win->hide(); } void ai(Fl_Widget* w, void* data){ string path = pfad(data); path += "attal-ai --themepath "+path+"../Resources/themes/ &"; system(path.c_str()); win->hide(); } void scen(Fl_Widget* w, void* data){ string path = pfad(data); path += "attal-scenario-editor --themepath "+path+"../Resources/themes/ &"; system(path.c_str()); win->hide(); } void camp(Fl_Widget* w, void* data){ string path = pfad(data); path += "attal-campaign-editor --themepath "+path+"../Resources/themes/ &"; system(path.c_str()); win->hide(); } void theme(Fl_Widget* w, void* data){ string path = pfad(data); path += "attal-theme-editor --themepath "+path+"../Resources/themes/ &"; system(path.c_str()); win->hide(); } int main (int argc, char **argv) { Fl::scheme("plastic"); Fl::visual(FL_RGB); Fl::get_system_colors(); fl_register_images(); cout << argv[0] << endl; {Fl_Window* o = new Fl_Window(335, 220); win = o; o->label("Attal: Lords of Doom"); o->align(FL_ALIGN_TOP|FL_ALIGN_INSIDE); o->begin(); {Fl_Button* o = new Fl_Button(195, 152, 48, 48); string serverstr = pfad(argv[0])+"../Resources/themes/medieval/images/misc/ico_attal-server.png"; Fl_Shared_Image* img; img = (Fl_Shared_Image::get(serverstr.c_str())); Fl_Image *temp; temp = img->copy(o->w(), o->h() * img->h() / img->w()); img->release(); img = (Fl_Shared_Image *)temp; o->image(img); o->box(FL_DOWN_BOX); o->callback(server,argv[0]); } {Fl_Button* o = new Fl_Button(115, 25, 96, 96); string clientstr = pfad(argv[0])+"../Resources/themes/medieval/images/misc/ico_attal-client.png"; //Fl_Shared_Image* img; o->image(Fl_Shared_Image::get(clientstr.c_str())); /*Fl_Image *temp; temp = img->copy(128, 128 * img->h() / img->w()); img->release(); img = (Fl_Shared_Image *)temp; o->image(img);*/ o->box(FL_NO_BOX); o->callback(client,argv[0]); } {Fl_Button* o = new Fl_Button(250, 112, 48, 48); string aistr = pfad(argv[0])+"../Resources/themes/medieval/images/misc/ico_attal-ai.png"; Fl_Shared_Image* img; img = (Fl_Shared_Image::get(aistr.c_str())); Fl_Image *temp; temp = img->copy(o->w(), o->h() * img->h() / img->w()); img->release(); img = (Fl_Shared_Image *)temp; o->image(img); o->box(FL_DOWN_BOX); o->callback(ai,argv[0]); } {Fl_Button* o = new Fl_Button(30, 112, 48, 48); string scenstr = pfad(argv[0])+"../Resources/themes/medieval/images/misc/ico_attal-scenario-editor.png"; Fl_Shared_Image* img; img = (Fl_Shared_Image::get(scenstr.c_str())); Fl_Image *temp; temp = img->copy(o->w(), o->h() * img->h() / img->w()); img->release(); img = (Fl_Shared_Image *)temp; o->image(img); o->box(FL_DOWN_BOX); o->callback(scen,argv[0]); } {Fl_Button* o = new Fl_Button(85, 152, 48, 48); string campstr = pfad(argv[0])+"../Resources/themes/medieval/images/misc/ico_attal-campaign-editor.png"; Fl_Shared_Image* img; img = (Fl_Shared_Image::get(campstr.c_str())); Fl_Image *temp; temp = img->copy(o->w(), o->h() * img->h() / img->w()); img->release(); img = (Fl_Shared_Image *)temp; o->image(img); o->box(FL_DOWN_BOX); o->callback(camp,argv[0]); } {Fl_Button* o = new Fl_Button(140, 172, 48, 48); string themestr = pfad(argv[0])+"../Resources/themes/medieval/images/misc/ico_attal-theme-editor.png"; Fl_Shared_Image* img; img = (Fl_Shared_Image::get(themestr.c_str())); Fl_Image *temp; temp = img->copy(o->w(), o->h() * img->h() / img->w()); img->release(); img = (Fl_Shared_Image *)temp; o->image(img); o->box(FL_DOWN_BOX); o->callback(theme,argv[0]); } {string testpfad = pfad(argv[0]); Fl_Box* o = new Fl_Box(75, -10, 185, 65, ""); o->labeltype(FL_ENGRAVED_LABEL); o->labelsize(19); o->align(FL_ALIGN_INSIDE); } o->end(); o->resizable(o); } win->show(argc, argv); return Fl::run(); } attal-src-1.0-rc2/admin/mingw32-g++/0000755000175000017500000000000011016113670014400 5ustar aaaaattal-src-1.0-rc2/admin/mingw32-g++/qmake.conf0000644000175000017500000001012410760353111016344 0ustar aaaa# qmake configuration for mingw32-g++ # # Written for MinGW # QT_BUILD_TREE = /usr/local/qt4-win32/4.3.3 CROSS_PREFIX = /usr/local/qt4-win32/4.3.3 MAKEFILE_GENERATOR = MINGW TEMPLATE = app CONFIG += qt warn_on release link_prl copy_dir_files precompile_header win32 win32-g++ CONFIG -= unix x11 QT += core gui # Accessibility doesn't want to link right DEFINES += UNICODE QT_NO_ACCESSIBILITY QMAKE_COMPILER_DEFINES += __GNUC__ WIN32 QMAKE_EXT_OBJ = .o QMAKE_EXT_RES = _res.o QMAKE_CC = i586-mingw32msvc-gcc QMAKE_LEX = flex QMAKE_LEXFLAGS = QMAKE_YACC = byacc QMAKE_YACCFLAGS = -d QMAKE_CFLAGS = -DWIN32 -isysroot /usr/i586-mingw32msvc/include QMAKE_CFLAGS_DEPS = -M QMAKE_CFLAGS_WARN_ON = -Wall QMAKE_CFLAGS_WARN_OFF = -w QMAKE_CFLAGS_RELEASE = -O2 QMAKE_CFLAGS_DEBUG = -g QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses QMAKE_CFLAGS_THREAD = -mthreads QMAKE_CXX = i586-mingw32msvc-g++ QMAKE_CXXFLAGS = $$QMAKE_CFLAGS QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD QMAKE_CXXFLAGS_RTTI_ON = -frtti QMAKE_CXXFLAGS_RTTI_OFF = -fno-rtti QMAKE_CXXFLAGS_EXCEPTIONS_ON = -fexceptions QMAKE_CXXFLAGS_EXCEPTIONS_OFF = -fno-exceptions QMAKE_INCDIR = /usr/i586-mingw32msvc/include $${QT_BUILD_TREE}/include $${QT_BUILD_TREE}/include/Qt $${QT_BUILD_TREE}/include/QtCore $${QT_BUILD_TREE}/include/QtGui QMAKE_INCDIR_QT = $${CROSS_PREFIX}/include QMAKE_LIBDIR_QT = $${CROSS_PREFIX}/lib QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -o $obj $src QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $obj $src QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< QMAKE_LINK = i586-mingw32msvc-g++ QMAKE_LFLAGS = -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-u,_WinMain@16 QMAKE_LFLAGS_RELEASE = -Wl,-s QMAKE_LFLAGS_DEBUG = QMAKE_LFLAGS_CONSOLE = -Wl,-subsystem,console QMAKE_LFLAGS_WINDOWS = -Wl,-subsystem,windows QMAKE_LFLAGS_DLL = -shared -Wl,-u,_WinMain@16 QMAKE_LINK_OBJECT_MAX = 10 QMAKE_LINK_OBJECT_SCRIPT= object_script QMAKE_LIBS_CORE = -lkernel32 -luser32 -lshell32 -luuid -lole32 -ladvapi32 -lws2_32 QMAKE_LIBS_GUI = -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lws2_32 -lole32 -luuid -luser32 -ladvapi32 QMAKE_LIBS_NETWORK = -lws2_32 QMAKE_LIBS_OPENGL = -lopengl32 -lglu32 -lgdi32 -luser32 QMAKE_LIBS_COMPAT = -ladvapi32 -lshell32 -lcomdlg32 -luser32 -lgdi32 -lws2_32 QMAKE_LIBS_QT_ENTRY = -lqtmain -lmingw32 QMAKE_LIBS = -L/usr/i586-mingw32msvc/lib -L$${CROSS_PREFIX}/lib QMAKE_DIR_SEP = / QMAKE_COPY = cp QMAKE_COPY_DIR = cp -rf QMAKE_MOVE = mv QMAKE_DEL_FILE = rm QMAKE_MKDIR = mkdir QMAKE_DEL_DIR = rmdir QMAKE_MOC = /usr/bin/moc-qt4 QMAKE_UIC = /usr/bin/uic-qt4 QMAKE_RCC = /usr/bin/rcc # Removed because I don't know what these are or if they're even used # QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe # QMAKE_IDL = midl QMAKE_LIB = i586-mingw32msvc-ar rus QMAKE_AR = i586-mingw32msvc-ar rus #QMAKE_POST_LINK = i586-mingw32msvc-ranlib ../$(TARGET) QMAKE_RC = i586-mingw32msvc-windres #QMAKE_RANLIB = i586-mingw32msvc-ranlib QMAKE_ZIP = zip -r -9 QMAKE_STRIP = i586-mingw32msvc-strip QMAKE_STRIPFLAGS_LIB += --strip-unneeded QMAKE_CHK_DIR_EXISTS = test -d load(qt_config) attal-src-1.0-rc2/admin/mingw32-g++/qplatformdefs.h0000644000175000017500000000711510760353276017441 0ustar aaaa/**************************************************************************** ** ** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved. ** ** This file is part of the qmake spec of the Qt Toolkit. ** ** This file may be used under the terms of the GNU General Public ** License version 2.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of ** this file. Please review the following information to ensure GNU ** General Public Licensing requirements will be met: ** http://www.trolltech.com/products/qt/opensource.html ** ** If you are unsure which license is appropriate for your use, please ** review the following information: ** http://www.trolltech.com/products/qt/licensing.html or contact the ** sales department at sales@trolltech.com. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ #ifndef QPLATFORMDEFS_H #define QPLATFORMDEFS_H #ifdef UNICODE #ifndef _UNICODE #define _UNICODE #endif #endif // Get Qt defines/settings #include "qglobal.h" #include #include #include #include #include #include #include #include #include #include #if !defined(_WIN32_WINNT) || (_WIN32_WINNT-0 < 0x0500) typedef enum { NameUnknown = 0, NameFullyQualifiedDN = 1, NameSamCompatible = 2, NameDisplay = 3, NameUniqueId = 6, NameCanonical = 7, NameUserPrincipal = 8, NameCanonicalEx = 9, NameServicePrincipal = 10, NameDnsDomain = 12 } EXTENDED_NAME_FORMAT, *PEXTENDED_NAME_FORMAT; #endif #define Q_FS_FAT #ifdef QT_LARGEFILE_SUPPORT #define QT_STATBUF struct _stati64 // non-ANSI defs #define QT_STATBUF4TSTAT struct _stati64 // non-ANSI defs #define QT_STAT ::_stati64 #define QT_FSTAT ::_fstati64 #else #define QT_STATBUF struct _stat // non-ANSI defs #define QT_STATBUF4TSTAT struct _stat // non-ANSI defs #define QT_STAT ::_stat #define QT_FSTAT ::_fstat #endif #define QT_STAT_REG _S_IFREG #define QT_STAT_DIR _S_IFDIR #define QT_STAT_MASK _S_IFMT #if defined(_S_IFLNK) # define QT_STAT_LNK _S_IFLNK #endif #define QT_FILENO _fileno #define QT_OPEN ::_open #define QT_CLOSE ::_close #ifdef QT_LARGEFILE_SUPPORT #define QT_LSEEK ::_lseeki64 #ifndef UNICODE #define QT_TSTAT ::_stati64 #else #define QT_TSTAT ::_wstati64 #endif #else #define QT_LSEEK ::_lseek #ifndef UNICODE #define QT_TSTAT ::_stat #else #define QT_TSTAT ::_wstat #endif #endif #define QT_READ ::_read #define QT_WRITE ::_write #define QT_ACCESS ::_access #define QT_GETCWD ::_getcwd #define QT_CHDIR ::_chdir #define QT_MKDIR ::_mkdir #define QT_RMDIR ::_rmdir #define QT_OPEN_RDONLY _O_RDONLY #define QT_OPEN_WRONLY _O_WRONLY #define QT_OPEN_RDWR _O_RDWR #define QT_OPEN_CREAT _O_CREAT #define QT_OPEN_TRUNC _O_TRUNC #define QT_OPEN_APPEND _O_APPEND #if defined(O_TEXT) # define QT_OPEN_TEXT _O_TEXT # define QT_OPEN_BINARY _O_BINARY #endif #define QT_FOPEN ::fopen #define QT_FSEEK ::fseek #define QT_FTELL ::ftell #define QT_FGETPOS ::fgetpos #define QT_FSETPOS ::fsetpos #define QT_FPOS_T fpos_t #define QT_OFF_T long #define QT_SIGNAL_ARGS int #define QT_VSNPRINTF ::_vsnprintf #define QT_SNPRINTF ::_snprintf # define F_OK 0 # define X_OK 1 # define W_OK 2 # define R_OK 4 #endif // QPLATFORMDEFS_H attal-src-1.0-rc2/ai/0000755000175000017500000000000011016113670012041 5ustar aaaaattal-src-1.0-rc2/ai/.cvsignore0000644000175000017500000000020710331243510014034 0ustar aaaamoc obj moc_* *.moc.cpp *.o *.opt *.plg *.dsp .deps Makefile.in Makefile Makefile.Release Makefile.Debug attal-ia AI.plg Debug Release attal-src-1.0-rc2/ai/ai.pro0000644000175000017500000000134010634007745013164 0ustar aaaaTEMPLATE = app include( ../config.pro ) INCLUDEPATH += .. LIBS += -L.. unix:LIBS += -lAttalServer unix:LIBS += -lAttalCommon unix:LIBS += -lAttalAi win32:LIBS += -lAttalServer9 win32:LIBS += -lAttalCommon9 win32:LIBS += -lAttalAi2 SOURCES += aiInterface.cpp SOURCES += main.cpp HEADERS += aiInterface.h TRANSLATIONS += ../i18n/de/attal_ai_de.ts TRANSLATIONS += ../i18n/fr/attal_ai_fr.ts TRANSLATIONS += ../i18n/ru/attal_ai_ru.ts TRANSLATIONS += ../i18n/it/attal_ai_it.ts DESTDIR = .. OBJECTS_DIR=./obj MOC_DIR=./moc TARGET = attal-ai win32 { contains( CONFIG, debug ) { CONFIG += console } } QT += xml network unix:!macx { QMAKE_LFLAGS += -Wl,-rpath,. } unix { target.path = $${ATT_PREFIX}/bin/ INSTALLS += target } attal-src-1.0-rc2/ai/aiInterface.cpp0000644000175000017500000002342410673175502014776 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** aiInterface.cpp ** interface for the ia-client ** ** Version : $Id: aiInterface.cpp,v 1.35 2007/09/16 09:45:38 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/02/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "aiInterface.h" // generic include files #include #include // include files for QT #include #include #include #include #include #include #include #include #include #include #include #include #include #include // application specific includes #include "conf.h" #include "libCommon/log.h" #include "libCommon/attalSocket.h" #include "libCommon/dataTheme.h" #include "libServer/fightAnalyst.h" #include "libAi/analyst.h" extern QString DATA_PATH; extern QString THEME; extern QString PORT; extern bool FAST; QTextEdit * screen; AiInterface::AiInterface() { _socket = NULL; _inClose = false; aifLog.setAiLogLevel(LOG_NORMAL); if( ! DataTheme.init() ) { /// XXX: we have to manage better this case QMessageBox::critical( this, tr( "Can't load theme" ), tr( "Theme " ) + THEME + tr( " has not been loaded successfully" ) ); } _socket = new AttalSocket; assert( _socket ); _analyst = new Analyst( _socket ); _analyst->start(); initActions(); initMenuBar(); initStatusBar(); _edit = new QTextEdit( this ); _edit->setReadOnly( true ); screen = _edit; setCentralWidget( _edit ); _config=0; connect( _socket, SIGNAL( disconnected()),SLOT(slot_connectionClosed())); connect( _socket, SIGNAL( connected()),SLOT(slot_connected())); connect( _socket, SIGNAL( error( QAbstractSocket::SocketError ) ), SLOT( slot_error( QAbstractSocket::SocketError ) ) ); connect( &aifLog, SIGNAL( sig_print( QString ) ), SLOT( slot_log( QString ) ) ); connect( &aifLog, SIGNAL( sig_printAi( QString ) ), SLOT( slot_logAi( QString ) ) ); if(FAST) aiConnect("localhost",PORT.toInt()); } AiInterface::~AiInterface() { delete _analyst; if(_config){ delete _config; } delete _socket; DataTheme.clear(); } void AiInterface::changeEvent ( QEvent * e ) { //used to replace setCaption switch (e->type()){ case QEvent::WindowTitleChange: { setWindowTitle( tr( "Attal: IA client" ) ); } break; default: QWidget::changeEvent ( e ); break; } } void AiInterface::slot_log( QString msg ) { screen->append( msg ); } void AiInterface::slot_logAi( QString result) { if( ( !screen ) ) return; screen->append( result ); screen->textCursor().atEnd(); } void AiInterface::initStatusBar() { statusBar()->showMessage( tr( "Log level : Normal" ), 0 ); } QAction * AiInterface::addAction( const QString & label, const QKeySequence & shortcut, MENU_ACTIONS id, QSignalMapper * sigmap ) { QAction * action = 0; action = new QAction( label, this ); action->setShortcut( shortcut ); _actions.insert( id, action ); sigmap->setMapping( action, id ); connect( action, SIGNAL( triggered() ), sigmap, SLOT( map() ) ); return action; } void AiInterface::initActions() { _actions.resize( NB_ACTIONS ); QAction * action; QSignalMapper * sigmap = new QSignalMapper( this ); addAction( tr( "&Connect to server" ), QKeySequence( tr( "CTRL+C" ) ), ACTION_CONNECT, sigmap ); action = addAction( tr( "&Disconnect" ), QKeySequence( tr( "CTRL+D" ) ), ACTION_DISCONNECT, sigmap ); action->setEnabled( false ); QActionGroup * groupLog = new QActionGroup( this ); action = addAction( tr( "Verbose" ), QKeySequence( tr( "" ) ), ACTION_LOGVERBOSE, sigmap ); action->setCheckable( true ); groupLog->addAction( action ); action = addAction( tr( "Normal" ), QKeySequence( tr( "" ) ), ACTION_LOGNORMAL, sigmap ); action->setCheckable( true ); groupLog->addAction( action ); action->setChecked( true ); action = addAction( tr( "Critical" ), QKeySequence( tr( "" ) ), ACTION_LOGCRITICAL, sigmap ); action->setCheckable( true ); groupLog->addAction( action ); action = addAction( tr( "Quiet" ), QKeySequence( tr( "" ) ), ACTION_LOGQUIET, sigmap ); action->setCheckable( true ); groupLog->addAction( action ); action = addAction( tr( "&Quit" ), QKeySequence( tr( "CTRL+Q" ) ), ACTION_QUIT, sigmap ); connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_action( int ) ) ); } /*! define menus */ void AiInterface::initMenuBar() { QMenu * menuFile = menuBar()->addMenu( tr( "&File" ) ); menuFile->addAction( _actions[ ACTION_CONNECT ] ); menuFile->addAction( _actions[ ACTION_DISCONNECT ] ); _menuLog = menuFile->addMenu( tr( "Log level" ) ); menuFile->addAction( _actions[ ACTION_QUIT ] ); _menuLog->addAction( _actions[ ACTION_LOGVERBOSE ] ); _menuLog->addAction( _actions[ ACTION_LOGNORMAL ] ); _menuLog->addAction( _actions[ ACTION_LOGCRITICAL ] ); _menuLog->addAction( _actions[ ACTION_LOGQUIET ] ); } void AiInterface::slot_action( int num ) { switch( num ) { case ACTION_CONNECT: actionConnect(false); break; case ACTION_DISCONNECT: actionDisconnect(); break; case ACTION_LOGVERBOSE: statusBar()->showMessage( tr( "Log level : Verbose" ), 0 ); aifLog.setAiLogLevel(LOG_VERBOSE); break; case ACTION_LOGNORMAL: statusBar()->showMessage( tr( "Log level : Normal" ), 0 ); aifLog.setAiLogLevel(LOG_NORMAL); break; case ACTION_LOGCRITICAL: statusBar()->showMessage( tr( "Log level : Critical" ), 0 ); aifLog.setAiLogLevel(LOG_CRITICAL); break; case ACTION_LOGQUIET: statusBar()->showMessage( tr( "Log level : Quiet" ), 0 ); aifLog.setAiLogLevel(LOG_QUIET); break; case ACTION_QUIT: actionQuit(); break; } } void AiInterface::actionConnect(bool fast) { bool success; if( _socket->state() == QAbstractSocket::UnconnectedState ) { if( _config == 0 ) { _config = new ConfigConnection( this ); } _config->setHost( "localhost" ); _config->setPort( PORT.toInt() ); _config->setPlayerName( "IA" ); _config->exec(); if( _config->result() == QDialog::Accepted || fast) { success = aiConnect(_config->getHost(), _config->getPort() ); } } else { QMessageBox::critical( this, tr( "Can't connect" ), tr( "You're already connected to a server. Please disconnect first." ) ); } } bool AiInterface::aiConnect(QString host, int port) { bool success = false; if( _socket->state() == QAbstractSocket::UnconnectedState ) { _socket->connectToHost( host, port ); _actions[ ACTION_CONNECT ]->setEnabled( false ); _actions[ ACTION_DISCONNECT ]->setEnabled( true ); success = true; } return success; } void AiInterface::slot_connectionClosed() { logDD("disconnected"); } void AiInterface::slot_connected() { logDD("connected"); } void AiInterface::slot_error( QAbstractSocket::SocketError error ) { logEE( "Cannot connect to server" ); switch( error ) { case QAbstractSocket::ConnectionRefusedError: logEE( "Connection Refused" ); break; case QAbstractSocket::HostNotFoundError: logEE( "Host not found" ); break; case QAbstractSocket::SocketAccessError: logEE( "Access to the socket failed" ); break; default: logEE( "Other socket error" ); break; } disconnect(); } void AiInterface::disconnect() { _socket->close(); _analyst->reinit(); _actions[ ACTION_CONNECT ]->setEnabled( true ); _actions[ ACTION_DISCONNECT ]->setEnabled( false ); } void AiInterface::actionDisconnect() { disconnect(); } void AiInterface::actionQuit() { disconnect(); qApp->quit(); } // // ----- ConfigConnection ----- // ConfigConnection::ConfigConnection( QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { setWindowTitle( tr( "Connection to server" ) ); QVBoxLayout * layout = new QVBoxLayout( this ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addSpacing( 5 ); QLabel * labHost = new QLabel( tr( "Host : " ), this ); FIXEDSIZE( labHost ); layH1->addWidget( labHost ); layH1->addSpacing( 5 ); _host = new QLineEdit( this ); _host->setFixedSize( 160, 20 ); layH1->addWidget( _host ); layH1->addStretch( 1 ); layout->addLayout( layH1, 1 ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addSpacing( 5 ); QLabel * labPort = new QLabel( tr( "Port : " ), this ); FIXEDSIZE( labPort ); layH2->addWidget( labPort ); layH2->addSpacing( 5 ); _port = new QLineEdit( this ); _port->setFixedSize( 80, 20 ); layH2->addWidget( _port ); layH2->addStretch( 1 ); layout->addLayout( layH2, 1 ); QHBoxLayout * layH4 = new QHBoxLayout(); layH4->addSpacing( 5 ); QLabel * labName = new QLabel( tr( "Name : " ), this ); FIXEDSIZE( labName ); layH4->addWidget( labName ); layH4->addSpacing( 5 ); _name = new QLineEdit( this ); _name->setFixedSize( 80, 20 ); layH4->addWidget( _name ); layH4->addStretch( 1 ); layout->addLayout( layH4, 1 ); QHBoxLayout * layH3 = new QHBoxLayout(); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Connect" ) ); FIXEDSIZE( pbOk ); layH3->addStretch( 1 ); layH3->addWidget( pbOk ); layH3->addStretch( 1 ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); layH3->addWidget( pbCan ); layH3->addStretch( 1 ); layout->addLayout( layH3, 2 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); setFixedSize( 250, 150 ); } attal-src-1.0-rc2/ai/aiInterface.h0000644000175000017500000000703710501060510014423 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** aiInterface.h ** interface for the ai-client ** ** Version : $Id: aiInterface.h,v 1.16 2006/09/10 19:02:32 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/02/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef AIINTERFACE_H #define AIINTERFACE_H // generic include files #include // include files for QT #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/log.h" class QAction; class QTextEdit; class QSignalMapper; class Analyst; class AttalSocket; class ConfigConnection; /* ------------------------------ * Interface * ------------------------------ */ /** comment for the class */ class AiInterface : public QMainWindow { Q_OBJECT public: /** Constructor */ AiInterface(); /** Destructor */ virtual ~AiInterface(); public slots: /** Slot managing 'File' menu */ void slot_action( int num ); void slot_connectionClosed(); void slot_connected(); void slot_log( QString msg ); void slot_logAi( QString msg ); void slot_error( QAbstractSocket::SocketError error ); protected: virtual void changeEvent ( QEvent * e ); private: enum MENU_ACTIONS { ACTION_CONNECT=0, ACTION_DISCONNECT, ACTION_LOGVERBOSE, ACTION_LOGNORMAL, ACTION_LOGCRITICAL, ACTION_LOGQUIET, ACTION_QUIT, NB_ACTIONS }; /** Defines menus */ void initMenuBar(); /** Defines statusBar */ void initStatusBar(); /** Defines actions */ void initActions(); /** Add a new action */ QAction * addAction( const QString & label, const QKeySequence & shortcut, MENU_ACTIONS id, QSignalMapper * sigmap ); void actionConnect(bool fast); void actionDisconnect(); void disconnect(); void actionQuit(); bool aiConnect(QString host, int port); QMenu * _menuLog; QTextEdit * _edit; AttalSocket * _socket; Analyst * _analyst; QVector _actions; ConfigConnection * _config; IALogLevel iaLogLevel; bool _inClose; }; /** Dialog for configuring connection to server */ class ConfigConnection : public QDialog { Q_OBJECT public: /** Constructor */ ConfigConnection( QWidget * parent = 0, const char * name = 0 ); /** Setting hostname */ void setHost( QString host ) { _host->setText( host ); } /** Getting hostname */ QString getHost() { return _host->text(); } int getPort() { return _port->text().toInt(); } /** Setting port number */ void setPort( int port ) { _port->setText( QString::number( port ) ); } /** Getting player's name */ QString getPlayerName() { return _name->text(); } /** Setting player's name */ void setPlayerName( QString name ) { _name->setText( name ); } void accept() { QDialog::accept(); } private: QLineEdit * _host, * _port, * _name; }; #define FIXEDSIZE( wid ) (wid)->setFixedSize( (wid)->sizeHint() ) #endif // INTERFACE_H attal-src-1.0-rc2/ai/main.cpp0000644000175000017500000000435410630060445013501 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** main.cpp ** main file for ia ** ** Version : $Id: main.cpp,v 1.19 2007/06/01 18:10:45 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 29/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include using namespace std; // include files for QT #include #include #include #include #include #include // application specific includes #include "conf.h" #include "libCommon/attalCommon.h" #include "ai/aiInterface.h" extern QString THEME; extern QString THEME_PATH; extern QString IMAGE_PATH; extern bool HIDE; int main( int argc, char **argv ) { QDir trfolder; trfolder = translationsDir(); QApplication app( argc, argv ); QTranslator translator( 0 ); translator.load( QString("attal_ai_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibs( 0 ); translatorlibs.load( QString("attal_libserver_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibai( 0 ); translatorlibai.load( QString("attal_libai_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); app.installTranslator( &translator ); app.installTranslator( &translatorlibs ); app.installTranslator( &translatorlibai ); if (parseArgs( argc, argv, AttalCommon::ATTALAI ) ) { return 1; } useTheme(); app.setWindowIcon(QIcon( IMAGE_PATH + "misc/ico_attal-ai.png")); if (app.windowIcon().isNull()) qDebug("Window icon is null!"); AiInterface game; //app.setMainWidget( &game ); if(!HIDE) { game.show(); } return app.exec(); } attal-src-1.0-rc2/campaignEditor/0000755000175000017500000000000011016113670014376 5ustar aaaaattal-src-1.0-rc2/campaignEditor/.cvsignore0000644000175000017500000000013010331243510016364 0ustar aaaamoc obj Makefile Makefile.Release Makefile.Debug moc_* *.moc.cpp *.o *.opt *.plg *.dsp attal-src-1.0-rc2/campaignEditor/campaignEditor.cpp0000644000175000017500000000462610630060445020042 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** campaignEditor.cpp ** main file for the campaign editor ** ** Version : $Id: campaignEditor.cpp,v 1.15 2007/06/01 18:10:45 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 20/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ // include files for QT #include #include #include #include #include #include #include // application specific includes #include "conf.h" #include "libCommon/attalCommon.h" #include "libCommon/log.h" #include "libClient/gui.h" #include "campaignEditor/campaignInterface.h" extern QString IMAGE_PATH; extern QString CAMPAIGN_PATH; extern QString SCENARIO_PATH; extern QString THEME; extern QString THEME_PATH; int main( int argc, char **argv ) { QDir trfolder; trfolder = translationsDir(); QApplication app( argc, argv ); QTranslator translator( 0 ); translator.load( QString("campaign_editor_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibcomm( 0 ); translatorlibcomm.load( QString("attal_libcommon_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibclient( 0 ); translatorlibclient.load( QString("attal_libclient_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); app.installTranslator( &translator ); app.installTranslator( &translatorlibcomm ); app.installTranslator( &translatorlibclient ); if (parseArgs( argc, argv, AttalCommon::ATTALCAMPAIGNEDITOR) ) { return 1; } useTheme(); app.setWindowIcon(QIcon( IMAGE_PATH + "misc/ico_attal-campaign-editor.png")); if (app.windowIcon().isNull()) qDebug("Window icon is null!"); CampaignInterface edit; //app.setMainWidget( &edit ); edit.show(); return app.exec(); } attal-src-1.0-rc2/campaignEditor/campaignEditor.pro0000644000175000017500000000172310634007746020064 0ustar aaaaTEMPLATE = app include( ../config.pro ) INCLUDEPATH += .. LIBS += -L.. unix:LIBS += -lAttalClient unix:LIBS += -lAttalCommon win32:LIBS += -lAttalClient9 win32:LIBS += -lAttalCommon9 contains( DEFINES, WITH_SOUND ) { win32:INCLUDEPATH += "$$quote($${SDL_DIR})\include" contains( CONFIG, staticlib ) { LIBS += -lSDL LIBS += -lSDL_mixer } } SOURCES += campaignEditor.cpp SOURCES += campaignInterface.cpp SOURCES += mainCampaignScreen.cpp HEADERS += campaignInterface.h HEADERS += mainCampaignScreen.h DESTDIR = .. OBJECTS_DIR=./obj MOC_DIR=./moc TARGET = attal-campaign-editor TRANSLATIONS += ../i18n/de/campaign_editor_de.ts TRANSLATIONS += ../i18n/fr/campaign_editor_fr.ts TRANSLATIONS += ../i18n/ru/campaign_editor_ru.ts TRANSLATIONS += ../i18n/it/campaign_editor_it.ts unix:!macx { QMAKE_LFLAGS += -Wl,-rpath,. } unix { target.path = $${ATT_PREFIX}/bin/ INSTALLS += target } QT += xml win32 { contains( CONFIG, debug ) { CONFIG += console } } attal-src-1.0-rc2/campaignEditor/campaignInterface.cpp0000644000175000017500000001166310522705147020520 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** campaignInterface.cpp ** Manages the campaign editor ** ** Version : $Id: campaignInterface.cpp,v 1.11 2006/11/03 18:28:55 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 20/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "campaignInterface.h" // include files for QT #include #include #include #include #include #include #include #include // application specific include files #include "conf.h" #include "libCommon/dataTheme.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "campaignEditor/mainCampaignScreen.h" extern QString IMAGE_PATH; extern QString DATA_PATH; extern QString CAMPAIGN_PATH; extern QString THEME; // // ----- CampaignInterface ----- // CampaignInterface::CampaignInterface() { _actions.resize( NB_ACTIONS ); initActions(); initMenuBar(); initStatusBar(); if( DataTheme.init() && ImageTheme.init() ) { _screen = new MainCampaignScreen( this ); setCentralWidget( _screen ); resize( 600, 600 ); } else { /// XXX: we could manage this better (later :) ) QMessageBox::critical( this, tr( "Can't load theme" ), tr( "Theme " ) + THEME + tr( " has not been loaded successfully" ) ); } } CampaignInterface::~CampaignInterface() { //free before ImageTheme, after DataTheme (clear of ImageTheme depend on DataTheme data) ImageTheme.clear(); DataTheme.clear(); } void CampaignInterface::changeEvent ( QEvent * e ) { //used to replace setCaption switch (e->type()){ case QEvent::WindowTitleChange: { setWindowTitle( "Campaign editor for 'Attal - Lords of Doom'" ); } break; default: QWidget::changeEvent ( e ); break; } } void CampaignInterface::addAction( const QString & label, const QString & key, MENU_ACTION num, QSignalMapper * sigmap ) { QAction * action = new QAction( label, this ); action->setShortcut( QKeySequence( key ) ); _actions.insert( num, action ); sigmap->setMapping( action, num ); connect( action, SIGNAL( triggered() ), sigmap, SLOT( map() ) ); } void CampaignInterface::initActions() { QSignalMapper * sigmap = new QSignalMapper( this ); addAction( tr( "&New" ), tr( "CTRL+N" ), ACTION_NEW, sigmap ); addAction( tr( "&Open" ), tr( "CTRL+O" ), ACTION_OPEN, sigmap ); addAction( tr( "&Save" ), tr( "CTRL+S" ), ACTION_SAVE, sigmap ); addAction( tr( "&Save as" ), "", ACTION_SAVEAS, sigmap ); addAction( tr( "&Quit" ), tr( "CTRL+Q" ), ACTION_QUIT, sigmap ); addAction( tr( "&Help" ), tr( "F1" ), ACTION_HELP, sigmap ); connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_action( int ) ) ); } void CampaignInterface::initStatusBar() { statusBar()->showMessage( "Status Bar", 0 ); } void CampaignInterface::initMenuBar() { QMenu * menuFile = menuBar()->addMenu( tr( "&File" ) ); QMenu * menuHelp = menuBar()->addMenu( tr( "&Help" ) ); menuFile->addAction( _actions[ ACTION_NEW ] ); menuFile->addAction( _actions[ ACTION_OPEN ] ); menuFile->addAction( _actions[ ACTION_SAVE ] ); menuFile->addAction( _actions[ ACTION_SAVEAS ] ); menuFile->addSeparator(); menuFile->addAction( _actions[ ACTION_QUIT ] ); menuHelp->addAction( _actions[ ACTION_HELP ] ); } void CampaignInterface::slot_action( int num ) { switch( num ) { case ACTION_NEW: actionNew(); break; case ACTION_OPEN: actionOpen(); break; case ACTION_SAVE: actionSave(); break; case ACTION_SAVEAS: actionSaveAs(); break; case ACTION_QUIT: actionQuit(); break; case ACTION_HELP: actionHelp(); break; } } void CampaignInterface::actionNew() { _filename = ""; _screen->newCampaign(); } void CampaignInterface::actionOpen() { QString filename = QFileDialog::getOpenFileName( this, "Open campaign", CAMPAIGN_PATH, "*.cmp" ); if( ! filename.isEmpty() ) { _filename= filename; _screen->load( filename ); } } void CampaignInterface::actionSave() { if( _filename.isEmpty() ) { slot_action( ACTION_SAVEAS ); } else { _screen->save( _filename ); } } void CampaignInterface::actionSaveAs() { _filename = QFileDialog::getSaveFileName( this, "Save campaign as", "", "*.cmp" ); if( ! _filename.isEmpty() ) { _screen->save( _filename ); } } void CampaignInterface::actionQuit() { qApp->quit(); } void CampaignInterface::actionHelp() { } void CampaignInterface::slot_status( const QString & text ) { statusBar()->showMessage( text, 0 ); } attal-src-1.0-rc2/campaignEditor/campaignInterface.h0000644000175000017500000000434210353757622020170 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** campaignInterface.h ** Manages the campaign editor ** ** Version : $Id: campaignInterface.h,v 1.4 2005/12/26 12:18:26 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 20/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CAMPAIGNINTERFACE_H #define CAMPAIGNINTERFACE_H // include files for QT #include #include #include #include // application specific includes class QAction; class QComboBox; class QSignalMapper; class MainCampaignScreen; /* ------------------------------ * CampaignInterface * ------------------------------ */ class CampaignInterface : public QMainWindow { Q_OBJECT public: /** Constructor */ CampaignInterface(); ~CampaignInterface(); public slots: /** Slot managing the actions */ void slot_action( int num ); /** Slot managing the status bar */ void slot_status( const QString & text ); protected: virtual void changeEvent ( QEvent * e ); private: enum MENU_ACTION { ACTION_NEW, ACTION_OPEN, ACTION_SAVE, ACTION_SAVEAS, ACTION_QUIT, ACTION_HELP, NB_ACTIONS }; void actionNew(); void actionOpen(); void actionSave(); void actionSaveAs(); void actionQuit(); void actionHelp(); /** Defines actions */ void initActions(); /** Define menus */ void initMenuBar(); /** Define statusBar */ void initStatusBar(); void addAction( const QString & label, const QString & key, MENU_ACTION num, QSignalMapper * sigmap ); QString _filename; MainCampaignScreen * _screen; QVector _actions; }; #endif // CAMPAIGNINTERFACE_H attal-src-1.0-rc2/campaignEditor/mainCampaignScreen.cpp0000644000175000017500000000657010531030057020634 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** mainCampaignScreen.cpp ** main widget of the campaign editor ** ** Version : $Id: mainCampaignScreen.cpp,v 1.10 2006/11/22 11:10:39 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 21/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "mainCampaignScreen.h" // generic include files // include files for QT #include #include #include #include // application specific includes #include "libCommon/campaign.h" #include "libCommon/log.h" #include "libClient/askWidget.h" MainCampaignScreen::MainCampaignScreen( QWidget * parent, char * /* name*/ ) : QWidget( parent ) { _campaign = 0; _name = new AskString( tr( "Name: " ), this ); _description = new AskString( tr( "Description: " ), this ); _scenarii = new AskStringList( this ); _scenarii->setLabel( tr( "List of scenarii: " ) ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( _name ); layout->addWidget( _description ); layout->addWidget( _scenarii ); layout->addStretch( 1 ); layout->activate(); } MainCampaignScreen::~MainCampaignScreen() { if( _campaign ) { delete _campaign; } } void MainCampaignScreen::reinit() { if( _campaign ) { uint nbScen = _campaign->getScenarioNumber(); _name->setValue( _campaign->getName() ); _description->setValue( _campaign->getDescription() ); _scenarii->clear(); for( uint i = 0; i < nbScen; ++i ) { _scenarii->addValue( _campaign->getScenario( i ) ); } } } bool MainCampaignScreen::load( const QString & filename ) { Campaign * newCampaign = new Campaign(); CampaignParser handler( newCampaign ); QFile file( filename ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if( ok ) { if( _campaign ) { delete _campaign; } _campaign = newCampaign; reinit(); } else { delete newCampaign; logEE( "Parse Error (%s) : %s", filename.toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } void MainCampaignScreen::save( const QString & filename ) { QFile f( filename ); if (! f.open(QIODevice::WriteOnly) ) { logEE( "Could not open file %s for writing\n", filename.toLatin1().constData() ); return; } uint nbScen = _scenarii->count(); _campaign->clearScenarii(); QTextStream ts( &f ); _campaign->setName( _name->getValue() ); _campaign->setDescription( _description->getValue() ); for( uint i = 0; i < nbScen; ++i ) { _campaign->addScenario(_scenarii->getValue(i) ); } if( _campaign ) { _campaign->save( & ts ); } f.close(); } void MainCampaignScreen::newCampaign() { if( _campaign ) { delete _campaign; } _campaign = new Campaign; reinit(); } attal-src-1.0-rc2/campaignEditor/mainCampaignScreen.h0000644000175000017500000000340410522705147020303 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** mainCampaignScreen.h ** main widget of the campaign editor ** ** Version : $Id: mainCampaignScreen.h,v 1.6 2006/11/03 18:28:55 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 21/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef MAINCAMPAIGNSCREEN_H #define MAINCAMPAIGNSCREEN_H // generic include files // include files for QT #include #include // application specific include files class AskString; class AskStringList; class Campaign; /* ------------------------------ * MainCampaignScreen * ------------------------------ */ class MainCampaignScreen : public QWidget { Q_OBJECT public: /** Constructor */ MainCampaignScreen( QWidget * parent = 0, char * name = 0 ); /** Destructor */ virtual ~MainCampaignScreen(); /** Load campaign */ bool load( const QString & filename ); /** Save campaign */ void save( const QString & filename ); /** Create new campaign */ void newCampaign(); private: void reinit(); Campaign * _campaign; AskString * _name, * _description; AskStringList * _scenarii; }; #endif // MAINCAMPAIGNSCREEN attal-src-1.0-rc2/client/0000755000175000017500000000000011016113670012726 5ustar aaaaattal-src-1.0-rc2/client/.cvsignore0000644000175000017500000000026410331243510014724 0ustar aaaamoc obj moc_* *.moc.cpp *.o *.opt *.plg *.dsp .deps Makefile.in Makefile Makefile.Release Makefile.Debug attal-client duel-client attal.plg libattal.plg libfight.plg Debug Release attal-src-1.0-rc2/client/client.pro0000644000175000017500000000217010761336141014734 0ustar aaaaTEMPLATE = app include( ../config.pro ) INCLUDEPATH += .. LIBS += -L.. unix:LIBS += -lAttalClient unix:LIBS += -lAttalFight unix:LIBS += -lAttalAi unix:LIBS += -lAttalServer unix:LIBS += -lAttalCommon win32:LIBS += -lAttalClient9 win32:LIBS += -lAttalFight8 win32:LIBS += -lAttalAi2 win32:LIBS += -lAttalServer9 win32:LIBS += -lAttalCommon9 contains(DEFINES, WITH_SOUND ) { win32:INCLUDEPATH += "$$quote($${SDL_DIR})\include" contains( CONFIG, staticlib ) { win32:LIBS += -L"$$quote($${SDL_DIR})\lib" LIBS += -lSDL LIBS += -lSDL_mixer } } SOURCES += clientWidgets.cpp SOURCES += clientInterface.cpp SOURCES += main.cpp HEADERS += clientWidgets.h HEADERS += clientInterface.h TRANSLATIONS += ../i18n/de/attal_client_de.ts TRANSLATIONS += ../i18n/fr/attal_client_fr.ts TRANSLATIONS += ../i18n/ru/attal_client_ru.ts TRANSLATIONS += ../i18n/it/attal_client_it.ts DESTDIR = .. OBJECTS_DIR=./obj MOC_DIR=./moc TARGET = attal-client unix:!macx { QMAKE_LFLAGS += -Wl,-rpath,. } unix { target.path = $${ATT_PREFIX}/bin/ INSTALLS += target } QT += xml network win32 { contains( CONFIG, debug ) { CONFIG += console } } attal-src-1.0-rc2/client/clientInterface.cpp0000644000175000017500000007444411016036211016541 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** clientInterface.cpp ** Manages the whole game ** ** Version : $Id: clientInterface.cpp,v 1.163 2008/05/24 16:04:25 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 17/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. ** ****************************************************************/ #include "clientInterface.h" // generic include files #include // include files for QT #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // application specific includes #include "conf.h" #include "client/clientWidgets.h" #include "libCommon/attalSettings.h" #include "libCommon/attalSocket.h" #include "libCommon/calendar.h" #include "libCommon/campaign.h" #include "libCommon/log.h" #include "libCommon/skill.h" #include "libCommon/unit.h" #include "libCommon/dataTheme.h" #include "libClient/aboutDialog.h" #include "libClient/attalStyle.h" #include "libClient/building.h" #include "libClient/chatWidget.h" #include "libClient/displayLord.h" #include "libClient/displayBase.h" #include "libClient/gainLevel.h" #include "libClient/game.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/optionsDialog.h" #include "libClient/widget.h" #include "libFight/fight.h" #include "libFight/fightResult.h" #include "libServer/attalServer.h" #include "libServer/engine.h" #include "libAi/analyst.h" extern QString DATA_PATH; extern QString THEME; extern QString SCENARIO_PATH; extern QString CAMPAIGN_PATH; extern QString SAVE_PATH; extern QString PORT; // // ----- ClientInterface ----- // ClientInterface::ClientInterface() { setWindowTitle( tr( "Attal - Lords of Doom" ) ); _socket = NULL; _fight = NULL; _level = 0; _base = NULL; _config = NULL; _state = SG_MAP; _mini = true; _full = true; _help = NULL; _proc = NULL; _msg = NULL; _scenInfo = ""; _statusBar = NULL; _progress = NULL; _progressNum = 0; qApp->setStyle( new AttalStyle( DATA_PATH + "style.dat" ) ); initActions(); initMenuBar(); _centralWindow = new QStackedWidget(this); setCentralWidget( _centralWindow ); //loadMenu(true); initProgressBar(); connect( & ImageTheme, SIGNAL( sig_loadStep() ), SLOT( slot_loadThemeStep() ) ); if( DataTheme.init() && ImageTheme.init() ) { ImageTheme.enableSound( AttalSettings::getInstance()->getStrategyModeSettings().isSoundOn ); ImageTheme.enableMusic( AttalSettings::getInstance()->getStrategyModeSettings().isMusicOn ); _socket = new AttalSocket(); _game = new Game( _centralWindow ); _game->setSocket( _socket ); _numWidg[0] = _centralWindow->addWidget( _game ); _centralWindow->setCurrentWidget( _game ); initStatusBar(); resizeWidget(); connect( this, SIGNAL( sig_animations() ), _game , SLOT( updateAnimations() ) ); connect( this, SIGNAL( sig_dispositions() ), _game , SLOT( updateDispositionMode() ) ); connect( _game, SIGNAL( sig_statusMsg( const QString & ) ), SLOT( slot_status( const QString & ) ) ); connect( _game, SIGNAL( sig_scenInfo( const QString & ) ), SLOT( slot_scenInfo( const QString & ) ) ); connect( _game, SIGNAL( sig_base( GenericBase * ) ), SLOT( slot_base( GenericBase * ) ) ); connect( _game, SIGNAL( sig_fight( GenericLord *, CLASS_FIGHTER ) ), SLOT( slot_fight( GenericLord *, CLASS_FIGHTER ) ) ); connect( _game, SIGNAL( sig_endGame() ), SLOT( slot_endGame() ) ); //connect( _game, SIGNAL( sig_endTurn() ), SLOT( slot_endTurn() ) ); connect( _game, SIGNAL( sig_beginTurn() ), SLOT( slot_beginTurn() ) ); connect( _game, SIGNAL( sig_exchange() ), SLOT( slot_exchange() ) ); connect( _game, SIGNAL( sig_result( bool ) ), SLOT( slot_result( bool ) ) ); connect( _game, SIGNAL( sig_statusBar() ), SLOT( slot_resourceBar() ) ); connect( this, SIGNAL( sig_map()), menuBar() , SLOT( show() ) ); connect( this, SIGNAL( sig_map()) , _statusBar , SLOT( show() ) ); connect( this, SIGNAL( sig_fightDisplay()) , menuBar() , SLOT( hide() ) ); connect( this, SIGNAL( sig_baseDisplay() ), _statusBar , SLOT( hide() ) ); connect( this, SIGNAL( sig_widgChanged(int)) , _centralWindow , SLOT( setCurrentIndex(int)) ); if( _game->getChat() ) { connect( this, SIGNAL( sig_newMessage( QString ) ), _game->getChat(), SLOT( slot_displayMessage( QString ) ) ); } connect( _socket, SIGNAL( readyRead() ), SLOT( slot_readSocket() ) ); connect( _socket, SIGNAL( hostFound() ), SLOT( slot_hostfound() ) ); connect( _socket, SIGNAL( disconnected() ), SLOT( slot_connectionClosed() ) ); connect( _socket, SIGNAL( error( QAbstractSocket::SocketError ) ), SLOT( slot_error( QAbstractSocket::SocketError ) ) ); _startDialog = new StartGameDialog(this); connect( _startDialog, SIGNAL( sig_newScen() ), this, SLOT( slot_newScen() ) ); connect( _startDialog, SIGNAL( sig_loadScen() ), this, SLOT( slot_loadScen() ) ); connect( _startDialog, SIGNAL( sig_newCamp() ), this, SLOT( slot_newCamp() ) ); connect( _startDialog, SIGNAL( sig_loadCamp() ), this, SLOT( slot_loadCamp() ) ); connect( _startDialog, SIGNAL( sig_dialogClosed() ), this, SLOT( slot_dialogClosed() ) ); } else { /// XXX: we could manage this better (later :) ) QMessageBox::critical( this, tr( "Can't load theme" ), tr( "Theme " ) + THEME + tr( " has not been loaded successfully" ) ); } loadMenu(false); //XXX here insert main menu } ClientInterface::~ClientInterface() { TRACE("~ClientInterface()"); if( _socket ) { disconnectClient(); } delete _game; if( _fight ) { delete _fight; } if( _base ) { delete _base; } if( _statusBar ) { delete _statusBar; } if( _progress ) { delete _progress; } delete _socket; //free before ImageTheme, after DataTheme (clear of ImageTheme depend on DataTheme data) ImageTheme.clear(); DataTheme.clear(); } void ClientInterface::reinit() { TRACE("ClientInterface::reinit"); _game->reinit(); //static int count = 0; _state = SG_MAP; _game->setVisible( true ); /* reinit resourceBar */ _resourceBar->reinit(); if( _fight ) { _fight->hide(); delete _fight; _fight = NULL; } if( _base ) { _base->hide(); delete _base; _base = NULL; } _scenInfo = ""; adjustWidgetLoading( W_NORMAL ); } void ClientInterface::changeEvent ( QEvent * e ) { //used to replace setCaption switch( e->type() ) { case QEvent::WindowTitleChange: setWindowTitle( tr( "Attal - Lords of Doom" ) ); break; default: QWidget::changeEvent ( e ); break; } } void ClientInterface::closeEvent( QCloseEvent * event ) { if( actionQuit() ) { event->accept(); } else { event->ignore(); } } QAction * ClientInterface::addAction( const QString & label, const QKeySequence & shortcut, MENU_ACTIONS id, QSignalMapper * sigmap ) { QAction * action; if( !label.isEmpty() ) { action = new QAction( label, this ); } else { action = new QAction( this ); } if( shortcut ) { action->setShortcut( shortcut ); } _actions.insert( id, action ); sigmap->setMapping( action, id ); connect( action, SIGNAL( triggered() ), sigmap, SLOT( map() ) ); return action; } void ClientInterface::initActions() { _actions.resize( NB_ACTIONS ); QAction * action; _sigmap = new QSignalMapper( this ); /* Menu File */ addAction( tr( "&Connect to server" ), QKeySequence( tr( "CTRL+C" ) ), ACTION_CONNECT, _sigmap ); addAction( tr( "&Start game" ), QKeySequence( tr( "CTRL+N" ) ), ACTION_START, _sigmap ); action = addAction( tr( "&End game" ), QKeySequence( tr( "CTRL+E" ) ), ACTION_END, _sigmap ); action->setDisabled( true ); action = addAction( tr( "&Save game" ), QKeySequence( tr( "CTRL+W" ) ), ACTION_SAVE, _sigmap ); action->setDisabled( true ); addAction( tr( "Fast &Server" ), QKeySequence( tr( "CTRL+S" ) ), ACTION_FASTCONNECT, _sigmap ); action = addAction( tr( "&Disconnect" ), QKeySequence( tr( "CTRL+D" ) ), ACTION_DISCONNECT, _sigmap ); action->setDisabled( true ); /* Menu Game */ addAction( tr( "&Mini map" ), QKeySequence( tr( "CTRL+M" ) ), ACTION_MINIMAP, _sigmap ); addAction( tr( "&Fullscreen" ), QKeySequence( tr( "CTRL+F" ) ), ACTION_FULL, _sigmap ); addAction( tr("&Popup message (base mode)"), QKeySequence( tr( "CTRL+T" ) ), ACTION_CHAT, _sigmap ); addAction( tr( "&Options" ), QKeySequence( tr( "CTRL+O" ) ), ACTION_OPTIONS, _sigmap ); action = addAction( tr( "&Scenario Informations" ), 0 , ACTION_INFO,_sigmap ); /* Right panel */ addAction( tr( "Next &Lord" ), QKeySequence( tr( "CTRL+L" ) ), ACTION_NEXTLORD, _sigmap ); addAction( tr( "Next &Base" ), QKeySequence( tr( "CTRL+B" ) ), ACTION_NEXTBASE, _sigmap ); addAction( tr( "&Help" ), QKeySequence( tr( "Key_F1" ) ), ACTION_HELP, _sigmap ); addAction( tr( "&About" ), QKeySequence( tr( "CTRL+A" ) ), ACTION_ABOUT, _sigmap ); addAction( tr( "&Quit" ), QKeySequence( tr( "ESC" ) ), ACTION_QUIT, _sigmap ); /* Menu Screen */ action = addAction( tr( "Free size" ), QKeySequence( "" ), ACTION_FREESIZE, _sigmap ); action->setChecked( true ); addAction( tr( "800x600" ), QKeySequence( "" ), ACTION_800, _sigmap ); addAction( tr( "1024x768" ), QKeySequence( "" ), ACTION_1024, _sigmap ); addAction( tr( "1280x1024" ), QKeySequence( "" ), ACTION_1280, _sigmap ); /// XXX: we have to use QActionGroup for switch between size of screen addAction( tr( "Test Style" ), QKeySequence( "CTRL+T" ), ACTION_TESTSTYLE, _sigmap ); connect( _sigmap, SIGNAL( mapped( int ) ), SLOT( slot_action( int ) ) ); } void ClientInterface::initMenuBar() { QMenu * menuFile = menuBar()->addMenu( tr( "&File" ) ); QMenu * menuGame = menuBar()->addMenu( tr( "&Game" ) ); QMenu * menuScreen = menuBar()->addMenu( tr( "&Screen" ) ); QMenu * menuHelp = menuBar()->addMenu( tr( "&Help" ) ); menuFile->addAction( _actions[ ACTION_START ] ); menuFile->addAction( _actions[ ACTION_END ] ); menuFile->addAction( _actions[ ACTION_SAVE ] ); menuFile->addAction( _actions[ ACTION_CONNECT ] ); menuFile->addAction( _actions[ ACTION_FASTCONNECT ] ); menuFile->addAction( _actions[ ACTION_DISCONNECT ] ); menuFile->addAction( _actions[ ACTION_QUIT ] ); menuGame->addAction( _actions[ ACTION_MINIMAP ] ); menuGame->addAction( _actions[ ACTION_FULL ] ); menuGame->addAction( _actions[ ACTION_CHAT ] ); //_centralWindow->addAction( _actions[ ACTION_CHAT ] ); menuGame->addAction( _actions[ ACTION_OPTIONS ] ); menuGame->addAction( _actions[ ACTION_INFO ] ); menuScreen->addAction( _actions[ ACTION_FREESIZE ] ); menuScreen->addAction( _actions[ ACTION_800 ] ); menuScreen->addAction( _actions[ ACTION_1024 ] ); menuScreen->addAction( _actions[ ACTION_1280 ] ); #ifdef TEST menuScreen->addAction( _actions[ ACTION_TESTSTYLE ] ); #endif menuHelp->addAction( _actions[ ACTION_HELP ] ); menuHelp->addAction( _actions[ ACTION_ABOUT ] ); } void ClientInterface::slot_action( int num ) { switch( num ) { case ACTION_START: actionStart(); break; case ACTION_END: actionEnd(); break; case ACTION_SAVE: save(); break; case ACTION_CONNECT: actionConnect(false); break; case ACTION_FASTCONNECT: actionFastConnect(); break; case ACTION_INFO: actionInfo(); break; case ACTION_DISCONNECT: actionDisconnect(); break; case ACTION_MINIMAP: actionMinimap(); break; case ACTION_FULL: actionFullScreen(); break; case ACTION_CHAT: actionPopupChat(); break; case ACTION_OPTIONS: actionOptions(); break; case ACTION_NEXTLORD: actionNextLord(); break; case ACTION_NEXTBASE: actionNextBase(); break; case ACTION_HELP: actionHelp(); break; case ACTION_ABOUT: actionAbout(); break; case ACTION_QUIT: actionQuit(); break; case ACTION_FREESIZE: actionResize( SIZEMODE_FREE ); break; case ACTION_800: actionResize( SIZEMODE_800 ); break; case ACTION_1024: actionResize( SIZEMODE_1024 ); break; case ACTION_1280: actionResize( SIZEMODE_1280 ); break; case ACTION_TESTSTYLE: actionTestStyle(); break; } } void ClientInterface::slot_exchange() { if( _base ) { _base->reinit(); } } void ClientInterface::slot_result( bool result ) { TRACE("ClientInterface::slot_result( bool result %d)",result); _winner = result; } void ClientInterface::slot_endConnection( QString /*name*/ ) { TRACE("ClientInterface::slot_endConnection"); _readyOut = true; } void ClientInterface::endEngine() { TRACE("ClientInterface::endEngine"); if( _engine ) { delete _engine; _engine = NULL; } } void ClientInterface::endServer() { TRACE("ClientInterface::endServer"); if( _server ){ delete _server; _server = NULL; } _game->setLocal( false ); } void ClientInterface::slot_endGame() { TRACE("ClientInterface::slot_endGame"); reinit(); if( _engine && _engine->getCampaign()) { handleResult( _winner ); } else { endGame(); } } void ClientInterface::slot_dialogClosed() { TRACE("ClientInterface::slot_dialogClosed"); disconnectClient(); } void ClientInterface::actionFastConnect() { TRACE("ClientInterface::actionFastConnect"); _proc = new QProcess(this); if( ! _proc ) { actionQuit(); } QStringList arglist; arglist.append( "--fast" ); #ifdef WIN32 _proc->start( "attal-server.exe", arglist ); #else QFile file("./attal-server"); if (file.exists()) { _proc->start( "./attal-server", arglist ); } else { _proc->start( "attal-server", arglist ); } #endif while( !_proc->waitForStarted()) {} QTimer::singleShot( 2000, this, SLOT( slot_clientConnect() ) ); } void ClientInterface::slot_clientConnect() { actionConnect( true ); } void ClientInterface::actionConnect(bool fast) { if( _socket->state() == QAbstractSocket::UnconnectedState ) { if( !_config ) { _config = new ConfigConnection( this ); } _config->setHost( "localhost" ); _config->setPort( PORT.toInt() ); _config->setPlayerName( _game->getGamePlayer()->getConnectionName() ); if(fast){ _config->accept(); } else { _config->exec(); } if( _config->result() == QDialog::Accepted ) { _game->setPlayerName( _config->getPlayerName() ); _socket->connectToHost( _config->getHost(), _config->getPort() ); adjustWidgetLoading( W_CLIENT ); } } else { QMessageBox::critical( this, tr( "Can't connect" ), tr( "You're already connected to a server. Please disconnect first." ) ); } } void ClientInterface::slot_hostfound() { if( !_server ) { emit sig_newMessage(QString (tr("Host found , connecting... "))); } } void ClientInterface::slot_error( QAbstractSocket::SocketError error ) { logEE("Cannot connect to server"); switch( error ) { case QAbstractSocket::ConnectionRefusedError: { logEE( "Connection Refused" ); emit sig_newMessage( QString( tr("Connection Refused") ) ); return; } break; case QAbstractSocket::HostNotFoundError: logEE( "Host not found" ); emit sig_newMessage( QString( "Host not found" ) ); break; case QAbstractSocket::RemoteHostClosedError: { logEE("The remote host closed the connection."); } break; case QAbstractSocket::SocketAccessError: logEE("The socket operation failed because the application lacked the required privileges."); break; case QAbstractSocket::SocketResourceError: logEE("The local system ran out of resources (e.g., too many sockets)."); break; case QAbstractSocket::SocketTimeoutError: logEE("The socket operation timed out."); break; case QAbstractSocket::DatagramTooLargeError: logEE("The datagram was larger than the operating system's limit (which can be as low as 8192 bytes)."); break; case QAbstractSocket::NetworkError: logEE("An error occurred with the network (e.g., the network cable was accidentally plugged out)."); break; case QAbstractSocket::AddressInUseError: logEE("The address specified to QUdpSocket::bind() is already in use and was set to be exclusive."); break; case QAbstractSocket::SocketAddressNotAvailableError: logEE("The address specified to QUdpSocket::bind() does not belong to the host."); break; case QAbstractSocket::UnsupportedSocketOperationError: logEE("The requested socket operation is not supported by the local operating system (e.g., lack of IPv6 support)."); break; default: { logEE( "Other socket error occured" ); emit sig_newMessage( QString( "Other socket error occured" ) ); return; } break; } disconnectClient(); } void ClientInterface::slot_connectionClosed() { TRACE( "Server disconnect" ); if( !_server ) { emit sig_newMessage(QString ("Server Disconnect ")); } killServer(); } void ClientInterface::killServer() { if(_proc) { _proc->close(); //QTimer::singleShot( 5000, _proc, SLOT( kill() ) ); _proc->terminate(); _proc->waitForFinished(); _proc = NULL; } } void ClientInterface::actionStart() { TRACE("ClientInterface::actionStart"); _server = new AttalServer( PORT.toInt(), QHostAddress::LocalHost ); _game->setLocal( true ); if( _server->isListening() ) { connect( _server, SIGNAL( sig_newPlayer( AttalPlayerSocket * ) ), this, SLOT( slot_ready() ) ); connect( _server, SIGNAL( sig_endConnection( QString ) ), this , SLOT( slot_endConnection( QString ) ) ); newEngine(); } else { delete _server; _server = 0; } actionConnect( true ); _startDialog->setVisible( true ); } void ClientInterface::actionEnd() { TRACE("ClientInterface::actionEnd"); if( _engine) { disconnectClient(); } } void ClientInterface::slot_newScen() { DisplayScenariiDialog scen( tr( "Choose new scenario" ) ); if( scen.exec() ) { _startDialog->hide(); loadSingle( scen.getFileName() ); } } void ClientInterface::slot_newCamp() { QString filename; filename = QFileDialog::getOpenFileName( this, tr( "Load campaign" ), CAMPAIGN_PATH, "*.cmp" ); if ( !filename.isEmpty() ) { _startDialog->hide(); loadCampaign( filename ); } } void ClientInterface::slot_loadScen() { QString filename; filename = QFileDialog::getOpenFileName( this, tr( "Load game" ), SAVE_PATH, "*.scn *.gam" ); if ( !filename.isEmpty() ) { _startDialog->hide(); loadSingle( filename ); } } void ClientInterface::slot_loadCamp() { QString filename; filename = QFileDialog::getOpenFileName( this, tr( "Load campaign" ), SAVE_PATH, "*.cms" ); if ( !filename.isEmpty() ) { _startDialog->hide(); loadCampaign( filename ); } } void ClientInterface::slot_endTurn() { } void ClientInterface::slot_beginTurn() { autosave(); } void ClientInterface::slot_ready() { TRACE("ClientInterface::slot_ready"); _readyIn = true; } void ClientInterface::addInternalAI() { TRACE("ClientInterface::addInternalAI"); QStringList arglist; AttalSocket * socket = new AttalSocket; Analyst * ai = new Analyst( socket ); socket->connectToHost( "localhost", PORT.toInt() ); _aiList.append( ai ); ai->start(); } bool ClientInterface::killAI() { int count; Analyst * ai; count = _aiList.count(); TRACE("bool ClientInterface::killAI count %d",count); AttalSocket * socket; if( _aiList.count() > 0 ) { for( int i = 0; i < count; i++ ) { ai = _aiList.takeFirst(); socket = ai->getSocket(); disconnect(socket, 0, 0, 0); delete ai; delete socket; } return true; } return false; } void ClientInterface::actionDisconnect() { TRACE("ClientInterface::actionDisconnect"); QMessageBox msb( tr( "Match" ), tr( "Do you want abandon the match ?" ), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape, 0, this ); if( msb.exec() != QMessageBox::Yes){ return; } disconnect(); } void ClientInterface::disconnectAI() { TRACE("ClientInterface::disconnectAI"); AttalSocket * socket; Analyst * ai; int count = _aiList.count(); if( _aiList.count() > 0 ) { for( int i = 0; i < count; i++ ) { TRACE("ClientInterface::disconnectAI _readyOut %d, i %d", _readyOut, i ); ai = _aiList.at(i); socket = ai->getSocket(); socket->disconnectFromHost(); } _readyOut = false; } } void ClientInterface::disconnectClient() { TRACE("ClientInterface::disconnectClient"); if( !_server ) { emit sig_newMessage(QString ("Disconnect from server")); } updateScreen(); _socket->abort(); endGame(); reinit(); } void ClientInterface::actionMinimap() { if( _game ) { _mini = ! _mini; _game->displayMiniMap( _mini ); _actions[ ACTION_MINIMAP ]->setChecked( _mini ); _actions[ ACTION_FULL ]->setEnabled( _mini ); } } void ClientInterface::actionPopupChat() { if( _base ) { ChatDialog chatDialog; connect( &chatDialog, SIGNAL(sig_message( QString )), _base, SLOT(slot_message( QString )) ); chatDialog.exec(); } } void ClientInterface::actionFullScreen() { if( _game ) { _full = ! _full; _game->displayFullScreen( _full ); _actions[ ACTION_FULL ]->setChecked( _full ); _actions[ ACTION_MINIMAP ]->setEnabled( _full ); } } void ClientInterface::actionNextLord() { if( _game ) { _game->nextLord(); } } void ClientInterface::actionNextBase() { if( _game ) { _game->nextBase(); } } void ClientInterface::actionInfo() { QMessageBox::information( this, "Information", _scenInfo ); } void ClientInterface::actionHelp() { if( ! _help ) { _help = new DisplayHelp( this ); } _help->resize( 800, 600 ); _help->show(); } void ClientInterface::actionAbout() { AboutDialog dialog; dialog.exec(); } bool ClientInterface::actionQuit() { bool ret = true; QMessageBox msb( tr("Are you sure ?"), tr("Do you really want to quit?"), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape, 0, this ); if ( msb.exec() == QMessageBox::Yes ) { AttalSettings::getInstance()->save(); /* this function is needed to handle an hack in Engine */ if( _engine ) { //_engine->setFinished( true ); endGame(); reinit(); } qApp->quit(); } else { ret = false; } return ret; } void ClientInterface::actionResize( SizeMode mode ) { _actions[ ACTION_FREESIZE ]->setChecked( false ); _actions[ ACTION_800 ]->setChecked( false ); _actions[ ACTION_1024 ]->setChecked( false ); _actions[ ACTION_1280 ]->setChecked( false ); switch( mode ) { case SIZEMODE_FREE: _actions[ ACTION_FREESIZE ]->setChecked( true ); setMinimumSize( 0, 0 ); setMaximumSize( 10000, 10000 ); AttalSettings::getInstance()->setDispositionMode( AttalSettings::DM_FULL ); break; case SIZEMODE_800: _actions[ ACTION_800 ]->setChecked( true ); setFixedSize( 800, 560 ); AttalSettings::getInstance()->setDispositionMode( AttalSettings::DM_VERYCOMPACT ); break; case SIZEMODE_1024: _actions[ ACTION_1024 ]->setChecked( true ); setFixedSize( 1024, 728 ); AttalSettings::getInstance()->setDispositionMode( AttalSettings::DM_COMPACT ); break; case SIZEMODE_1280: _actions[ ACTION_1280 ]->setChecked( true ); setFixedSize( 1280, 964); AttalSettings::getInstance()->setDispositionMode( AttalSettings::DM_FULL ); break; } emit sig_dispositions(); } void ClientInterface::actionTestStyle() { #ifdef TEST TestAttalStyle test; test.exec(); #endif } void ClientInterface::slot_status( const QString & text ) { _statusBar->showMessage( text, 1000 ); } void ClientInterface::slot_scenInfo( const QString & text ) { _scenInfo = text; } void ClientInterface::initStatusBar() { _statusBar = statusBar(); _resourceBar = new RessourceBar( this ); _resourceBar->setPlayer( _game->getGamePlayer() ); _cal = new QLabel( this ); _statusBar->addWidget( _resourceBar, 1 ); _statusBar->addWidget( _cal ); //_statusBar->showMessage( tr( "Status Bar" ), 0 ); } void ClientInterface::loadMenu( bool show ) { //XXX : don't display text, but a good start if( !_msg ) { _msg = new AttalMessage(this, false); _msg->setWindowTitle( tr("Loading Data...") ); _msg->addText( tr("Loading Data...") ); _msg->resize( 300, 70 ); _msg->setModal(false); } if( show ) { _msg->setVisible( true ); } else { _msg->setVisible( false ); } } void ClientInterface::initProgressBar() { if( ! _progress ) { _progress = new QProgressDialog( tr( "Loading data..." ), tr( "Cancel" ), 0, ImageTheme.getMaxLoadStep(), this, Qt::CustomizeWindowHint ); _progress->setLabelText( tr( "Loading data..." ) ); } //_progress->setWindowModality(Qt::WindowModal); } void ClientInterface::slot_loadThemeStep() { if( _progress ) { _progress->setValue( ++_progressNum ); qApp->processEvents(); } } void ClientInterface::slot_base( GenericBase * base ) { _state = SG_BASE; if( _base && _base->getBase() != base ) { _centralWindow->removeWidget( _base ); delete _base; _base = NULL; } /* destroy and create, modify is too much complicated */ if( !_base ) { _base = new DisplayBase( _centralWindow, base, _game, _socket ); _numWidg[1] = _centralWindow->addWidget( _base ); connect( _base, SIGNAL( sig_quit() ), SLOT( slot_map() ) ); connect( this, SIGNAL( sig_baseDisplay() ), _base , SLOT( show() ) ); } _base->reinit(); //_centralWindow->setCurrentWidget( _base ); emit sig_widgChanged( _numWidg[1] ); emit sig_baseDisplay(); ImageTheme.playMusicBase( base->getRace() ); } void ClientInterface::slot_map() { updateScreen(); ImageTheme.playMusicMap(); } void ClientInterface::updateScreen() { /* switch( _state ) { case SG_MAP: return; break; case SG_FIGHT: //_fight->hide(); //menuBar()->setVisible( true ); break; case SG_BASE: //_base->hide(); //_statusBar->setVisible( true ); break; default: logEE( "Should not happen" ); break; } */ _state = SG_MAP; emit sig_map(); emit sig_widgChanged( _numWidg[0] ); //_centralWindow->setCurrentWidget( _game ); } void ClientInterface::slot_fight( GenericLord * lord, CLASS_FIGHTER cla ) { if ( !_fight ) { _fight = new Fight( _centralWindow ); _fight->setGame( _game ); _numWidg[2] = _centralWindow->addWidget( _fight ); connect( _fight, SIGNAL( sig_quit() ), SLOT( slot_map() ) ); connect( _fight, SIGNAL( sig_statusMsg( const QString & ) ), SLOT( slot_status( const QString & ) ) ); connect( this, SIGNAL( sig_fightDisplay() ), _fight , SLOT( hide() ) ); } else { _fight->reinit(); } _state = SG_FIGHT; _fight->setSocket( _socket ); _fight->setLord( lord, cla ); emit sig_fightDisplay(); emit sig_widgChanged( _numWidg[2] ); //_centralWindow->setCurrentWidget( _fight ); ImageTheme.playMusicFight(); } void ClientInterface::slot_readSocket() { _socket->readData(); //TRACE( "Socket received %d | %d | %d", _socket->getCla1(), _socket->getCla2(), _socket->getCla3() ); switch( _state ) { case SG_MAP: _game->handleSocket(); break; case SG_FIGHT: _fight->handleSocket(); break; case SG_BASE: _base->handleSocket(); break; } if( _socket->bytesAvailable() > 0 ) { slot_readSocket(); } } void ClientInterface::slot_resourceBar() { _resourceBar->reinit(); _cal->setText( _game->getCalendar()->getDate()); } void ClientInterface::actionOptions() { OptionsDialog * options = new OptionsDialog( this ); connect( options, SIGNAL( sig_animation( int ) ), this , SLOT( actionOptionsAnimations( int ) ) ); #ifdef WITH_SOUND connect( options, SIGNAL( sig_music( int ) ), this , SLOT( actionOptionsMusic( int ) ) ); connect( options, SIGNAL( sig_sound( int ) ), this , SLOT( actionOptionsSound( int ) ) ); #endif connect( options, SIGNAL( sig_dispositions() ), this, SIGNAL( sig_dispositions() ) ); options->exec(); delete options; } void ClientInterface::actionOptionsAnimations( int state ) { AttalSettings::StrategyModeSettings settings = AttalSettings::getInstance()->getStrategyModeSettings(); switch( state ) { case Qt::Checked: { settings.isAnimationEnabled = true; } break; case Qt::Unchecked: { settings.isAnimationEnabled = false; } break; default: break; } AttalSettings::getInstance()->setStrategyModeSettings( settings ); emit sig_animations(); } #ifdef WITH_SOUND void ClientInterface::actionOptionsMusic( int state ) { AttalSettings::StrategyModeSettings settings = AttalSettings::getInstance()->getStrategyModeSettings(); switch( state ) { case Qt::Checked: { settings.isMusicOn = true; } break; case Qt::Unchecked: { settings.isMusicOn = false; } break; default: break; } ImageTheme.enableMusic( settings.isMusicOn ); AttalSettings::getInstance()->setStrategyModeSettings( settings ); } void ClientInterface::actionOptionsSound( int state ) { AttalSettings::StrategyModeSettings settings = AttalSettings::getInstance()->getStrategyModeSettings(); switch( state ) { case Qt::Checked: { settings.isSoundOn = true; } break; case Qt::Unchecked: { settings.isSoundOn = false; } break; default: break; } ImageTheme.enableSound( settings.isSoundOn ); AttalSettings::getInstance()->setStrategyModeSettings( settings ); } #endif void ClientInterface::adjustWidgetLoading( StatusWidget type ) { TRACE("ClientInterface::adjustWidgetLoading( StatusWidget type %d)", type); switch( type ) { case W_ENGINE: _actions[ ACTION_START ]->setEnabled( false ); _actions[ ACTION_END ]->setEnabled( true ); _actions[ ACTION_SAVE ]->setEnabled( true ); _actions[ ACTION_CONNECT ]->setEnabled( false ); _actions[ ACTION_DISCONNECT ]->setEnabled( false ); _actions[ ACTION_FASTCONNECT ]->setEnabled(false); break; case W_NORMAL: _actions[ ACTION_START ]->setEnabled( true ); _actions[ ACTION_END ]->setEnabled( false ); _actions[ ACTION_SAVE ]->setEnabled( false ); _actions[ ACTION_CONNECT ]->setEnabled( true ); _actions[ ACTION_DISCONNECT ]->setEnabled( false ); _actions[ ACTION_FASTCONNECT ]->setEnabled( true ); break; case W_CLIENT: _actions[ ACTION_START ]->setEnabled( false ); _actions[ ACTION_END ]->setEnabled( false ); _actions[ ACTION_SAVE ]->setEnabled( false ); _actions[ ACTION_CONNECT ]->setEnabled( false ); _actions[ ACTION_DISCONNECT ]->setEnabled( true ); _actions[ ACTION_FASTCONNECT ]->setEnabled(false); break; default: break; } } void ClientInterface::resizeWidget() { switch( QApplication::desktop()->width() ) { case 1280: actionResize(SIZEMODE_1280); break; case 1024: actionResize(SIZEMODE_1024); break; case 800: actionResize(SIZEMODE_800); break; default: actionResize( SIZEMODE_FREE ); break; } } attal-src-1.0-rc2/client/clientInterface.h0000644000175000017500000001352011016036211016172 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** clientInterface.h ** Manages the whole game ** ** Version : $Id: clientInterface.h,v 1.70 2008/05/24 16:04:25 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 17/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CLIENTINTERFACE_H #define CLIENTINTERFACE_H // include files for QT #include #include #include #include #include #include #include #include #include #include // application specific includes #include "libCommon/displayHelp.h" #include "libCommon/genericBuilding.h" #include "libClient/player.h" #include "libClient/game.h" #include "libClient/gui.h" #include "libClient/ressourceBar.h" #include "libServer/loadGame.h" class QProcess; class QAction; class QProgressDialog; class QSignalMapper; class AttalSocket; class DisplayBase; class Fight; class GainLevel; class GenericLord; class ConfigConnection; class StartGameDialog; class AttalMessage; class AttalServer; class Engine; class Analyst; /* ------------------------------ * ClientInterface * ------------------------------ */ class ClientInterface : public QMainWindow, public LoadGame { Q_OBJECT public: /** Constructor */ ClientInterface(); /** Destructor */ ~ClientInterface(); public slots: /** Slot for managing 'actions' */ void slot_action( int num ); /** Slot for writing in the StatusBar */ void slot_status( const QString & text ); void slot_scenInfo( const QString & text ); /** Slot for reading the socket */ void slot_readSocket(); /** when connection is closed by server **/ void slot_connectionClosed(); void slot_endGame(); void slot_exchange(); void slot_hostfound(); /** manage connection's errors **/ void slot_error( QAbstractSocket::SocketError error ); /** Slot for displaying the base */ void slot_base( GenericBase * base ); /** Slot for quitting the base */ void slot_map(); /** Slot for beginning fight */ void slot_fight( GenericLord * lord, CLASS_FIGHTER cla ); void slot_clientConnect(); void slot_quit() { actionQuit(); } void slot_newScen(); void slot_newCamp(); void slot_loadScen(); void slot_loadCamp(); void slot_dialogClosed(); void slot_ready(); void slot_endConnection( QString name ); void slot_endTurn(); void slot_beginTurn(); void slot_result(bool result); void slot_resourceBar(); void slot_loadThemeStep(); void actionOptionsAnimations(int state); #ifdef WITH_SOUND void actionOptionsMusic(int state); void actionOptionsSound(int state); #endif signals: void sig_newMessage( const QString & ); void sig_map(); void sig_baseDisplay(); void sig_fightDisplay(); void sig_widgChanged( int ); void sig_animations(); void sig_dispositions(); protected: void closeEvent( QCloseEvent* ); void updateScreen(); void resizeWidget(); virtual void changeEvent ( QEvent * e ); private: enum MENU_ACTIONS { ACTION_CONNECT = 0, ACTION_START, ACTION_END, ACTION_SAVE, ACTION_FASTCONNECT , ACTION_DISCONNECT, ACTION_MINIMAP, ACTION_FULL, ACTION_CHAT, ACTION_OPTIONS, ACTION_INFO, ACTION_ENDTURN, ACTION_NEXTLORD, ACTION_NEXTBASE, ACTION_HELP, ACTION_ABOUT, ACTION_QUIT, ACTION_FREESIZE, ACTION_800, ACTION_1024, ACTION_1280, ACTION_TESTSTYLE, NB_ACTIONS }; enum StateGame { SG_MAP, SG_FIGHT, SG_BASE }; enum SizeMode { SIZEMODE_FREE, SIZEMODE_800, SIZEMODE_1024, SIZEMODE_1280 }; /** Define menus */ void initMenuBar(); /** Define statusBar */ void initStatusBar(); void initActions(); void initProgressBar(); void loadMenu( bool show ); /** Add a new action */ QAction * addAction( const QString & label, const QKeySequence & shortcut, MENU_ACTIONS id, QSignalMapper * sigmap ); /** Manage socket SO_FIGHT */ void socketFight(); /** Manage socket QR */ void socketQR(); void showFightResults( char result ); void updateUnits(); void actionConnect(bool fast); void actionStart(); void actionEnd(); void actionFastConnect(); void actionDisconnect(); void actionMinimap(); void actionFullScreen(); void actionPopupChat(); void actionOptions(); void actionInfo(); void actionNextLord(); void actionNextBase(); void actionHelp(); void actionAbout(); bool actionQuit(); void actionResize( SizeMode mode ); void actionTestStyle(); void killServer(); void addInternalAI(); bool killAI(); void adjustWidgetLoading( StatusWidget type ); void endEngine(); void endServer(); void disconnectClient(); void disconnectAI(); void reinit(); Game * _game; Fight * _fight; DisplayBase * _base; AttalSocket * _socket; GainLevel * _level; ConfigConnection * _config; StartGameDialog * _startDialog; bool _mini, _inLoad; bool _full; QProcess * _proc; QVector _actions; QList _aiList; DisplayHelp * _help; QStackedWidget * _centralWindow; AttalMessage * _msg; QProgressDialog * _progress; int _progressNum; QString _scenInfo; QStatusBar * _statusBar; RessourceBar * _resourceBar; QLabel * _cal; int _numWidg[3]; QSignalMapper * _sigmap; StateGame _state; }; #endif // CLIENTINTERFACE_H attal-src-1.0-rc2/client/clientWidgets.cpp0000644000175000017500000002540110770044606016251 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** clientWidgets.cpp ** Various dialog for client ** ** Version : $Id: clientWidgets.cpp,v 1.6 2008/03/18 23:00:22 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 26/07/2006 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "clientWidgets.h" // generic include files #include #include #include #include #include #include #include // application specific include files #include "libCommon/log.h" #include "libClient/gui.h" #include "libServer/scenarioDescription.h" extern QString SCENARIO_PATH; // // ----- ConfigConnection ----- // ConfigConnection::ConfigConnection( QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { setWindowTitle( tr( "Connection to server" ) ); QVBoxLayout * layout = new QVBoxLayout( this ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addSpacing( 5 ); QLabel * labHost = new QLabel( tr( "Host : " ), this ); FIXEDSIZE( labHost ); layH1->addWidget( labHost ); layH1->addSpacing( 5 ); _host = new QLineEdit( this ); _host->setFixedSize( 160, 20 ); layH1->addWidget( _host ); layH1->addStretch( 1 ); layout->addLayout( layH1, 1 ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addSpacing( 5 ); QLabel * labPort = new QLabel( tr( "Port : " ), this ); FIXEDSIZE( labPort ); layH2->addWidget( labPort ); layH2->addSpacing( 5 ); _port = new QLineEdit( this ); _port->setFixedSize( 80, 20 ); layH2->addWidget( _port ); layH2->addStretch( 1 ); layout->addLayout( layH2, 1 ); QHBoxLayout * layH4 = new QHBoxLayout(); layH4->addSpacing( 5 ); QLabel * labName = new QLabel( tr( "Name : " ), this ); FIXEDSIZE( labName ); layH4->addWidget( labName ); layH4->addSpacing( 5 ); _name = new QLineEdit( this ); _name->setFixedSize( 80, 20 ); layH4->addWidget( _name ); layH4->addStretch( 1 ); layout->addLayout( layH4, 1 ); QHBoxLayout * layH3 = new QHBoxLayout(); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Connect" ) ); FIXEDSIZE( pbOk ); layH3->addStretch( 1 ); layH3->addWidget( pbOk ); layH3->addStretch( 1 ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); layH3->addWidget( pbCan ); layH3->addStretch( 1 ); layout->addLayout( layH3, 2 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); setFixedSize( 250, 150 ); } // // ----- StartGameDialog ----- // StartGameDialog::StartGameDialog( QWidget * parent ) : QDialog( parent, Qt::Dialog | Qt::CustomizeWindowHint ) { setWindowTitle( tr( "Start Game" ) ); QVBoxLayout * layout = new QVBoxLayout( this ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addSpacing( 5 ); QPushButton * labScen = new QPushButton( this ); labScen->setText( tr( "Start Scenario " ) ); labScen->setFixedSize( 150,30); layH1->addWidget( labScen ); layH1->addSpacing( 5 ); layout->addLayout( layH1, 1 ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addSpacing( 5 ); QPushButton * labCamp = new QPushButton( this ); labCamp->setText( tr( "Start Campaign " ) ); labCamp->setFixedSize( 150,30); layH2->addWidget( labCamp ); layH2->addSpacing( 5 ); layout->addLayout( layH2, 1 ); QHBoxLayout * layH4 = new QHBoxLayout(); layH4->addSpacing( 5 ); QPushButton * labLoadScen = new QPushButton( this ); labLoadScen->setText( tr( "Load Scenario " ) ); labLoadScen->setFixedSize( 150,30); layH4->addWidget( labLoadScen ); layH4->addSpacing( 5 ); layout->addLayout( layH4, 1 ); QHBoxLayout * layH5 = new QHBoxLayout(); layH5->addSpacing( 5 ); QPushButton * labLoadCamp = new QPushButton( this ); labLoadCamp->setText( tr( "Load Campaign " ) ); labLoadCamp->setFixedSize( 150,30); layH5->addWidget( labLoadCamp ); layH5->addSpacing( 5 ); layout->addLayout( layH5, 1 ); layout->activate(); connect( labScen, SIGNAL( clicked() ), SIGNAL( sig_newScen() ) ); connect( labCamp, SIGNAL( clicked() ), SIGNAL( sig_newCamp() ) ); connect( labLoadScen, SIGNAL( clicked() ), SIGNAL( sig_loadScen() ) ); connect( labLoadCamp, SIGNAL( clicked() ), SIGNAL( sig_loadCamp() ) ); setFixedSize( 250, 150 ); } StartGameDialog::~StartGameDialog() { } void StartGameDialog::closeEvent(QCloseEvent *event) { emit sig_dialogClosed(); event->accept(); } // // ----- DisplayScenarioDescription ----- // DisplayScenarioDescription::DisplayScenarioDescription( QWidget * parent ) : QWidget( parent ) { _labName = new QLabel( this ); _labName->setFixedSize( _labName->sizeHint() ); _labDescription = new QLabel( this ); _labDescription->setWordWrap( true ); _labDescription->setFixedWidth( 250 ); _labPlayers = new QLabel( this ); _labPlayers->setFixedSize( _labPlayers->sizeHint() ); _labSize = new QLabel( this ); _labSize->setFixedSize( _labSize->sizeHint() ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addWidget( _labName ); layout->addWidget( _labSize ); layout->addWidget( _labPlayers ); layout->addWidget( _labDescription ); layout->addStretch( 1 ); layout->activate(); clear(); setFixedWidth( 300 ); } void DisplayScenarioDescription::init( ScenarioDescription * desc ) { if( desc ) { _labName->setText( tr( "Name: %1" ).arg( desc->getName() ) ); _labName->setFixedSize( _labName->sizeHint() ); _labPlayers->setText( tr( "Opponent(s): %1" ).arg( desc->getNbPlayers()-1 ) ); _labPlayers->setFixedSize( _labPlayers->sizeHint() ); _labSize->setText( tr( "Size: %1x%2" ).arg( desc->getWidth() ).arg( desc->getHeight() ) ); _labSize->setFixedSize( _labSize->sizeHint() ); _labDescription->setText( tr( "Description: %1" ).arg( desc->getDescription() ) ); //_labDescription->setFixedSize( _labDescription->sizeHint() ); } } void DisplayScenarioDescription::clear() { _labName->setText( tr( "Name: " ) ); _labName->setFixedSize( _labName->sizeHint() ); _labPlayers->setText( tr( "Opponent(s): " ) ); _labPlayers->setFixedSize( _labPlayers->sizeHint() ); _labSize->setText( tr( "Size: " ) ); _labSize->setFixedSize( _labSize->sizeHint() ); _labDescription->setText( tr( "Description: " ) ); //_labDescription->setFixedSize( _labDescription->sizeHint() ); } // // ----- ScenarioListViewItem ----- // ScenarioListViewItem::ScenarioListViewItem( QTreeWidget * list, ScenarioDescription * desc ) : QTreeWidgetItem( list ) { _desc = desc; QString temp; temp.sprintf( "%dx%d", _desc->getWidth(), _desc->getHeight() ); setText( 0, temp ); //setText( 1, QString::number( _desc->getNbPlayers() ) ); setText( 1, _desc->getName() ); } ScenarioListViewItem::~ScenarioListViewItem() { if( _desc ) { delete _desc; } } ScenarioDescription * ScenarioListViewItem::getScenario() { return _desc; } // // ----- DisplayScenarii ----- // DisplayScenarii::DisplayScenarii( QWidget * parent ) : QWidget( parent ) { _currentScen = 0; _list = new QTreeWidget( this ); _list->setRootIsDecorated( false ); _list->setSelectionBehavior( QAbstractItemView::SelectRows ); _list->setColumnCount( 2 ); QStringList labels; labels << tr( "Size" ); //labels << tr( "Players" ); labels << tr( "Name" ); _list->setHeaderLabels( labels ); _description = new DisplayScenarioDescription( this ); _description->setMinimumWidth( 250 ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->addWidget( _list, 1 ); layout->addWidget( _description ); layout->activate(); init(); connect( _list, SIGNAL( itemClicked( QTreeWidgetItem *, int ) ), SLOT( slot_clicked( QTreeWidgetItem * ) ) ); connect( _list, SIGNAL( itemDoubleClicked( QTreeWidgetItem *, int ) ), SIGNAL( sig_dbleClicked() ) ); setMinimumWidth( 600 ); } void DisplayScenarii::slot_clicked( QTreeWidgetItem * item ) { ScenarioListViewItem * scenarioItem = ( ScenarioListViewItem * ) item; _currentScen = scenarioItem->getScenario(); _description->init( scenarioItem->getScenario() ); emit sig_scenarioSelected(); } void DisplayScenarii::init() { QDir scenarioDir( SCENARIO_PATH ); scenarioDir.setFilter( QDir::Files | QDir::Hidden ); scenarioDir.setSorting( QDir::Size | QDir::Reversed ); scenarioDir.setNameFilters( QStringList( "*.scn" ) ); const QList fileList = scenarioDir.entryInfoList(); ScenarioDescription * desc; uint nbItems = (uint)fileList.count(); for( uint i = 0; i < nbItems; ++i ) { desc = new ScenarioDescription(); desc->load( fileList[ i ].absoluteFilePath() ); new ScenarioListViewItem( _list, desc ); } /* was while ( (fileInfo = it.value() ) != 0 ) { desc = new ScenarioDescription(); desc->load( fileInfo->absFilePath() ); new ScenarioListViewItem( _list, desc ); ++it; }*/ } void DisplayScenarii::clear() { _list->clear(); } // // ----- DisplayScenariiDialog ----- // DisplayScenariiDialog::DisplayScenariiDialog( const QString & title, QWidget * parent ) : QDialog( parent, Qt::Dialog | Qt::CustomizeWindowHint ) { setWindowTitle( title ); _display = new DisplayScenarii( this ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addWidget( _display, 1 ); QPushButton * pbOk = _pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); pbOk->setFixedSize( pbOk->sizeHint() ); pbOk->setEnabled(false); QPushButton * pbCancel = new QPushButton( this ); pbCancel->setText( tr( "Cancel" ) ); pbCancel->setFixedSize( pbCancel->sizeHint() ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addStretch( 1 ); layH2->addWidget( pbOk ); layH2->addStretch( 1 ); layH2->addWidget( pbCancel ); layH2->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layH1, 1 ); layout->addLayout( layH2 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pbCancel, SIGNAL( clicked() ), SLOT( reject() ) ); connect( _display, SIGNAL( sig_scenarioSelected() ), SLOT ( slot_scenarioSelected() ) ); connect( _display, SIGNAL( sig_dbleClicked() ), SLOT( accept() ) ); } void DisplayScenariiDialog::slot_scenarioSelected() { _pbOk->setEnabled(true); } QString DisplayScenariiDialog::getFileName() { QString ret = ""; ret = _display->getCurrentScenario()->getFileName(); return ret; } attal-src-1.0-rc2/client/clientWidgets.h0000644000175000017500000001015310621451207015706 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** clientWidgets.h ** Various dialog for client ** ** Version : $Id: clientWidgets.h,v 1.4 2007/05/12 23:49:27 audoux Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 26/07/2006 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CLIENTWIDGETS_H #define CLIENTWIDGETS_H // generic include files // include files for QT #include #include #include #include #include #include // application specific include files class QLabel; class ScenarioDescription; /** Dialog for configuring connection to server */ class ConfigConnection : public QDialog { Q_OBJECT public: /** Constructor */ ConfigConnection( QWidget * parent = 0, const char * name = 0 ); /** Setting hostname */ void setHost( QString host ) { _host->setText( host ); } /** Getting hostname */ QString getHost() { return _host->text(); } int getPort() { return _port->text().toInt(); } /** Setting port number */ void setPort( int port ) { _port->setText( QString::number( port ) ); } /** Getting player's name */ QString getPlayerName() { return _name->text(); } /** Setting player's name */ void setPlayerName( QString name ) { _name->setText( name ); } void accept() { QDialog::accept(); } private: QLineEdit * _host, * _port, * _name; }; /** Dialog for start the game */ class StartGameDialog : public QDialog { Q_OBJECT public: /** Constructor */ StartGameDialog( QWidget * parent = 0 ); /** Distructor */ ~StartGameDialog(); void closeEvent(QCloseEvent *event); void accept() { QDialog::accept(); } signals: void sig_newScen(); void sig_newCamp(); void sig_loadScen(); void sig_loadCamp(); void sig_dialogClosed(); }; /* ------------------------------ * DisplayScenarioDescription * ------------------------------ */ class DisplayScenarioDescription : public QWidget { Q_OBJECT public: /** Constructor */ DisplayScenarioDescription( QWidget * parent = 0 ); void init( ScenarioDescription * desc ); void clear(); protected: QLabel * _labName; QLabel * _labDescription; QLabel * _labPlayers; QLabel * _labSize; }; class ScenarioListViewItem : public QTreeWidgetItem { public: /** Constructor */ ScenarioListViewItem( QTreeWidget * list, ScenarioDescription * desc ); /** Destructor */ virtual ~ScenarioListViewItem(); ScenarioDescription * getScenario(); protected: ScenarioDescription * _desc; }; /* ------------------------------ * DisplayScenarii * ------------------------------ */ class DisplayScenarii : public QWidget { Q_OBJECT public: /** Constructor */ DisplayScenarii( QWidget * parent = 0 ); void init(); void clear(); ScenarioDescription * getCurrentScenario() { return _currentScen; } public slots: void slot_clicked( QTreeWidgetItem * item ); signals: void sig_scenarioSelected(); void sig_dbleClicked(); protected: DisplayScenarioDescription * _description; ScenarioDescription * _currentScen; QTreeWidget * _list; }; /* ------------------------------ * DisplayScenariiDialog * ------------------------------ */ class DisplayScenariiDialog : public QDialog { Q_OBJECT public: /** Constructor */ DisplayScenariiDialog( const QString & title = "", QWidget * parent = 0 ); QString getFileName(); public slots: void slot_scenarioSelected(); protected: QPushButton * _pbOk; DisplayScenarii * _display; }; #endif // CLIENTWIDGETS_H attal-src-1.0-rc2/client/duel.cpp0000644000175000017500000000267710331243510014373 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** duel.cpp ** main file ** ** Version : $Id: duel.cpp,v 1.2 2005/10/30 22:20:56 audoux Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 29/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ // include files for QT #include #include #include // application specific includes #include "client/interfaceDuel.h" #include "conf.h" QString IMAGE_PATH( IMAGE_DEFAULT_PATH ); QString DATA_PATH( DATA_DEFAULT_PATH ); QString THEME( THEME_DEFAULT ); int main( int argc, char **argv ) { QApplication app( argc, argv ); for( int i = 1; i < argc; i++ ) { if ( strcmp( argv[i], "-theme" ) == 0 ) { i++; if( i < argc ) THEME = QString( argv[i] ); } } useTheme(); InterfaceDuel game; app.setMainWidget( &game ); game.show(); return app.exec(); } attal-src-1.0-rc2/client/interfaceDuel.cpp0000644000175000017500000001042410522705150016206 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** interface.cpp ** Manages the whole game ** ** Version : $Id: interfaceDuel.cpp,v 1.5 2006/11/03 18:28:56 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 29/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "interfaceDuel.h" // include files for QT #include #include #include #include #include #include // application specific include #include "conf.h" #include "common/log.h" #include "common/dataTheme.h" #include "client/attalStyle.h" #include "client/fight.h" #include "client/attalStyle.h" #include "client/imageTheme.h" extern QString DATA_PATH; extern QString IMAGE_PATH; /** add comments here */ InterfaceDuel::InterfaceDuel() { _socket = 0; qApp->setStyle( new AttalStyle( DATA_PATH + "style.dat" ) ); setWindowTitle( "Attal - The Duel" ); initMenuBar(); initStatusBar(); DataTheme.init(); ImageTheme.init(); _fight = new Fight( this ); setCentralWidget( _fight ); } void InterfaceDuel::initStatusBar() { statusBar()->message( "Status Bar", 0 ); } /*! define menus */ void InterfaceDuel::initMenuBar() { QPopupMenu * menuFile = new QPopupMenu(); CHECK_PTR( menuFile ); menuFile->insertItem( "Connect to Server", FIL_NET ); menuFile->insertItem( "Send Message", FIL_MSG ); menuFile->insertItem( "Quit", FIL_QUIT ); connect( menuFile, SIGNAL( activated( int ) ), this, SLOT( slot_menuFileActivated( int ) ) ); QPopupMenu * menuGame = new QPopupMenu(); CHECK_PTR( menuGame ); menuGame->insertItem( "Show ressources", GAM_INFO ); menuGame->insertItem( "Show Lord", GAM_LORD ); menuGame->insertItem( "Next Lord", GAM_NEXT ); menuGame->insertItem( "End turn", GAM_TURN ); menuGame->insertItem( "Show powers", GAM_POWER ); connect( menuGame, SIGNAL( activated( int ) ), this, SLOT( slot_menuGameActivated( int ) ) ); menuBar()->insertItem( "&File", menuFile ); menuBar()->insertItem( "&Game", menuGame ); } void InterfaceDuel::slot_menuFileActivated( int num ) { switch( num ) { case FIL_NET: _socket = new AttalSocket; _socket->connectToHost( "localhost", ATTAL_PORT ); connect( _socket, SIGNAL( readyRead() ), SLOT( slot_readSocket() ) ); break; case FIL_MSG: if( _socket ) { _socket->sendMessage( "Hello" ); } break; case FIL_QUIT: qApp->quit(); } } void InterfaceDuel::slot_menuGameActivated( int num ) { switch( num ) { case GAM_INFO: { } break; case GAM_LORD: break; case GAM_NEXT: break; case GAM_TURN: break; case GAM_POWER: break; } } void InterfaceDuel::slot_status( QString text ) { statusBar()->message( text, 0 ); } void InterfaceDuel::slot_readSocket() { char buf[50]; _socket->readBlock( buf, 50 ); switch( buf[0] ) { case SO_MSG: logDD( "MSG : %s", buf+(2*sizeof(char)) ); break; case SO_GAME: if( buf[1] == C_GAME_BEG ) { logDD( "start new game" ); /// XXX: clear old stuff if necessary } else { logDD( "end game" ); } break; case SO_TURN: if( buf[1] == C_TURN_BEG ) { logDD( "start turn" ); /// XXX: clear old stuff if necessary } else { logDD( "end turn" ); } break; case SO_MODIF: break; case SO_QR: logDD( "Q/R" ); switch( buf[1] ) { case C_QR_MSG_END: /// to be improved QMessageBox::information( this, "Information", QString( buf+(3*sizeof(char)) ), 0 ); break; } break; case SO_MVT: case SO_TECHNIC: case SO_EXCH: case SO_CONNECT: case SO_FIGHT: { if( buf[1] == C_FIGHT_INIT ) { _fight->reinit(); } else if( buf[1] == C_FIGHT_END ) { } else { //_fight->socketFight(); } } break; default: logEE( "Unknown socket_class" ); } if( _socket->bytesAvailable() > 0 ) slot_readSocket(); } attal-src-1.0-rc2/client/interfaceDuel.h0000644000175000017500000000377310331243510015657 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** interfaceDuel.h ** Manages the game of The Duel ** ** Version : $Id: interfaceDuel.h,v 1.2 2005/10/30 22:20:56 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 29/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef INTERFACEDUEL_H #define INTERFACEDUEL_H // include files for QT #include #include #include // application specific includes #include "common/attalSocket.h" #include "client/player.h" #include "client/gui.h" class Fight; /* ------------------------------ * Interface * ------------------------------ */ /** comment for the class */ class InterfaceDuel : public QMainWindow { Q_OBJECT public: /** Constructor */ InterfaceDuel(); public slots: /** Slot for managing 'File' menu */ void slot_menuFileActivated( int num ); /** Slot for managing 'Game' menu */ void slot_menuGameActivated( int num ); /** Slot for writing on the StatusBar */ void slot_status( QString text ); /** Slot for reading socket */ void slot_readSocket(); private: enum MENU_FIL { FIL_NET, FIL_MSG, FIL_QUIT }; enum MENU_GAM { GAM_INFO, GAM_LORD, GAM_NEXT, GAM_TURN, GAM_POWER }; /** define menus */ void initMenuBar(); /** define statusBar */ void initStatusBar(); Fight * _fight; AttalSocket * _socket; }; #endif // INTERFACEDUEL_H attal-src-1.0-rc2/client/main.cpp0000644000175000017500000000574010770044606014374 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attal.cpp ** main file ** ** Version : $Id: main.cpp,v 1.22 2008/03/18 23:00:22 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier - Sardi Carlo ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ // include files for QT #include #include #include #include #include #include #include // application specific includes #include "libCommon/attalCommon.h" #include "client/clientInterface.h" extern QString THEME; extern QString THEME_PATH; extern QString IMAGE_PATH; extern QString PORT; int main( int argc, char **argv ) { QApplication app( argc, argv ); QDir trfolder; trfolder = translationsDir(); QTranslator translator( 0 ); QString trstring("attal_client_" + QLocale::system().name().section('_', 0,0 ) ); if (!translator.load( trstring, trfolder.absolutePath() ) ) { logEE("failed to load translator %s", qPrintable( trfolder.absolutePath() )); } QTranslator translatorlibs( 0 ); translatorlibs.load( QString("attal_libserver_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibcomm( 0 ); translatorlibcomm.load( QString("attal_libcommon_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibclient( 0 ); translatorlibclient.load( QString("attal_libclient_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibai( 0 ); translatorlibai.load( QString("attal_libai_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibfight( 0 ); translatorlibfight.load( QString("attal_libfight_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); app.installTranslator( &translator ); app.installTranslator( &translatorlibs ); app.installTranslator( &translatorlibcomm ); app.installTranslator( &translatorlibclient ); app.installTranslator( &translatorlibfight ); app.installTranslator( &translatorlibai ); if (parseArgs( argc, argv, AttalCommon::ATTALCLIENT ) ) { return 1; } useTheme(); app.setWindowIcon(QIcon( IMAGE_PATH + "misc/ico_attal-client.png")); if (app.windowIcon().isNull()) qDebug("Window icon is null!"); ClientInterface game; game.showMaximized(); //app.setMainWidget( &game ); game.show(); return app.exec(); } attal-src-1.0-rc2/docs/0000755000175000017500000000000011016113670012400 5ustar aaaaattal-src-1.0-rc2/docs/fightProtocol.txt0000644000175000017500000000533010443116113015763 0ustar aaaa == Server Side== a)Begin Fight can begin in some situations: 1)movingOnLord startFight(lord, lord) 2)movingOnCreature (CreatureFight) startFight(lord, creature) 3)handleAnswerCreatureJoin (no accept and creature is not fleeing) startFight(lord, creature) b)StartFight 1)create FightEngine (assign a server to a fight engine, initialise variables, create a fake lord for combact with creatures (useful in combact with lords??)) 2)Connect sig_endfight with slot_endfight 3)change state (IN_FIGHT) 4)set defendCell ?? (useful??) 5)(if fight with units initialize units) 6)initialisation fight 6.1)Initialisation variables 6.2)Initialisation ai (if present) (analyst and units) 6.3)Start fight 6.3.1)C_FIGHT_INIT (class,attacker lord id) 6.3.2)C_FIGHT_LORD (class,defender lord id) 6.3.3)C_FIGHT_CREATURE (if necessary) 6.3.4)C_FIGHT_UNIT (opponent unit data) 6.4)Initialisation new map 6.5)Setup unit (initial placement of units on map) 6.6)New turn c)New turn 1)Initialize values (movement) 2)OrderTroops (create a list with all units with number > 0) 3)Activate troops (C_FIGHT_ACTIVE) (activate mean also set _currentUnit) SIGNALS: a)C_FIGHT_MOVE (request from client to server, one cell at time) moveUnit and send C_FIGHT_MOVE (reponse from server to client, one cell at time) 1)control if valid move 2)if NEAR_FREE moveUnit send C_FIGHT_MOVE 3)if NEAR_OCCUPIED fightUnit send C_FIGHT_MESSAGE send C_FIGHT_DAMAGE (attackPlayer and defendPlayer) b)C_FIGHT_ENDMOVE;C_FIGHT_WAIT;C_FIGHT_DEFEND : nextUnit 1)Compute results if winner or loser ->endFight 2)Remove _currentUnit from list 3) c)C_FIGHT_FLEE: endFight 1)Update units 2)C_FIGHT_END == Client side == Begin 1)Do an action that activa fight (see server side) 2)C_FIGHT_INIT Set up my lord (attacker or defender) 2a) C_FIGHT_LORD Set up opponent lord (opponent from lord list) 3)C_FIGHT_CREATURE If fight against a creature 4)C_FIGHT_UNIT (update opponent units) 5)C_FIGHT_ACTIVE (activate unit) Do something with unit it should be: 5.1)C_FIGHT_FLEE end fight (and lose lord) 5.2)C_FIGHT_WAIT pass turn 5.2)C_FIGHT_DEFEND 5.3)C_FIGHT_DISTATTACK 5.3)C_FIGHT_MOVE (request from client to server, one cell at time) and, last 5.4)C_FIGHT_ENDMOVE 6)C_FIGHT_DAMAGE update unit 7)C_FIGHT_MESSAGE handle message 8)C_FIGHT_END 8.1)update units Fight protocol enum CLASS_FIGHT { C_FIGHT_INIT, C_FIGHT_CREATURE, C_FIGHT_LORD, C_FIGHT_CELL, C_FIGHT_UNIT, C_FIGHT_MODUNIT, C_FIGHT_MOVE, C_FIGHT_ENDMOVE, C_FIGHT_ACTIVE, C_FIGHT_DISTATTACK, C_FIGHT_WAIT, C_FIGHT_FLEE, C_FIGHT_DEFEND, C_FIGHT_DAMAGE, C_FIGHT_END, }; NO MORE USED C_FIGHT_MODUNIT C_FIGHT_CELL attal-src-1.0-rc2/i18n/0000755000175000017500000000000011016113670012227 5ustar aaaaattal-src-1.0-rc2/i18n/de/0000755000175000017500000000000011016113670012617 5ustar aaaaattal-src-1.0-rc2/i18n/de/.cvsignore0000644000175000017500000000000507721766423014634 0ustar aaaa*.qm attal-src-1.0-rc2/i18n/de/attal_ai_de.ts0000644000175000017500000001264211016036212015416 0ustar aaaa AiInterface Attal: IA client Attal: KI Client Log level : Verbose Log-Stufe: Viele Meldungen Verbose Viele Meldungen Normal Normal Critical Kritische Meldungen Quiet Wenige Meldungen &File &Datei Can't connect Die Verbindung kann nicht hergestellt werden You're already connected to a server. Please disconnect first. Sie sind bereits mit dem Server verbunden, bitte trennen Sie die Verbindung zuvor. Log level : Normal Log-Stufe: Normal Log level : Critical Log-Stufe: Kritische Meldungen Log level : Quiet Log-Stufe: Wenige Meldungen &Connect to server &Verbinde mit Server CTRL+C STRG+C &Disconnect &Trennen CTRL+D STRG+D &Quit &Beenden CTRL+Q STRG+Q Can't load theme Kann angegebenes Thema nicht laden Theme Thema has not been loaded successfully konnte nicht erfolgreich geladen werden Log level Log-Stufe ConfigConnection Connection to server Verbindung zum Server Host : Anbieter : Port : Port : Name : Name : Connect Verbindung aufbauen Cancel Abbrechen attal-src-1.0-rc2/i18n/de/attal_client_de.ts0000644000175000017500000003674111016036212016311 0ustar aaaa ClientInterface CTRL+C STRG+C CTRL+D STRG+D CTRL+M STRG+M Can't connect Die Verbindung kann nicht hergestellt werden You're already connected to a server. Please disconnect first. Sie sind bereits mit dem Server verbunden, bitte trennen sie die Verbindung zuvor. Attal - Lords of Doom Attal - Herren des Schicksals &Connect to server Verbinde mit &Server &Disconnect &Trenne Verbindung &Mini map Übersichts&karte &Quit &Beenden &File &Datei &Game Spie&l Match Kampf Do you want abandon the match ? Wollen Sie den Kampf aufgeben? &Fullscreen &Vollbild CTRL+F STRG+F Can't load theme Kann angegebenes Thema nicht laden Theme Thema has not been loaded successfully konnte nicht erfolgreich geladen werden Fast &Server Schneller &Einstieg CTRL+S STRG+S &Help &Hilfe Key_F1 Taste_F1 Next &Lord Nächster &Lord CTRL+L STRG+L Next &Base &Nächste Basis CTRL+B STRG+B Free size Freie Größe 800x600 800x600 1280x1024 1280x1024 Test Style Teststil &Screen &Bildschirm &About &Über CTRL+A STRG+A 1024x768 1024x768 Are you sure ? Sind Sie sicher? Do you really want to quit? Wollen sie Attal wirklich beenden? Loading Data... Lade Daten... &Start game &Spiel starten CTRL+N STRG+N &End game Spiel &beenden CTRL+E STRG+E &Save game &Speichern CTRL+W STRG+W &Scenario Informations &Szenarioinformationen Choose new scenario Wähle neues Szenario Load campaign Kampagne laden Load game Spiel Laden Loading data... Lade Daten... Cancel Abbrechen &Options CTRL+O ESC CTRL+T &Popup message (base mode) Host found , connecting... Connection Refused ConfigConnection Connection to server Verbindung zum Server Host : Anbieter : Port : Port : Name : Name : Connect Verbinden Cancel Abbrechen DisplayScenarii Size Größe Name Name DisplayScenariiDialog Ok Ok Cancel Abbrechen DisplayScenarioDescription Name: %1 Name: %1 Size: %1x%2 Größe: %1x%2 Description: %1 Beschreibung: %1 Name: Name: Size: Größe: Description: Beschreibung: Opponent(s): %1 Opponent(s): StartGameDialog Start Game Spiel starten Start Scenario Szenario starten Start Campaign Kampagne starten Load Scenario Szenario laden Load Campaign Kampagne laden attal-src-1.0-rc2/i18n/de/attal_libai_de.ts0000644000175000017500000000011510630060110016070 0ustar aaaa attal-src-1.0-rc2/i18n/de/attal_libclient_de.ts0000644000175000017500000005352011016036212016772 0ustar aaaa AboutDialog Attal is a turn-based strategy game. Can be played alone (against AI) or against other through a network (local or internet). It's available under Linux and Windows. Version: AskChest Choose between earning Gold or Experience Gold Experience AskCost Change AskDialog Yes No AskPixmap Open pixmap AttalPopup About BuildingPanel Info Building informations Ok Buy Sell Name: BuyCreature All Buy Quit Recruit No room left No room left for a new unit CentralControl Next Lord End Turn DisplayBase View Buildings Creatures Resources DisplayBaseInfo Base Information DisplayCreature no building next week Attack Defense Damage Health Speed Growth Available : DisplayCreatureBase Creatures DisplayGeneral Attack Defense Power Knowledge Specialty None DisplayLord Info Lord DisplayLordTab General Units Artefacts Technics DisplayLordTabGeneral No specialty DisplayLordTabTechnics Not yet implemented DisplayLordTabUnits Split unit Now click on a free cell or a unit of same type Unit Do you want destroy this unit ? DisplayUnit Unit Do you want destroy this unit ? EditCost Ok Cancel ExchangeResources All Buy Game Lord - Artefact: Chest About Cell: row %1, col %2, coordinates x %3, y %4 It is , a new week is beginning Are you sure ? One or more heroes may still move. Are you sure you want to end your turn ? You lose You lose Player has lost. A player has lost. A player has Win. You win !! has win. Connection established, %1 Host address %1 Host port %1, Our port %1 Connection ID, %1 Name of player: %1 Information The creatures are fleeing. Do you want to let them flee ? You can buy these creatures. Do you want to buy them ? The creatures want to join. Do you accept them ? InsideActionAllBuildings Buildings Building Are you sure to sell this building? Can't buy Not enough ressources to buy this building Market Marketplace Kingdom resources Available for trade OptionsDialog Enable animation Disposition: Extra compact Compact Normal Enable music Enable sound Tavern Some lords are visiting your base and are available in your tavern. Here is the list: TavernLord Buy attal-src-1.0-rc2/i18n/de/attal_libcommon_de.ts0000644000175000017500000003203511015367040017007 0ustar aaaa Action Unknown date first time first time lord next time change owner every ElementaryAction Unknown attack defense power knowledge move maxmove techpoint maxtechpoint morale luck vision experience skill artefact unit resource random resource percentage resource charisma population add %1 give %1 give between 0 and %1 resource from resource for every %1 modify by give one percentage people InsideBuildingModel Description: Not implemented Main Building (not sellable) Castle Produce Market Tavern Cost: Require: QObject Ok Ok Bonus Resource: Fixed Value: Base Obedient Friendly Neutral Aggressive Hostile Stable Percentage fixed Percentage variable Quest Do you accept this quest ? Nehmen Sie diesen Auftrag an ? Only once Nur einmal Once for each player Einmal für jeden Spieler Once for each lord Einmal für jeden Lord Anytime requested Bei jeder Anforderung QuestConditionDate Must be accomplished before day %1, week %2, month %3 Muss vor Tag %1, Woche %2 und Monat %3 erfüllt werden Must be accomplished before %1 days Muss innerhalb von %1 Tagen erfüllt werden attal-src-1.0-rc2/i18n/de/attal_libfight_de.ts0000644000175000017500000001124211015367040016615 0ustar aaaa CasualtiesReport Report - Your lord %1 Bericht - Ihr Lord %1 Report - Opponent lord %1 Bericht - Gegnerischer Lord %1 Report - Opponent creatures %1 Bericht - Gegnerische Kreaturen %1 %1 %2 killed %1 %2 getötet No creatures killed Keine Kreaturen getötet Fight Cell: row %1, col %2, coordinates x %3, y %4 Zelle: Zeile %1, Spalte %2, Koordinaten x %3, y %4 FightControl Options Optionen Surrender Kapitulieren Flee Fliehen Auto-fight Auto-Kampf Spells Zaubersprüche Wait Warten Defend Verteidigen FightResultWizard FightResultWizard KampfBerichtAssistent Congratulations, you win! Glückwunsch, Sie haben gewonnen! Humm, you have fled! Hmm, Sie sind geflohen! Pff, you have surrendered! Pff, Sie haben kapituliert! Sorry, you lose! Schade, Sie verlieren! FightSettingsDialog Settings Einstellungen Animation Animationen Animation Speed Animationsgeschwindigkeit Show cells Zellen zeigen attal-src-1.0-rc2/i18n/de/attal_libserver_de.ts0000644000175000017500000000231311015367040017021 0ustar aaaa Engine You have no place for recruiting new creatures You have not enough resources for recruiting this creatures Error with scenario Wrong number of connected players QObject Unknown Unbekannt attal-src-1.0-rc2/i18n/de/attal_server_de.ts0000644000175000017500000002217711015367041016345 0ustar aaaa ChooseFileWidget Choose Wähle Choose scenario Wähle Szenario ConfigConnection Start server Server starten Host : Anbieter : Port : Port : Start Starten Quit Beenden DisplayScenarii Size Größe Players Spieler Name Name DisplayScenariiDialog Cancel Abbrechen Ok Ok DisplayScenarioDescription Name: %1 Name: %1 Player(s): %1 Spieler: %1 Size: %1x%2 Größe: %1x%2 Description: %1 Beschreibung: %1 Name: Name: Player(s): Spieler: Size: Größe: Description: Beschreibung: ServerInterface Attal - Lords of Doom (Server) Attal - Lords of Doom (Server) Server error Server-Fehler Could not listen for sockets. Es können keine Sockets benutzt werden. Try again Wiederholen Quit Beenden Status Bar Statusleiste &File &Datei Can't load theme Kann das Thema nicht laden Theme Thema has not been loaded successfully konnte nicht erfolgreich geladen werden Load scenario Lade Szenario Load campaign Lade Kampagne Load game Laden Save game Speichern End game Spiel beenden Fill with AI Fülle mit KI-Spielern &Game &Spiel Debug AI KI debuggen Hide AI KI verstecken Continue campaign Kampagne fortsetzen Fill with External AI Mit externen KI-Spielern auffüllen Add external AI player Externen KI-Spieler hinzufügen ServerWidget Name Name Address Adresse Start Starten Save Speichern End Spielende attal-src-1.0-rc2/i18n/de/campaign_editor_de.ts0000644000175000017500000000421010630007066016763 0ustar aaaa CampaignInterface Can't load theme Kann Thema nicht laden Theme Thema has not been loaded successfully konnte nicht erfolgreich geladen werden &New &Neu CTRL+N STRG+N &Open &Öffnen CTRL+O STRG+O &Save &Speichern CTRL+S STRG+S &Save as &Speichern unter &Quit &Beenden CTRL+Q STRG+Q &Help &Hilfe F1 F1 &File &Datei MainCampaignScreen Name: Name: Description: Beschreibung: List of scenarii: Liste der Szenarios: attal-src-1.0-rc2/i18n/de/scenario_editor_de.ts0000644000175000017500000011662111016036213017014 0ustar aaaa AskLordCharac Charac Charac DecorationSelection Auto-path Auto-Pfad DisplayQuests Main quest: Hauptaufgabe: Edit Bearbeiten Other quests: Nebenaufgaben: Add Hinzufügen Del Entfernen Ok Ok Cancel Abbrechen EditTroop Race : Rasse: Name : Art: Number : Anzahl: FillDialog Choose tile Wähle Kachel Ok Ok Cancel Abbrechen %1 (weight=%2) %1 (Gewicht=%2) GeneralPropertiesBase Owner: Besitzer: Buildings Gebäude Name: Name: Res Base: Description Actions None NewQuestConditionDialog AND OR Date Lord Player PropertiesBase Base properties General Units Ok Ok Cancel Abbrechen PropertiesBonus Resource: Fixed value: Primary skill: Attack Defense Power Knowledge Morale Luck Charisma Add value: Bonus for secondary skills are not yet implemented Bonus for spells are not yet implemented PropertiesBuilding building properties Owner: Besitzer: Res Buil: Ok Ok None PropertiesCreature Res Crea: Behaviour of creatures: Never flee: Looking at right side: Growth of creatures: Growth param 0: Growth param 1: Number of creatures in stack %1: Ok Ok Cancel Abbrechen PropertiesEvent Condition Cancel Abbrechen Ok Ok PropertiesLord Lord properties General Units Artefacts War Machines Technics Ok Ok Cancel Abbrechen Lord's properties error The lord must have at least 1 unit The lord must have an owner PropertiesLordArtefacts Common artefacts list Lord's artefacts list PropertiesLordGeneral Select player: Default PropertiesLordTechnics Common technics list Lord's technics list PropertiesLordWarMachines Common war machines list Lord's war machines list PropertiesPlayers Players Properties Ruled by AI Team : QObject Tile Transition Decoration Building Base Lord Artefact Bonus Creature Tool QuestConditionDateProperties Before date: Day Week Month Year Before day(s) Ok Ok Cancel Abbrechen QuestConditionDialog Condition Ok Ok Cancel Abbrechen &Properties &Add condition &Delete condition QuestConditionEditor Condition: Edit Bearbeiten QuestConditionLordProperties Primary skill value: Secondary skill Artefact Number of creatures Spell Ok Ok Cancel Abbrechen QuestConditionPlayerProperties Nb lords Nb bases Basename = Ok Ok Cancel Abbrechen QuestEditor Name: Name: Description: Type: Ask player confirmation of quest Confirmation question: Ok Ok Cancel Abbrechen Start condition: Fail condition: Success condition: ScenarioInfo General Scenario Informations General Information Name: Name: Theme: Number of players: Map height: Map width: Day: Week: Month: Year: Description: Ok Ok Cancel Abbrechen Map Map for Attal ScenarioInterface Can't load theme Theme has not been loaded successfully &New CTRL+N &Open CTRL+O &Save CTRL+S &Save as &Quit CTRL+Q &Scenario information CTRL+I &Players properties CTRL+P Quests management &Clear screen CTRL+C &Fill screen CTRL+F &Mini map CTRL+M &Grid CTRL+G &Help F1 &About CTRL+A &File &Scenario &Tools Open scenario Save scenario as Screen &Delete &Properties (Cell %1x%2) TilePresentation %1 (weight=%2) %1 (Gewicht=%2) attal-src-1.0-rc2/i18n/de/theme_editor_de.ts0000644000175000017500000012746411016036213016322 0ustar aaaa AskDiversificationList New Del DialogArtefactAction Action type: Characteristic Spell Fixed value Ratio Modification type: Parameter: Value: Ok Cancel DialogBuildingAction Action type: Coeff: Elementary Action: Arg0: Arg1: Ok Cancel DialogCreatureAnimation Moving Fighting Schooting SchootHigh SchootLow Defending StartMoving EndMoving Dying Dead AttackHigh AttackLow Selecting Action: Start Frame: End Frame: Ok Cancel DialogEffect Effect type: Effect value: Ok Cancel EditCreature Name: Attack: Defense: Max Health: Max Move: Dist Attack: Min Damages: Max Damages: Morale: Luck: Size: Cost: Maintenance cost: X Offset: X Offset mirror: Y Offset: Num. Frames: Picture: EditTroop Race : Name : Number : EditWidget Add Edit Del MapDispositionEditor Free Occupied Door Columns: Rows: PreviewBaseDialog Buildings QObject Action: Charac Spell modify by % AnimationType: first frame last frame Effect ' ' with param SectionArtefact Artefact Name: Position: Icon: Item: SectionBase Base Name: Res Base: Res Cost: Preview inside Base : %1/%2 SectionBuilding Building Name: Description: Number Frames: Animation Freq.: Type: Res Build: Picture: SectionCreature Race Name: Creature Race : %1/%2 Creature : %1/%2 Creature : %1/?? SectionDecoration Decoration group Name: Info: Decoration item Image: SectionExperience List of required experience to gain for accessing the next level: SectionGeneral Vision management: Number of unit/lord Logo (200x180): Day Name: Week Month Day : %1/%2 Week : %1/%2 Month : %1/%2 SectionGround Tiles Width: Height: Name: Coef: Color: Tile SectionInsideBuilding Building Name: Description: Cost: Maintenance cost: Not yet used Main Building Castle Prod Creature Market Tavern Params: Requirements Building : %1/%2 SectionLord Lord Photo: Icon: Name : Category : Attack : Defense : Power : Knowledge : Charisma : MaxMoves : Vision : Cost: (Race: SectionLordCategory Lord Categories Name: Description: Race: Evolution of Attack skill (weight): Evolution of Defense skill (weight): Evolution of Power skill (weight): Evolution of Knowledge skill (weight): SectionMachine War Machine Name: Type: Param (1): Params: Icon: Item: SectionResource Resource Name: Icon: Small icon: Local Preservable Local Not Preservable Global Preservable Global Not Preservable SectionSelector General Artefacts Teams Bases Buildings Creatures Decorations Grounds Lord Categories Lords Levels Resources War Machines SectionTeam Team Name: Color Flag: SelectionDate None SelectionWidget None ThemeInterface Can't load theme Theme has not been loaded successfully Theme editor for 'Attal - Lords of Doom' Status Bar &New theme CTRL+N &Open theme CTRL+O &Save theme CTRL+S &Quit CTRL+Q &Help F1 &About CTRL+A &File Open theme attal-src-1.0-rc2/i18n/fr/0000755000175000017500000000000011016113670012636 5ustar aaaaattal-src-1.0-rc2/i18n/fr/.cvsignore0000644000175000017500000000000507721766424014654 0ustar aaaa*.qm attal-src-1.0-rc2/i18n/fr/attal_ai_fr.ts0000644000175000017500000001250011016036213015446 0ustar aaaa AiInterface Attal: IA client Attal: client AI Log level : Verbose Niveau de log : Bavard Verbose Bavard Normal Normal Critical Critique Quiet Calme &File &Fichier Can't connect Impossible de se connecter You're already connected to a server. Please disconnect first. Déjà connecté à un serveur. Déconnectez-vous au préalable. Log level : Normal Niveau de log : Normal Log level : Critical Niveau de log : Critique Log level : Quiet &Connect to server &Connexion au serveur CTRL+C CTRL+C &Disconnect &Déconnexion CTRL+D CTRL+D &Quit &Quitter CTRL+Q CTRL+Q Can't load theme Impossible de charger le thème Theme Thème has not been loaded successfully n'a pas été chargé correctement Log level Niveau de log ConfigConnection Connection to server Connexion au serveur Host : Hôte: Port : Port: Name : Nom: Connect Connecter Cancel Annuler attal-src-1.0-rc2/i18n/fr/attal_client_fr.ts0000644000175000017500000003657511016036213016355 0ustar aaaa ClientInterface CTRL+C CTRL+C CTRL+D CTRL+D CTRL+M CTRL+M Can't connect Connection impossible You're already connected to a server. Please disconnect first. Vous êtes déjà connecté(e). Déconnectez-vous d'abord. Attal - Lords of Doom Attal - Lords of Doom &Connect to server &Connexion au serveur &Disconnect &Déconnexion &Mini map &Mini-carte &Quit &Quitter &File &Fichier &Game &Jeu Match Partie Do you want abandon the match ? Voulez-vous abandonner la partie ? &Fullscreen &Plein écran CTRL+F CTRL+P Can't load theme Impossible de charger le thème Theme Thème has not been loaded successfully n'a pas été chargé correctement Fast &Server &Serveur CTRL+S CTRL+S &Help &Aide Key_F1 Key_F1 Next &Lord &Seigneur suivant CTRL+L CTRL+S Next &Base &Base suivante CTRL+B Free size Taille libre 800x600 1280x1024 Test Style Test style &Screen &Affichage &About &A propos CTRL+A CTRL+A 1024x768 1024x768 Are you sure ? Etes-vous sûrs ? Do you really want to quit? Voulez-vous quitter ? Loading Data... Chargement... &Start game &Démarrer CTRL+N CTRL+N &End game &Terminer CTRL+E CTRL+E &Save game &Sauver CTRL+W CTRL+W &Scenario Informations &Informations Choose new scenario Nouveau scénario Load campaign Charger une campagne Load game Charger une partie Loading data... Chargement... Cancel Annuler &Options CTRL+O ESC CTRL+T &Popup message (base mode) Host found , connecting... Connection Refused ConfigConnection Connection to server Connexion au serveur Host : Hôte : Port : Port : Name : Nom : Connect Connecter Cancel Annuler DisplayScenarii Size Taille Name Nom DisplayScenariiDialog Ok Ok Cancel Annuler DisplayScenarioDescription Name: %1 Nom: %1 Size: %1x%2 Taille : %1x%2 Description: %1 Description : %1 Name: Nom : Size: Taille : Description: Description : Opponent(s): %1 Opponent(s): StartGameDialog Start Game Démarrer partie Start Scenario Démarrer scénario Start Campaign Démarrer campagne Load Scenario Charger scénario Load Campaign Charger campagne attal-src-1.0-rc2/i18n/fr/attal_libai_fr.ts0000644000175000017500000000011510704431775016153 0ustar aaaa attal-src-1.0-rc2/i18n/fr/attal_libclient_fr.ts0000644000175000017500000005362311016036213017035 0ustar aaaa AboutDialog Attal is a turn-based strategy game. Can be played alone (against AI) or against other through a network (local or internet). It's available under Linux and Windows. Attal est un jeu de stratégie tour par tour. Il est possible d'y jouer seul (contre IA) ou avec d'autres par réseau (local ou internet). Il est disponible sous Linux et Windows. Version: Version : AskChest Choose between earning Gold or Experience Choisissez entre l'or et l'expérience Gold Or Experience Expérience AskCost Change AskDialog Yes Oui No Non AskPixmap Open pixmap Image AttalPopup About A propos BuildingPanel Info Info Building informations Bâtiment Ok Ok Buy Acheter Sell Vendre Name: BuyCreature All Buy Acheter Quit Recruit No room left No room left for a new unit CentralControl Next Lord Seigneur suivant End Turn Fin du tour DisplayBase View Buildings Bâtiments Resources Creatures Créatures DisplayBaseInfo Base Information Info sur la base DisplayCreature no building next week Attack Defense Damage Health Speed Growth Available : DisplayCreatureBase Creatures Créatures DisplayGeneral Attack Defense Power Knowledge Specialty None DisplayLord Info Lord DisplayLordTab General Général Units Unités Artefacts Objets Technics Techniques DisplayLordTabGeneral No specialty DisplayLordTabTechnics Not yet implemented A venir DisplayLordTabUnits Split unit Diviser l'unité Now click on a free cell or a unit of same type Cliquer sur une case vide ou de même type Unit Do you want destroy this unit ? DisplayUnit Unit Do you want destroy this unit ? EditCost Ok Ok Cancel ExchangeResources All Buy Acheter Game Lord Seigneur - - Artefact: Objet : Chest Coffre About A propos Cell: row %1, col %2, coordinates x %3, y %4 Case : %1, %2, coord x %3, y %4 It is C'est , a new week is beginning , une nouvelle semaine commence Are you sure ? Etes-vous surs ? One or more heroes may still move. Are you sure you want to end your turn ? Un héros peut encore se déplacer. Confirmez-vous la fin du tour ? You lose Perdu You lose Perdu Player Joueur has lost. a perdu. A player has lost. Un joueur a perdu. A player has Win. Un joueur a gagné. You win !! Vous avez gagné !! has win. a gagné. Connection established, %1 Connexion établie, %1 Host address %1 Hôte %1 Host port %1, Port %1, Our port %1 Notre port %1 Connection ID, %1 Connexion ID, %1 Name of player: %1 Nom du joueur : %1 Information Information The creatures are fleeing. Do you want to let them flee ? Les créatures fuient. Les laissez-vous partir ? You can buy these creatures. Do you want to buy them ? Vous pouvez acheter ces créatures. Les soudoyer ? The creatures want to join. Do you accept them ? Ces créatures veulent se joindre à vous. Vous acceptez ? InsideActionAllBuildings Buildings Bâtiments Building Bâtiment Are you sure to sell this building? Etes-vous sur de vendre ce bâtiment ? Can't buy Not enough ressources to buy this building Market Marketplace Kingdom resources Available for trade OptionsDialog Enable animation Animer Disposition: Disposition : Extra compact Très compact Compact Compact Normal Normal Enable music Enable sound Tavern Some lords are visiting your base and are available in your tavern. Here is the list: TavernLord Buy Acheter attal-src-1.0-rc2/i18n/fr/attal_libcommon_fr.ts0000644000175000017500000003202511015367042017046 0ustar aaaa Action Unknown date first time first time lord next time change owner every ElementaryAction Unknown attack defense power knowledge move maxmove techpoint maxtechpoint morale luck vision experience skill artefact unit resource random resource percentage resource charisma population add %1 give %1 give between 0 and %1 resource from resource for every %1 modify by give one percentage people InsideBuildingModel Description: Not implemented Main Building (not sellable) Castle Produce Market Tavern Cost: Require: QObject Ok Ok Bonus Resource: Fixed Value: Base Obedient Friendly Neutral Aggressive Hostile Stable Percentage fixed Percentage variable Quest Do you accept this quest ? Acceptez-vous cette quête ? Only once Juste une fois Once for each player Une fois par joueur Once for each lord Une fois par seigneur Anytime requested A chaque fois QuestConditionDate Must be accomplished before day %1, week %2, month %3 Doit être accompli avant le %1, semaine %2, mois %3 Must be accomplished before %1 days Doit être accompli sous %1 jours attal-src-1.0-rc2/i18n/fr/attal_libfight_fr.ts0000644000175000017500000001117611015367042016663 0ustar aaaa CasualtiesReport Report - Your lord %1 Rapport - Votre seigneur %1 Report - Opponent lord %1 Rapport - Seigneur ennemi %1 Report - Opponent creatures %1 Rapport - Créatures adverses %1 %1 %2 killed %1 %2 tués No creatures killed Aucune créatures de tuées Fight Cell: row %1, col %2, coordinates x %3, y %4 Case : %1, %2, coord. x %3, y %4 FightControl Options Options Surrender Se rendre Flee Fuir Auto-fight Combat auto Spells Sorts Wait Attendre Defend Défendre FightResultWizard FightResultWizard Résultats Congratulations, you win! Bravo, vous avez gagné ! Humm, you have fled! Humm, c'est un échec! Pff, you have surrendered! Hou, vous avez capitulé! Sorry, you lose! Désolé, vous avez perdu! FightSettingsDialog Settings Réglages Animation Animation Animation Speed Vitesse animation Show cells Afficher les cases attal-src-1.0-rc2/i18n/fr/attal_libserver_fr.ts0000644000175000017500000000233211015367043017063 0ustar aaaa Engine You have no place for recruiting new creatures You have not enough resources for recruiting this creatures Error with scenario Wrong number of connected players QObject Unknown Inconnu attal-src-1.0-rc2/i18n/fr/attal_server_fr.ts0000644000175000017500000002224611015367043016402 0ustar aaaa ChooseFileWidget Choose Choisir Choose scenario Choisir un scénario ConfigConnection Start server Démarrer le serveur Host : Hôte: Port : Port: Start Démarrer Quit Quitter DisplayScenarii Size Taille Players Joueurs Name Nom DisplayScenariiDialog Cancel Annuler Ok Ok DisplayScenarioDescription Name: %1 Nom : %1 Player(s): %1 Joueur(s) : %1 Size: %1x%2 Taille : %1x%2 Description: %1 Description : %1 Name: Nom : Player(s): Joueur(s) : Size: Taille : Description: Description : ServerInterface Attal - Lords of Doom (Server) Serveur pour 'Attal - Lords of Doom' Server error Erreur du serveur Could not listen for sockets. Impossible d'écouter les sockets. Try again Essayez à nouveau Quit Quitter Status Bar Barre de statut &File &Fichier Can't load theme Impossible de charger le thème Theme Thème has not been loaded successfully n'a pas été chargé correctement Load scenario Charger scenario Load campaign Charger campagne Load game Charger jeu Save game Sauver jeu End game Fin du jeu Fill with AI Compléter avec des IA &Game &Jeu Debug AI Débugguer IA Hide AI Cacher IA Continue campaign Continuer la campagne Fill with External AI Ajouter d'autres IA Add external AI player Ajouter un joueur IA ServerWidget Name Nom Address Adresse Start Démarrer Save Sauver End Finir attal-src-1.0-rc2/i18n/fr/campaign_editor_fr.ts0000644000175000017500000000552110340436512017027 0ustar aaaa CampaignInterface Can't load theme Impossible de charger le thème Theme Thème has not been loaded successfully n'a pas été chargé correctement New Nouveau &New &Nouveau CTRL+N CTRL+N Open Ouvrir &Open &Ouvrir CTRL+O CTRL+O Save Sauver &Save &Sauver CTRL+S CTRL+S Save as Sauver sous &Save as &Sauver sous Quit Quitter &Quit &Quitter CTRL+Q CTRL+Q Help Aide &Help &Aide F1 F1 &File &Fichier MainCampaignScreen Name: Nom : Description: Description : List of scenarii: List des scenarii : attal-src-1.0-rc2/i18n/fr/scenario_editor_fr.ts0000644000175000017500000011502411015367043017055 0ustar aaaa AskLordCharac Charac Caractéristique DecorationSelection Auto-path Automatique DisplayQuests Main quest: Quête principale : Edit Editer Other quests: Autres quêtes : Add Ajouter Del Supprimer Ok Ok Cancel Annuler EditTroop Race : Race : Name : Nom : Number : Nombre : FillDialog Choose tile Choisissez un sol Ok Ok Cancel Annuler %1 (weight=%2) %1 (poids=%2) GeneralPropertiesBase Owner: Possesseur : Buildings Bâtiments Name: Nom : None Aucun Description Description Actions Actions Res Base: NewQuestConditionDialog AND ET OR OU Date Date Lord Seigneur Player Joueur PropertiesBase Base properties Propriété de la base Ok Ok General Général Units Unités Cancel Annuler PropertiesBonus Resource: Ressource : Fixed value: Valeur : Primary skill: Compétence primaire : Attack Attaque Defense Défense Power Puissance Knowledge Savoir Morale Moral Luck Chance Add value: Ajouter une valeur : Bonus for secondary skills are not yet implemented Les bonus pour les compétences secondaires ne sont pas encore implémentés Bonus for spells are not yet implemented Les bonus pour les sorts ne sont pas encore implémentés Charisma Charisme PropertiesBuilding building properties Propriété du bâtiment Owner: Possesseur : Ok Ok None Aucun Res Buil: PropertiesCreature Ok Ok Never flee: Ne fuit jamais : Looking at right side: Tournée vers la droite: Cancel Annuler Behaviour of creatures: Comportement: Growth of creatures: Croissance : Growth param 0: Param. de croissance 0 : Growth param 1: Param. de croissance 1 : Number of creatures in stack %1: Res Crea: PropertiesEvent Condition Condition Cancel Annuler Ok Ok PropertiesLord Lord properties Propriété du seigneur General Général Units Unités Artefacts Artefacts War Machines Machines de guerre Technics Techniques Lord's properties error Erreur dans les propriétés du seigneur The lord must have at least 1 unit Un seigneur doit posséder au moins une unité Ok Ok Cancel Annuler The lord must have an owner PropertiesLordArtefacts Common artefacts list Liste des artefacts disponibles Lord's artefacts list Liste des artefacts du seigneur PropertiesLordGeneral Select player: Choisir un joueur : Default Défaut PropertiesLordTechnics Common technics list Liste des techniques disponibles Lord's technics list Liste des techniques du seigneur PropertiesLordWarMachines Common war machines list Liste des machines disponibles Lord's war machines list Liste des machines du seigneur PropertiesPlayers Players Properties Propriétés des joueurs Ruled by AI Dirigé par une IA Team : Equipe : QObject Tile Sol Transition Transition Decoration Décoration Building Bâtiment Base Base Lord Seigneur Artefact Artefact Creature Créature Tool Outils Bonus Bonus QuestConditionDateProperties Before date: Avant : Day Jour Week Semaine Month Mois Before Avant day(s) jour(s) Ok Ok Cancel Annuler Year QuestConditionDialog Condition Condition Ok Ok Cancel Annuler &Properties &Propriétés &Add condition &Ajouter une condition &Delete condition &Supprimer QuestConditionEditor Condition: Condition : Edit Editer QuestConditionLordProperties Primary skill Compétence primaire value: valeur : Secondary skill Compétence secondaire Artefact Artefact Spell Sort Ok Ok Cancel Annuler Number of creatures Nombre de créatures QuestConditionPlayerProperties Nb lords Nb seigneurs Nb bases Nb bases Basename = Nom = Ok Ok Cancel Annuler QuestEditor Name: Nom : Description: Description : Type: Type : Ask player confirmation of quest Demander confirmation de la quête Confirmation question: Question de confirmation : Ok Ok Cancel Annuler Start condition: Condition de démarrage : Fail condition: Condition d'échec : Success condition: Condition de succès : ScenarioInfo General Scenario Informations Informatios générales du scénario General Information Informations générales Name: Nom : Theme: Thème : Number of players: Nombre de joueurs : Map height: Hauteur carte : Map width: Largeur carte : Description: Description : Ok Ok Cancel Annuler Map Carte Map for Attal Carte pour Attal Day: Jour : Week: Semaine : Month: Mois : Year: Année : ScenarioInterface &New &Nouveau CTRL+N CTRL+N &Open &Ouvrir CTRL+O CTRL+O &Save &Sauvegarder CTRL+S CTRL+S &Save as &Sauvegarder sous &Quit &Quitter CTRL+Q CTRL+Q &Scenario information &Information sur le scénario CTRL+I CTRL+I &Players properties &Propriétés des joueurs CTRL+P CTRL+P &Clear screen Effacer la &carte CTRL+C CTRL+C &Fill screen &Remplir la carte CTRL+F &Help &Aide F1 F1 &File &Fichier &Scenario &Scenario &Tools &Outils Can't load theme Impossible de charger le thème Theme Thème has not been loaded successfully n'a pas été chargé correctement Quests management Gestion des quêtes &Mini map &Mini carte CTRL+M CTRL+M &Grid &Grille CTRL+G Open scenario Ouvrir un scénario Save scenario as Sauvegarder un scénario sous &About &A propos CTRL+A CTRL+A Screen &Delete &Properties &Propriétés (Cell %1x%2) TilePresentation %1 (weight=%2) %1 (poids=%2) attal-src-1.0-rc2/i18n/fr/theme_editor_fr.ts0000644000175000017500000012474411016036213016356 0ustar aaaa AskDiversificationList New Nouveau Del Supprimer DialogArtefactAction Action type: Type d'action: Characteristic Caractéristique Spell Sort Fixed value Valeur Ratio Ratio Modification type: Type de modif: Parameter: Paramètre: Value: Valeur: Ok Ok Cancel Annuler DialogBuildingAction Action type: Type d'action: Elementary Action: Action élémentaire : Coeff: Coeff : Ok Ok Cancel Annuler Arg0: Arg1: DialogCreatureAnimation Moving Déplacement Fighting Combat Schooting Tir Defending Défense StartMoving Début mouvement EndMoving Fin mouvement Dying Mourrant AttackHigh Attaque en haut Selecting Choisissant Action: Action: Start Frame: Frame de départ : End Frame: Frame de fin : Ok Ok Cancel Annuler SchootHigh Tir max SchootLow Tir min Dead Mort AttackLow Attaque basse DialogEffect Effect type: Type d'effet : Ok Ok Cancel Annuler Effect value: Effet: EditCreature Name: Nom : Attack: Attaque : Defense: Défense : Max Health: Santé max. : Max Move: Mouvements max. : Dist Attack: Attaque distante : Min Damages: Dommages minimaux : Max Damages: Dommages maximaux : Morale: Moral : Luck: Chance : Size: Taille : Cost: Coût : Maintenance cost: Coût de maintenance : Picture: Image : X Offset: Offset X : Y Offset: Offset Y : Num. Frames: Nb frames: X Offset mirror: X Offset miroir : EditTroop Race : Race: Name : Nom: Number : Nombre: EditWidget Add Ajouter Edit Editer Del Supprimer MapDispositionEditor Free Libre Occupied Occupé Door Porte Columns: Colonnes : Rows: Lignes : PreviewBaseDialog Buildings Bâtiments QObject Effect ' Effet ' ' with param ' avec comme paramètre Action: Action: Charac Carac Spell Sort modify by modifié par % % AnimationType: Type d'animation : first frame Première frame last frame dernière frame SectionArtefact Artefact Artefact Name: Nom : Position: Position : Icon: Icone : Item: Objet : SectionBase Base Base Name: Nom : Res Cost: Coût ress : Preview inside Prévisualisation intérieur Base : %1/%2 Base : %1/%2 Res Base: SectionBuilding Building Bâtiment Name: Nom : Description: Description : Type: Type : Picture: Image : Number Frames: Nombre d'animations : Animation Freq.: Fréq. d'animation : Res Build: SectionCreature Race Race Name: Nom : Creature Créature Race : %1/%2 Race : %1/%2 Creature : %1/%2 Créature : %1/%2 Creature : %1/?? Créature : %1/?? SectionDecoration Name: Nom : Info: Info : Image: Image : Decoration group Groupe déco Decoration item Objet déco SectionExperience List of required experience to gain for accessing the next level: Liste des points d'expériences pour changer de niveau : SectionGeneral Number of unit/lord Nombre d'unités par seigneur Logo (200x180): Logo (200x180) : Vision management: Gestion de la vision : Day Jour Name: Nom : Week Semaine Month Mois Day : %1/%2 Jour : %1/%2 Week : %1/%2 Semaine : %1/%2 Month : %1/%2 Mois : %1/%2 SectionGround Tiles Sols Name: Nom : Coef: Coef : Color: Couleur : Tile Sol Width: Larg. : Height: Hauteur : SectionInsideBuilding Building Bâtiment Name: Nom : Description: Description : Cost: Coût : Maintenance cost: Coût de maintenance : Params: Paramètres : Not yet used Pas encore utilisé Main Building Bâtiment principal Castle Château Prod Creature Générateur créatures Market Marché Tavern Taverne Requirements Pré-requis Building : %1/%2 Bâtiment : %1/%2 SectionLord Lord Seigneur Photo: Photo : Icon: Icone : Name : Nom : Category : Catégorie : Attack : Attaque : Defense : Défense : Power : Puissance : Knowledge : Savoir : MaxMoves : Mouvements max : Vision : Vision : (Race: (Race : Charisma : Charisme : Cost: Coût : SectionLordCategory Lord Categories Catégories des seigneurs Name: Nom : Description: Description : Race: Race : Evolution of Attack skill (weight): Evolution de l'attaque (pondération) : Evolution of Defense skill (weight): Evolution de la défense (pondération) : Evolution of Power skill (weight): Evolution de la puissance (pondération) : Evolution of Knowledge skill (weight): Evolution du savoir (pondération) : SectionMachine War Machine Machines de guerre Name: Nom : Type: Type : Param (1): Param (1) : Params: Paramètres : Icon: Icone : Item: Objet : SectionResource Resource Ressource Name: Nom : Icon: Icone : Small icon: Petite icone : Local Preservable Local Not Preservable Global Preservable Global Not Preservable SectionSelector General Général Artefacts Artefacts Teams Equipes Bases Bases Buildings Bâtiments Creatures Créatures Decorations Décorations Grounds Sols Lords Seigneurs Resources Ressources War Machines Machines Lord Categories Catégories des seigneurs Levels Niveaux SectionTeam Team Equipe Name: Nom : Color Couleur Flag: Drapeau : SelectionDate None Aucun SelectionWidget None Aucun ThemeInterface Theme editor for 'Attal - Lords of Doom' Editeur de thème pour 'Attal - Lords of Doom' Status Bar Barre de statut Open theme Ouvrir un thème &File &Fichier &Help &Aide &New theme &Nouveau thème CTRL+N CTRL+N &Open theme &Ouvrir CTRL+O CTRL+O &Save theme &Sauver CTRL+S CTRL+S &Quit &Quitter CTRL+Q CTRL+Q F1 F1 Can't load theme Impossible de charger le thème Theme Thème has not been loaded successfully n'a pas été chargé correctement &About &A propos CTRL+A CTRL+A attal-src-1.0-rc2/i18n/.cvsignore0000644000175000017500000000001710347252224014232 0ustar aaaaMakefile *.so* attal-src-1.0-rc2/i18n/i18n.pro0000644000175000017500000000037110435342742013541 0ustar aaaaTEMPLATE = lib include( ../config.pro ) CONFIG +=thread unix { target.path = $${ATT_PREFIX}/share/games/attal/translations/ target.files = de/*.qm target.files += fr/*.qm target.files += it/*.qm target.files += ru/*.qm INSTALLS += target } attal-src-1.0-rc2/i18n/it/0000755000175000017500000000000011016113670012643 5ustar aaaaattal-src-1.0-rc2/i18n/it/.cvsignore0000644000175000017500000000000507737111054014647 0ustar aaaa*.qm attal-src-1.0-rc2/i18n/it/attal_ai_it.ts0000644000175000017500000001277511016036214015477 0ustar aaaa AiInterface Attal: IA client Attal: client AI Log level : Verbose Livello di log: Prolisso Verbose Prolisso Normal Normale Critical Critico Quiet Calmo &File &File Can't connect Non posso connettermi You're already connected to a server. Please disconnect first. Sei già connesso al server. Per piacere prima disconnettiti Log level : Normal Livello di log: Normale Log level : Critical Livello di log: Critico Log level : Quiet Livello di log: Calmo &Connect to server &Collegamento al server CTRL+C CTRL+C &Disconnect &Disconnessione CTRL+D CTRL+D &Quit &Esci CTRL+Q CTRL+Q Can't load theme Non posso caricare il tema Theme Il tema has not been loaded successfully non è stato caricato con successo Log level Livello di log ConfigConnection Connection to server Collegamento al server Host : Host : Port : Porta : Name : Nome : Connect Collega Cancel Annulla attal-src-1.0-rc2/i18n/it/attal_client_it.ts0000644000175000017500000003653011016036214016357 0ustar aaaa ClientInterface Attal - Lords of Doom Attal - Signori del Destino &Connect to server &Collegamento al server CTRL+C CTRL+C &Disconnect &Disconnessione CTRL+D CTRL+D &Mini map &Mini mappa CTRL+M CTRL+M &Quit &Esci &File &File &Game &Gioco Can't connect Non posso connettermi You're already connected to a server. Please disconnect first. Sei già connesso ad un server, per piacere disconnettiti Match Partita Do you want abandon the match ? Vuoi abbandonare la partita? &Fullscreen &Schermo Intero CTRL+F CTRL+F Can't load theme Non posso caricare il tema Theme Il tema has not been loaded successfully non è stato caricato con successo Fast &Server &Server CTRL+S &Help &Aiuto Key_F1 Tasto_F1 Next &Lord Prossimo &Signore CTRL+L Next &Base Prossima &Base CTRL+B Free size Dimensione libera 800x600 1280x1024 Test Style Stile del testo &Screen &Schermo &About &Informazioni su Attal CTRL+A 1024x768 Are you sure ? Sei sicuro? Do you really want to quit? Vuoi uscire sul serio? Loading Data... Caricamento dati... &Start game &Inizio gioco CTRL+N &End game &Fine gioco CTRL+E &Save game &Salva CTRL+W &Scenario Informations &Informazioni sulla mappa Choose new scenario Scegli una nuova mappa Load campaign Carica campagna Load game Carica mappa Loading data... Caricamento dati... Cancel Annulla &Options &Opzioni CTRL+O ESC CTRL+T &Popup message (base mode) &Messaggio di popup ( nel castello ) Host found , connecting... Host trovato, mi sto connettendo.... Connection Refused Connessione rifiutata ConfigConnection Connection to server Collegamento al server Host : Host: Port : Porta : Name : Nome : Connect Collega Cancel Annulla DisplayScenarii Size Dimensione Name Nome DisplayScenariiDialog Ok Cancel Annulla DisplayScenarioDescription Name: %1 Nome %1 Size: %1x%2 Dimensioni: %1x%2 Description: %1 Descrizione: %1 Name: Nome: Size: Dimensione: Description: Descrizione: Opponent(s): %1 Avversario(i): %1 Opponent(s): Avversario(i): StartGameDialog Start Game Inizio gioco Start Scenario Nuova mappa Start Campaign Nuova campagna Load Scenario Carica mappa Load Campaign Carica campagna attal-src-1.0-rc2/i18n/it/attal_libai_it.ts0000644000175000017500000000011510630060111016141 0ustar aaaa attal-src-1.0-rc2/i18n/it/attal_libclient_it.ts0000644000175000017500000005350111016036214017043 0ustar aaaa AboutDialog Attal is a turn-based strategy game. Can be played alone (against AI) or against other through a network (local or internet). It's available under Linux and Windows. Attal è un gioco di strategia a turni. Si può giocare da soli ( contro l'AI) o contro altri giocatori via rete ( locale o internet). E' disponibile per Linux e Windows. Version: Versione: AskChest Choose between earning Gold or Experience Scegli tra guadagnare Oro o Esperienza Gold Oro Experience Esperienza AskCost Change AskDialog Yes Si No AskPixmap Open pixmap Apri pixmap AttalPopup About Circa BuildingPanel Info Building informations Informazioni sull'edificio Ok Buy Compra Sell Vendi Name: Nome: BuyCreature All Tutto Buy Compra Quit Esci Recruit Recluta No room left Non c'è posto No room left for a new unit Non c'è posto per una nuova unità CentralControl Next Lord Sign succ End Turn Fine turno DisplayBase View Vista Buildings Edifici Resources Risorse Creatures Creature DisplayBaseInfo Base Information Informazioni sul castello DisplayCreature no building no edificio next week nuova sett. Attack Attacco Defense Difesa Damage Danno Health Punti ferita Speed Velocità Growth Crescita Available : Disponibile : DisplayCreatureBase Creatures Creature DisplayGeneral Attack Attacco Defense Difesa Power Potere Knowledge Conoscenza Specialty None No Specialità DisplayLord Info Lord Info Sign. DisplayLordTab General Generale Units Unità Artefacts Artefatti Technics Tecniche DisplayLordTabGeneral No specialty No specialità DisplayLordTabTechnics Not yet implemented Non ancora implementato DisplayLordTabUnits Split unit Dividi unità Now click on a free cell or a unit of same type Adesso clicca su una cella libera o su un'unità dello stesso tipo Unit Unità Do you want destroy this unit ? Vuoi distruggere questa unità? DisplayUnit Unit Unità Do you want destroy this unit ? Vuoi distruggere questa unità? EditCost Ok Ok Cancel Annulla ExchangeResources All Tutto Buy Compra Game Lord Signore - - Artefact: Artefatto: Chest Forziere About Circa Cell: row %1, col %2, coordinates x %3, y %4 Cella: riga %1, col %2, coordinate x %3, y%4 It is E' , a new week is beginning , sta iniziando una nuova settimana Are you sure ? Sei sicuro? One or more heroes may still move. Are you sure you want to end your turn ? Uno o più signori possono muoversi ancora. Sei sicuro di volere finire il tuo turno? You lose Hai perso You lose Hai perso Player Il giocatore has lost. ha perso. A player has lost. Un giocatore ha perso. A player has Win. Un giocatore ha vinto. You win !! Hai vinto!! has win. ha vinto. Connection established, %1 Connessione stabilita, %1 Host address %1 Indirizzo dell'host %1 Host port %1, Porta dell'host %1, Our port %1 La tua porta %1 Connection ID, %1 ID della connessione, %1 Name of player: %1 Nome del giocatore: %1 Information Informazione The creatures are fleeing. Do you want to let them flee ? Le creature stanno fuggendo. Le lasci fuggire? You can buy these creatures. Do you want to buy them ? Puoi comprare queste creature. Le comperi? The creatures want to join. Do you accept them ? Queste creature vogliono unirsi a te. Le accetti? InsideActionAllBuildings Buildings Edifici Building Edificio Are you sure to sell this building? Sei sicuro di voler vendere questo edificio? Can't buy Non puoi comprare Not enough ressources to buy this building Non ci sono abbastanza risorse per comperare questo edificio Market Marketplace Mercato Kingdom resources Risorse del regno Available for trade Disponibile per il commercio OptionsDialog Enable animation Abilita le animazioni Disposition: Disposizione: Extra compact Molto compatto Compact Compatto Normal Normale Enable music Enable sound Tavern Some lords are visiting your base and are available in your tavern. Here is the list: Alcuni signori sono in visita nella tua base e sono disponibili nella tua taverna. Ecco la lista: TavernLord Buy Compra attal-src-1.0-rc2/i18n/it/attal_libcommon_it.ts0000644000175000017500000003117511016112060017052 0ustar aaaa Action Unknown Sconosciuto date data first time prima volta first time lord prima volta signore next time prossima volta change owner cambia possessore every ogni ElementaryAction Unknown Sconosciuto attack attacco defense difesa power potenza knowledge conoscienza move mossa maxmove massima mossa techpoint punti tecnologia maxtechpoint massimi punti tecnologia morale luck fortuna vision visione experience esperienza skill abilità artefact artefatto unit unità resource risorsa random resource risorsa casuale percentage resource risorsa percentuale charisma carisma population popolazione add %1 aggiunge %1 give %1 dà %1 give between 0 and %1 dà tra 0 e %1 resource from resource risorsa da risorsa for every %1 per ogni %1 modify modifica by di give one dà un percentage percentuale people persone InsideBuildingModel Description: Descizione: Not implemented Non funzionante Main Building (not sellable) Edificio principale ( non vendibile ) Castle Castello Produce Produce Market Mercato Tavern Taverna Cost: Costa: Require: Richiede: QObject Ok Bonus Bonus Resource: Risorsa: Fixed Value: Valore fisso: Base Obedient Obbediente Friendly Amichevole Neutral Neutrale Aggressive Aggressiva Hostile Ostile Stable Stabile Percentage fixed Percentuale fissa Percentage variable Percentuale variabile Quest Do you accept this quest ? Accetti questa missione? Only once Solo una volta Once for each player Una volta per ogni giocatore Once for each lord Una volta per ciascun signore Anytime requested Ogni volta sia richiesta QuestConditionDate Must be accomplished before day %1, week %2, month %3 Deve essere compiuta prima del giorni %1, settimana %2, mese %3 Must be accomplished before %1 days Deve essere compiuta prima di %1 giorni attal-src-1.0-rc2/i18n/it/attal_libfight_it.ts0000644000175000017500000001120511015367044016670 0ustar aaaa CasualtiesReport Report - Your lord %1 Rapporto - Il tuo signore %1 Report - Opponent lord %1 Rapporto - Signore nemico %1 Report - Opponent creatures %1 Repporto -Creatura nemica %1 %1 %2 killed %1 %2 uccise No creatures killed Nessuna creatura uccisa Fight Cell: row %1, col %2, coordinates x %3, y %4 Cella: riga %1, col %2, coordinate x %3, y %4 FightControl Options Opzioni Surrender Arrendersi Flee Fuga Auto-fight Auto-combattimento Spells Magie Wait Attesa Defend Difendi FightResultWizard FightResultWizard Risulati finali Congratulations, you win! Congratulazioni, hai vinto! Humm, you have fled! Humm, sei fuggito! Pff, you have surrendered! Pff, ti sei arreso! Sorry, you lose! Mi spiace, hai perso! FightSettingsDialog Settings Configurazioni Animation Animazioni Animation Speed Velocità di animazione Show cells Mostra le celle attal-src-1.0-rc2/i18n/it/attal_libserver_it.ts0000644000175000017500000000246011015367044017100 0ustar aaaa Engine You have no place for recruiting new creatures Non hai posto per reclutare nuove creature You have not enough resources for recruiting this creatures Non hai abbastanza risorse per reclutare queste creature Error with scenario Errore nello scenario Wrong number of connected players Numero errato di giocatori connessi QObject Unknown Sconosciuto attal-src-1.0-rc2/i18n/it/attal_server_it.ts0000644000175000017500000002212711015367044016413 0ustar aaaa ChooseFileWidget Choose Apri Choose scenario Scegli lo scenario ConfigConnection Start server Avvia server Host : Host : Port : Porta : Start Avvia Quit Esci DisplayScenarii Size Dimensione Players Giocatori Name Nome DisplayScenariiDialog Cancel Annulla Ok Ok DisplayScenarioDescription Name: %1 Nome: %1 Player(s): %1 Giocatore(i): %1 Size: %1x%2 Dimensione: %1x%2 Description: %1 Descrizione: %1 Name: Nome: Player(s): Giocatore(i): Size: Dimensione: Description: Descrizione: ServerInterface Attal - Lords of Doom (Server) Server error Errore del server Could not listen for sockets. Non posso ascoltare i socket. Try again Prova di nuovo Quit Esci Status Bar Barra di stato &File Can't load theme Non posso caricare il tema Theme Il tema has not been loaded successfully non è stato caricato con successo Load scenario Carica lo scenario Load campaign Carica la campagna Load game Carica il gioco Save game Salva il gioco End game Fine gioco Fill with AI Completa con l'IA &Game &Gioco Debug AI Hide AI Nascondi l'IA Continue campaign Continua campagna Fill with External AI Completa con un'AI esterna Add external AI player Aggiungi un bot AI ServerWidget Name Nome Address Indirizzo Start Inizia Save Salva End Fine attal-src-1.0-rc2/i18n/it/campaign_editor_it.ts0000644000175000017500000000543210342607027017045 0ustar aaaa CampaignInterface Can't load theme Non posso caricare il tema Theme Il tema has not been loaded successfully non è stato caricato con successo New Nuovo &New &Nuovo CTRL+N Open Apri &Open &Apri CTRL+O Save Salva &Save &Salva CTRL+S Save as Salva come &Save as &Salva come Quit Esci &Quit &Esci CTRL+Q Help Aiuto &Help &Aiuto F1 &File &File MainCampaignScreen Name: Nome: Description: Descrizione: List of scenarii: Lista degli scenari: attal-src-1.0-rc2/i18n/it/scenario_editor_it.ts0000644000175000017500000011463411015367045017077 0ustar aaaa AskLordCharac Charac Caratteristica DecorationSelection Auto-path Auto-cammino DisplayQuests Main quest: Missione Principale: Edit Modifica Other quests: Altre missioni: Add Aggiungi Del Cancella Ok Ok Cancel Annulla EditTroop Race : Specie: Name : Nome: Number : Numero: FillDialog Choose tile Scegli il tipo di suolo Ok Ok Cancel Annulla %1 (weight=%2) %1 (peso=%2) GeneralPropertiesBase Owner: Proprietario: Buildings Edificio Name: Nome: None Niente Description Descrizione Actions Azioni Res Base: NewQuestConditionDialog AND E OR O Date Incontro Lord Signore Player Giocatore PropertiesBase Base properties Proprietà del castello Ok Ok General Generale Units Unità Cancel Annulla PropertiesBonus Resource: Risorsa: Fixed value: Valore fisso: Primary skill: Abilità primaria: Attack Attacco Defense Difesa Power Potenza Knowledge Conoscenza Morale Luck Fortuna Add value: Aggiungi valore: Bonus for secondary skills are not yet implemented I bonus per le abilità secondarie non sono ancora stati implementati Bonus for spells are not yet implemented I bonus per le magie non sono ancora stati implementati Charisma Carisma PropertiesBuilding building properties Proprietà dell'edificio Owner: Proprietario: Ok Ok None Niente Res Buil: Res Edif: PropertiesCreature Ok Ok Never flee: Non fuggire mai: Looking at right side: Girato verso destra: Cancel Annulla Behaviour of creatures: Comportamento delle creature: Growth of creatures: Crescita delle creature: Growth param 0: Crescita param 0: Growth param 1: Crescita param 1: Number of creatures in stack %1: Numero di creature nella pila %1: Res Crea: PropertiesEvent Condition Condizione Cancel Annulla Ok Ok PropertiesLord Lord properties Proprietà del signore General Generale Units Unità Artefacts Artefatti War Machines Macchine da guerra Technics Tecniche Lord's properties error Errore nelle proprietà del signore The lord must have at least 1 unit Il signore deve avere almeno un'unità Ok Ok Cancel Annulla The lord must have an owner Il signore deve avere un possessore PropertiesLordArtefacts Common artefacts list Lista degli artefatti disponibili Lord's artefacts list Lista degli artefatti del signore PropertiesLordGeneral Select player: Scegli il giocatore: Default PropertiesLordTechnics Common technics list Lista delle tecniche disponibili Lord's technics list Lista tecniche del signore PropertiesLordWarMachines Common war machines list Lista delle macchine da guerra disponibili Lord's war machines list Lista delle macchine da guerra del signore PropertiesPlayers Players Properties Proprietà del giocatore Ruled by AI Comandato dall'AI Team : Squadra: QObject Tile Transition Transizione Decoration Decorazione Building Edificio Base Castello Lord Signore Artefact Artefatto Bonus Creature Creatura Tool Strumento QuestConditionDateProperties Before date: Prima della data: Day Giorno Week Settimana Month Mese Year Anno Before Prima di day(s) giorno(i) Ok Ok Cancel Annulla QuestConditionDialog Condition Condizione Ok Ok Cancel Annulla &Properties &Proprietà &Add condition &Aggiungi condizione &Delete condition &Cancella condizione QuestConditionEditor Condition: Condizione: Edit Modifica QuestConditionLordProperties Primary skill Abilità primaria value: valore: Secondary skill Abilità secondaria Artefact Artefatto Number of creatures Numero di creature Spell Magia Ok Ok Cancel Annulla QuestConditionPlayerProperties Nb lords Nb signori Nb bases Nb castelli Basename = Nome castello = Ok Ok Cancel Annulla QuestEditor Name: Nome: Description: Descrizione: Type: Tipo: Ask player confirmation of quest Domanda al giocatore la conferma della missione Confirmation question: Domanda di conferma: Ok Ok Cancel Annulla Start condition: Condizione iniziale: Fail condition: Condizione finale: Success condition: Condizione per il successo: ScenarioInfo General Scenario Informations Informazioni generali sullo scenario General Information Informazioni generali Name: Nome: Theme: Tema: Number of players: Numero di giocatori: Map height: Altezza della mappa: Map width: Larghezza della mappa: Day: Giorno: Week: Settimana: Month: Mese: Year: Anno: Description: Descrizione: Ok Ok Cancel Annulla Map Mappa Map for Attal Mappa per Attal ScenarioInterface Can't load theme Non posso caricare il tema Theme Tema has not been loaded successfully non è stato caricato con successo &New &Nuovo CTRL+N &Open &Apri CTRL+O &Save &Salva CTRL+S &Save as &Salva come &Quit &Esci CTRL+Q &Scenario information &Informazioni sullo scenario CTRL+I &Players properties &Proprietà dei giocatori CTRL+P Quests management Gestione delle missioni &Clear screen &Pulisci lo schermo CTRL+C &Fill screen &Riempi lo schermo CTRL+F &Mini map &Minimappa CTRL+M &Grid &Griglia CTRL+G &Help &Aiuto F1 &About &Informazioni su Attal CTRL+A &File &Scenario &Tools &Strumenti Open scenario Apri scenario Save scenario as Salva scenario come Screen &Delete &Cancella &Properties &Proprietà (Cell %1x%2) (Cella %1x%2) TilePresentation %1 (weight=%2) %1 (peso=%2) attal-src-1.0-rc2/i18n/it/theme_editor_it.ts0000644000175000017500000012465211016036214016367 0ustar aaaa AskDiversificationList New Nuovo Del Cancella DialogArtefactAction Action type: Tipo di azione: Characteristic Caratteristica Spell Sortilegio Fixed value Valore Ratio Percentuale Modification type: Tasso di modifica: Parameter: Parametro: Value: Valore: Ok Ok Cancel Annulla DialogBuildingAction Action type: Tipo di azione: Elementary Action: Azione elementare: Coeff: Coeff: Ok Cancel Annulla Arg0: Arg1: DialogCreatureAnimation Moving Mossa Fighting Combattimento Schooting Tiro Defending Difesa StartMoving Inizio mossa EndMoving Fine mossa Dying Morto AttackHigh Attacco Alto Selecting Scelto Action: Azione: Start Frame: Frame iniziale: End Frame: Frame finale: Ok Ok Cancel Annulla SchootHigh TiroAlto SchootLow TiroBasso Dead Morto AttackLow AttaccoBasso DialogEffect Effect type: Tipo di effetto: Ok Cancel Annulla Effect value: Valore dell'effetto: EditCreature Name: Nome: Attack: Attacco: Defense: Difesa: Max Health: Punti vita max.: Max Move: Movimento max.: Dist Attack: Attacco a distanza: Min Damages: Danni minimi: Max Damages: Danni massimi: Morale: Morale: Luck: Fortuna: Size: Dimensione: Cost: Costo: Maintenance cost: Costo di mantenimento: Picture: Immagine: X Offset: Scostamento X: Y Offset: Scostamento Y: Num. Frames: Num. di Frames: X Offset mirror: Scostamento X specchio: EditTroop Race : Specie: Name : Nome: Number : Numero: EditWidget Add Aggiungi Edit Modifica Del Cancella MapDispositionEditor Free Libero Occupied Occupato Door Entrata Columns: Colonne: Rows: Righe: PreviewBaseDialog Buildings Edifici QObject Effect ' Effetto ' ' with param ' con parametro Action: Azione: Charac Caratteristica Spell Sortilegio modify by modificata di % % AnimationType: Tipo di animazione: first frame primo frame last frame ultimo frame SectionArtefact Artefact Artefatto Name: Nome: Position: Posizione: Icon: Icona: Item: Oggetto: SectionBase Base Castello Name: Nome: Res Cost: Costo ris: Preview inside Anteprima interno Base : %1/%2 Castello : %1/%2 Res Base: SectionBuilding Building Edificio Name: Nome: Description: Descrizione: Type: Tipo: Picture: Immagine: Number Frames: Numero di frame: Animation Freq.: Frequenza di animazione: Res Build: Res Edif: SectionCreature Race Specie Name: Nome: Creature Creatura Race : %1/%2 Specie : %1/%2 Creature : %1/%2 Creatura : %1/%2 Creature : %1/?? Creatura : %1/?? SectionDecoration Name: Nome: Info: Informazioni: Image: Immagine: Decoration group Gruppo di decorazioni Decoration item Decorazione SectionExperience List of required experience to gain for accessing the next level: Lista di punti esperienza richiesti per accedere al livello successivo: SectionGeneral Number of unit/lord Numero di unità/signori Logo (200x180): Logo (200x180): Vision management: Gestione della vista: Day Giorno Name: Nome: Week Settimana Month Mese Day : %1/%2 Giorno : %1/%2 Week : %1/%2 Settimana : %1/%2 Month : %1/%2 Mese : %1/%2 SectionGround Tiles Suoli Name: Nome: Coef: Coefficiente: Color: Colore: Tile Suolo Width: Larghezza: Height: Altezza: SectionInsideBuilding Building Edificio Name: Nome: Description: Descrizione: Cost: Costo: Maintenance cost: Costo di mantenimento: Params: Parametri: Not yet used Non ancora usato Main Building Edificio principale Castle Castello Prod Creature Produce Creature Market Mercato Tavern Taverna Requirements Requisiti Building : %1/%2 Edificio : %1/%2 SectionLord Lord Signore Photo: Foto: Icon: Icona: Name : Nome: Category : Categoria: Attack : Attacco : Defense : Difesa: Power : Potere : Knowledge : Conoscenza : MaxMoves : Movimento max.: Vision : Visione : (Race: (Specie: Charisma : Carisma: Cost: Costo: SectionLordCategory Lord Categories Categorie dei signori Name: Nome: Description: Descrizione: Race: Specie: Evolution of Attack skill (weight): Evoluzione dell'abilità attacco (peso): Evolution of Defense skill (weight): Evoluzione dell'abilità difesa (peso): Evolution of Power skill (weight): Evoluzione dell'abilità potere (peso): Evolution of Knowledge skill (weight): Evoluzione dell'abilità conoscenza (peso): SectionMachine War Machine Macchina da guerra Name: Nome: Type: Tipo: Param (1): Parametro (1): Params: Parametri: Icon: Icona: Item: Oggetto: SectionResource Resource Risorsa Name: Nome: Icon: Icona: Small icon: Icona piccola: Local Preservable Locale preservabile Local Not Preservable Locale non preservabile Global Preservable Globale preservabile Global Not Preservable Globale non preservabile SectionSelector General Generale Artefacts Artefatti Teams Squadre Bases Castelli Buildings Edifici Creatures Creature Decorations Decorazioni Grounds Terreni Lords Signori Resources Risorse War Machines Macchine da guerra Lord Categories Categorie dei signori Levels Livelli SectionTeam Team Squadra Name: Nome: Color Colore Flag: Bandiera: SelectionDate None Niente SelectionWidget None Niente ThemeInterface Theme editor for 'Attal - Lords of Doom' Editor di temi per 'Attal - Signori del Destino' Status Bar Barra di stato Open theme Apri tema &File &File &Help &Aiuto &New theme &Nuovo tema CTRL+N CTRL+N &Open theme &Apri tema CTRL+O CTRL+O &Save theme &Salva tema CTRL+S CTRL+S &Quit &Esci CTRL+Q CTRL+Q F1 F1 Can't load theme Non posso caricare il tema Theme Il tema has not been loaded successfully non è stato caricato con successo &About &A proposito CTRL+A attal-src-1.0-rc2/i18n/ru/0000755000175000017500000000000011016113670012655 5ustar aaaaattal-src-1.0-rc2/i18n/ru/.cvsignore0000644000175000017500000000000507721766424014673 0ustar aaaa*.qm attal-src-1.0-rc2/i18n/ru/attal_ai_ru.ts0000644000175000017500000001357211016036214015517 0ustar aaaa AiInterface Attal: IA client Attal: ИИ-клиент Log level : Verbose Уровень подробности комментариев: многословный Verbose Многословный Normal Нормальный Critical Критический Quiet Отсутствуют &File &Файл Can't connect Соединение невозможно You're already connected to a server. Please disconnect first. Вы уже соединены с сервером. Пожалуйста, разорвите соединение сначала. Log level : Normal Уровень подробности комментариев: Нормальный Log level : Critical Уровень подробности комментариев: Критический Log level : Quiet Уровень подробности комментариев: Отсутствуют &Connect to server &Подключиться к серверу CTRL+C CTRL+C &Disconnect П&рервать соединение CTRL+D CTRL+D &Quit &Выход CTRL+Q CTRL+Q Can't load theme Невозможно загрузить тему Theme Тема has not been loaded successfully не была успешно загружена Log level ConfigConnection Connection to server Соединение с сервером Host : Хост: Port : Порт: Name : Название: Connect Установить соединение Cancel Отмена attal-src-1.0-rc2/i18n/ru/attal_client_ru.ts0000644000175000017500000004001211016036214016371 0ustar aaaa ClientInterface CTRL+C CTRL+C CTRL+D CTRL+D CTRL+M CTRL+M Can't connect Невозможно установить соединение You're already connected to a server. Please disconnect first. Вы уже соеденены с сервером. Пожалуйста, разорвите ваше соединение сначала. Attal - Lords of Doom Attal - Lords of Doom &Connect to server &Установить соединение с сервером &Disconnect &Разорвать соединение &Mini map &Мини-карта &Quit &Выход &File &Файл &Game &Игра Match Матч Do you want abandon the match ? Вы хотите прервать матч? &Fullscreen &Полный экран CTRL+F CTRL+F Can't load theme Невозможно загрузить тему Theme Тема has not been loaded successfully не была успешно загружена Fast &Server "Быстрый" &Сервер CTRL+S CTRL+S &Help Key_F1 Next &Lord CTRL+L Next &Base CTRL+B Free size 800x600 1280x1024 Test Style &Screen &About CTRL+A 1024x768 Are you sure ? Do you really want to quit? Loading Data... &Start game CTRL+N &End game CTRL+E &Save game CTRL+W &Scenario Informations Choose new scenario Load campaign Load game Loading data... Cancel Отмена &Options CTRL+O ESC CTRL+T &Popup message (base mode) Host found , connecting... Connection Refused ConfigConnection Connection to server Соединение с сервером Host : Хост: Port : Порт: Name : Имя: Connect Установить соединение Cancel Отмена DisplayScenarii Size Name DisplayScenariiDialog Ok Cancel Отмена DisplayScenarioDescription Name: %1 Size: %1x%2 Description: %1 Name: Size: Description: Opponent(s): %1 Opponent(s): StartGameDialog Start Game Start Scenario Start Campaign Load Scenario Load Campaign attal-src-1.0-rc2/i18n/ru/attal_libai_ru.ts0000644000175000017500000000011510630060111016165 0ustar aaaa attal-src-1.0-rc2/i18n/ru/attal_libclient_ru.ts0000644000175000017500000005352011016036214017070 0ustar aaaa AboutDialog Attal is a turn-based strategy game. Can be played alone (against AI) or against other through a network (local or internet). It's available under Linux and Windows. Version: AskChest Choose between earning Gold or Experience Gold Experience AskCost Change AskDialog Yes No AskPixmap Open pixmap AttalPopup About BuildingPanel Info Building informations Ok Buy Sell Name: BuyCreature All Buy Quit Recruit No room left No room left for a new unit CentralControl Next Lord End Turn DisplayBase View Buildings Resources Creatures DisplayBaseInfo Base Information DisplayCreature no building next week Attack Defense Damage Health Speed Growth Available : DisplayCreatureBase Creatures DisplayGeneral Attack Defense Power Knowledge Specialty None DisplayLord Info Lord DisplayLordTab General Units Artefacts Technics DisplayLordTabGeneral No specialty DisplayLordTabTechnics Not yet implemented DisplayLordTabUnits Split unit Now click on a free cell or a unit of same type Unit Do you want destroy this unit ? DisplayUnit Unit Do you want destroy this unit ? EditCost Ok Cancel ExchangeResources All Buy Game Lord - Artefact: Chest About Cell: row %1, col %2, coordinates x %3, y %4 It is , a new week is beginning Are you sure ? One or more heroes may still move. Are you sure you want to end your turn ? You lose You lose Player has lost. A player has lost. A player has Win. You win !! has win. Connection established, %1 Host address %1 Host port %1, Our port %1 Connection ID, %1 Name of player: %1 Information The creatures are fleeing. Do you want to let them flee ? You can buy these creatures. Do you want to buy them ? The creatures want to join. Do you accept them ? InsideActionAllBuildings Buildings Building Are you sure to sell this building? Can't buy Not enough ressources to buy this building Market Marketplace Kingdom resources Available for trade OptionsDialog Enable animation Disposition: Extra compact Compact Normal Enable music Enable sound Tavern Some lords are visiting your base and are available in your tavern. Here is the list: TavernLord Buy attal-src-1.0-rc2/i18n/ru/attal_libcommon_ru.ts0000644000175000017500000003173611015367046017120 0ustar aaaa Action Unknown date first time first time lord next time change owner every ElementaryAction Unknown attack defense power knowledge move maxmove techpoint maxtechpoint morale luck vision experience skill artefact unit resource random resource percentage resource charisma population add %1 give %1 give between 0 and %1 resource from resource for every %1 modify by give one percentage people InsideBuildingModel Description: Not implemented Main Building (not sellable) Castle Produce Market Tavern Cost: Require: QObject Ok Bonus Resource: Fixed Value: Base Obedient Friendly Neutral Aggressive Hostile Stable Percentage fixed Percentage variable Quest Do you accept this quest ? Only once Once for each player Once for each lord Anytime requested QuestConditionDate Must be accomplished before day %1, week %2, month %3 Must be accomplished before %1 days attal-src-1.0-rc2/i18n/ru/attal_libfight_ru.ts0000644000175000017500000001120011015367046016711 0ustar aaaa CasualtiesReport Report - Your lord %1 Report - Opponent lord %1 Report - Opponent creatures %1 %1 %2 killed No creatures killed Fight Cell: row %1, col %2, coordinates x %3, y %4 FightControl Options Surrender Flee Auto-fight Spells Wait Defend FightResultWizard FightResultWizard Congratulations, you win! Humm, you have fled! Pff, you have surrendered! Sorry, you lose! FightSettingsDialog Settings Animation Animation Speed Show cells attal-src-1.0-rc2/i18n/ru/attal_libserver_ru.ts0000644000175000017500000000232411015367046017125 0ustar aaaa Engine You have no place for recruiting new creatures You have not enough resources for recruiting this creatures Error with scenario Wrong number of connected players QObject Unknown attal-src-1.0-rc2/i18n/ru/attal_server_ru.ts0000644000175000017500000002260311015367047016441 0ustar aaaa ChooseFileWidget Choose Выберете Choose scenario ConfigConnection Start server Стартовый сервер Host : Хост: Port : Порт: Start Старт Quit Выход DisplayScenarii Size Размер Players Игроки Name Имя DisplayScenariiDialog Cancel Отмена Ok Ок DisplayScenarioDescription Name: %1 Имя: %1 Player(s): %1 Игрок(и): %1 Size: %1x%2 Размер: %1x%2 Description: %1 Описание: %1 Name: Имя: Player(s): Игрок(и): Size: Размер: Description: Описание: ServerInterface Attal - Lords of Doom (Server) Attal - Lords of Doom (Server) Server error Ошибка сервера Could not listen for sockets. Невозможно прослушать сокеты. Try again Попробовать снова Quit Выход Status Bar Полоска состояния &File &Файл Can't load theme Невозможно загрузить тему Theme Тема has not been loaded successfully не была успешно загружена Load scenario Load campaign Load game Save game End game Fill with AI &Game Debug AI Hide AI Continue campaign Fill with External AI Add external AI player ServerWidget Name Имя Address Адрес Start Старт Save Сохранить End Закончить attal-src-1.0-rc2/i18n/ru/campaign_editor_ru.ts0000644000175000017500000000573510342607030017071 0ustar aaaa CampaignInterface Can't load theme Невозможно загрузить тему Theme Тема has not been loaded successfully не была загружена успешно New Новый &New &Новый CTRL+N CTRL+N Open Открыть &Open &Открыть CTRL+O CTRL+O Save Сохранить &Save &Сохранить CTRL+S CTRL+S Save as Сохранить как &Save as &Сохранить как Quit Выход &Quit &Выход CTRL+Q CTRL+Q Help Помощь &Help &Помощь F1 F1 &File &Файл MainCampaignScreen Name: Имя: Description: Описание: List of scenarii: Список сценариев: attal-src-1.0-rc2/i18n/ru/scenario_editor_ru.ts0000644000175000017500000011764611015367047017133 0ustar aaaa AskLordCharac Charac Персонаж DecorationSelection Auto-path DisplayQuests Main quest: Главная задача: Edit Редактировать Other quests: Другие задачи: Add Добавить Del Удалить Ok Ок Cancel Отмена EditTroop Race : Раса: Name : Имя: Number : Количество: FillDialog Choose tile Выберете покрытие Ok Ок Cancel Отмена %1 (weight=%2) GeneralPropertiesBase Owner: Владелец: Buildings Строения Name: Название: None Нет Description Actions Res Base: NewQuestConditionDialog AND И OR ИЛИ Date Дата Lord Лорд Player Игрок PropertiesBase Base properties Основные свойства Ok Ок General Общие Units Юниты Cancel Отмена PropertiesBonus Resource: Ресурс: Fixed value: Фиксированное значение: Primary skill: Основной навык: Attack Атака Defense Защита Power Сила Knowledge Знание Morale Мораль Luck Удача Add value: Добавить значение: Bonus for secondary skills are not yet implemented Бонус за добавочные навыки еще не реализованы Bonus for spells are not yet implemented Бонусы за заклинания еще не реализованы Charisma PropertiesBuilding building properties свойства здания Owner: Владелец: Ok Ок None Нет Res Buil: PropertiesCreature Ok Ок Never flee: Никогда не отступать: Looking at right side: Смотрит направо: Cancel Отмена Behaviour of creatures: Growth of creatures: Growth param 0: Growth param 1: Number of creatures in stack %1: Res Crea: PropertiesEvent Condition Условие Cancel Отмена Ok Ок PropertiesLord Lord properties Свойства лорда General Общие Units Юниты Artefacts Артефакты War Machines Боевые машины Technics Техники Lord's properties error Ошибка в свойсвах лорда The lord must have at least 1 unit Лорд должен иметь хотя бы 1 юнит Ok Ок Cancel Отмена The lord must have an owner PropertiesLordArtefacts Common artefacts list Общий список артефактов Lord's artefacts list Список артефактов лорда PropertiesLordGeneral Select player: Выберете игрока: Default По умолчанию PropertiesLordTechnics Common technics list Общий список техник Lord's technics list Список техник лорда PropertiesLordWarMachines Common war machines list Общий список боевых машин Lord's war machines list Список боевых машин лорда PropertiesPlayers Players Properties Ruled by AI Team : QObject Tile Покрытие Transition Переходное покрытие Decoration Декорация Building Здание Base База Lord Лорд Artefact Артефакт Creature Создание Tool Инструмент Bonus Бонус QuestConditionDateProperties Before date: Предыдущая дата: Day День Week Неделя Month Месяц Before Перед day(s) День(дни) Ok Ок Cancel Отмена Year QuestConditionDialog Condition Условие Ok Ок Cancel Отмена &Properties &Свойства &Add condition &Добавить условие &Delete condition &Удалить условие QuestConditionEditor Condition: Условие: Edit Редактировать QuestConditionLordProperties Primary skill Основной навык value: значение: Secondary skill Вторичный навык Artefact Артефакт Spell Заклинание Ok Ок Cancel Отмена Number of creatures QuestConditionPlayerProperties Nb lords Nb bases Basename = Ok Ок Cancel Отмена QuestEditor Name: Название: Description: Описание: Type: Тип: Ask player confirmation of quest Спрашивать игрока о подтверждении задания Confirmation question: Запрос на подтверждение: Ok Ок Cancel Отмена Start condition: Стартовое условие: Fail condition: Условие поражения: Success condition: Условие победы: ScenarioInfo General Scenario Informations Общая информация о сценарии General Information Общая информация Name: Название: Theme: Тема: Number of players: Число игроков: Map height: Высота карты: Map width: Ширина карты: Description: Описание: Ok Ок Cancel Отмена Map Карта Map for Attal Карта Attal Day: Week: Month: Year: ScenarioInterface &New &Новый CTRL+N CTRL+N &Open &Открыть CTRL+O CTRL+O &Save &Сохранить CTRL+S CTRL+S &Save as &Сохранить как &Quit &Выход CTRL+Q CTRL+Q &Scenario information &Информация о сценарии CTRL+I CTRL+I &Players properties &Свойства игрока CTRL+P CTRL+P &Clear screen &Очистить экран CTRL+C CTRL+C &Fill screen &Запонить экран CTRL+F CTRL+F &Help &Помощь F1 F1 &File &Файл &Scenario &Сценарий &Tools &Инструменты Can't load theme Невозможно загрузить тему Theme Тема has not been loaded successfully не была успешно загружена Quests management Управление заданиями &Mini map &Миникарта CTRL+M CTRL+M &Grid CTRL+G Open scenario Save scenario as &About CTRL+A Screen &Delete &Properties &Свойства (Cell %1x%2) TilePresentation %1 (weight=%2) attal-src-1.0-rc2/i18n/ru/theme_editor_ru.ts0000644000175000017500000013057711016036215016417 0ustar aaaa AskDiversificationList New Новый Del Удалить DialogArtefactAction Action type: Тип действия: Characteristic Характеристика Spell Заклинание Fixed value Фиксированное значение Ratio Пропорция Modification type: Тип изменения: Parameter: Параметр: Value: Величина: Ok ОК Cancel Отмена DialogBuildingAction Action type: Тип действия: Elementary Action: Элементарное действие: Coeff: Коэффициент: Ok ОК Cancel Отмена Arg0: Arg1: DialogCreatureAnimation Moving Fighting Schooting Defending StartMoving EndMoving Dying AttackHigh Selecting Action: Действие: Start Frame: End Frame: Ok ОК Cancel Отмена SchootHigh SchootLow Dead AttackLow DialogEffect Effect type: Тип эффекта: Ok ОК Cancel Отмена Effect value: Сила эффекта: EditCreature Name: Название: Attack: Атака: Defense: Защита: Max Health: Максимальное Здоровье: Max Move: Максимальное количество ходов: Dist Attack: Атака на расстоянии: Min Damages: Минимальное повреждение: Max Damages: Максимальное повреждение: Morale: Мораль: Luck: Удача: Size: Размер: Cost: Цена: Maintenance cost: Цена разработки: Picture: Изображение: X Offset: Y Offset: Num. Frames: X Offset mirror: EditTroop Race : Раса: Name : Название: Number : Количество: EditWidget Add Добавить Edit Редактировать Del Удалить MapDispositionEditor Free Свободный Occupied Занятый Door Дверь Columns: Колонки: Rows: Строки: PreviewBaseDialog Buildings Здания QObject Effect ' Эффект ' ' with param ' с параметром Action: Действие: Charac Персонаж Spell Заклинание modify by изменить с помощью % % AnimationType: first frame last frame SectionArtefact Artefact Артефакт Name: Название: Position: Позиция: Icon: Иконка: Item: Объект: SectionBase Base База Name: Название: Res Cost: Стоимость ресурса: Preview inside Просмотр внутри Base : %1/%2 Res Base: SectionBuilding Building Здание Name: Название: Description: Описание: Type: Тип: Picture: Изображение: Number Frames: Количество фреймов: Animation Freq.: Частота анимации: Res Build: SectionCreature Race Раса Name: Имя: Creature Создание Race : %1/%2 Creature : %1/%2 Creature : %1/?? SectionDecoration Name: Название: Info: Информация: Image: Изображение: Decoration group Decoration item SectionExperience List of required experience to gain for accessing the next level: Список необходимых навыков и опыта для достижения следующего уровня: SectionGeneral Number of unit/lord Количество юнитов/лордов Logo (200x180): Логотип (200x180): Vision management: Управление обзором: Day Name: Week Month Day : %1/%2 Week : %1/%2 Month : %1/%2 SectionGround Tiles Покрытие Name: Название: Coef: Коэффициент: Color: Цвет: Tile Покрытие Width: Height: SectionInsideBuilding Building Здание Name: Название: Description: Описание: Cost: Цена: Maintenance cost: Цена разработки: Params: Параметры: Not yet used Main Building Castle Prod Creature Market Tavern Requirements Building : %1/%2 SectionLord Lord Лорд Photo: Портрет: Icon: Иконка: Name : Имя: Category : Категория: Attack : Атака: Defense : Защита: Power : Мощь: Knowledge : Знание: MaxMoves : Максимально количество ходов: Vision : Дальность взгляда: (Race: (Раса: Charisma : Cost: Цена: SectionLordCategory Lord Categories Категории лордов Name: Имя: Description: Описание: Race: Раса: Evolution of Attack skill (weight): Продвижение навыка атаки (вес): Evolution of Defense skill (weight): Продвижение уровня защиты (вес): Evolution of Power skill (weight): Продвижение уровня силы (вес): Evolution of Knowledge skill (weight): Продвижение уровня знания (вес): SectionMachine War Machine Боевая машина Name: Название: Type: Тип: Param (1): Параметр (1): Params: Параметры: Icon: Иконка: Item: Элемент: SectionResource Resource Ресурс Name: Icon: Иконка: Small icon: Маленькая иконка: Local Preservable Local Not Preservable Global Preservable Global Not Preservable SectionSelector General Общее Artefacts Артефакты Teams Команды Bases Базы Buildings Здания Creatures Создания Decorations Декорации Grounds Земли Lords Лорды Resources Ресурсы War Machines Боевые машины Lord Categories Категории лордов Levels Уровни SectionTeam Team Команда Name: Название: Color Цвет Flag: Флаг: SelectionDate None Ничего SelectionWidget None Ничего ThemeInterface Theme editor for 'Attal - Lords of Doom' Редактор тем для "Attal - Лорды судьбы" Status Bar Статусная панель Open theme Открыть файл темы &File &Файл &Help &Помощь &New theme &Новая тема CTRL+N CTRL+N &Open theme &Открыть тему CTRL+O CTRL+O &Save theme &Сохранить тему CTRL+S CTRL+S &Quit &Выйти CTRL+Q CTRL+Q F1 F1 Can't load theme Невозможно загрузить тему Theme Тема has not been loaded successfully не была успешно загружена &About CTRL+A attal-src-1.0-rc2/libAi/0000755000175000017500000000000011016113671012471 5ustar aaaaattal-src-1.0-rc2/libAi/aiLord.cpp0000644000175000017500000000252410574550754014431 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** aiLord.cpp ** manages an ai lord ** ** Version : $Id: aiLord.cpp,v 1.7 2007/03/10 15:42:36 lusum Exp $ ** ** Author(s) : Sardi Carlo ** ** Date : 27/07/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "aiLord.h" // generic include files // include files for QT // application specific include files #include "libCommon/genericMapCreature.h" #include "libCommon/unit.h" extern QString DATA_PATH; // // ----- GenericLord ----- // AiLord::AiLord():GenericLord() { for(int i = PR_ENEMY;i<=PR_LAST;i++){ _priorities[i]=(i*10); } } AiLord::~AiLord() { } void AiLord::reinit() { } void AiLord::initParams() { _curPrio = PR_LAST * 10; _destinationCell = getCell(); _mincost = getCharac( MOVE ) + 10; } attal-src-1.0-rc2/libAi/aiLord.h0000644000175000017500000000405410574550754014076 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** aiLord.h ** manages ai lord ** ** Version : $Id: aiLord.h,v 1.7 2007/03/10 15:42:36 lusum Exp $ ** ** Author(s) : Sardi Carlo ** ** Date : 27/07/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef AILORD_H #define AILORD_H // generic include files // include files for QT // application specific include files #include "libCommon/genericLord.h" enum AILORD_STATUS { NOFREE, FREE }; /* ------------------------------ * AiLord * ------------------------------ */ class AiLord : public GenericLord { public: /** Constructor */ AiLord(); /** Destructor */ virtual ~AiLord(); void reinit(); void initParams(); void setPriority( LordPriority num, int value ) { _priorities[ num ] = value; } /** Return the unit 'num' */ int getPriority( LordPriority num ) { return _priorities[ num ]; } void setCurPrio( int value ) { _curPrio = value; } int getCurPrio() { return _curPrio; } void setMincost( int value ) { _mincost = value; } int getMincost() { return _mincost; } void setStatus( int value ) { _status = value; } int getStatus() { return _status; } void setDestCell( GenericCell * cell ) { _destinationCell = cell; } GenericCell * getDestCell() { return _destinationCell; } protected: int _priorities[ PR_LAST + 1 ]; private: int _curPrio; int _mincost; int _status; GenericCell * _destinationCell; }; #endif // AILORD_H attal-src-1.0-rc2/libAi/analyst.cpp0000644000175000017500000011764610766751062014704 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** analyst.cpp ** analyse the game and play ** ** Version : $Id: analyst.cpp,v 1.74 2008/03/15 13:42:10 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 06/02/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "analyst.h" // generic include files #include #include #include // include files for QT // application specific include files #include "libCommon/artefactManager.h" #include "libCommon/attalSocket.h" #include "libCommon/attalTemplates.h" #include "libCommon/calendar.h" #include "libCommon/dataTheme.h" #include "libCommon/genericBase.h" #include "libCommon/genericBonus.h" #include "libCommon/genericChest.h" #include "libCommon/genericLord.h" #include "libCommon/genericEvent.h" #include "libCommon/genericMap.h" #include "libCommon/genericMapCreature.h" #include "libCommon/genericPlayer.h" #include "libCommon/pathFinder.h" #include "libCommon/priceMarket.h" #include "libCommon/quest.h" #include "libCommon/questManager.h" extern QString VERSION; // // ----- Analyst ----- // Analyst::Analyst( AttalSocket * socket) : QThread(), GameData() { _nbLord = 0; _nbLordRead = 0; _fight = 0; _socket = socket; _map = new GenericMap(); _player = new GenericPlayer( _map ); reinit(); _numTurn=-1; _numlords=0; _totalTurn = 0 ; srand( time( NULL ) ); _SuffisantPower = 1000; connect( _socket, SIGNAL( readyRead() ), this ,SLOT( slot_readSocket() ) ); } Analyst::~Analyst() { TRACE("~Analyst"); while( ! _players.isEmpty() ) { delete _players.takeFirst(); } delete _player; } void Analyst::run() { } void Analyst::reinitAi() { reinit(); //XXX : cause bug, but to use when socket api will change //delete _player; //delete _map; _fight = 0; //_map = new GenericMap(); //_player = new GenericPlayer( _map ); _player->cleanData(); _map->clearData(); _numTurn=-1; _totalTurn = 0 ; _numlords=0; } void Analyst::reinit() { while( ! _players.isEmpty() ) { delete _players.takeFirst(); } GameData::reinit(); } void Analyst::initLords() { uint nbLords = DataTheme.lords.count(); for( uint i = 0; i < nbLords; i++ ) { AiLord * lord = new AiLord(); lord->setId( i ); _lords.append((GenericLord *) lord ); } } void Analyst::slot_readSocket() { _socket->readData(); ialogV( "Socket received %d | %d | %d", _socket->getCla1(), _socket->getCla2(), _socket->getCla3() ); switch( _socket->getCla1() ) { case SO_MSG: socketMsg(); break; case SO_CONNECT: socketConnect(); break; case SO_MVT: socketMvt(); break; case SO_TECHNIC: socketTechnic(); break; case SO_FIGHT: socketFight(); break; case SO_QR: socketQR(); break; case SO_EXCH: socketExch(); break; case SO_MODIF: socketModif(); break; case SO_TURN: socketTurn(); break; case SO_GAME: socketGame(); break; default: ialogC( "Socket class unknown" ); break; } if( _socket->bytesAvailable() > 0 ) slot_readSocket(); } void Analyst::socketMsg() { ialogV( "SO_MSG" ); int cla2 = _socket->getCla2(); QString msg; uchar len = _socket->readChar(); for( uint i = 0; i < len; i++ ) { msg[i] = _socket->readChar(); } } void Analyst::socketConnect() { ialogV( "SO_CONNECT" ); switch( _socket->getCla2() ) { case C_CONN_OK: ialogN( "Receive: Connect Ok" ); _socket->sendConnectionVersion( VERSION ); _socket->sendConnectionName( "IA" ); break; case C_CONN_ID:{ _player->setNum(_socket->readChar()); ialogN( "Receive: Connect Id = %d", _player->getNum() ); } break; case C_CONN_NAME: socketConnectName(); break; case C_CONN_PLAYER: ialogN( "Receive: Connect Player" ); break; } } void Analyst::socketConnectName() { QString res; uint len = _socket->readChar(); for( uint i = 0; i < len; i++) { res.append( _socket->readChar() ); } _player->setConnectionName(res); ialogN( "Receive: Connect Name %s", res.toLatin1().constData()); } void Analyst::socketMvt() { ialogV( "SO_MVT" ); uchar lord = _socket->readChar(); int row = _socket->readInt(); int col = _socket->readInt(); AiLord * theLord; theLord = (AiLord * ) getLord( lord ); theLord->setCell( _map->at( row, col ) ); /// TODO: manage enter inside buildings if( _map->at( row, col )->getBuilding() != 0 ) { if( _map->at(row, col)->getBuilding()->getOwner() != theLord->getOwner()) { _map->at(row, col)->getBuilding()->setOwner(theLord->getOwner()); } if( theLord->getOwner() == _player ) { /// TODO: enter( _player->getSelectedLord(), _map->at( row, col )->getBuilding() ); } } else if( _map->at( row, col )->getBase() != 0 ) { if( theLord->getOwner() == _player ) { enterBase(theLord, _map->at( row, col )->getBase()); } } } void Analyst::socketTechnic() { ialogV( "SO_TECHNIC" ); } void Analyst::socketFight() { ialogV( "SO_FIGHT" ); switch( _socket->getCla2() ) { case C_FIGHT_INIT: socketFightInit(); break; case C_FIGHT_END: socketFightEnd(); break; default: if( _fight ) { _fight->handleFightSocket(); } else { logEE( "Should not happen" ); } break; } } void Analyst::socketFightInit() { ialogN( "FIGHT INIT" ); if( ! _fight ) { _fight = new FightAnalyst( this ); _fight->setSocket( _socket ); } _fight->handleFightSocket(); } void Analyst::socketFightEnd() { ialogN( "FIGHT END" ); TRACE( "ai: FIGHT END" ); bool isCrea; isCrea = _fight->IsCreature(); _fight->updateUnits(); delete _fight; _fight = 0; if(InTurn()){ ialogV( "FIGHT END creature" ); sendLordTurn( C_ANALYST_SAME_LORD ); } } void Analyst::socketQR() { ialogV( "SO_QR" ); switch( _socket->getCla2() ) { case C_QR_MSG_NEXT: socketQRMsgNext(); break; case C_QR_MSG_END: socketQRMsgEnd(); break; case C_QR_LEVEL: { ialogV( "level" ); //_socket->sendAnswer( 0 ); } break; case C_QR_CHEST: { ialogV( "Chest" ); _socket->sendAnswerEnum( 0 ); sendLordTurn( C_ANALYST_SAME_LORD ); } break; case C_QR_CREATURE_FLEE: _socket->sendAnswerYesNo( true ); sendLordTurn( C_ANALYST_SAME_LORD ); break; case C_QR_CREATURE_MERCENARY: _socket->sendAnswerYesNo( false ); sendLordTurn( C_ANALYST_SAME_LORD ); break; case C_QR_CREATURE_JOIN: _socket->sendAnswerYesNo( true ); sendLordTurn( C_ANALYST_SAME_LORD ); break; case C_QR_ANSWER: logEE( "Should not happen" ); break; } } void Analyst::socketQRMsgNext() { uchar len = _socket->readChar(); for( uint i = 0; i < len; i++ ) { _msg.append( _socket->readChar() ); } ialogV( "Information: %s", _msg.toLatin1().constData() ); } void Analyst::socketQRMsgEnd() { /*uchar type = */_socket->readChar(); socketQRMsgNext(); ialogV( "Information: %s", _msg.toLatin1().constData() ); _msg = ""; } void Analyst::socketExch() { ialogV( "SO_EXCH" ); switch( _socket->getCla2() ) { case C_EXCH_START: exchangeStart(); break; case C_EXCH_UNIT: exchangeUnits(); break; case C_EXCH_ARTEFACT: exchangeArtefact(); break; case C_EXCH_BASEUNITCL: exchangeBaseUnits(); break; default: break; } } void Analyst::exchangeStart() { /// XXX: not finished... //uchar idLord1 = _socket->readChar(); //uchar idLord2 = _socket->readChar(); //AiLord * lord1 = _lords.at( idLord1 ); //AiLord * lord2 = _lords.at( idLord2 ); } void Analyst::exchangeUnits() { /*uchar idLord1 = */_socket->readChar(); /*uchar idUnit1 = */_socket->readChar(); /*uchar idLord2 = */_socket->readChar(); /*uchar idUnit2 = */_socket->readChar(); logEE(" should not happens"); } void Analyst::exchangeArtefact() { uchar idLord1 = _socket->readChar(); int item = _socket->readInt(); uchar idLord2 = _socket->readChar(); exchangeArtefactLord( idLord1, idLord2, item); } void Analyst::exchangeBaseUnits() { /*int row = */_socket->readInt(); /*int col = */_socket->readInt(); /*uchar idUnit1 = */_socket->readChar(); /*uchar idLord *= */_socket->readChar(); /*uchar idUnit2 = */ _socket->readChar(); logEE(" should not happens"); } void Analyst::socketModif() { ialogV( "SO_MODIF" ); switch( _socket->getCla2() ) { case C_MOD_MAP: socketModifMap(); break; case C_MOD_CELL: socketModifCell(); break; case C_MOD_PLAYER: socketModifPlayer(); break; case C_MOD_LORD: socketModifLord(); break; case C_MOD_BASE: socketModifBase(); break; case C_MOD_BUILD: socketModifBuilding(); break; case C_MOD_ARTEFACT: socketModifArtefact(); break; case C_MOD_CREATURE: socketModifCreature(); break; case C_MOD_EVENT: socketModifEvent(); break; } } void Analyst::socketModifMap() { int h = _socket->readInt(); int w = _socket->readInt(); _map->newUnknownMap( h, w ); } void Analyst::socketModifCell() { int row = _socket->readInt(); int col = _socket->readInt(); int type = _socket->readInt(); uchar diversification = _socket->readChar(); int a4 = _socket->readInt(); int a5 = _socket->readInt(); int a6 = _socket->readInt(); int a7 = _socket->readInt(); _map->changeCell( row, col, type, a4, a5, a6, a7, diversification ); } void Analyst::socketModifLord() { switch( _socket->getCla3() ) { case C_LORD_VISIT: socketModifLordVisit(); break; case C_LORD_NEW: socketModifLordNew(); break; case C_LORD_CHARAC: socketModifLordCharac(); break; case C_LORD_UNIT: socketModifLordUnit(); break; case C_LORD_REMOVE: socketModifLordRemove(); break; } } void Analyst::socketModifLordVisit() { uchar num = _socket->readChar(); int row = _socket->readInt(); int col = _socket->readInt(); uchar id = _socket->readChar(); uchar present = _socket->readChar(); AiLord * lord = (AiLord *) _lords.at( id ); if( present == 1 ) { lord->setOwner( getPlayer( num ) ); lord->setCell( _map->at( row, col ) ); } else { if( lord->getCell() ) { lord->getCell()->setLord(NULL); } } } void Analyst::socketModifLordNew() { int row = _socket->readInt(); int col = _socket->readInt(); uchar id = _socket->readChar(); AiLord * lord = (AiLord *) _lords.at( id ); lord->setCell( _map->at( row, col ) ); lord->setOwner( _player ); _player->addLord( lord ); } void Analyst::socketModifLordUnit() { uchar id = _socket->readChar(); uchar pos = _socket->readChar(); uchar race = _socket->readChar(); uchar level = _socket->readChar(); int nb = _socket->readInt(); uchar move = _socket->readChar(); int health = _socket->readInt(); updateLordUnit( id ,pos , race, level, nb, move, health ); } void Analyst::socketModifLordRemove() { int idLord = _socket->readChar(); AiLord * lord = (AiLord *) _lords.at( idLord ); //GenericPlayer * player = lord->getOwner(); lord->removeFromGame(); } void Analyst::socketModifLordCharac() { char lord = _socket->readChar(); char charac = _socket->readChar(); int nb = _socket->readInt(); if(_lords.at( lord )) { _lords.at( lord )->setBaseCharac( (LordCharac) charac, nb ); } } void Analyst::socketModifLordGarrison() { /*uchar lord =*/ _socket->readChar(); /*uchar state =*/ _socket->readChar(); } void Analyst::socketModifLordMachine() { uchar lord = _socket->readChar(); uchar id = _socket->readChar(); if(_lords.at( lord )) { _lords.at( lord )->addMachine( id ); } } void Analyst::socketModifPlayer() { switch( _socket->getCla3() ) { case C_PLAY_RESS: socketModifRess( _player , _socket); break; case C_PLAY_PRICE: { uchar ress = _socket->readChar(); uint price = _socket->readInt(); _player->getPriceMarket()->setResourcePrice( ress, price); } break; /* case C_PLAY_POPUL: { uint population = _socket->readInt(); _player->setPopulation( population ); } break; */ } } void Analyst::socketModifBase() { switch( _socket->getCla3() ) { case C_BASE_NEW: socketModifBaseNew(); break; case C_BASE_OWNER: socketModifBaseOwner(); break; case C_BASE_NAME: socketModifBaseName(); break; case C_BASE_BUILDING: socketModifBaseBuilding(); break; case C_BASE_UNIT: socketModifBaseUnit(); break; case C_BASE_POPUL: socketModifBasePopulation(); break; case C_BASE_RESS: socketModifBaseResources(); break; case C_BASE_PRODUCTION: socketModifBaseProduction(); break; } } void Analyst::socketModifBaseNew() { uchar race = _socket->readChar(); int row = _socket->readInt(); int col = _socket->readInt(); int population = _socket->readInt(); uchar id = _socket->readChar(); int nb = _socket->readChar(); QList forbidlist; for( int i = 0; i < nb; i++ ) { forbidlist.append( _socket->readChar() ); } getNewBase( race, row, col, population, id, nb, forbidlist); } void Analyst::socketModifBaseOwner() { int row = _socket->readInt(); int col = _socket->readInt(); uchar playerNum = _socket->readChar(); GenericBase * base = (GenericBase*)_map->at( row, col )->getBase(); if( playerNum == _player->getNum() ) { _player->addBase( base ); base->setOwner( _player ); } else { if( base->getOwner() == _player ) { _player->removeBase( (GenericBase*)base ); } base->setOwner( getPlayer( playerNum ) ); } } void Analyst::socketModifBaseName() { int row = _socket->readInt(); int col = _socket->readInt(); uint length = _socket->readInt(); QString name; for( uint i = 0; i < length; i++ ) { name[i] = _socket->readChar(); } GenericBase * base = _map->at( row, col )->getBase(); base->setName( name ); } void Analyst::socketModifBasePopulation() { int row = _socket->readInt(); int col = _socket->readInt(); uint popul = _socket->readInt(); GenericBase * base = 0; if(_map->at( row, col )) { base = (GenericBase*) _map->at( row, col )->getBase(); } if(base) base->setPopulation(popul); } void Analyst::socketModifBaseResources() { int row = _socket->readInt(); int col = _socket->readInt(); GenericBase * base = _map->at( row, col )->getBase(); TRACE("Analyst::socketModifBaseResources row %d, col %d", row,col ); socketModifRess( base , _socket); } void Analyst::socketModifBaseProduction() { int row = _socket->readInt(); int col = _socket->readInt(); uchar race = _socket->readChar(); uchar level = _socket->readChar(); int number = _socket->readInt(); if( _map->at( row, col )->getBase() ) { GenericBase * base = (GenericBase *)_map->at( row, col )->getBase(); Creature * creature = DataTheme.creatures.at( race, level ); base->setCreatureProduction( creature, number ); } } void Analyst::socketModifBaseBuilding() { int row = _socket->readInt(); int col = _socket->readInt(); uchar level = _socket->readChar(); bool create = (bool)_socket->readChar(); updateBaseBuilding( row, col, level, create ); } void Analyst::socketModifBaseUnit() { int row = _socket->readInt(); int col = _socket->readInt(); uchar pos = _socket->readChar(); uchar race = _socket->readChar(); uchar level = _socket->readChar(); int number = _socket->readInt(); if( _map->at( row, col )->getBase() ) { GenericBase * base = (GenericBase *)_map->at( row, col )->getBase(); base->addUnit( pos, race, level, number ); } } void Analyst::socketModifBuilding() { switch( _socket->getCla3() ) { case C_BUILD_NEW: socketModifBuildingNew(); break; case C_BUILD_OWNER: socketModifBuildingOwner(); break; case C_BUILD_RESS: socketModifBuildingResources(); break; default: logDD("Should not happens"); break; } } void Analyst::socketModifBuildingNew() { uchar type = _socket->readChar(); int id = _socket->readInt(); int row = _socket->readInt(); int col = _socket->readInt(); getNewBuilding( type, id , row, col); } void Analyst::socketModifBuildingOwner() { int row = _socket->readInt(); int col = _socket->readInt(); int playNum = _socket->readInt(); GenericBuilding * build = _map->at( row, col )->getBuilding(); if( playNum == _player->getNum() ) { if( build ) { _player->addBuilding( build ); build->setOwner( _player ); } } else { if( build ) { if(build->getOwner() == _player){ _player->removeBuilding( build ); } if( playNum == GenericPlayer::NO_PLAYER ) { build->setOwner( 0 ); } else { build->setOwner( getPlayer(playNum) ); } } } } void Analyst::socketModifBuildingResources() { int row = _socket->readInt(); int col = _socket->readInt(); TRACE("Analyst::socketModifBuildingOwner row %d, col %d", row,col); GenericBuilding * build = _map->at( row, col )->getBuilding(); socketModifRess( build , _socket); } void Analyst::socketModifArtefact() { switch( _socket->getCla3() ) { case C_ART_DELLORD: { uint type = _socket->readInt(); char lord = _socket->readChar(); _lords.at( lord )->getArtefactManager()->removeArtefactByType( type ); } break; case C_ART_ADDLORD: { uint type = _socket->readInt(); char lord = _socket->readChar(); if( ! _lords.at( lord )->getArtefactManager()->hasArtefactType( type ) ) { _lords.at( lord )->getArtefactManager()->addArtefact( type ); } } break; } } void Analyst::setPlayerNumber( uint nb ) { _players.clear(); for( uint i = 0; i < nb; i++ ) { _players.append( new GenericPlayer( 0 ) ); } } void Analyst::socketModifEvent() { switch( _socket->getCla3() ) { case C_EVENT_NEW: socketModifEventNew(); break; case C_EVENT_DEL: socketModifEventDel(); break; } } void Analyst::socketModifEventNew() { int row = _socket->readInt(); int col = _socket->readInt(); GenericEvent::EventType type = (GenericEvent::EventType) _socket->readChar(); GenericEvent * event; uchar nbParam; uchar typeArtefact; uchar typeBonus; int id; GenericArtefact * artefact; GenericBonus * bonus; GenericChest * chest; switch( type ) { case GenericEvent::EventArtefact: id = _socket->readInt(); typeArtefact = _socket->readChar(); event = getNewArtefact(); artefact = event->getArtefact(); artefact->setId( id ); artefact->setType( typeArtefact ); break; case GenericEvent::EventBonus: typeBonus = _socket->readChar(); nbParam = _socket->readChar(); event = getNewBonus(); bonus = event->getBonus(); bonus->setType( (GenericBonus::BonusType) typeBonus ); for( uint i = 0; i < nbParam; i++ ) { bonus->addParam( _socket->readInt() ); } bonus->setupBonus(); break; case GenericEvent::EventChest: nbParam = _socket->readChar(); event = getNewChest(); chest = event->getChest(); for( uint i = 0; i < nbParam; i++ ) { chest->addParam( _socket->readInt() ); } break; default: // this makes sure that setCell isn't called without event being initialized, however possibly the old behavior was desired? case GenericEvent::EventNone: return; break; } event->setCell( _map->at( row, col ) ); _map->at( row, col )->setEvent( (GenericEvent *) event ); } void Analyst::socketModifEventDel() { int row = _socket->readInt(); int col = _socket->readInt(); removeEvent( row, col ); } void Analyst::socketModifCreature() { switch( _socket->getCla3() ) { case C_CRE_NEW: socketModifCreatureNew(); break; case C_CRE_UPDATE: socketModifCreatureUpdate(); break; case C_CRE_RESS: socketModifCreatureRess(); break; case C_CRE_DEL: socketModifCreatureDel(); break; } } void Analyst::socketModifCreatureNew() { int row = _socket->readInt(); int col = _socket->readInt(); uchar race = _socket->readChar(); uchar level = _socket->readChar(); int nb = _socket->readInt(); bool looking = (bool) _socket->readChar(); getNewMapCreature( row, col, race, level, nb, looking); } void Analyst::socketModifCreatureUpdate() { int row = _socket->readInt(); int col = _socket->readInt(); int nb = _socket->readInt(); GenericMapCreature * creature = _map->at( row, col )->getCreature(); if( creature ) { creature->setCategoryNumber( nb ); } } void Analyst::socketModifCreatureDel() { int row = _socket->readInt(); int col = _socket->readInt(); removeMapCreature( row, col ); } void Analyst::socketModifCreatureRess() { int row = _socket->readInt(); int col = _socket->readInt(); GenericMapCreature * creature = _map->at( row, col )->getCreature(); socketModifRess( creature , _socket); } void Analyst::socketGame() { ialogN( "SO_GAME" ); switch( _socket->getCla2() ) { case C_GAME_END : socketGameEnd(); break; case C_GAME_LOST : socketGameLost(); break; case C_GAME_WIN : socketGameWin(); break; case C_GAME_BEGIN : socketGameBegin(); break; case C_GAME_INFO : socketGameInfo(); break; case C_GAME_TAVERN : socketGameTavern(); break; case C_GAME_CALENDAR: socketGameCalendar(); break; default : { ialogN( "Should not happens" ); ialogN("sock %d ",_socket->getCla2()); } break; } } void Analyst::socketGameEnd() { reinitAi(); ialogN( "SO_GAME_END" ); } void Analyst::socketGameLost() { int nb = _socket->readChar(); if(nb == _player->getNum()) { ialogN("I'm the loser, i'm num %d",nb); } else { ialogN("player %d has lost",nb); } ialogN( "SO_GAME_LOST" ); } void Analyst::socketGameWin() { int nb = _socket->readChar(); if(nb == _player->getNum()) { ialogN("I'm the winner, i'm num %d",nb); } else { ialogN("player %d has win",nb); } ialogN( "SO_GAME_WIN" ); } void Analyst::socketGameBegin() { ialogN( "SO_GAME_ BEGIN" ); setPlayerNumber( _socket->readChar() ); } void Analyst::socketGameTavern() { ialogV( "SO_GAME_TAVERN " ); switch( _socket->getCla3() ) { case C_TAVERN_INFO: socketGameTavernInfo(); break; case C_TAVERN_LORD: socketGameTavernLord(); break; } } void Analyst::socketGameTavernInfo() { _nbLord = _socket->readChar(); _nbLordRead = 0; _lordtav.clear(); if( _nbLordRead < _nbLord && _basetav) { _socket->askTavernLord( _basetav, _nbLordRead ); } } void Analyst::socketGameTavernLord() { uint idLord = _socket->readInt(); AiLord * lord = new AiLord(); lord->setId( idLord ); _lordtav.append( lord ); if(_player->numLord() < 2 ) { if(_player->canBuy(DataTheme.lords.at(idLord)) && !_basetav->isVisitorLord()) { int col = _basetav->getCell()->getCol(); int row = _basetav->getCell()->getRow(); _socket->sendLordBuy( lord , row, col); } } } void Analyst::socketGameInfo() { ialogN( "SO_GAME_INFO " ); switch( _socket->getCla3() ) { case C_INFOPLAYER_TEAM: { uchar player = _socket->readChar(); uchar teamId = _socket->readChar(); if( getPlayer( player ) ) { getPlayer( player )->setTeam( teamId ); } if( player == _player->getNum() ) { _player->setTeam( teamId ); } } break; case C_INFOPLAYER_NAME: break; } } void Analyst::socketGameCalendar() { _calendar->setDateByType( 0 , _socket->readInt()); _calendar->setDateByType( 1 , _socket->readInt()); _calendar->setDateByType( 2 , _socket->readInt()); _calendar->setDateByType( 3 , _socket->readInt()); _calendar->setDateByType( 4 , _socket->readInt()); } void Analyst::socketTurn() { ialogV( "SO_TURN" ); switch( _socket->getCla2() ) { //case C_TURN_BEG: // socketTurnBegin(); // break; case C_TURN_PLAY: socketTurnPlay(); break; case C_TURN_END: ialogC( "Should not happen (SO_TURN/C_TURN_END)" ); break; case C_TURN_LORD: ialogC( "Should not happen (SO_TURN/C_TURN_LORD)" ); break; case C_TURN_PLORD: socketTurnLord(); break; } } void Analyst::socketTurnPlay() { uint num = _socket->readChar(); if( num == (uint) _player->getNum() ) { socketTurnBegin(); } else { ialogV( "Player: %d,get num %d", num,_player->getNum() ); } } void Analyst::socketTurnBegin() { _totalTurn++ ; _currentLord = 0; ialogN( "Start turn num. %d" , _totalTurn ); if( _calendar->getDay() == 1 ) { //_player->newWeek(); } _player->newTurn(); _numTurn = 8; if( _player->numBase() > 0 ){ for( int i = 0; i < (int)_player->numBase(); i++ ) { GenericBase * base = _player->getBase( i ); manageBase( base ); } } sendLordTurn( C_ANALYST_SAME_LORD ); } void Analyst::sendLordTurn( int opt ) { if( opt == C_ANALYST_NEXT_LORD ) { _numTurn = 8; } _socket->sendLordTurn( opt ); } void Analyst::socketTurnLord() { int nlord = _socket->readInt(); ialogV("lord number %d",nlord); //logDD("lord number %d",nlord); //int lordCount = _lords.count(); //logDD("Start turn currLord %d, numTurn %d", _currentLord, _numTurn); if(InTurn()){ if( nlord == C_ANALYST_NEXT_LORD ) { _currentLord++; } while( _lords.at( _currentLord )->getCell() == 0 ) { _currentLord++; if( _currentLord >= _lords.count() || _numTurn==0 ){ break; } } if( _currentLord >= _lords.count() ){ ialogN("End turn currLord %d, numTurn %d", _currentLord, _numTurn); //logDD("End turn currLord %d, numTurn %d", _currentLord, _numTurn); _socket->sendTurnEnd(); _numTurn=-1; } else if( _lords.at( _currentLord )->getCell() == 0 || _numTurn == 0 ) { sendLordTurn( C_ANALYST_NEXT_LORD ); } else { playLordTurn( _currentLord ) ; } } } void Analyst::playLordTurn( int nlord ) { analyzeLord( (AiLord *) _lords.at( nlord ) ); } void Analyst::analyzeLord( AiLord * lord ) { ialogV("Analyze lord id %d", lord->getId()); //logDD("Analyze lord id %d", lord->getId()); int movePoints = lord->getCharac( MOVE ); GenericCell * cell = lord->getCell(); GenericCell * destinationCell; int lordTurn = C_ANALYST_SAME_LORD; lord->initParams(); lord->setStatus( _status ); lord->setCurPrio(lord->getPriority(PR_LAST)); lord->setDestCell( cell ); /* if a lord is already in a base */ if( cell->getBase() != 0 ) { if( lord->getOwner() == _player ) { enterBase(lord, cell->getBase()); } } /* if lord is powerful, prefer to fight and explore instead cumulate units */ if(lord->computeForceIndicator(true) > _SuffisantPower){ lord->setPriority(PR_BASEOWNER,(PR_EXPLORE*10)+5); lord->setPriority(PR_CREAT,(PR_BASE*10)-1); //ialogV("prio %d",lord->getPower()); //ialogV("creat %d",lord->getPriority(PR_CREAT)); } else { lord->setPriority(PR_BASEOWNER,(PR_BASEOWNER*10)); lord->setPriority(PR_CREAT,(PR_CREAT*10)); } PathFinder * path = _map->getPath(); path->reinit( _map ); path->computePath( cell ); if(!path->isNearPath( cell ) ){ ialogN("no path"); movePoints = 0; } if( movePoints <= 0 ) { ialogV("Turn pass"); lordTurn = C_ANALYST_NEXT_LORD; } else { analyzeLordMap( lord ); _status = lord->getStatus(); destinationCell = lord->getDestCell(); if(destinationCell == cell){ ialogN("Destination cell = cell"); lordTurn = C_ANALYST_NEXT_LORD; } ialogV("status %d", _status ); ialogV("startRow %d, startCol %d",cell->getRow(),cell->getCol()); ialogV("destRow %d, destCol %d",destinationCell->getRow(),destinationCell->getCol()); QList list; int movePt = lord->getCharac( MOVE ); QStack * cellPathStack = NULL; if( _status == FREE ) { // if no possibility to move, destination cell = starting cell and sanity check if(path->isPath(destinationCell)==false) { ialogV(" no path "); destinationCell = cell; goto finish; } if( path->isPath(destinationCell)==true && destinationCell != cell){ cellPathStack = path->giveCells( destinationCell ); } } else if( _status == NOFREE ) { if( path->isNearPath(destinationCell)==true && destinationCell != cell && destinationCell->isStoppable() ){ cellPathStack = path->giveNearCells( destinationCell ); cellPathStack->prepend( destinationCell ); } } if( cellPathStack ) { GenericCell * tmp = cell; while( ! cellPathStack->isEmpty() ) { GenericCell * movCell = cellPathStack->pop(); int cost = path->computeCostMvt( tmp,movCell ); if( ( cost != -1 ) && ( cost <= movePt ) && movCell!=cell /* workaround for a strange path function */ ) { list.append( movCell ); tmp = movCell; movePt = movePt - cost; } } _socket->sendMvts( lord->getId(), list ); delete cellPathStack; cellPathStack = 0; } } finish: _numTurn--; ialogV("Turn finish %d",lordTurn); sendLordTurn( lordTurn ); } void Analyst::analyzeLordMap( AiLord * lord ) { int i; //GenericCell * cell = NULL; uint opPower = 0; //int cost; lord->setStatus( FREE ); /* the priority with lower value is the more important*/ for( i = 0; i < _lords.count(); i++ ) { AiLord * tmplord = 0; tmplord = (AiLord *) _lords.at(i); if( tmplord && ( lord->getPriority(PR_ENEMY) <= lord->getCurPrio() ) ) { if( tmplord->getCell() ) { if(!tmplord->getOwner() ) { ialogN( "Try Enemy (no owner)"); manageMeetingsLord( lord, tmplord , PR_ENEMY); } else if( tmplord->getOwner() != _player && tmplord->getOwner()->getTeamId() != _player->getTeamId() ) { ialogN( "Try Enemy Lord"); manageMeetingsLord(lord, tmplord, PR_ENEMY); } } } } //for for( i = 0; i < _bases.count(); i++ ) { GenericBase * base = 0; base = _bases.at(i); if( base && (lord->getPriority(PR_BASE) <= lord->getCurPrio() ) ) { if(!base->getOwner()) { ialogN( "Try Base (no owner)"); manageMeetingsThings(lord,base->getCell() ,PR_BASE); } else if( base->getOwner() != _player && base->getOwner()->getTeamId() != _player->getTeamId()) { ialogN( "Try Base Enemy"); manageMeetingsThings(lord, base->getCell(),PR_BASE); } } if( base && (lord->getPriority(PR_BASEOWNER) <= lord->getCurPrio() ) ) { if( base->getOwner() == _player && base->isUnitBought() ) { ialogN( "Try Base Owned"); manageMeetingsThings(lord,base->getCell() ,PR_BASEOWNER); } } } //for for( i = 0; i < _buildings.count(); i++ ) { GenericBuilding * building = 0; building = _buildings.at(i); if( building && (lord->getPriority(PR_BUILD) <= lord->getCurPrio()) ) { if(!building->getOwner()) { ialogN( "Try Build (no owner)"); manageMeetingsThings(lord,building->getCell() ,PR_BUILD); } else if( building->getOwner() != _player && building->getOwner()->getTeamId() != _player->getTeamId()) { ialogN( "Try Build Enemy"); manageMeetingsThings(lord, building->getCell() ,PR_BUILD ); } else { ialogV( "My Build,ignore"); } } } //for for( i = 0; i < _events.count(); i++ ) { GenericEvent * event = 0; event = _events.at(i); if( event){ if( event->getType()==GenericEvent::EventArtefact && ( lord->getPriority(PR_ART) < lord->getCurPrio() ) ) { ialogN( "Try Event-Artefact"); manageMeetingsThings(lord, event->getCell() , PR_ART ); } if( event->getType()==GenericEvent::EventBonus && ( lord->getPriority(PR_BONUS) < lord->getCurPrio() ) ) { ialogN( "Try Event-Bonus"); manageMeetingsThings(lord, event->getCell() , PR_BONUS ); } if( event->getType()==GenericEvent::EventChest && ( lord->getPriority(PR_CHEST)< lord->getCurPrio() ) ) { ialogN( "Try Event-chest"); manageMeetingsThings(lord, event->getCell() , PR_CHEST ); } ialogV( "row %d, col %d",event->getCell()->getRow(),event->getCell()->getCol()); } } //for for( i = 0; i < _creatures.count(); i++ ) { GenericMapCreature * creature = 0; creature = _creatures.at(i); if( creature ){ if (lord->getPriority(PR_CREAT) < lord->getCurPrio()) { ialogN( "Try Creat"); ialogV( "row %d, col %d",creature->getCell()->getRow(),creature->getCell()->getCol()); opPower = creature->computeForceIndicator( false ); /* adjust enemy power, be more careful with creatures */ opPower = (opPower * 150) / 100; manageMeetings(lord,creature->getCell() ,lord->getPriority(PR_CREAT),opPower,false); } } } //for //ai explore map if ( lord->getPriority(PR_EXPLORE) <= lord->getCurPrio()) { ialogN( "Try Explore"); GenericCell * dest = 0; dest = findNotExploredCell(lord->getCell()); if(dest){ manageMeetings(lord,dest ,lord->getPriority(PR_EXPLORE),0,false); } else { dest = randomPath( lord->getCell() ); manageMeetings(lord,dest ,lord->getPriority(PR_EXPLORE),0,false); } } } void Analyst::manageBase(GenericBase * base) { _basetav = 0; // scan all buildings looking for creatures uint count = base->getBuildingCount(); uint nbuil; ialogN("Try buy"); for( nbuil = 0; nbuil < count ; nbuil++ ) { GenericInsideBuilding * building=base->getBuilding( nbuil ); InsideAction * action = DataTheme.bases.at( base->getRace() )->getBuildingModel( building->getLevel() )->getAction(); if(action){ switch( action->getType() ) { case INSIDE_CREA: manageBaseCreature(base , action); break; case INSIDE_MARKET: manageBaseMarket(); break; case INSIDE_TAVERN: { _basetav = base; _socket->askTavernInfo( base ); } break; default: break; } } } int bought = 0; GenericBaseModel * baseModel = DataTheme.bases.at( base->getRace() ); int modelCount = baseModel->getBuildingCount(); InsideBuildingModel * model; for( int i = 0; i < modelCount; i++ ) { GenericInsideBuilding * building= base->getBuildingByType( i ); if( _player && _socket && !building && bought == 0) { model = DataTheme.bases.at( base->getRace() )->getBuildingModel( i ) ; /* ai don't buy buildings that not implement actions */ if (model->getAction()) { if(model->getAction()->getType() != INSIDE_NONE) { if( _player->canBuy( model ) && base->canBuildBuilding( model ) ) { _socket->requestBuilding( base, i, true ); ialogN("Request Building model %d",i); //logDD("Request Building model %d",i); bought = 1; } else { //logDD("Can't buy, Not enough resources to buy this building" ); } } } } } if( base->getCell()->getLord() ) { enterBase( (AiLord *)base->getCell()->getLord(), base ); } } void Analyst::manageBaseMarket() { /* ugly algho, hardcoded values, but fast and it work ... */ int ress = -1; uint qty = 0; for( int i = 0 ; i < DataTheme.resources.count(); i++ ) { if(_player->getResourceList()->getValue( i )> 1000 && _player->getResourceList()->getValue( i )> qty){ ress = i; qty =_player->getResourceList()->getValue( i ) ; } for( int i = 0 ; i < DataTheme.resources.count(); i++ ) { if( ress != -1 ) { if( _player->getResourceList()->getValue( i ) < 20 ) { //logDD("exchange ress %d , i %d",ress,i); _socket->sendBaseMarket(ress,i,20); } } } } } void Analyst::manageBaseCreature(GenericBase * base, InsideAction *action) { int race = action->getParam( 0 ); int level = action->getParam( 1 ); Creature * creature = DataTheme.creatures.at( race, level); int prodBase = base->getCreatureProduction( creature ); int prodPlayer = _player->computeBuyCreatureMax( creature ); //logDD(" creature %p, prodBase%d, prodPlayer %d", creature, prodBase, prodPlayer ); int num = std::min( prodBase, prodPlayer ); if(_player->canBuy( creature, num ) && num > 0){ ialogN("BUY num creat. %d, race %d ,level %d",num,race, level); //logDD("BUY num %d, race %d ,level %d",num,race, level); _player->buy(creature,num); _socket->sendBaseUnitBuy( base, creature, num); //base->buyCreature( creature, num ); base->isUnitBought(true); } } void Analyst::enterBase(AiLord * lord,GenericBase * base ) { int i; int j; ialogN("Enter base"); base->enter( lord ); for( i = 0; i < MAX_UNIT; i++ ) { for( j = 0; j < MAX_UNIT; j++ ) { if( lord->getUnit( i ) && lord->getUnit( j ) && i != j ) { if( lord->getUnit(i)->getCreature() == lord->getUnit(j)->getCreature() ) { _socket->sendExchangeUnit( lord, i, lord, j ); } } } } if( lord->countUnits() < MAX_UNIT ) { for( i = 0; i < MAX_UNIT; i++ ) { for( j = 0; j < MAX_UNIT; j++ ) { if( lord->getUnit( j ) && base->getGarrisonUnit( i ) ) { if( lord->getUnit( j )->getCreature() == base->getGarrisonUnit( i )->getCreature() ) { _socket->sendExchangeBaseUnit( base, i, lord, j ); } } } } for( i = 0; i < MAX_UNIT; i++ ) { for( j = 0; j < MAX_UNIT; j++ ) { if( !lord->getUnit( j ) && base->getGarrisonUnit( i ) ) { _socket->sendExchangeBaseUnit( base, i, lord, j ); //ialogN("Exch ,pos i %d ,pos j %d",i,j); } } } } base->isUnitBought(false); base->out( lord ); } void Analyst::manageMeetingsLord( AiLord * lord, AiLord * opponent, LordPriority prioType ) { ialogV( "Enemy lord row %d, col %d",opponent->getCell()->getRow(), opponent->getCell()->getCol()); GenericCell * cell = opponent->getCell(); bool flee = true; uint opPower = opponent->computeForceIndicator(false); uint myPower = lord->computeForceIndicator(true); if( myPower < opPower ) { cell = fleePath(lord); } manageMeetings(lord, cell ,lord->getPriority(prioType),opPower,flee); } void Analyst::manageMeetingsThings( AiLord * lord, GenericCell * cell, LordPriority prioType ) { ialogV( "Things row %d, col %d",cell->getRow(), cell->getCol()); manageMeetings(lord, cell ,lord->getPriority(prioType),0,false); } void Analyst::manageMeetings( AiLord * lord, GenericCell * cell, int prior, uint opPower, bool isFlee ) { int cost; uint myPower = lord->computeForceIndicator(true); int status; int movePoints = lord->getCharac( MOVE ); PathFinder * path = _map->getPath(); if(opPower>0) { ialogN("opPower %d, myPower %d",opPower,myPower); /* now ai try to match more powerful enemy, not so right, cause is difficult for ai to attack */ tuneAiPower( opPower ); } /* if creature is more powerful than us, ignore it */ if( myPower < opPower && !isFlee) return; /* if no path to target or cell is not stoppable, ignore it */ if(!path->isNearPath( cell ) || !cell->isStoppable() ) return; if( cell->isFree() && cell->getType() != 0 ) { cost = path->getDist( cell ); status = FREE; } else { GenericCell * nearcell; nearcell=path->getNearCell( cell ); /* workaround for getNearCell bug? */ if( nearcell->getRow() > 0 && nearcell->getCol() > 0) { cost = path->getDist( nearcell ); } else { return; } status = NOFREE; } // if they are more targets with same priority, use that with minimal cost // or reset mincost every time we change priority if( lord->getCurPrio() != prior ) { lord->setMincost(movePoints+100); } /* is the target is reachable or not, go */ if( ( cost < lord->getMincost() ) && ( cost > 0 ) && ( myPower > opPower ) ) { lord->setMincost(cost); lord->setCurPrio(prior); lord->setDestCell(cell); //ialogN("Meeting"); lord->setStatus(status); return; /* flee if enemy is more powerful and near */ } else if( cost < movePoints && myPower < opPower && isFlee) { lord->setCurPrio(prior); lord->setDestCell(cell); lord->setStatus(status); return; } return; } GenericCell * Analyst::fleePath( AiLord * lord ) { GenericCell * cell = lord->getCell(); GenericCell * ret = cell; GenericCell * tmp = NULL; QList list = _map->giveRadiusCell( cell , 8 ); PathFinder * path = _map->getPath(); int maxdist = 0; for (int i = 0; i < list.size(); ++i) { tmp = list.at( i ); if( list.at( i ) == cell ) { continue; } int dist = GenericMap::computeDist( lord->getDestCell(), tmp ); if( path->isPath( tmp ) && dist > maxdist ) { maxdist = dist; ret = tmp; } } return ret; } GenericCell * Analyst::randomPath( GenericCell * cell ) { int currRow= cell->getRow(); int currCol= cell->getCol(); GenericCell *rcell; PathFinder * path = _map->getPath(); int destRow,destCol; int i,j; int count = 0; while( count <= 20 ) { i=(int) (6*(rand()/(RAND_MAX+1.0))); j=(int) (6*(rand()/(RAND_MAX+1.0))); destRow = currRow + i - 3; destCol = currCol + i - 3; if( _map->inMap(destRow,destCol)) { if( path->isPath(_map->at(destRow, destCol)) ) { rcell= _map->at(destRow,destCol); if( rcell != cell ) { return rcell; } } } count++; } return cell; } GenericCell * Analyst::findNotExploredCell(GenericCell * cell) { GenericCell * dest = 0; QList list = _map->giveRadiusCell( cell , 8 ); PathFinder * path = _map->getPath(); for (int i = 0; i < list.size(); ++i) { dest = list.at(i); if( dest->getType() == 0 ) { if( path->isNearPath(dest)==true && dest != cell && dest->isStoppable() ){ return dest; } } } return NULL; } void Analyst::tuneAiPower( uint opPower ) { /* tune ai based on enemy stength */ if(opPower > _SuffisantPower ) { _SuffisantPower = opPower ; ialogV("suffisantPower - opPower %d",opPower); } else { _SuffisantPower = 1000; } } attal-src-1.0-rc2/libAi/analyst.h0000644000175000017500000001422410761264502014326 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** analyst.h ** analyse the game and play ** ** Version : $Id: analyst.h,v 1.26 2008/02/27 13:44:34 lusum Exp $ ** ** Author(s) : Pascal Audoux - Carlo ** ** Date : 06/02/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ANALYST_H #define ANALYST_H #define DIM 100 // generic include files // include files for QT //#include #include #include #include #include // application specific include files #include "libCommon/artefact.h" #include "libCommon/attalSocket.h" #include "libCommon/gameData.h" #include "libCommon/genericBuilding.h" #include "libCommon/log.h" #include "libServer/fightAnalyst.h" #include "libAi/aiLord.h" extern Log aifLog; class AttalSocket; class FightAnalyst; class GenericPlayer; class GenericLord; class GenericMap; class Calendar; class PathFinder; /* ------------------------------ * Analyst * ------------------------------ */ /** comment for the class */ class Analyst : public QThread, public GameData { Q_OBJECT public: /** Constructor */ Analyst( AttalSocket * socket ); /** Destructor */ ~Analyst(); void run(); void reinitAi(); void reinit(); void initLords(); AttalSocket * getSocket () { return _socket; } /** Handle SO_MSG socket data */ void socketMsg(); /** Handle SO_CONNECT socket data */ void socketConnect(); void socketConnectName(); /** Handle SO_MVT socket data */ void socketMvt(); /** Handle SO_TECHNIC socket data */ void socketTechnic(); /** Handle SO_FIGHT socket data */ void socketFight(); void socketFightInit(); void socketFightEnd(); /** Handle SO_QR socket data */ void socketQR(); void socketQRMsgNext(); void socketQRMsgEnd(); /** Handle SO_EXCH socket data */ void socketExch(); void socketGameInfo(); void socketGameTavern(); void socketGameTavernInfo(); void socketGameTavernLord(); void socketGameCalendar(); /** Handle SO_MODIF socket data */ void socketModif(); void socketModifMap(); void socketModifCell(); void socketModifLord(); void socketModifLordVisit(); void socketModifLordNew(); void socketModifLordUnit(); void socketModifLordRemove(); void socketModifLordCharac(); void socketModifLordGarrison(); void socketModifLordMachine(); void socketModifBase(); void socketModifBaseNew(); void socketModifBaseOwner(); void socketModifBaseName(); void socketModifBaseBuilding(); void socketModifBaseUnit(); void socketModifBasePopulation(); void socketModifBaseResources(); void socketModifBaseProduction(); void socketModifBuilding(); void socketModifBuildingNew(); void socketModifBuildingOwner(); void socketModifBuildingResources(); void socketModifArtefact(); void socketModifPlayer(); void socketModifCreature(); void socketModifCreatureNew(); void socketModifCreatureUpdate(); void socketModifCreatureDel(); void socketModifCreatureRess(); void socketModifEvent(); void socketModifEventNew(); void socketModifEventDel(); /** Handle SO_TURN socket data */ void socketTurn(); void socketTurnBegin(); void socketTurnPlay(); void socketTurnLord(); /** Handle SO_GAME socket data */ void socketGame(); void socketGameEnd(); void socketGameLost(); void socketGameWin(); void socketGameBegin(); /* Return exact lord power */ int getPower(AiLord *lord); void exchangeStart(); /** manage exchange units */ void exchangeUnits(); /** manage exchange artefact */ void exchangeArtefact(); void exchangeBaseUnits(); void setPlayerNumber( uint nb ); void manageBase(GenericBase * base); void manageBaseCreature(GenericBase *base, InsideAction * action); void manageBaseMarket(); void enterBase(AiLord * lord,GenericBase * base ); public slots: /** Slot for reading sockets */ void slot_readSocket(); private: void playLordTurn(int nlord); void analyzeLord( AiLord * lord ); void analyzeLordMap( AiLord * lord ); void sendLordTurn( int opt ); GenericCell * randomPath(GenericCell * cell ); GenericCell * fleePath( AiLord * lord ); GenericCell * findNotExploredCell(GenericCell * cell); void tuneAiPower( uint opPower ); void manageMeetingsLord( AiLord * lord, AiLord * opponent, LordPriority prioType ); void manageMeetingsThings( AiLord * lord, GenericCell * cell, LordPriority prioType ); /* manageMeetings * with * lord = our lord * cell = target cell * prior = priority of the target * opPower = opponent power, 0 if no opponent * isFlee = our lord flee if enemy is more powerful? true yes, false no (only care with opPower>0) */ void manageMeetings( AiLord * lord, GenericCell * cell,int prior,uint opPower, bool isFlee ); /* tell if the ai is in her turn (for coordinate lord's turn) */ bool InTurn() { return _numTurn>=0 ? true : false; } AttalSocket * _socket; FightAnalyst * _fight; GenericPlayer * _player; GenericBase * _basetav; QString _msg; QList _lordtav; QList _tabuCells; uchar _nbLord, _nbLordRead; int _currentLord; int _lastLord; int _status; int _numlords; int _numTurn; uint _SuffisantPower; int _totalTurn; //GenericMap * _map; //AiLord ** _lords; //QPtrList _artefacts; }; #ifdef WIN32VC6 #define ialogV aifLog.ialog #define ialogN aifLog.ialog #define ialogC aifLog.ialog #else /** Log with level */ #define ialogV( format, args... ) aifLog.ialog( LOG_VERBOSE, format, ## args ) #define ialogN( format, args... ) aifLog.ialog( LOG_NORMAL, format, ## args ) #define ialogC( format, args... ) aifLog.ialog( LOG_CRITICAL, format, ## args ) #endif // VC6 #endif // ANALYST_H attal-src-1.0-rc2/libAi/libAi.pro0000644000175000017500000000123211015367572014243 0ustar aaaaTEMPLATE = lib include( ../config.pro ) INCLUDEPATH += .. LIBS += -L.. unix:LIBS += -lAttalCommon win32:LIBS += -lAttalCommon9 unix:LIBS += -lAttalServer win32:LIBS += -lAttalServer9 VERSION = 3.0.0 SOURCES += aiLord.cpp SOURCES += analyst.cpp HEADERS += aiLord.h HEADERS += analyst.h TRANSLATIONS += ../i18n/de/attal_libai_de.ts TRANSLATIONS += ../i18n/fr/attal_libai_fr.ts TRANSLATIONS += ../i18n/ru/attal_libai_ru.ts TRANSLATIONS += ../i18n/it/attal_libai_it.ts DESTDIR = .. OBJECTS_DIR=./obj MOC_DIR=./moc TARGET = AttalAi unix { target.path = $${ATT_LIB_PREFIX} INSTALLS += target } #The following line was inserted by qt3to4 QT += xml network attal-src-1.0-rc2/libClient/0000755000175000017500000000000011016113672013357 5ustar aaaaattal-src-1.0-rc2/libClient/.cvsignore0000644000175000017500000000042410331243510015351 0ustar aaaamoc obj moc_* *.moc.cpp *.o *.opt *.plg *.dsp .deps Makefile.in Makefile Makefile.Release Makefile.Debug attal-client duel-client attal.plg libattal.plg libfight.plg Debug Release AttalClient_resource.rc object_ld_script.AttalClient.Debug object_ld_script.AttalClient.Release attal-src-1.0-rc2/libClient/aboutDialog.cpp0000644000175000017500000000435610560653653016340 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** aboutDialog.cpp ** dialog for displaying info about Attal and link to website ** ** Version : $Id: aboutDialog.cpp,v 1.2 2007/02/02 15:24:27 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 28/11/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "aboutDialog.h" // generic include files // include files for QT #include #include #include // application specific include files #include "libClient/attalButton.h" extern QString VERSION; AboutDialog::AboutDialog( QWidget * parent ) : QDialog( parent ) { QLabel * label = new QLabel( this ); label->setText( tr( "Attal is a turn-based strategy game. \nCan be played alone (against AI) or against other through a network (local or internet). \nIt's available under Linux and Windows." ) ); QLabel * version = new QLabel( this ); version->setText( tr( "Version: " ) + VERSION ); QHBoxLayout * layH1 = new QHBoxLayout(); QVBoxLayout * layV1 = new QVBoxLayout(); layH1->setMargin( 5 ); layH1->setSpacing( 5 ); layV1->addWidget( label, 1 ); layV1->addWidget( version, 1 ); layH1->addLayout( layV1 ); AttalButton * pbOk = new AttalButton( this, AttalButton::BT_OK ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->setMargin( 5 ); layH2->setSpacing( 5 ); layH2->addStretch( 1 ); layH2->addWidget( pbOk ); layH2->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addStretch( 1 ); layout->addLayout( layH1 ); layout->addStretch( 1 ); layout->addLayout( layH2 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); } attal-src-1.0-rc2/libClient/aboutDialog.h0000644000175000017500000000247310347251261015773 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** aboutDialog.h ** dialog for displaying info about Attal and link to website ** ** Version : $Id: aboutDialog.h,v 1.2 2005/12/12 10:36:33 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 28/11/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ABOUTDIALOG_H #define ABOUTDIALOG_H // generic include files // include files for QT #include // application specific include files /* ------------------------------ * AboutDialog * ------------------------------ */ class AboutDialog : public QDialog { Q_OBJECT public: /** Constructor */ AboutDialog( QWidget * parent = 0 ); }; #endif // ABOUTDIALOG_H attal-src-1.0-rc2/libClient/askChest.cpp0000644000175000017500000000542710777503651015655 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** askChest.cpp ** Dialog for asking the player about the chest content ** ** Version : $Id: askChest.cpp,v 1.6 2008/04/10 21:33:29 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "askChest.h" // generic include files // include files for QT #include #include #include #include // application specific include files #include "libCommon/log.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/widget.h" AskChest::AskChest() : QDialog( 0, Qt::Dialog ) { _result = 0; QLabel * chooseLabel = new QLabel( this ); chooseLabel->setText( tr( "Choose between earning Gold or Experience" ) ); FIXEDSIZE( chooseLabel ); QLabel * goldLabel = new QLabel(this); goldLabel->setText( QString::number( 1000 ) ); QLabel * experienceLabel = new QLabel(this); experienceLabel->setText( QString::number( 2500 ) ); QPushButton * goldButton = new QPushButton( this ); goldButton->setText( tr( "Gold" ) ); FIXEDSIZE( goldButton ); QPushButton * experienceButton = new QPushButton( this ); experienceButton->setText( tr( "Experience" ) ); FIXEDSIZE( experienceButton ); Icon * goldIcon = new Icon( this ); goldIcon->setPixmap( QPixmap( *ImageTheme.getResourceIcon( 0 ) ) ); Icon * experienceIcon = new Icon( this ); experienceIcon->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( ICO_EXPERIENCE ) ) ); QGridLayout * layout = new QGridLayout(this); layout->addWidget(chooseLabel, 0, 0, 1, 2, Qt::AlignHCenter); layout->addWidget(goldIcon, 1, 0, Qt::AlignHCenter); layout->addWidget(experienceIcon, 1, 1, Qt::AlignHCenter); layout->addWidget(goldLabel, 2, 0, Qt::AlignHCenter); layout->addWidget(experienceLabel, 2, 1, Qt::AlignHCenter); layout->addWidget(goldButton, 3, 0, Qt::AlignHCenter); layout->addWidget(experienceButton, 3, 1, Qt::AlignHCenter); connect( goldButton, SIGNAL( clicked() ), SLOT( slot_gold() ) ); connect( experienceButton, SIGNAL( clicked() ), SLOT( slot_experience() ) ); } void AskChest::slot_gold() { _result = 0; accept(); } void AskChest::slot_experience() { _result = 1; accept(); } attal-src-1.0-rc2/libClient/askChest.h0000644000175000017500000000257710331243510015302 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** askChest.h ** Dialog for asking the player about the chest content ** ** Version : $Id: askChest.h,v 1.2 2005/10/30 22:20:56 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ASKCHEST_H #define ASKCHEST_H // generic include files // include files for QT #include // application specific include files /* ------------------------------ * AskChest * ------------------------------ */ class AskChest : public QDialog { Q_OBJECT public: /** Constructor */ AskChest(); uchar getResult() { return _result; } public slots: void slot_gold(); void slot_experience(); protected: uchar _result; }; #endif // ASKCHEST_H attal-src-1.0-rc2/libClient/askCost.cpp0000644000175000017500000001131210740437744015504 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** askCost.cpp ** Widget for asking cost ** ** Version : $Id: askCost.cpp,v 1.1 2008/01/07 15:06:12 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 25/08/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "askCost.h" // generic include files // include files for QT #include #include #include #include #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libClient/gui.h" // // ----- AskCost ----- // AskCost::AskCost( const QString & text, QWidget * parent, const char * /*name*/ ) : QWidget( parent ) { _text = new QLabel( this ); _text->setText( text ); FIXEDSIZE( _text ); _cost = new QLabel( this ); _cost->setText( "0" ); FIXEDSIZE( _cost ); QPushButton * pbChange = new QPushButton( this ); pbChange->setText( tr( "Change" ) ); FIXEDSIZE( pbChange ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _text ); layout->addWidget( _cost ); layout->addWidget( pbChange ); layout->addStretch( 1 ); layout->activate(); connect( pbChange, SIGNAL( clicked() ), SLOT( slot_change() ) ); } void AskCost::setText( const QString & text ) { _text->setText( text ); FIXEDSIZE( _text ); } void AskCost::slot_change() { EditCost cost( _resources, this ); _resources = cost.getResources(); if( cost.exec() ) { _resources = cost.getResources(); } updateCost(); } void AskCost::updateCost() { ResourceList & themeResources = DataTheme.resources; uint nbRes = themeResources.count(); QString text = ""; for( uint i = 0; i < nbRes; ++i ) { if( _resources[ themeResources.getRessource( i ) ] != 0 ) { if( text != "" ) { text += " + "; } text += QString::number( _resources[ themeResources.getRessource( i ) ] ) + " " + themeResources.getRessource( i ); } } if( text == "" ) { text = "0"; } _cost->setText( text ); FIXEDSIZE( _cost ); } void AskCost::setValue( uint num, uint value ) { ResourceList & themeResources = DataTheme.resources; uint nbRes = themeResources.count(); if( num < nbRes ) { _resources[ themeResources.getRessource( num ) ] = value; } updateCost(); } uint AskCost::getValue( uint num ) { uint ret = 0; ResourceList & themeResources = DataTheme.resources; uint nbRes = themeResources.count(); if( num < nbRes ) { ret = _resources[ themeResources.getRessource( num ) ]; } return ret; } // // ----- EditCost ----- // EditCost::EditCost( const QMap & resources, QWidget * parent, const char * /*name*/ ) : QDialog( parent, Qt::Dialog ) { ResourceList & themeResources = DataTheme.resources; uint nbRes = themeResources.count(); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); QGridLayout * grid = new QGridLayout(); QLabel * label; QSpinBox * box; for( uint i = 0; i < nbRes; i++ ) { label = new QLabel( themeResources.getRessource( i ), this ); FIXEDSIZE( label ); grid->addWidget( label, i, 0 ); box = new QSpinBox( this ); box->setMinimum( 0 ); box->setMaximum( 1000000 ); box->setValue( resources[ themeResources.getRessource( i ) ] ); FIXEDSIZE( box ); grid->addWidget( box, i, 1 ); _boxes.append( box ); } QHBoxLayout * layH = new QHBoxLayout(); layH->addStretch( 1 ); layH->addWidget( pbOk ); layH->addStretch( 1 ); layH->addWidget( pbCan ); layH->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( grid, 1 ); layout->addLayout( layH ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); } QMap EditCost::getResources() { QMap ret; ResourceList & themeResources = DataTheme.resources; uint nb = _boxes.count(); for( uint i = 0; i < nb; ++i ) { ret.insert( themeResources.getRessource( i ), _boxes[ i ]->value() ); } return ret; } attal-src-1.0-rc2/libClient/askCost.h0000644000175000017500000000352710740437744015162 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** askCost.h ** Widget for asking cost ** ** Version : $Id: askCost.h,v 1.1 2008/01/07 15:06:12 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 25/08/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ASKCOST_H #define ASKCOST_H // generic include files // include files for QT #include #include #include #include #include #include // application specific include files class QLabel; /* ------------------------------ * AskCost * ------------------------------ */ class AskCost : public QWidget { Q_OBJECT public: /** Constructor */ AskCost( const QString & text = "", QWidget * parent = 0, const char * name = 0 ); void setText( const QString & text ); void setValue( uint num, uint value ); uint getValue( uint num ); public slots: void slot_change(); protected: void updateCost(); QLabel * _text, * _cost; QMap _resources; }; class EditCost : public QDialog { Q_OBJECT public: EditCost( const QMap & resources, QWidget * parent = 0, const char * name = 0 ); QMap getResources(); protected: QList _boxes; }; #endif // ASKCOST_H attal-src-1.0-rc2/libClient/askDialog.cpp0000644000175000017500000000370310404347364015773 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** askDialog.cpp ** Dialog for questions to player ** ** Version : $Id: askDialog.cpp,v 1.4 2006/03/10 19:09:40 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 27/11/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "askDialog.h" // generic include files // include files for QT #include #include #include #include // application specific include files #include "libCommon/log.h" #include "libClient/attalButton.h" #include "libClient/gui.h" AskDialog::AskDialog() : QDialog( 0, Qt::Dialog ) { _pb1 = new AttalButton( this, AttalButton::BT_OK ); _pb2 = new AttalButton( this, AttalButton::BT_CANCEL ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( _pb1 ); layH1->addStretch( 1 ); layH1->addWidget( _pb2 ); layH1->addStretch( 1 ); _text = new QLabel( this ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( _text, 1 ); layout->addLayout( layH1 ); layout->activate(); connect( _pb1, SIGNAL( clicked() ), SLOT( accept() ) ); connect( _pb2, SIGNAL( clicked() ), SLOT( reject() ) ); } void AskDialog::setText( const QString & text ) { _text->setText( text ); } void AskDialog::setYesNo() { _pb1->setText( tr( "Yes" ) ); FIXEDSIZE( _pb1 ); _pb2->setText( tr( "No" ) ); FIXEDSIZE( _pb2 ); } attal-src-1.0-rc2/libClient/askDialog.h0000644000175000017500000000262110332232424015424 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** askDialog.h ** Dialog for questions to player ** ** Version : $Id: askDialog.h,v 1.6 2005/11/02 21:52:20 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 27/11/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ASKDIALOG_H #define ASKDIALOG_H // generic include files // include files for QT #include // application specific include files class QLabel; class AttalButton; /* ------------------------------ * AskDialog * ------------------------------ */ class AskDialog : public QDialog { Q_OBJECT public: /** Constructor */ AskDialog(); void setText( const QString & text ); void setYesNo(); private: QLabel * _text; AttalButton * _pb1, * _pb2; }; #endif // ASKDIALOG_H attal-src-1.0-rc2/libClient/askWidget.cpp0000644000175000017500000002705010712373076016021 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** askWidget.cpp ** Classes for asking values to user ** ** Version : $Id: askWidget.cpp,v 1.15 2007/11/01 15:52:30 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "askWidget.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/log.h" #include "libClient/attalButton.h" #include "libClient/gui.h" // // ----- AskString ----- // AskString::AskString( QString text, QWidget * parent, const char * /* name */) : QWidget( parent ) { QHBoxLayout * layout = new QHBoxLayout( this ); layout->addSpacing( 5 ); _label = new QLabel( this ); _label->setText( text ); FIXEDSIZE( _label ); layout->addWidget( _label ); layout->addSpacing( 5 ); _value = new QLineEdit( this ); _value->setFixedWidth( 250 ); layout->addWidget( _value ); layout->addStretch( 1 ); layout->addSpacing( 5 ); layout->activate(); } void AskString::setText( QString text ) { _label->setText( text ); FIXEDSIZE( _label ); } // // ----- AskBool ----- // AskBool::AskBool( QString text, QWidget * parent, const char * /* name */) : QWidget( parent ) { QHBoxLayout * layout = new QHBoxLayout( this ); _value = new QCheckBox( text, this ); FIXEDSIZE( _value ); layout->addWidget( _value ); layout->addStretch( 1 ); layout->addSpacing( 5 ); layout->activate(); connect( _value, SIGNAL( clicked() ), SIGNAL( sig_changed() ) ); } void AskBool::setText( QString text ) { _value->setText( text ); FIXEDSIZE( _value ); } // // ----- AskInt ----- // AskInt::AskInt( QString text, QWidget * parent, const char * /* name */ ) : QWidget( parent ) { QHBoxLayout * layout = new QHBoxLayout( this ); setFixedWidth( 200 ); layout->addSpacing( 4 ); _label = new QLabel( this ); _label->setText( text ); FIXEDSIZE( _label ); if( _label->width() > 200 ) { setFixedWidth( 300 ); } layout->addWidget( _label ); //layout->addSpacing( 5 ); layout->addStretch( 1 ); _value = new QSpinBox( this ); _value->setMinimum( 0 ); _value->setMaximum( 255 ); FIXEDSIZE( _value ); layout->addWidget( _value ); //layout->addStretch( 1 ); //layout->addSpacing( 5 ); layout->activate(); } void AskInt::setText( QString text ) { _label->setText( text ); FIXEDSIZE( _label ); if( _label->width() > 200 ) { setFixedWidth( 300 ); } } // // ----- AskCombo ----- // AskCombo::AskCombo( QString text, QWidget * parent, const char * /*name */ ) : QWidget( parent ) { QHBoxLayout * layout = new QHBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); _label = new QLabel( this ); _label->setText( text ); FIXEDSIZE( _label ); layout->addWidget( _label ); _combo = new QComboBox( this ); _combo->setEditable( false ); FIXEDSIZE( _combo ); layout->addWidget( _combo ); layout->addStretch( 1 ); layout->activate(); connect( _combo, SIGNAL( activated( int ) ), SIGNAL( sig_activated( int ) ) ); } void AskCombo::clear() { _combo->clear(); } void AskCombo::setText( const QString & text ) { _label->setText( text ); FIXEDSIZE( _label ); } void AskCombo::insertItem( const QString & item ) { _combo->addItem( item ); FIXEDSIZE( _combo ); } int AskCombo::currentItem() { return _combo->currentIndex(); } void AskCombo::setCurrentItem( int num ) { _combo->setCurrentIndex( num ); } // // ----- AskPixmap ----- // AskPixmap::AskPixmap( bool display, const QString & destination, QString text, QWidget * parent, const char * /* name */) : QWidget( parent ) { _pix = NULL; _display = display; _destination = destination; _value = destination; QHBoxLayout * layout = new QHBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); QLabel * label = new QLabel( this ); label->setText( text ); FIXEDSIZE( label ); layout->addWidget( label ); _butLoad = new AttalButton( this ); FIXEDSIZE( _butLoad ); layout->addWidget( _butLoad ); layout->addStretch( 1 ); layout->activate(); connect( _butLoad, SIGNAL( clicked() ), SLOT( slot_loadPixmap() ) ); updateDisplay(); } AskPixmap::~AskPixmap() { if( _pix ) { delete _pix; } } void AskPixmap::slot_loadPixmap() { QString filename; filename = QFileDialog::getOpenFileName( this, tr( "Open pixmap" ), "", "*.png" ); if ( !filename.isNull() ) { _value = filename; updateDisplay(); } } void AskPixmap::setValue( const QString & value ) { _value = value; updateDisplay(); } void AskPixmap::setDestination( const QString & destination ) { _destination = destination; setValue( destination ); } void AskPixmap::updateDisplay() { if( _display ) { if( _pix ) { delete _pix; } _pix = new QPixmap( _value ); _butLoad->setPixmap( *_pix ); } else { _butLoad->setText( _value ); } FIXEDSIZE( _butLoad ); } void AskPixmap::save() { char c; if( _value != _destination ) { QFile fileIn( _value ); QFile fileOut( _destination ); if( fileIn.exists() ) { fileIn.open( QIODevice::ReadOnly ); fileOut.open( QIODevice::WriteOnly ); while( !fileIn.atEnd() ) { fileIn.getChar( &c ); fileOut.putChar( c ); } } fileOut.close(); fileIn.close(); } } // // ----- AskList ----- // AskList::AskList( QWidget * parent, const char * /* name */) : QWidget( parent ) { _limit = 0; _label = new QLabel( this ); FIXEDSIZE( _label ); QVBoxLayout * layout = new QVBoxLayout( this ); //layV1->setMargin( 5 ); layout->addWidget( _label ); layout->addStretch( 1 ); _list = new QListWidget( this ); QVBoxLayout * layV2 = new QVBoxLayout(); layV2->setMargin( 5 ); layV2->addWidget( _list, 1 ); _pbNew = new QPushButton( this ); _pbNew->setText( "New" ); FIXEDSIZE( _pbNew ); _pbDel = new QPushButton( this ); _pbDel->setText( "Del" ); FIXEDSIZE( _pbDel ); _pbUp = new QPushButton( this ); _pbUp->setText( "Up" ); FIXEDSIZE( _pbUp ); _pbDown = new QPushButton( this ); _pbDown->setText( "Down" ); FIXEDSIZE( _pbDown ); QVBoxLayout * layV3 = new QVBoxLayout(); layV3->setSpacing( 5 ); layV3->setMargin( 5 ); layV3->addWidget( _pbNew ); layV3->addWidget( _pbDel ); layV3->addStretch( 1 ); layV3->addWidget( _pbUp ); layV3->addWidget( _pbDown ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setMargin( 5 ); layH1->setSpacing( 5 ); layH1->addLayout( layV2 ); layH1->addLayout( layV3 ); layH1->addStretch( 1 ); layout->addLayout( layH1 ); layout->activate(); connect( _pbNew, SIGNAL( clicked() ), SLOT( slot_new() ) ); connect( _pbDel, SIGNAL( clicked() ), SLOT( slot_del() ) ); connect( _pbUp, SIGNAL( clicked() ), SLOT( slot_up() ) ); connect( _pbDown, SIGNAL( clicked() ), SLOT( slot_down() ) ); connect( _list, SIGNAL( itemDoubleClicked( QListWidgetItem * ) ), SLOT( slot_change( QListWidgetItem * ) ) ); } void AskList::setLabel( const QString & label ) { _label->setText( label ); FIXEDSIZE( _label ); } void AskList::setLimit( int limit ) { _limit = limit; if( _limit ) { } } uint AskList::count() { return _list->count(); } void AskList::clear() { _list->clear(); } void AskList::slot_new() { bool ok; QString text = askValue( "", ok ); if( ok ) { _list->addItem( text ); _list->setCurrentRow( _list->count() - 1 ); } } void AskList::slot_del() { if( _list->currentRow() > -1 ) { _list->takeItem( _list->currentRow() ); } } void AskList::slot_up() { int index = _list->currentRow(); if( index > 0 ) { QString up = _list->item( index - 1 )->text(); QString down = _list->item( index )->text(); _list->item( index )->setText( up ); _list->item( index - 1 )->setText( down ); _list->setCurrentRow( index - 1 ); } } void AskList::slot_down() { int index = _list->currentRow(); if( index < (int)count() - 1 ) { QString up = _list->item( index )->text(); QString down = _list->item( index + 1 )->text(); _list->item( index + 1 )->setText( up ); _list->item( index )->setText( down ); _list->setCurrentRow( index + 1 ); } } void AskList::slot_change( QListWidgetItem * item ) { bool ok; QString text = askValue( item->text(), ok ); if( ok ) { _list->currentItem()->setText( text ); } } QString AskList::askValue( const QString & value, bool & ok ) { return QInputDialog::getText( 0 ,"New item", "Enter new item text: ", QLineEdit::Normal, value, &ok ); } // // ----- AskStringList // AskStringList::AskStringList( QWidget * parent, const char * /* name */ ) : AskList( parent ) { } void AskStringList::addValue( const QString & value ) { _list->addItem( value ); } void AskStringList::setValue( uint num, const QString & value ) { if( (int)num < _list->count() ) { _list->item( num )->setText( value ); } } QString AskStringList::getValue( uint num ) { QString ret; if( (int)num < _list->count() ) { ret = _list->item( num )->text(); } return ret; } // // ----- AskIntList ----- // AskIntList::AskIntList( QWidget * parent, const char * /* name */ ) : AskList( parent ) { _min = -2147483647; _max = 2147483647; } void AskIntList::setMinValue( int value ) { _min = value; if( _min > _max ) { _max = _min; } } void AskIntList::setMaxValue( int value ) { _max = value; if( _max < _min ) { _min = _max; } } void AskIntList::addValue( int value ) { _list->addItem( QString::number( value ) ); } void AskIntList::setValue( uint num, int value ) { if( (int)num < _list->count() ) { _list->item( num )->setText( QString::number( value ) ); } } int AskIntList::getValue( uint num ) { int ret = 0; if( (int)num < _list->count() ) { ret = _list->item( num )->text().toInt(); } return ret; } QString AskIntList::askValue( const QString & value, bool & ok ) { return QString::number( QInputDialog::getInteger( 0, "New item", "Enter new number: ", value.toInt(), _min, _max, 1, &ok ) ); } // // ----- AskColor ----- // AskColor::AskColor( const QString & text, QWidget * parent, const char * /* name */) : QWidget( parent ) { _color = Qt::black; _label = new QLabel( this ); _label->setText( text ); FIXEDSIZE( _label ); _colorButton = new QPushButton( this ); QPalette palette; palette.setColor(_colorButton->backgroundRole(), _color); _colorButton->setPalette(palette); FIXEDSIZE( _colorButton ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->addSpacing( 5 ); layout->addWidget( _label ); layout->addSpacing( 5 ); layout->addWidget( _colorButton ); layout->addStretch( 1 ); layout->activate(); connect( _colorButton, SIGNAL( clicked() ), SLOT( slot_color() ) ); } void AskColor::slot_color() { _color = QColorDialog::getColor( _color, this ); QPalette palette; palette.setColor(_colorButton->backgroundRole(), _color); _colorButton->setPalette(palette); } void AskColor::setText( const QString & text ) { _label->setText( text ); FIXEDSIZE( _label ); } void AskColor::setValue( const QColor & color ) { _color = color; QPalette palette; palette.setColor(_colorButton->backgroundRole(), _color); _colorButton->setPalette(palette); } QColor AskColor::getValue() { return _color; } attal-src-1.0-rc2/libClient/askWidget.h0000644000175000017500000001430610404562730015461 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** askWidget.h ** Classes for asking values to user ** ** Version : $Id: askWidget.h,v 1.9 2006/03/11 14:59:36 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 07/01/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ASKWIDGET_H #define ASKWIDGET_H // generic include files // include files for QT #include #include #include #include #include // application specific include files class QComboBox; class QLabel; class QListWidget; class QListWidgetItem; class QPixmap; class QPushButton; class AttalButton; /** Usefull widget for asking a string */ class AskString : public QWidget { public: /** Constructor */ AskString( QString text = "", QWidget * parent = 0, const char * name = 0 ); /** Set the text of the question */ void setText( QString text ); /** \return Returns the value asked (a string) */ QString getValue() { return _value->text(); } /** Sets the value */ void setValue( QString value ) { _value->setText( value ); } /** Sets the width of the lineedit */ void setValueSize( int size ) { _value->setFixedWidth( size ); } private: QLineEdit * _value; QLabel * _label; }; /** Usefull widget for asking a boolean */ class AskBool : public QWidget { Q_OBJECT public: /** Constructor */ AskBool( QString text = "", QWidget * parent = 0, const char * name = 0 ); /** Set the text of the question */ void setText( QString text ); /** \return Returns the value */ bool getValue() { return _value->isChecked(); } /** Sets the value */ void setValue( bool value ) { _value->setChecked( value ); } signals: void sig_changed(); private: QCheckBox * _value; }; /** Usefull widget for asking an int */ class AskInt : public QWidget { public: /** Constructor */ AskInt( QString text = "", QWidget * parent = 0, const char * name = 0 ); /** Sets text of the question */ void setText( QString text ); /** \return Returns the value */ int getValue() { return _value->value(); } /** Sets the value */ void setValue( int value ) { _value->setValue( value ); } /** Sets the 'min' value */ void setMinValue( int val ) { _value->setMinimum( val ); } /** Sets the 'max' value */ void setMaxValue( int val ) { _value->setMaximum( val ); } private: QSpinBox * _value; QLabel * _label; }; /** Usefull widget for asking a case in an enum */ class AskCombo : public QWidget { Q_OBJECT public: /** Constructor */ AskCombo( QString text = "", QWidget * parent = 0, const char * name = 0 ); /** Clears the combo */ void clear(); /** Sets the text of the question */ void setText( const QString & text ); /** Inserts an item in the combo */ void insertItem( const QString & item ); /** \return Returns current item */ int currentItem(); /** Sets current item to num */ void setCurrentItem( int num ); signals: void sig_activated( int ); private: QLabel * _label; QComboBox * _combo; }; /** Useful widget for asking a pixmap */ class AskPixmap : public QWidget { Q_OBJECT public: /** Constructor */ AskPixmap( bool display, const QString & destination, QString text = "", QWidget * parent = 0, const char * name = 0 ); /** Destructor */ ~AskPixmap(); /** \return Returns the value (path to the pixmap) */ QString getValue() { return _value; } /** Sets path to the pixmap */ void setValue( const QString & value ); /** \return Returns destination of the pixmap */ QString getDestination() { return _destination; } /** Sets destination of the pixmap */ void setDestination( const QString & destination ); /** Save pixmap to the destination */ void save(); public slots: /** Slot for loading the pixmap */ void slot_loadPixmap(); private: void updateDisplay(); QPixmap * _pix; QString _value, _destination; AttalButton * _butLoad; bool _display; }; class AskList : public QWidget { Q_OBJECT public: /** Constructor */ AskList( QWidget * parent = 0, const char * name = 0 ); void setLabel( const QString & label ); /** Sets limit of the list. 0 means no limit */ void setLimit( int limit ); /** Returns the current number of items */ uint count(); void clear(); public slots: /** Slot for adding a new item */ void slot_new(); /** Slot for deleting the current item */ void slot_del(); /** Slot for putting the current item up */ void slot_up(); /** Slot for putting the current item down */ void slot_down(); /** Slot for changing the value of an item */ void slot_change( QListWidgetItem * item ); protected: virtual QString askValue( const QString & val, bool & ok ); int _limit; QListWidget * _list; QLabel * _label; QPushButton * _pbNew, * _pbDel, * _pbUp, * _pbDown; }; class AskStringList : public AskList { public: AskStringList( QWidget * parent = 0, const char * name = 0 ); void addValue( const QString & value ); void setValue( uint num, const QString & value ); QString getValue( uint num ); protected: //virtual QString askValue(); }; class AskIntList : public AskList { public: AskIntList( QWidget * parent = 0, const char * name = 0 ); void addValue( int value ); void setValue( uint num, int value ); int getValue( uint num ); void setMinValue( int value ); void setMaxValue( int value ); protected: virtual QString askValue( const QString & value, bool & ok ); int _min, _max; }; class AskColor : public QWidget { Q_OBJECT public: AskColor( const QString & text = "", QWidget * parent = 0, const char * name = 0 ); void setText( const QString & text ); void setValue( const QColor & color ); QColor getValue(); public slots: void slot_color(); protected: QLabel * _label; QPushButton * _colorButton; QColor _color; }; #endif // ASKWIDGET_H attal-src-1.0-rc2/libClient/attalButton.cpp0000644000175000017500000000530710615355175016403 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalButton.cpp ** Class for managing buttons in attal ** ** Version : $Id: attalButton.cpp,v 1.7 2007/04/30 12:01:01 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 30/10/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "attalButton.h" // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/log.h" #include "libClient/imageTheme.h" AttalButton::AttalButton( QWidget * parent, ButtonType type ) : QPushButton( parent ) { _type = type; switch( _type ) { case BT_NONE: break; case BT_LORD: createButtonLord(); break; case BT_BASE: createButtonBase(); break; case BT_OK: createButtonOk(); break; case BT_CANCEL: createButtonCancel(); break; case BT_PREV: createButtonPrevious(); break; case BT_NEXT: createButtonNext(); break; } } void AttalButton::setLord( uint id ) { if( _type != BT_LORD ) { _type = BT_LORD; createButtonLord(); } setIcon( * ImageTheme.getLordSmallPixmap( id ) ); } void AttalButton::setBase( uint race ) { if( _type != BT_BASE ) { _type = BT_BASE; createButtonBase(); } setIcon( * ImageTheme.getBaseSmallPixmap( race ) ); } void AttalButton::createButtonLord() { setFixedSize( 52, 42 ); setIconSize( QSize( 50, 40 ) ); } void AttalButton::createButtonBase() { setFixedSize( 52, 42 ); setIconSize( QSize( 50, 40 ) ); } void AttalButton::createButtonOk() { setPixmap( * ImageTheme.getOkPixmap() ); } void AttalButton::createButtonCancel() { setPixmap( * ImageTheme.getCancelPixmap() ); } void AttalButton::createButtonPrevious() { setFixedSize( 52, 42 ); setText( "<<" ); } void AttalButton::createButtonNext() { setFixedSize( 52, 42 ); setText( ">>" ); } void AttalButton::setPixmap( const QPixmap & pixmap ) { QSize size = pixmap.size(); setFixedSize( size.width() + 2, size.height() + 2 ); setIconSize( size ); setIcon( pixmap ); } void AttalButton::setBackgroundColor( const QColor & color ) { QPalette palette; palette.setColor(backgroundRole(), color); setPalette(palette); } attal-src-1.0-rc2/libClient/attalButton.h0000644000175000017500000000341510615355176016047 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalButton.h ** Class for managing buttons in attal ** ** Version : $Id: attalButton.h,v 1.6 2007/04/30 12:01:02 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 30/10/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ATTALBUTTON_H #define ATTALBUTTON_H // generic include files // include files for QT #include #include // application specific include files /* ------------------------------ * AttalButton * ------------------------------ */ class AttalButton : public QPushButton { public: enum ButtonType { BT_NONE, BT_LORD, BT_BASE, BT_OK, BT_CANCEL, BT_PREV, BT_NEXT }; /** Constructor */ AttalButton( QWidget * parent, ButtonType type = BT_NONE ); void setLord( uint id ); void setBase( uint race ); void setPixmap( const QPixmap & pixmap ); void setBackgroundColor( const QColor & color ); protected: void createButtonLord(); void createButtonBase(); void createButtonOk(); void createButtonCancel(); void createButtonPrevious(); void createButtonNext(); ButtonType _type; }; #endif // ATTALBUTTON_H attal-src-1.0-rc2/libClient/attalSound.cpp0000644000175000017500000001257410761341307016216 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalSound.cpp ** Manage sound and music (or not) for attal client ** ** Version : $Id: attalSound.cpp,v 1.30 2008/02/27 20:06:31 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 22/09/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "attalSound.h" AttalSoundData::AttalSoundData() { state = MUSIC_NULL; race = 0; } #ifdef WITH_SOUND // generic include files #include // include files for QT #include // application specific include files #include extern QString MUSIC_PATH; extern QString SOUND_PATH; #ifdef WITH_SOUND extern bool ATT_SOUND; #endif //this is to mix C and C++ code AttalSound * _sndPointer = NULL; AttalSound::AttalSound() { _sndPointer = this; _enableMusic = true; _enableSound = true; _soundId = -1; _sound = 0; } AttalSound::~AttalSound() { _sndPointer = NULL; clear(); } void AttalSound::enableSound( bool enabled ) { _enableSound = enabled; } void AttalSound::enableMusic( bool enabled ) { _enableMusic = enabled; if( _enableMusic ) { playMusic( _soundData ); } else { endMusic(); } } void AttalSound::init() { if(ATT_SOUND){ if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) { fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); clear(); } //atexit(SDL_Quit); #ifdef WIN32 const size_t buf_size = 4096; #else const size_t buf_size = 1024; #endif if ( Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, buf_size) < 0 ) { fprintf(stderr, "Warning: Couldn't set 11025 Hz 8-bit audio\n- Reason: %s\n", SDL_GetError() ); clear(); } Mix_AllocateChannels(16); } } void AttalSound::loadMusic(QString filename) { Mix_Music * music; music = Mix_LoadMUS( QString(MUSIC_PATH + filename).toLatin1().constData() ); if( music == NULL ) { fprintf(stderr, "Warning: Couldn't load music: %s\n", Mix_GetError() ); return; } _musicCache.insert(filename , music ); } void AttalSound::loadSound(QString filename) { Mix_Chunk * sound; sound = Mix_LoadWAV( QString(SOUND_PATH + filename).toLatin1().constData()); if( sound == NULL ) { fprintf(stderr, "Warning: Couldn't load sound: %s\n", Mix_GetError() ); return; } _soundCache.insert(filename , sound ); } void AttalSound::clear() { if(ATT_SOUND){ endMusic(); Mix_HaltChannel( -1 ); QMap::iterator i; for( i = _soundCache.begin(); i != _soundCache.end(); ++i) Mix_FreeChunk( i.value() ); _soundCache.clear(); QMap::iterator j; for( j = _musicCache.begin(); j != _musicCache.end(); ++j) Mix_FreeMusic(j.value()); _musicCache.clear(); if(SDL_WasInit(SDL_INIT_AUDIO) != 0) { Mix_CloseAudio(); SDL_QuitSubSystem(SDL_INIT_AUDIO); } SDL_Quit(); } } void AttalSound::endMusic() { if(ATT_SOUND){ if( Mix_PlayingMusic() ) { Mix_HookMusicFinished(0); Mix_HaltMusic(); } } } void AttalSound::playMusic( AttalSoundData soundData) { if(ATT_SOUND){ _soundData.state = soundData.state; if( _enableMusic ) { Mix_Music * music; if( Mix_PlayingMusic() ) { Mix_HookMusicFinished(AttalSound::musicCompleted); Mix_FadeOutMusic( 500 ); } else { QString file = computeMusicFile( _soundData.state ); if( file != "" ) { if( !_musicCache.contains( file ) ) { loadMusic( file ); } } music = _musicCache.value(file); if( music ) { Mix_FadeInMusic( music, -1, 500 ); } } } } } QString AttalSound::computeSoundFile( SoundType snd ) { QString ret = ""; switch( snd ) { case SND_NEWTURN: ret = "newturn.wav"; break; case SND_HIT: ret = "hit.wav"; break; case SND_ARROW: ret = "arrow.wav"; break; case SND_GOOD: ret = "good.wav"; break; case SND_WIN: ret = "win.wav"; break; } return ret; } QString AttalSound::computeMusicFile( MusicState msc ) { switch( msc ) { case MUSIC_MAP: return "map.ogg"; break; case MUSIC_BASE: return "castle.ogg"; break; case MUSIC_FIGHT: return "battle01.ogg"; break; default: // in case there are any new "MusicState"s, and this code hasn't been changed, it will default to not playing anything case MUSIC_NULL: return ""; break; } } void AttalSound::playSound( SoundType snd ) { if(ATT_SOUND && _enableSound ) { Mix_Chunk * sound; QString file = computeSoundFile( snd ); Mix_HaltChannel( -1 ); if( file != "" ) { if( !_soundCache.contains( file ) ) { loadSound( file ); } sound = _soundCache.value( file ); if( sound ) { _soundId = Mix_PlayChannel( -1, sound, 0 ); // I don't know why _soundId is even being stored, it isn't used anywhere else } } } } void AttalSound::playNextMusic() { playMusic( _soundData ); } void AttalSound::musicCompleted() { if(! Mix_PlayingMusic() ) { if( _sndPointer ) { _sndPointer->playNextMusic(); } } } #endif attal-src-1.0-rc2/libClient/attalSound.h0000644000175000017500000000534411016037363015656 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalSound.h ** Manage sound and music (or not) for attal client ** ** Version : $Id: attalSound.h,v 1.18 2008/05/24 16:14:43 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 22/09/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ATTALSOUND_H #define ATTALSOUND_H enum MusicState { MUSIC_NULL, MUSIC_MAP, MUSIC_BASE, MUSIC_FIGHT }; class AttalSoundData { public: AttalSoundData(); MusicState state; int race; }; #include #ifdef WITH_SOUND // generic include files // include files for QT #include #include // application specific include files #include #include /* ------------------------------ * AttalSound * ------------------------------ */ class AttalSound : public QObject { Q_OBJECT public: enum SoundType { SND_NEWTURN, SND_HIT, SND_ARROW, SND_GOOD, SND_WIN }; /** Constructor */ AttalSound(); /** Destructor */ virtual ~AttalSound(); void init(); void loadMusic(QString filename); void loadSound(QString filename); void enableSound( bool enabled ); void enableMusic( bool enabled ); void playSound( SoundType snd ); void playMusic( AttalSoundData data ); void endMusic(); void playNextMusic(); static void musicCompleted(); protected: QString computeSoundFile( SoundType snd ); QString computeMusicFile( MusicState msc ); Mix_Chunk * _sound; int _soundId; bool _enableSound , _enableMusic; QMap _musicCache; QMap _soundCache; AttalSoundData _soundData; private: void clear(); }; #else // No sound!! class AttalSound { public: enum SoundType { SND_NEWTURN, SND_HIT, SND_ARROW, SND_GOOD, SND_WIN }; /** Constructor */ AttalSound() {} ~AttalSound() {} void init() {} void loadMusic(QString ) {} void loadSound(QString ) {} void enableSound( bool ) {} void enableMusic( bool ) {} void playSound( SoundType ) {} void playMusic( AttalSoundData ) {} void endMusic() {} private: void clear() {} }; #endif #endif // ATTALSOUND_H attal-src-1.0-rc2/libClient/attalSprite.cpp0000644000175000017500000000550411006433264016364 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalSprite.cpp ** class to implement animations ** ** Version : $Id: attalSprite.cpp,v 1.13 2008/05/01 21:31:32 lusum Exp $ ** ** Author(s) : Sardi Carlo ** ** Date : 28/08/2006 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "attalSprite.h" // generic include files // include files for QT #include #include // application specific include files #include "libCommon/log.h" /*partially taken from examples of qt4.2 libraries (gpl licensed)*/ /** add comments here */ AttalSprite::AttalSprite( QList * animation,QGraphicsScene *scene) : QObject(), QGraphicsItem(0, scene), currentFrame(0), frames(animation), vx(0), vy(0) { _animated = false; //_timer = 0; //_period = 10; //_phase = 0; //_isAdv = false; } AttalSprite::~AttalSprite() { /* if( _timer ) { killTimer(_timer); _timer = 0; } */ } void AttalSprite::setFrame(int frame) { if (!frames->isEmpty()) { prepareGeometryChange(); currentFrame = frame % frames->size(); } } void AttalSprite::advance(int phase) { if( _animated ) { if (phase == 1 && !frames->isEmpty()) { setFrame(currentFrame + 1); } } if (vx || vy) moveBy(vx, vy); } void AttalSprite::setSequence(QList * sequence) { frames = sequence; } void AttalSprite::setAnimated( bool animated ) { /* if( animated ) { _timer = startTimer( _period ); } else { if( _timer ) { killTimer(_timer); _timer = 0; } } */ _animated = animated; } //no more used , code used for sprite-based timer /* void AttalSprite::setAdvancePeriod( int period ) { _period = period; if( _timer && _animated ) { killTimer( _timer ); _timer = startTimer( _period ); } } void AttalSprite::timerEvent(QTimerEvent *event) { if( !_isAdv) { _isAdv = true; if( _phase == 0 ) { _phase = 1; } else { _phase = 0; } advance( _phase ); _isAdv = false; } } */ QRectF AttalSprite::boundingRect() const { return QRectF(QPointF( 0 , 0 ) , frames->at(currentFrame).size() ); } void AttalSprite::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { painter->setClipRect( option->exposedRect ); painter->drawPixmap(0, 0, frames->at(currentFrame)); } attal-src-1.0-rc2/libClient/attalSprite.h0000644000175000017500000000522310771665466016052 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalSprite.h ** class to implement animations ** ** Version : $Id: attalSprite.h,v 1.10 2008/03/24 08:49:58 lusum Exp $ ** ** Author(s) : Sardi Carlo ** ** Date : 28/08/2006 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ATTALSPRITE_H #define ATTALSPRITE_H // generic include files // include files for QT #include #include // application specific include files /* ------------------------------ * AttalSprite * ------------------------------ */ /* taken from examples of qt4.2 libraries (gpl licensed)*/ /** comment for the class */ class AttalSprite: public QObject, public QGraphicsItem { Q_OBJECT public: /** Constructor */ AttalSprite( QList * animation, QGraphicsScene *scene = 0); /** Destructor */ ~AttalSprite(); inline void setVelocity(qreal xvel, qreal yvel) { vx = xvel; vy = yvel; } inline qreal xVelocity() const { return vx; } void setAnimated( bool animated ); //void setAdvancePeriod( int period ); bool animated() { return _animated; } QPixmap image() { return frames->at(currentFrame); } QPixmap image( int numFrame ) { return frames->at(numFrame); } inline qreal yVelocity() const { return vy; } virtual void advance(int phase); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); QRectF boundingRect() const; protected: void setFrame(int frame); inline int frame() const { return currentFrame; } inline int frameCount() const { return frames->size(); } inline QPixmap image(int frame) const { return frames->isEmpty() ? QPixmap() : frames->at(frame % frames->size()); } void setImage(QPixmap pixmap, int frame) const { frames->replace(frame % frames->size(), pixmap); } void setSequence(QList * sequence); //void timerEvent(QTimerEvent *event); private: int currentFrame; qreal vx, vy; bool _animated; QList * frames; //bool _isAdv; //int _timer, _period, _phase; }; #endif // ATTALSPRITE_H attal-src-1.0-rc2/libClient/attalStyle.cpp0000644000175000017500000002273710760357523016236 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalStyle.cpp ** Manages style of client ** ** Version : $Id: attalStyle.cpp,v 1.11 2008/02/24 21:19:15 lusum Exp $ ** ** Author(s) : Cyrille Verrier - Pascal Audoux ** ** Date : 17/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "attalStyle.h" // generic include files #include // include files for QT #include #include #include #include #include // for now #include #include #include #include #include #include #include #include #include #include #include #include // application specific include #include "conf.h" #include "libCommon/log.h" #include "libClient/attalButton.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" extern QString IMAGE_PATH; AttalStyle::AttalStyle( const QString & colorFile ) : QWindowsStyle() { init( colorFile ); } bool AttalStyle::init( const QString & colorFile ) { QFile f( colorFile ); if (! f.open(QIODevice::ReadOnly) ) { logEE("Could not open file %s for reading\n", colorFile.toLatin1().constData() ); return false; } QTextStream ts( &f ); if( ts.atEnd() ) { return false; } int colR, colG, colB; ts >> colR; ts >> colG; ts >> colB; _textColor.setRgb( colR, colG, colB ); ts >> colR; ts >> colG; ts >> colB; _buttonColor.setRgb( colR, colG, colB ); ts >> colR; ts >> colG; ts >> colB; _borderColor.setRgb( colR, colG, colB ); f.close(); backgroundImage = QPixmap( IMAGE_PATH + "misc/background.png" ); return true; } void AttalStyle::polish( QPalette & palette ) { QColor brown(212, 140, 95); QColor beige(236, 182, 120); QColor slightlyOpaqueBlack(0, 0, 0, 63); palette = QPalette(brown); palette.setBrush( QPalette::BrightText, Qt::white); palette.setBrush( QPalette::Base, beige); palette.setBrush( QPalette::AlternateBase, Qt::green ); /// XXX: it is a test... palette.setBrush( QPalette::Highlight, Qt::darkGray ); /// XXX: to improve palette.setBrush( QPalette::Button, QBrush( brown, backgroundImage ) ); palette.setBrush( QPalette::Text, _textColor ); // color in entry widget (lineedit, checkbox...) palette.setBrush( QPalette::ButtonText, _buttonColor ); // color in buttons palette.setBrush( QPalette::WindowText, _buttonColor ); // color in labels, checkbox label //palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush); //setTexture( palette, QPalette::Foreground, backgroundImage); setTexture( palette, QPalette::Background, backgroundImage); QBrush brush = palette.background(); brush.setColor( brush.color().dark() ); palette.setBrush(QPalette::Disabled, QPalette::Foreground, brush); palette.setBrush(QPalette::Disabled, QPalette::Text, brush); palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush); palette.setBrush(QPalette::Disabled, QPalette::Base, brush); palette.setBrush(QPalette::Disabled, QPalette::Button, brush); palette.setBrush(QPalette::Disabled, QPalette::Mid, brush); } void AttalStyle::setTexture( QPalette & palette, QPalette::ColorRole role, const QPixmap & pixmap ) { for( int i = 0; i < QPalette::NColorGroups; ++i ) { QColor color = palette.brush(QPalette::ColorGroup(i), role).color(); palette.setBrush(QPalette::ColorGroup(i), role, QBrush(color, pixmap)); } } void AttalStyle::polish( QWidget * w ) { // the polish function sets some widgets to transparent mode and // some to translate background mode in order to get the full // benefit from the nice pixmaps in the color group. if (w->inherits("QTipLabel") || w->inherits("QLCDNumber") ){ return; } if ( ! w->isTopLevel() ) { if ( w->inherits("QPushButton") || w->inherits("QToolButton") || w->inherits("QGroupBox") || w->inherits("QTabWidget") || w->inherits("QComboBox") ) { /// XXX: no more in q4 ? w->setAutoMask( TRUE ); return; } /* if( w->inherits("QLabel") || w->inherits("QButton") ) { //w->setBackgroundOrigin( QWidget::ParentOrigin ); } */ } } void AttalStyle::unPolish( QWidget * w ) { // the polish function sets some widgets to transparent mode and // some to translate background mode in order to get the full // benefit from the nice pixmaps in the color group. if (w->inherits("QTipLabel") || w->inherits("QLCDNumber") ){ return; } if ( !w->isTopLevel() ) { if ( w->inherits("QPushButton") || w->inherits("QToolButton") || w->inherits("QGroupBox") || w->inherits("QTabWidget") || w->inherits("QComboBox") ) { /// XXX: no more in q4 ? w->setAutoMask( FALSE ); return; } /* if (w->inherits("QLabel") || w->inherits("QButton") ) { w->setBackgroundOrigin( QWidget::WidgetOrigin ); } */ } } /* function not used cause without this the graphic seem more faster otherwise is the 'right' method to handle controls for qt, so for future use i will leave this one function (that work, btw) */ /* void AttalStyle::drawControl(ControlElement element, const QStyleOption *option,QPainter *painter,const QWidget *widget) const { switch (element) { case CE_PushButton: { QStyleOptionButton myButtonOption; const QStyleOptionButton *buttonOption = qstyleoption_cast(option); myButtonOption = *buttonOption; QColor brown(212, 140, 95); QColor beige(236, 182, 120); QColor slightlyOpaqueBlack(0, 0, 0, 63); QPixmap backgroundImage( IMAGE_PATH + "misc/background.png" ); myButtonOption.palette = QPalette(brown); myButtonOption.palette.setBrush( QPalette::BrightText, Qt::white); myButtonOption.palette.setBrush( QPalette::Base, beige); myButtonOption.palette.setBrush( QPalette::Window, beige); myButtonOption.palette.setBrush( QPalette::AlternateBase, Qt::green ); /// XXX: it is a test... myButtonOption.palette.setBrush( QPalette::Highlight, Qt::darkGray ); /// XXX: to improve myButtonOption.palette.setBrush( QPalette::Button, QBrush( brown, backgroundImage ) ); myButtonOption.palette.setBrush( QPalette::Text, Qt::yellow ); // color in entry widget (lineedit, checkbox...) myButtonOption.palette.setBrush( QPalette::ButtonText, Qt::yellow ); // color in buttons myButtonOption.palette.setBrush( QPalette::WindowText, Qt::yellow ); // color in labels, checkbox label for( int i = 0; i < QPalette::NColorGroups; ++i ) { QColor color = myButtonOption.palette.brush(QPalette::ColorGroup(i), QPalette::Background).color(); myButtonOption.palette.setBrush(QPalette::ColorGroup(i), QPalette::Background, QBrush(color, backgroundImage)); } QBrush brush = myButtonOption.palette.background(); brush.setColor( brush.color().dark() ); myButtonOption.palette.setBrush(QPalette::Disabled, QPalette::Foreground, brush); myButtonOption.palette.setBrush(QPalette::Disabled, QPalette::Text, brush); myButtonOption.palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush); myButtonOption.palette.setBrush(QPalette::Disabled, QPalette::Base, brush); myButtonOption.palette.setBrush(QPalette::Disabled, QPalette::Button, brush); myButtonOption.palette.setBrush(QPalette::Disabled, QPalette::Mid, brush); QWindowsStyle::drawControl(element, &myButtonOption, painter, widget); } break; default: QWindowsStyle::drawControl(element, option, painter, widget); } } */ static inline int buttonthickness( int d ) { return d > 20 ? 5 : ( d < 10 ? 2: 3 ); } // // ----- TestAttalStyle ----- // TestAttalStyle::TestAttalStyle() : QDialog( 0 ) { QPushButton * pb = new QPushButton( this ); pb->setText( "test pushbutton" ); FIXEDSIZE( pb ); QPushButton * pbDisabled = new QPushButton( this ); pbDisabled->setText( "test pushbutton disabled" ); pbDisabled->setEnabled( false ); FIXEDSIZE( pbDisabled ); QLabel * lab = new QLabel( "test label", this ); FIXEDSIZE( lab ); QLineEdit * le = new QLineEdit( this ); FIXEDSIZE( le ); QCheckBox * cb = new QCheckBox( this ); cb->setText( "Checkbox" ); FIXEDSIZE( cb ); QPushButton * pbImage = new QPushButton( this ); pbImage->setFixedSize( 52, 42 ); pbImage->setIconSize( ImageTheme.getLordSmallPixmap( 5 )->size() ); pbImage->setIcon( * ImageTheme.getLordSmallPixmap( 5 ) ); AttalButton * butLord = new AttalButton( this, AttalButton::BT_LORD ); butLord->setLord( 5 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->addWidget( pb ); layout->addWidget( pbDisabled ); layout->addWidget( lab ); layout->addWidget( le ); layout->addWidget( cb ); layout->addWidget( pbImage ); layout->addWidget( butLord ); layout->activate(); } attal-src-1.0-rc2/libClient/attalStyle.h0000644000175000017500000000351610760357524015676 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalStyle.h ** Manages style of client ** ** Version : $Id: attalStyle.h,v 1.5 2008/02/24 21:19:16 lusum Exp $ ** ** Author(s) : Cyrille Verrier - Pascal Audoux ** ** Date : 17/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ATTALSTYLE_H #define ATTALSTYLE_H // generic include files // include files for QT #include #include #include #include // application specific include class QPushButton; /** Attal style (depends also of theme) */ class AttalStyle : public QWindowsStyle { public: AttalStyle( const QString & colorFile ); virtual void polish( QPalette & palette ); virtual void polish( QWidget * widget ); virtual void unPolish( QWidget * widget ); /* do not cancel, see motivations in cpp file */ //void drawControl(ControlElement element, const QStyleOption *option,QPainter *painter,const QWidget *widget) const; private: bool init( const QString & colorFile ); void setTexture( QPalette & palette, QPalette::ColorRole role, const QPixmap & pixmap ); QColor _textColor; QColor _buttonColor; QColor _borderColor; QPixmap backgroundImage; }; class TestAttalStyle : public QDialog { public: TestAttalStyle(); }; #endif // ATTALSTYLE_H attal-src-1.0-rc2/libClient/bonus.cpp0000644000175000017500000000331710621643651015223 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** bonus.cpp ** Displays bonus on map ** ** Version : $Id: bonus.cpp,v 1.9 2007/05/13 17:15:21 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 29/08/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "bonus.h" // generic include files // include files for QT // application specific include files #include "conf.h" #include "libCommon/genericCell.h" #include "libCommon/log.h" #include "libClient/imageTheme.h" #include "libClient/lord.h" const int Bonus::RTTI = Type; Bonus::Bonus( QGraphicsScene * canvas ) :AttalSprite( ImageTheme.bonus[0], canvas ) { setFrame( 0 ); setZValue( CAN_ARTEFACT ); } void Bonus::setCell( GenericCell * cell ) { TRACE("Bonus::setCell"); setPos( cell->getCol() * DataTheme.tiles.getWidth() , ( cell->getRow() + 1 ) * DataTheme.tiles.getHeight() - boundingRect().height() ); } void Bonus::setupBonus() { setFrame( 0 ); setSequence( ImageTheme.bonus[ (uint)_type ] ); if( _type == BonusResource ) { setFrame( getParam( 0 ) ); } } int Bonus::type() const { // Enable the use of qgraphicsitem_cast with this item. return Type; } attal-src-1.0-rc2/libClient/bonus.h0000644000175000017500000000272010510250452014653 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** bonus.h ** Displays bonus on map ** ** Version : $Id: bonus.h,v 1.5 2006/10/02 17:49:30 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 29/08/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef BONUS_H #define BONUS_H // generic include files // include files for QT // application specific include files #include "libCommon/genericBonus.h" #include "libClient/attalSprite.h" class GenericCell; /* ------------------------------ * Bonus * ------------------------------ */ class Bonus : public AttalSprite, public GenericBonus { public: /** Constructor */ Bonus( QGraphicsScene * canvas ); enum { Type = QGraphicsItem::UserType + 1008 }; void setCell( GenericCell * cell ); void setupBonus(); static const int RTTI; int type() const; }; #endif // BONUS_H attal-src-1.0-rc2/libClient/building.cpp0000644000175000017500000000667110760367734015711 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** building.cpp ** manages building ** ** Version : $Id: building.cpp,v 1.11 2008/02/24 22:29:48 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 26/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "building.h" // generic include files // include files for QT #include // application specific include #include "libCommon/genericPlayer.h" #include "libClient/displayBase.h" #include "libClient/map.h" // // ----- Base ----- // Base::Base( Map * map, int race ) : GraphicalBase( map ), GenericBase( race ) { // internal comments _map = map; GraphicalBase::setRace( race ); } void Base::setPosition( GenericCell * cell ) { setPosition( cell->getRow(), cell->getCol() ); } void Base::setPosition( int row, int col ) { GenericBase::setPosition( (GenericCell *)_map->at( row, col ) ); // dispositions start from top/left, starting with index 0, cell start from bottom/right // so getDoorCol() is the orizontal offset, orizontal offset is dispoHeight - doorRow GraphicalBase::setPosition( (GenericCell *)_map->at( row, col ), ( getDoorRow()-getDispoHeight() + 1 ), ( - getDoorCol() ) ); //_map->at( row, col )->setBase( this ); } void Base::enter( GenericLord * lord ) { GenericBase::enter( lord ); TRACE("Base::enter You are in a castle, lord %p", lord ); } void Base::setRace( int race ) { GenericBase::setRace( race ); GraphicalBase::setRace( race ); } void Base::setOwner( GenericPlayer * player ) { GenericBase::setOwner( player ); GraphicalBase::setOwner( player ); } // // ----- Building ----- // Building::Building( QGraphicsScene * canvas , int type ) : GraphicalBuilding( canvas ), GenericBuilding( type ) { //setFrame( 0 ); //setAnimation( GenericBuilding::getNbFrame(), GenericBuilding::getAnimFreq() ); GraphicalBuilding::setType( type ); setAnimation( GenericBuilding::getNbFrame(), GenericBuilding::getAnimFreq() ); } void Building::setPosition( GenericCell * cell ) { GenericBuilding::setPosition( cell ); // dispositions start from top/left, starting with index 0, cell start from top/left // so - getDoorCol() is the orizontal offset, vertical offset is dispoHeight + 1 - doorRow TRACE("void Building::setPosition( GenericCell * cell ) row %d, cell col %d, getDoorRow %d, getDispoHeight %d, getDispoWidth %d, getDoorCol %d",cell->getRow(), cell->getCol(), getDoorRow(), getDispoHeight(), getDispoWidth(), getDoorCol()); GraphicalBuilding::setPosition( cell , ( getDispoHeight()-1 - getDoorRow() ), - getDoorCol() ); //cell->setBuilding( this ); } void Building::setType( int type ) { GenericBuilding::setType( type ); GraphicalBuilding::setType( type ); setAnimation( GenericBuilding::getNbFrame(), GenericBuilding::getAnimFreq() ); } void Building::setOwner( GenericPlayer * player ) { GenericBuilding::setOwner( player ); GraphicalBuilding::setOwner( player ); } attal-src-1.0-rc2/libClient/building.h0000644000175000017500000000443410751372502015336 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** building.h ** manages buildings... ** ** Version : $Id: building.h,v 1.7 2008/02/03 17:09:22 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef BUILDING_H #define BUILDING_H // generic include files // include files for QT #include // application specific include files #include "libCommon/genericBuilding.h" #include "libCommon/genericBase.h" #include "libClient/graphicalBuilding.h" class GenericPlayer; class Map; /* ------------------------------ * Building * ------------------------------ */ class Base : public GraphicalBase, public GenericBase { public: /** Construtor */ Base( Map * map, int race = 0 ); /** Initialises the building position */ void setPosition( GenericCell * cell ); /** Initialises the building position */ void setPosition( int row, int col ); /** The lord enters in the base */ void enter( GenericLord * lord ); /** Sets the race of the base */ void setRace( int race ); virtual void setOwner( GenericPlayer * player ); protected: Map * _map; }; /** Manage building in client side (on the map) */ class Building : public GraphicalBuilding, public GenericBuilding { public: /** Constructor */ Building( QGraphicsScene * canvas, int type = 0 ); /** initialises the building position */ void setPosition( GenericCell * cell ); bool load( QTextStream * ) { return true; } void enter( GenericLord * ) {} void out( GenericLord * ) {} /** Sets type of building */ void setType( int type ); virtual void setOwner( GenericPlayer * player ); }; #endif // BUILDING_H attal-src-1.0-rc2/libClient/cell.cpp0000644000175000017500000000273510525423231015010 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** cell.cpp ** ** Version : $Id: cell.cpp,v 1.12 2006/11/11 19:38:01 fdarling Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "cell.h" // generic include files #include // include files for QT // application specific includes #include "libCommon/log.h" /** Constructor : some initializations */ Cell::Cell( int row , int col , QGraphicsScene * canvas ) : GraphicalCell( row, col ,canvas ), GenericCell( row, col ) { _decorationCell = 0; } Cell::~Cell() { delete _decorationCell; } void Cell::setDecoration( uint group, uint item ) { GenericCell::setDecoration( group, item ); delete _decorationCell; _decorationCell = NULL; if( group ) { _decorationCell = new Decoration( this, scene() ); _decorationCell->setDecoration( group, item ); } } attal-src-1.0-rc2/libClient/cell.h0000644000175000017500000000274410525423231014455 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** cell.h ** ** Version : $Id: cell.h,v 1.9 2006/11/11 19:38:01 fdarling Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CELL_H #define CELL_H // generic include files // include files for QT // application specific includes #include "libCommon/genericCell.h" #include "libClient/graphicalCell.h" /* ------------------------------ * Cell * ------------------------------ */ /** comment for the class */ class Cell : public GraphicalCell , public GenericCell { public: /** Construtor */ Cell( int row, int col, QGraphicsScene * canvas ); /** Destructor */ ~Cell(); /** Add a decoration to the cell */ void setDecoration( uint group, uint item ); private: Decoration * _decorationCell; }; #endif // CELL_H attal-src-1.0-rc2/libClient/chatWidget.cpp0000644000175000017500000000537211002651052016147 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** chatWidget.cpp ** Widget for chat between players ** ** Version : $Id: chatWidget.cpp,v 1.10 2008/04/20 14:24:42 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 13/03/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "chatWidget.h" // generic include files // include files for QT #include #include // application specific include files #include "libCommon/log.h" // // ----- ChatWidget ----- // ChatWidget::ChatWidget( QWidget * parent, const char * /* name */ ) : QWidget( parent ) { _chat = new ChatLineEdit( this ); _chat->setReadOnly( true ); _edit = new QLineEdit( this ); _edit->setMinimumHeight( _edit->sizeHint().height() ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( _chat ); layout->addSpacing( 1 ); layout->addWidget( _edit ); layout->activate(); connect( _edit, SIGNAL( returnPressed() ), SLOT( slot_message() ) ); connect( parent , SIGNAL( sig_newMessage( QString ) ), SLOT( slot_displayMessage( QString ) ) ); setMinimumHeight( 40 ); } void ChatWidget::clear() { _edit->clear(); _chat->clear(); } void ChatWidget::slot_message() { emit sig_message( _edit->text() ); _edit->clear(); } void ChatWidget::slot_displayMessage( QString msg ) { _chat->append( msg ); /// XXX: usefull ? _chat->setCursorPosition( _chat->numLines(), 0 ); } // // ----- ChatLineEdit ----- // ChatLineEdit::ChatLineEdit( QWidget * parent, const char * /* name */) : QTextEdit( parent ) { } QMenu * ChatLineEdit::createPopupMenu( const QPoint & /* pos */ ) { QMenu * ret = createStandardContextMenu(); ret->addAction( "Clear", this, SLOT( clear() ) ); return ret; } // // ----- ChatDialog ----- // ChatDialog::ChatDialog() : QDialog( 0, Qt::Dialog ) { _edit = new QLineEdit( this ); _edit->setMinimumHeight( _edit->sizeHint().height() ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( _edit ); layout->activate(); connect( _edit, SIGNAL( returnPressed() ), SLOT( slot_message() ) ); setMinimumHeight( 20 ); } void ChatDialog::clear() { _edit->clear(); } void ChatDialog::slot_message() { emit sig_message( _edit->text() ); _edit->clear(); } attal-src-1.0-rc2/libClient/chatWidget.h0000644000175000017500000000443510664305124015624 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** chatWidget.h ** Widget for chat between players ** ** Version : $Id: chatWidget.h,v 1.5 2007/08/26 14:12:36 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 13/03/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CHATWIDGET_H #define CHATWIDGET_H // generic include files // include files for QT #include #include #include #include // application specific include files class QMenu; class ChatLineEdit; /* ------------------------------ * ChatWidget * ------------------------------ */ /// XXX: Don't works perfeectly class ChatWidget : public QWidget { Q_OBJECT public: /** Constructor */ ChatWidget( QWidget * parent = 0, const char * name = 0 ); /** Clear chat log */ void clear(); public slots: /** A new message to send */ void slot_message(); /** A new message to display */ void slot_displayMessage( QString ); signals: void sig_message( QString msg ); private: QLineEdit * _edit; ChatLineEdit * _chat; }; /* ------------------------------ * ChatDialog * ------------------------------ */ class ChatDialog : public QDialog { Q_OBJECT public: /** Constructor */ ChatDialog(); /** Clear chat log */ void clear(); public slots: /** A new message to send */ void slot_message(); signals: void sig_message( QString msg ); private: QLineEdit * _edit; }; /** */ class ChatLineEdit : public QTextEdit { public: /** constructor */ ChatLineEdit( QWidget * parent = 0, const char * name = 0 ); protected: QMenu * createPopupMenu( const QPoint & pos ); }; #endif // CHATWIDGET_H attal-src-1.0-rc2/libClient/chest.cpp0000644000175000017500000000330310621643651015176 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** chest.cpp ** Displays chests on map ** ** Version : $Id: chest.cpp,v 1.8 2007/05/13 17:15:21 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 29/08/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "chest.h" // generic include files // include files for QT // application specific include files // generic include files // include files for QT // application specific include files #include "conf.h" #include "libCommon/genericCell.h" #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libClient/imageTheme.h" #include "libClient/lord.h" const int Chest::RTTI = Type; Chest::Chest( QGraphicsScene * canvas ) :AttalSprite( ImageTheme.chest, canvas ) { setFrame( 0 ); setZValue( CAN_ARTEFACT ); } void Chest::setCell( GenericCell * cell ) { TRACE("Chest::setCell"); setPos( cell->getCol() * DataTheme.tiles.getWidth() , (cell->getRow() + 1) * DataTheme.tiles.getHeight() - boundingRect().height() ); } void Chest::setupChest() { } int Chest::type() const { // Enable the use of qgraphicsitem_cast with this item. return Type; } attal-src-1.0-rc2/libClient/chest.h0000644000175000017500000000272610510250453014642 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** chest.h ** Displays chests on map ** ** Version : $Id: chest.h,v 1.3 2006/10/02 17:49:31 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 29/08/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CHEST_H #define CHEST_H // generic include files // include files for QT // application specific include files #include "libCommon/genericChest.h" #include "libClient/attalSprite.h" class GenericCell; /* ------------------------------ * Chest * ------------------------------ */ class Chest : public AttalSprite, public GenericChest { public: /** Constructor */ Chest( QGraphicsScene * canvas ); enum { Type = QGraphicsItem::UserType + 1009 }; void setCell( GenericCell * cell ); void setupChest(); static const int RTTI; int type() const; }; #endif // CHEST_H attal-src-1.0-rc2/libClient/displayArtefacts.cpp0000644000175000017500000001230010522705150017360 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayArtefacts.cpp ** Displays the artefacts of a lord ** ** Version : $Id: displayArtefacts.cpp,v 1.8 2006/11/03 18:28:56 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/12/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "displayArtefacts.h" // generic include files // include files for QT #include #include #include #include // application specific include files #include "libCommon/artefactManager.h" #include "libCommon/dataTheme.h" #include "libClient/graphicalArtefact.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/player.h" extern QString IMAGE_PATH; // // ----- DisplayArtefacts ----- // DisplayArtefacts::DisplayArtefacts( Player * player, QWidget * parent, const char * /* name */ ) : QFrame( parent ) { _player = player; _index = 0; uint i; QPalette palette; palette.setBrush(backgroundRole(), QBrush(QPixmap(IMAGE_PATH + "misc/artefactLord.png"))); setPalette(palette); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->addStretch( 1 ); QHBoxLayout * layH1 = new QHBoxLayout(); QPushButton * pb1 = new QPushButton( this ); pb1->setText( "<" ); FIXEDSIZE( pb1 ); layH1->addWidget( pb1 ); /// XXX : to remove cause use the old api for artefacts (no more used), leave it as example for a new /// function that match new api... /* /// WIN: was "_used = new (IconArtefact *) [DataTheme.specifications.getArtefactNumber()];" _used = new IconArtefact * [DataTheme.specifications.getArtefactNumber()]; SpecificationArtefact * temp; for( i = 0; i < DataTheme.specifications.getArtefactNumber(); i++ ) { temp = DataTheme.specifications.getArtefact( i ); //_used[i] = new IconArtefact( this ); //_used[i]->move( temp->getX(), temp->getY() ); } */ layH1->addStretch( 1 ); for( i = 0; i < 3; i++ ) { _ico[i] = new IconArtefact( this ); _ico[i]->clear(); layH1->addWidget( _ico[i] ); } layH1->addStretch( 1 ); QPushButton * pb2 = new QPushButton( this ); pb2->setText( ">" ); FIXEDSIZE( pb2 ); layH1->addWidget( pb2 ); layout->addLayout( layH1 ); layout->activate(); connect( pb1, SIGNAL( clicked() ), SLOT( slot_prevArtefact() ) ); connect( pb2, SIGNAL( clicked() ), SLOT( slot_nextArtefact() ) ); } DisplayArtefacts::~DisplayArtefacts() { } void DisplayArtefacts::reinit() { GenericLord * lord = _player->getSelectedLord(); if(lord){ for( int i = 0; i < 3; i++ ) { if( ( _index + i ) < lord->getArtefactManager()->getArtefactNumber() ) { _ico[i]->setType( lord->getArtefactManager()->getArtefact( _index + i )->getType() ); } else { _ico[i]->clear(); } } } } void DisplayArtefacts::slot_nextArtefact() { GenericLord * lord = _player->getSelectedLord(); if(lord){ if( _index + 3 < lord->getArtefactManager()->getArtefactNumber() ) { _index++; reinit(); } } } void DisplayArtefacts::slot_prevArtefact() { if( _index > 0 ) { _index--; reinit(); } } // // ----- DisplayLordTabArtefacts ----- // DisplayLordTabArtefacts::DisplayLordTabArtefacts( Player * player, QWidget * parent, const char * /* name */) : QWidget( parent ) { _player = player; _index = 0; uint i; QPushButton * pb1 = new QPushButton( this ); pb1->setText( "<" ); FIXEDSIZE( pb1 ); QPushButton * pb2 = new QPushButton( this ); pb2->setText( ">" ); FIXEDSIZE( pb2 ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pb1 ); for( i = 0; i < 4; i++ ) { _ico[i] = new IconArtefact( this ); _ico[i]->clear(); layH1->addWidget( _ico[i] ); } layH1->addWidget( pb2 ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layH1 ); layout->addStretch( 1 ); layout->activate(); connect( pb1, SIGNAL( clicked() ), SLOT( slot_prevArtefact() ) ); connect( pb2, SIGNAL( clicked() ), SLOT( slot_nextArtefact() ) ); } void DisplayLordTabArtefacts::reinit() { GenericLord * lord = _player->getSelectedLord(); if( lord ) { for( int i = 0; i < 4; i++ ) { if( ( _index + i ) < lord->getArtefactManager()->getArtefactNumber() ) { _ico[ i ]->setType( lord->getArtefactManager()->getArtefact( _index + i )->getType() ); } else { _ico[ i ]->clear(); } } } } void DisplayLordTabArtefacts::slot_nextArtefact() { GenericLord * lord = _player->getSelectedLord(); if(lord){ if( _index + 3 < lord->getArtefactManager()->getArtefactNumber() ) { _index++; reinit(); } } } void DisplayLordTabArtefacts::slot_prevArtefact() { if( _index > 0 ) { _index--; reinit(); } } attal-src-1.0-rc2/libClient/displayArtefacts.h0000644000175000017500000000414410345406733017044 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayArtefacts.h ** Displays the artefacts of a lord ** ** Version : $Id: displayArtefacts.h,v 1.5 2005/12/06 22:16:59 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/12/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef DISPLAYARTEFACTS_H #define DISPLAYARTEFACTS_H // generic include files // include files for QT #include // application specific include files #include "libClient/widget.h" class Player; /* ------------------------------ * DisplayArtefacts * ------------------------------ */ /** artefact information of the lord */ class DisplayArtefacts : public QFrame { Q_OBJECT public: /** Construtor */ DisplayArtefacts( Player * player, QWidget * parent = 0, const char * name = 0 ); /** Destructor */ ~DisplayArtefacts(); /** Reinit info displayed */ void reinit(); /** Update info displayed */ void reupdate() { reinit(); } public slots: void slot_nextArtefact(); void slot_prevArtefact(); private: Player * _player; IconArtefact * _ico[3]; uint _index; }; class DisplayLordTabArtefacts : public QWidget { Q_OBJECT public: /** Constructor */ DisplayLordTabArtefacts( Player * player, QWidget * parent = 0, const char * name = 0 ); /** Reinit info displayed */ void reinit(); public slots: void slot_nextArtefact(); void slot_prevArtefact(); protected: Player * _player; IconArtefact * _ico[ 4 ]; /// XXX TODO why 4... uint _index; }; #endif // DISPLAYARTEFACTS_H attal-src-1.0-rc2/libClient/displayBase.cpp0000644000175000017500000006054010770561476016347 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayBase.cpp ** inside the base ** ** Version : $Id: displayBase.cpp,v 1.75 2008/03/20 22:20:46 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 03/09/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "displayBase.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include #include // application specific include files #include "conf.h" #include "libCommon/attalSettings.h" #include "libCommon/attalSocket.h" #include "libCommon/attalTemplates.h" #include "libCommon/dataTheme.h" #include "libCommon/genericBuilding.h" #include "libCommon/genericLord.h" #include "libCommon/log.h" #include "libClient/attalButton.h" #include "libClient/displayCreature.h" #include "libClient/game.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/insideAction.h" #include "libClient/insideBase.h" #include "libClient/market.h" #include "libClient/tavern.h" #include "libClient/unitExchange.h" extern QString DATA_PATH; extern QString IMAGE_PATH; DisplayBase::DisplayBase( QWidget * parent, GenericBase * base, Game * game, AttalSocket * socket ) : QWidget( parent ) { _game = game; _socket = socket; _player = game->getGamePlayer(); _base = base; _allBuildings = NULL; _tavern = NULL; _inside = new InsideBase( this, _base ); _panel = new BaseRightPanel( this, _player, _base, _socket ); FIXEDSIZE( _panel ); _tabs = new QTabWidget( this ); _ressW = new TabRessourceWin( _tabs, RS_GRID, _player, _base->getResourceList()); _view = new InsideBaseView( _inside, _tabs ); _manageBuildings = new InsideActionAllBuildings( _tabs , _base, _player, _socket ); _manageCreatures = new DisplayCreatureBase( this, _base, _player, _socket ); _tabs->addTab( _view, tr( "View" ) ); _tabs->addTab( _manageBuildings, tr( "Buildings" ) ); _tabs->addTab( _manageCreatures, tr( "Creatures" ) ); _tabs->addTab( _ressW, tr( "Resources" ) ); _layVerticalView = NULL; _layout = new QHBoxLayout( this ); updateDispositionMode(); connect( _view, SIGNAL( sig_building( GenericInsideBuilding * ) ), SLOT( slot_building( GenericInsideBuilding * ) ) ); connect( _panel, SIGNAL( sig_quit() ), SIGNAL( sig_quit() ) ); //connect( _baseButtons, SIGNAL( sig_exchange() ), _baseLords, SLOT( slot_exchange() ) ); //connect( _baseLords, SIGNAL( sig_exchange( bool ) ), _baseButtons, SLOT( slot_exchange( bool ) ) ); } DisplayBase::~DisplayBase() { TRACE("~DisplayBase"); if( _allBuildings ) { delete _allBuildings; } if( _tavern ) { delete _tavern; _tavern = NULL; } delete _view; delete _inside; } void DisplayBase::reinit() { /// XXX:_baseSummary->reinit(); TRACE("DisplayBase::reinit"); _panel->reinit(); if( _allBuildings ) { _allBuildings->updateView(); } if( _manageBuildings ) { _manageBuildings->updateView(); } _ressW->reinit(); emit sig_castle(); } void DisplayBase::reinitBase() { _panel->reinit(); _inside->reinit(); updateDispositionMode(); } void DisplayBase::setSocket( AttalSocket * socket ) { _socket = socket; _panel->setSocket( socket ); } void DisplayBase::updateDispositionMode() { AttalSettings::DispositionMode mode = AttalSettings::getInstance()->getDispositionMode(); _layout->removeWidget( _panel ); if( _layVerticalView ) { _layout->removeItem( _layVerticalView ); delete _layVerticalView; } _layVerticalView = new QVBoxLayout(); switch( mode ) { case AttalSettings::DM_VERYCOMPACT: _tabs->setMinimumSize( 0, 0 ); _view->setMinimumSize( 0, 0 ); //_view->setMaximumSize( 960, 720 ); _view->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); _view->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); _layVerticalView->addWidget( _tabs, 1 ); break; case AttalSettings::DM_COMPACT: _tabs->setMinimumSize( 0, 0 ); _view->setMinimumSize( 0, 0 ); //_view->setMaximumSize( 960, 720 ); _view->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded ); _view->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded ); _layVerticalView->addWidget( _tabs, 1 ); break; case AttalSettings::DM_FULL: _tabs->setFixedSize( 960, 740 ); _view->setFixedSize( 960, 720 ); _view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); _view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); _layVerticalView->addWidget( _tabs ); //_layVerticalView->addStretch( 1 ); break; } _layout->addLayout( _layVerticalView, 1 ); _layout->addWidget( _panel ); _layout->activate(); } void DisplayBase::handleSocket() { if( _tavern ) { _tavern->handleSocket(); } _game->handleSocket(); _socket->reReadData(); switch( _socket->getCla1() ) { case SO_MSG: socketMsg(); break; case SO_GAME: break; case SO_TURN: break; case SO_MODIF: socketModif(); break; case SO_QR: break; case SO_MVT: break; case SO_TECHNIC: break; case SO_EXCH: break; case SO_CONNECT: break; case SO_FIGHT: break; default: logEE( "Unknown socket_class" ); } } void DisplayBase::socketMsg() { /*int cla2 =*/ _socket->getCla2(); QString msg; uchar len = _socket->readChar(); for( uint i = 0; i < len; i++ ) { msg[i] = _socket->readChar(); } _view->newMessage( msg ); } void DisplayBase::socketModif() { switch( _socket->getCla2() ) { case C_MOD_MAP: break; case C_MOD_CELL: break; case C_MOD_LORD: if( _socket->getCla3() == C_LORD_NEW ) { if( _tavern ) { _tavern->restart(); } reinit(); } break; case C_MOD_PLAYER: socketModifPlayer(); break; case C_MOD_BASE: socketModifBase(); break; case C_MOD_BUILD: break; case C_MOD_ARTEFACT: break; case C_MOD_CREATURE: break; case C_MOD_EVENT: break; default: break; } } void DisplayBase::socketModifPlayer() { switch( _socket->getCla3() ) { case C_PLAY_RESS: emit sig_resource(); reinit(); break; case C_PLAY_PRICE: break; default: break; } } void DisplayBase::socketModifBase() { switch( _socket->getCla3() ) { case C_BASE_NEW: break; case C_BASE_OWNER: break; case C_BASE_NAME: break; case C_BASE_BUILDING: socketModifBaseBuilding(); break; case C_BASE_RESS: socketModifBaseResources(); break; case C_BASE_UNIT: reinit(); break; case C_BASE_POPUL: break; case C_BASE_PRODUCTION: reinit(); emit sig_castle(); break; default: break; } } void DisplayBase::socketModifBaseBuilding() { int row = _socket->readInt(); int col = _socket->readInt(); uchar level = _socket->readChar(); bool create = (bool)_socket->readChar(); if( ( _base->getCell()->getRow() == row ) && ( _base->getCell()->getCol() == col ) ) { if( create ) { GenericInsideBuilding * building = _base->getBuildingByType( level ); _inside->addBuilding( building ); } else { _inside->delBuilding( level ); } } reinit(); } void DisplayBase::socketModifBaseResources() { int row = _socket->readInt(); int col = _socket->readInt(); TRACE("DisplayBase::socketModifBaseResources row %d, col %d", row,col ); socketModifRess( _base , _socket); emit sig_resource(); reinit(); } void DisplayBase::slot_message( QString msg ) { if( _socket ) { _socket->sendMessage( _player->getConnectionName() + " : " + msg ); } else { _view->newMessage( "(Not connected) : " + msg ); } } void DisplayBase::slot_building( GenericInsideBuilding * building ) { if( _base ) { InsideBuildingModel * model = DataTheme.bases.at( _base->getRace() )->getBuildingModel( building->getLevel() ); if( model->getAction() ) { switch( model->getAction()->getType() ) { case INSIDE_NONE: break; case INSIDE_VILLAGE: actionAllBuildings(); break; case INSIDE_CASTLE: actionAllCreatures(); break; case INSIDE_CREA: actionSomeCreatures( building ); break; case INSIDE_MARKET: actionMarket(); break; case INSIDE_TAVERN: actionTavern(); break; default: logEE( "Unknown action %d", model->getAction()->getType() ); break; } } } } void DisplayBase::actionAllBuildings() { if( ! _allBuildings ) { _allBuildings = new InsideActionAllBuildings( NULL, _base, _player, _socket ); } _allBuildings->exec(); reinit(); } void DisplayBase::actionAllCreatures() { DisplayCreatureBase creatures( this, _base, _player, _socket ); creatures.exec(); reinit(); } void DisplayBase::actionSomeCreatures( GenericInsideBuilding * building ) { if( _base ) { InsideAction * action = DataTheme.bases.at( _base->getRace() )->getBuildingModel( building->getLevel() )->getAction(); if( action ) { //InsideActionSomeCreature dialog( action->getParam( 0 ), action->getParam( 1 ) ); BuyCreature dialog( this ); dialog.initSocket( _socket ); int race = action->getParam( 0 ); int level = action->getParam( 1 ); dialog.init( _player, _base, DataTheme.creatures.at( race, level ) ); if( dialog.exec() ) { // try to buy some creature } } } reinit(); } void DisplayBase::actionMarket() { Market mark( this, _player, _socket ); mark.setPrices( _player->getPriceMarket()); mark.exec(); reinit(); } void DisplayBase::actionTavern() { if( !_tavern ) { _tavern = new Tavern( this ); _tavern->initSocket( _socket ); _tavern->initPlayer( _player ); } _tavern->start( _base ); reinit(); } void DisplayBase::setBase( GenericBase * base ) { _base = base; reinit(); } // // ----- BaseRightPanel ----- // BaseRightPanel::BaseRightPanel( QWidget * parent, Player * player, GenericBase * base , AttalSocket * socket) : QWidget( parent ) { TRACE("BaseRightPanel QWidget * parent %p, Player * player %p, GenericBase * base %p )", parent, player, base ); _socket = socket; _displayLords = 0; _player = player; _base = base; _pbLord = new AttalButton( this ); _pbLord->setFixedSize( 60, 60 ); /* _popul = new QLabel( this ); _popul->setAlignment( Qt::AlignHCenter ); _totPopul = new QLabel( this ); _totPopul->setAlignment( Qt::AlignHCenter ); */ _lordLabel = new QLabel( this ); _lordLabel->setText( "\n\n" ); _lordLabel->setAlignment( Qt::AlignLeft ); _lordLabel->setWordWrap( true ); _lordLabel->setMinimumWidth( 64 ); _lordLabel->setMinimumHeight( _lordLabel->sizeHint().height() ); _pbInfo = new QPushButton( this ); _pbInfo->setText( "Info" ); FIXEDSIZE( _pbInfo ); _ress = new RessourceWin(this,RS_VERT, player, _base->getResourceList()); //_bases = new BaseButtons( this ); /// XXX: use pixmap instead AttalButton * pbQuit = new AttalButton( this, AttalButton::BT_OK ); FIXEDSIZE( pbQuit ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 10 ); layout->addWidget( _pbLord ); layout->addWidget( _lordLabel ); layout->addSpacing( 10 ); layout->addWidget( _pbInfo ); layout->addWidget( _ress ); //layout->addWidget( _popul, 0, Qt::AlignLeft ); //layout->addWidget( _totPopul, 0, Qt::AlignLeft ); layout->addStretch( 1 ); layout->addWidget( pbQuit ); layout->addStretch( 1 ); //XXX useless now //layout->addWidget( _bases ); reinit(); layout->activate(); connect( pbQuit, SIGNAL( clicked() ), SIGNAL( sig_quit() ) ); connect( _pbLord, SIGNAL( clicked() ), SLOT( slot_lords() ) ); connect( _pbInfo, SIGNAL( clicked() ), SLOT( slot_info() ) ); } void BaseRightPanel::slot_lords() { _displayLords = new DisplayBaseLord( this , _player, _base, _socket ); _displayLords->exec(); reinit(); delete _displayLords; _displayLords = 0; } void BaseRightPanel::slot_info() { DisplayBaseInfo displayInfo( this , _player, _base ); displayInfo.exec(); } void BaseRightPanel::setSocket( AttalSocket * socket ) { _socket = socket; } void BaseRightPanel::reinit() { GenericLord * lord = 0; QString text; text = "\nNo lord\n"; if( _base->getGarrisonLord() ) { lord = _base->getGarrisonLord(); text.sprintf( "Lord\n%s\n(Guarrison)", lord->getName().toLatin1().constData() ); } else if( _base->getVisitorLord() ) { lord = _base->getVisitorLord(); text.sprintf( "Lord\n%s\n(Visitor)", lord->getName().toLatin1().constData() ); } if( lord ) { _pbLord->setPixmap( * _player->getLordPixmapById( lord->getId() ) ); } else { /// XXX: should be optimized in imageTheme _pbLord->setPixmap( QPixmap( IMAGE_PATH + "/lords/noLord.png" ) ); } _lordLabel->setText( text ); if( _displayLords ) { _displayLords->reinit(); } _ress->reinit(); //_popul->setText( QString(" Base Pop \n%1 ").arg( _base->getPopulation() ) ); //FIXEDSIZE( _popul ); //_totPopul->setText( QString(" Total Pop \n%1 ").arg( _player->getPopulation() ) ); } // // ----- BaseSummary ----- // BaseSummary::BaseSummary( QWidget * parent, Player * player , GenericBase * base ) : QWidget( parent ) { _player = player; _base = base; //int i; //QHBoxLayout * lay1 = new QHBoxLayout(); //lay1->addWidget( new QLabel( tr("Population") + QString(":") ), 0, Qt::AlignLeft ); //lay1->addWidget( _popul = new QLabel( this ), 0, Qt::AlignRight ); _ress = new RessourceWin( this, RS_GRID, player , _base->getResourceList()); // XXX: TODO /*QHBoxLayout * lay2 = new QHBoxLayout(); lay2->addStretch( 1 ); for( i = 0; i < 4; i++ ) { _unitIco[i] = new UnitSummary( this ); lay2->addWidget( _unitIco[i] ); lay2->addStretch( 1 ); } QHBoxLayout * lay3 = new QHBoxLayout(); lay3->addStretch( 1 ); for( i = 0; i < 4; i++ ) { _unitIco[4+i] = new UnitSummary( this ); lay3->addWidget( _unitIco[4+i] ); lay3->addStretch( 1 ); }*/ reinit(); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( _ress ); layout->addStretch( 2 ); //layout->addLayout( lay1 ); //layout->addLayout( lay2 ); //layout->addLayout( lay3 ); //layout->addStretch( 1 ); layout->activate(); } void BaseSummary::reinit() { _ress->reinit(); //_popul->setText( QString::number( _base->getPopulation() ) ); } // // ----- DisplayBaseInfo ----- // DisplayBaseInfo::DisplayBaseInfo( QWidget * parent, Player * player , GenericBase * base ) : QDialog( parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint ) { setWindowTitle( tr( "Base Information" ) ); _widget = new BaseSummary( this, player, base ); AttalButton * pbOk = new AttalButton( this, AttalButton::BT_OK ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addWidget( _widget );; layout->addWidget( pbOk, 0, Qt::AlignHCenter ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); } void DisplayBaseInfo::reinit() { _widget->reinit(); } // // ----- BaseLords ----- // BaseLords::BaseLords( QWidget * parent) : QWidget( parent ) { _base = 0; _isExchange = false; _socket = 0; setFixedHeight( 240 ); QVBoxLayout * layout = new QVBoxLayout( this ); _garrison = new BaseTroop( true, this ); layout->addWidget( _garrison, 1 ); _visitor = new BaseTroop( false, this ); layout->addWidget( _visitor, 1 ); layout->activate(); connect( _garrison, SIGNAL( sig_photo() ), SLOT( slot_photoGarrison() ) ); connect( _garrison, SIGNAL( sig_unit( int ) ), SLOT( slot_unitGarrison( int ) ) ); connect( _visitor, SIGNAL( sig_photo() ), SLOT( slot_photoVisitor() ) ); connect( _visitor, SIGNAL( sig_unit( int ) ), SLOT( slot_unitVisitor( int ) ) ); _garrisonSelected = false; _visitorSelected = false; _unitGarrison = -1; _unitVisitor = -1; } void BaseLords::setPlayer( Player * player ) { _player = player; _garrison->setPlayer( player ); _visitor->setPlayer( player ); } void BaseLords::setBase( GenericBase * base ) { _base = base; _garrison->setBase( base ); _visitor->setBase( base ); _garrisonSelected = false; _visitorSelected = false; } void BaseLords::reinit() { _garrison->reinit(); _visitor->reinit(); } void BaseLords::slot_exchange() { _isExchange = !_isExchange; } void BaseLords::slot_photoGarrison() { unselectUnits(); if( _garrisonSelected ) { /// XXX: show info lord _garrisonSelected = false; } else { if( _visitorSelected ) { exchangeLords(); } else if( _base->isGarrisonLord() ) { _garrisonSelected = true; } } } void BaseLords::slot_photoVisitor() { unselectUnits(); if( _visitorSelected ) { /// XXX: show info lord _visitorSelected = false; } else { if( _garrisonSelected ) { exchangeLords(); } else if( _base->isVisitorLord() ) { _visitorSelected = true; } } } void BaseLords::exchangeLords() { _garrisonSelected = false; _visitorSelected = false; _base->exchangeLords(); GenericLord * visitor = _base->getVisitorLord(); _visitor->setLord( visitor ); if( visitor ) { _socket->sendLordGarrison( visitor, false ); } GenericLord * garrison = _base->getGarrisonLord(); _garrison->setLord( garrison ); if( garrison ) { _socket->sendLordGarrison( garrison, true ); } } void BaseLords::exchangeUnitsGV() { GenericLord * garrison = _base->getGarrisonLord(); GenericLord * visitor = _base->getVisitorLord(); if(visitor){ if(garrison){ _socket->sendExchangeUnit( garrison, _unitGarrison, visitor, _unitVisitor ); } else { _socket->sendExchangeBaseUnit( _base, _unitGarrison, visitor, _unitVisitor ); } } _garrison->reinit(); _visitor->reinit(); } void BaseLords::exchangeUnitsVG() { GenericLord * garrison = _base->getGarrisonLord(); GenericLord * visitor = _base->getVisitorLord(); if(garrison){ _socket->sendExchangeUnit( visitor, _unitVisitor, garrison, _unitGarrison ); } else { _socket->sendExchangeBaseUnit( _base, _unitGarrison, visitor, _unitVisitor ); } _garrison->reinit(); _visitor->reinit(); } void BaseLords::exchangeUnitsGG( int u1, int u2 ) { if( u1 == u2 ) { return; } GenericLord * garrison = _base->getGarrisonLord(); if(garrison){ _socket->sendExchangeUnit( garrison, u1, garrison, u2 ); } else { _socket->sendExchangeBaseUnit( _base, u1, 0, u2 ); } _garrison->reinit(); } void BaseLords::exchangeUnitsVV( int u1, int u2 ) { if( u1 == u2 ) { return; } GenericLord * visitor = _base->getVisitorLord(); _socket->sendExchangeUnit( visitor, u1, visitor, u2 ); _visitor->reinit(); } void BaseLords::slot_unitGarrison( int num ) { unselectPhoto(); if( _isExchange ) { if( _unitGarrison != -1 ) { } else { } } else { if( ( _unitGarrison != -1 ) || ( _unitVisitor != -1 ) ) { if( _unitGarrison != -1 ) { exchangeUnitsGG( _unitGarrison, num ); } else { _unitGarrison = num; exchangeUnitsVG(); } unselectUnits(); } else { if( _base->getGarrisonUnit( num ) != 0 ) { _unitGarrison = num; _garrison->selectUnit( _unitGarrison ); emit sig_exchange( true ); } } } } void BaseLords::slot_unitVisitor( int num ) { unselectPhoto(); if( _isExchange ) { } else { if( ( _unitGarrison != -1 ) || ( _unitVisitor != -1 ) ) { if( _unitVisitor != -1 ) { exchangeUnitsVV( _unitVisitor, num ); } else { _unitVisitor = num; exchangeUnitsGV(); } unselectUnits(); } else { if( _base->getVisitorUnit( num ) != 0 ) { _unitVisitor = num; _visitor->selectUnit( _unitVisitor ); emit sig_exchange( true ); } } } } void BaseLords::unselectUnits() { _unitGarrison = -1; _garrison->unselectUnits(); _unitVisitor = -1; _visitor->unselectUnits(); emit sig_exchange( false ); } void BaseLords::unselectPhoto() { _garrisonSelected = false; _garrison->unselectPhoto(); _visitorSelected = false; _visitor->unselectPhoto(); } // // ----- DisplayBaseLord ----- // DisplayBaseLord::DisplayBaseLord( QWidget * parent, Player * player, GenericBase * base, AttalSocket * socket ) : QDialog( parent, Qt::Dialog ) { _widget = new BaseLords( this ); _widget->setPlayer( player ); _widget->setSocket( socket ); _widget->setBase( base ); AttalButton * pbOk = new AttalButton( this, AttalButton::BT_OK ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( _widget, 1 ); layout->addLayout( layH1 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); } void DisplayBaseLord::init( Player * player, GenericBase * base, AttalSocket * socket ) { _widget->setPlayer( player ); _widget->setSocket( socket ); _widget->setBase( base ); } void DisplayBaseLord::reinit() { _widget->reinit(); } // // ----- BaseButtons ----- // BaseButtons::BaseButtons( QWidget * parent, const char * /* name */ ) : QWidget( parent ) { QVBoxLayout * layout = new QVBoxLayout( this ); _pbExch = new QPushButton( this ); _pbExch->setFixedSize( 50, 40 ); layout->addWidget( _pbExch ); layout->addStretch( 1 ); layout->activate(); setFixedHeight( 240 ); _pbExch->setEnabled( false ); connect( _pbExch, SIGNAL( clicked() ), SIGNAL( sig_exchange() ) ); } void BaseButtons::slot_exchange( bool st ) { if( st ) { _pbExch->setEnabled( true ); } else { _pbExch->setEnabled( false ); } } // // ----- UnitSummary ----- // UnitSummary::UnitSummary( QWidget * parent, const char * /* name */ ) : QWidget( parent ) { _ico = new QLabel( this ); _ico->setFixedSize( 50, 40 ); _nb = new QLabel( this ); _nb->setFixedSize( 50, 20 ); _nb->setAlignment( Qt::AlignCenter ); _nb->move( 0, 40 ); setFixedSize( 50, 60 ); } void UnitSummary::setCreature( int /*id*/ ) { /// XXX: TODO logEE( "not yet implemented" ); } void UnitSummary::setNumber( int num ) { if( num == 0 ) { _nb->setText( "" ); } else { _nb->setText( "+" + QString::number( num ) ); } } // // ----- BaseTroop ----- // BaseTroop::BaseTroop( bool isGarrison, QWidget * parent, const char * /* name */ ) : QWidget( parent ) { _isGarrison = isGarrison; _lord = 0; QHBoxLayout * layout = new QHBoxLayout( this ); QVBoxLayout * layV2 = new QVBoxLayout(); _photo = new Icon( this ); _name = new QLabel( this ); _name->setFixedSize( 60, 20 ); layV2->addWidget( _photo ); layV2->addWidget( _name ); layout->addLayout( layV2 ); layout->addStretch( 1 ); QVBoxLayout * layV[ MAX_UNIT ]; QSignalMapper * sigmap = new QSignalMapper( this ); for( int i = 0; i < MAX_UNIT; i++ ) { layV[i] = new QVBoxLayout(); _units[i] = new Icon( this ); _numUnit[i] = new QLabel( this ); _numUnit[i]->setFixedSize( 60, 20 ); _numUnit[i]->setAlignment( Qt::AlignCenter ); layV[i]->addWidget( _units[i] ); layV[i]->addWidget( _numUnit[i] ); layout->addLayout( layV[i] ); sigmap->setMapping( _units[i], i ); connect( _units[i], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); } layout->addStretch( 1 ); layout->activate(); connect( _photo, SIGNAL( sig_clicked() ), SIGNAL( sig_photo() ) ); connect( sigmap, SIGNAL( mapped( int ) ), SIGNAL( sig_unit( int ) ) ); } void BaseTroop::clear() { _lord = 0; _photo->clear(); _name->clear(); for( int i = 0; i < MAX_UNIT; i++ ) { _units[i]->clear(); _numUnit[i]->clear(); } } void BaseTroop::setLord( GenericLord * lord ) { _lord = lord; reinit(); } void BaseTroop::setBase( GenericBase * base ) { _base = base; if( _isGarrison ) { _lord = base->getGarrisonLord(); } else { _lord = base->getVisitorLord(); } reinit(); } void BaseTroop::reinit() { QString text; if( _lord == 0 ) { clear(); if( _isGarrison ) { _name->setText( _base->getName()); for( int i = 0; i < MAX_UNIT; i++ ) { if( _base->getUnit( i ) ) { _units[i]->setPixmap( ImageTheme.getPhotoCreature( _base->getUnit( i ) ) ); _numUnit[i]->setText( QString::number( _base->getUnit( i )->getNumber() ) ); text = _base->getUnit(i)->getUnitDescription(); _units[i]->setPopupText( text ); } else { _numUnit[i]->clear(); } } } return; } _photo->setPixmap( *_player->getLordPixmapById( _lord->getId() ) ); _name->setText( _lord->getName()); for( int i = 0; i < MAX_UNIT; i++ ) { if( _lord->getUnit( i ) ) { _units[i]->setPixmap( ImageTheme.getPhotoCreature( _lord->getUnit( i ) ) ); _numUnit[i]->setText( QString::number( _lord->getUnit( i )->getNumber() ) ); text = _lord->getUnit(i)->getUnitDescription(); _units[i]->setPopupText( text ); } else { _units[i]->clear(); _numUnit[i]->clear(); } } } attal-src-1.0-rc2/libClient/displayBase.h0000644000175000017500000002066710761270226016010 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayBase.h ** inside the base ** ** Version : $Id: displayBase.h,v 1.30 2008/02/27 14:15:50 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 03/09/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef DISPLAYBASE_H #define DISPLAYBASE_H // generic include files // include files for QT #include #include // application specific includes #include "libCommon/unit.h" #include "libCommon/priceMarket.h" #include "libClient/displayCreature.h" #include "libClient/player.h" #include "libClient/widget.h" #include "libClient/ressourceWin.h" class QHBoxLayout; class QVBoxLayout; class QTabWidget; class AttalButton; class AttalSocket; class BaseSummary; class BaseLords; class BaseButtons; class BaseRightPanel; class BaseTroop; class DisplayBaseLord; class DisplayCreatureBase; class Game; class GenericBase; class GenericLord; class GenericInsideBuilding; class InsideActionAllBuildings; class InsideBase; class InsideBaseView; class Tavern; class UnitSummary; /* ------------------------------ * DisplayBase * ------------------------------ */ #define NB_CREATURE_BASE 7 /** Display inside of a base */ class DisplayBase : public QWidget { Q_OBJECT public: /** Construtor */ DisplayBase( QWidget * parent = 0, GenericBase * base = NULL, Game * game = NULL , AttalSocket * socket = NULL ); ~DisplayBase(); /** Initialize the base to display */ void setBase( GenericBase * base ); GenericBase * getBase() { return _base; } /** Reinits the display of the base */ void reinit(); /** Reinits the display of the base for teams */ void reinitBase(); /** Set socket for sending infos to server */ void setSocket( AttalSocket * sock ); /** Gives game info to this object */ void setGame( Game * game ) { _game = game; } /** Handles socket's data */ void handleSocket(); void updateDispositionMode(); signals: /** Signal for quitting */ void sig_quit(); void sig_resource(); void sig_castle(); public slots: /** Slot when a building is clicked */ void slot_building( GenericInsideBuilding * ); void slot_message( QString ); private: void socketMsg(); void socketModif(); void socketModifBase(); void socketModifBaseBuilding(); void socketModifBaseResources(); void socketModifPlayer(); void actionAllBuildings(); void actionAllCreatures(); void actionSomeCreatures( GenericInsideBuilding * building ); void actionMarket(); void actionTavern(); Player * _player; GenericBase * _base; AttalSocket * _socket; QHBoxLayout * _layout; QVBoxLayout * _layVerticalView; QTabWidget * _tabs; InsideBase * _inside; InsideBaseView * _view; BaseRightPanel * _panel; BaseSummary * _baseSummary; Game * _game; InsideActionAllBuildings * _allBuildings, * _manageBuildings; DisplayCreatureBase * _manageCreatures; Tavern * _tavern; TabRessourceWin * _ressW; }; class BaseRightPanel : public QWidget { Q_OBJECT public: BaseRightPanel( QWidget * parent = 0, Player * player = NULL , GenericBase * base = NULL, AttalSocket * socket = NULL ); void setSocket( AttalSocket * socket ); void reinit(); signals: void sig_quit(); public slots: void slot_lords(); void slot_info(); protected: AttalButton * _pbLord; QPushButton * _pbInfo; QLabel * _lordLabel; BaseButtons * _bases; GenericBase * _base; Player * _player; AttalSocket * _socket; DisplayBaseLord * _displayLords; RessourceWin * _ress; QLabel * _popul, * _totPopul; }; /** Widget for displaying a summary of the base info */ class BaseSummary : public QWidget { Q_OBJECT public: /** Constructor */ BaseSummary( QWidget * parent = 0, Player * player = NULL , GenericBase * base = NULL ); /** Initialize with the current base to display */ void setBase( GenericBase * base ); void reinit(); private: UnitSummary * _unitIco[8]; GenericBase * _base; Player * _player; RessourceWin * _ress; QLabel * _popul; }; class DisplayBaseInfo : public QDialog { Q_OBJECT public: DisplayBaseInfo( QWidget * parent = 0, Player * player = NULL , GenericBase * base = NULL ); void reinit(); protected: BaseSummary * _widget; }; /** Displays the lord of the base */ class BaseLords : public QWidget { Q_OBJECT public: /** Constructor */ BaseLords( QWidget * parent = 0 ); /** Initialize with the current base to display */ void setBase( GenericBase * base ); /** Reinit the widget */ void reinit(); /** Initialize the player */ void setPlayer( Player * _player ); /** Tell if there is a visiting lord */ bool isVisitor() { return (_visitor == 0); } /** Sets the socket for requesting the server */ void setSocket( AttalSocket * socket ) { _socket = socket; } public slots: /** Slot for exchange button */ void slot_exchange(); /** Slot if the garrison lord is clicked */ void slot_photoGarrison(); /** Slot if the visitor lord is clicked */ void slot_photoVisitor(); /** Slot if the 'num'-th unit of garrison is clicked */ void slot_unitGarrison( int num ); /** Slot if the 'num'-th unit of visit is clicked */ void slot_unitVisitor( int num ); signals: /** Signal for exchanging lords */ void sig_exchange( bool st ); private: void unselectUnits(); void unselectPhoto(); void exchangeLords(); void exchangeUnitsGV(); void exchangeUnitsVG(); void exchangeUnitsGG( int u1, int u2 ); void exchangeUnitsVV( int u1, int u2 ); bool _isExchange; BaseTroop * _garrison, * _visitor; GenericBase * _base; Player * _player; bool _garrisonSelected, _visitorSelected; int _unitGarrison, _unitVisitor; AttalSocket * _socket; }; class DisplayBaseLord : public QDialog { Q_OBJECT public: DisplayBaseLord( QWidget * parent = 0, Player * player = NULL , GenericBase * base = NULL , AttalSocket * socket = NULL ); void init( Player * player, GenericBase * base, AttalSocket * socket ); void reinit(); protected: BaseLords * _widget; }; /** Button for changing of base */ class BaseButtons : public QWidget { Q_OBJECT public: /** Constructors */ BaseButtons( QWidget * parent = 0, const char * name = 0 ); /** Initialize the player */ void setPlayer( Player * player ) { _player = player; } public slots: /** Slot for exchanging lords */ void slot_exchange( bool st ); signals: /** Signal for quitting */ void sig_quit(); /** Signal for exhanging */ void sig_exchange(); private: Player * _player; QPushButton * _pbExch; }; /** Summary of units of a lord */ class UnitSummary : public QWidget { public: /** Constructor */ UnitSummary( QWidget * parent = 0, const char * name = 0 ); /** Initialize the creature to display */ void setCreature( int id ); /** Initialize the player */ void setPlayer( Player * player ) { _player = player; } /** Det the number of creatures */ void setNumber( int num ); private: QLabel * _ico, * _nb; Player * _player; }; /** Display troops inside base */ class BaseTroop : public QWidget { Q_OBJECT public: /** Constructor */ BaseTroop( bool isGarrison, QWidget * parent = 0, const char * name = 0 ); /** Clear BaseTroop Widget */ void clear(); /** Initialize the player */ void setPlayer( Player * player ) { _player = player; } /** Initialize the lord to display */ void setLord( GenericLord * lord ); /** Initialize the base to display */ void setBase( GenericBase * base ); /** Reinit the widget (to synchronize change) */ void reinit(); /** Select the 'photo' widget */ void selectPhoto() {} /** Unselect the 'photo' widget */ void unselectPhoto() {} /** Select unit 'num' */ void selectUnit( int /*num*/ ) {} /** Unselect all units */ void unselectUnits() {} signals: /** Signal if photo clicked */ void sig_photo(); /** Signal if unit clicked */ void sig_unit( int ); private: Icon * _photo; Icon * _units[MAX_UNIT]; bool _isGarrison; GenericLord * _lord; GenericBase * _base; QLabel * _numUnit[ MAX_UNIT ], * _name; Player * _player; }; #endif // DISPLAYBASE_H attal-src-1.0-rc2/libClient/displayCreature.cpp0000644000175000017500000002236311016036216017227 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayCreature.cpp ** widget for displaying, buying cretaures ** ** Version : $Id: displayCreature.cpp,v 1.34 2008/05/24 16:04:30 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 01/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "displayCreature.h" // generic include files #include // include files for QT #include #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/attalSocket.h" #include "libCommon/dataTheme.h" #include "libCommon/genericPlayer.h" #include "libCommon/log.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/widget.h" extern QString DATA_PATH; // // ----- DisplayCreature ----- // DisplayCreature::DisplayCreature( QWidget * parent, const char * /* name */) : QFrame( parent ) { _creature = NULL; setFrameStyle( QFrame::Box | QFrame::Raised ); setLineWidth( 1 ); setMidLineWidth( 1 ); QVBoxLayout * info = new QVBoxLayout(); info->addWidget( _name = new QLabel( this ) ); info->addWidget( _picture = new QLabel( this ) ); info->addWidget( _available = new QLabel( this ) ); QGridLayout * stats = new QGridLayout(); stats->addWidget( new QLabel( tr("Attack"), this ), 0, 0 ); stats->addWidget( new QLabel( tr("Defense"), this ), 1, 0 ); stats->addWidget( new QLabel( tr("Damage"), this ), 2, 0 ); stats->addWidget( new QLabel( tr("Health"), this ), 3, 0 ); stats->addWidget( new QLabel( tr("Speed"), this ), 4, 0 ); stats->addWidget( new QLabel( tr("Growth"), this ), 5, 0 ); stats->addWidget( _attack = new QLabel( this ), 0, 1, Qt::AlignRight ); stats->addWidget( _defense = new QLabel( this ), 1, 1, Qt::AlignRight ); stats->addWidget( _damage = new QLabel( this ), 2, 1, Qt::AlignRight ); stats->addWidget( _health = new QLabel( this ), 3, 1, Qt::AlignRight ); stats->addWidget( _speed = new QLabel( this ), 4, 1, Qt::AlignRight ); stats->addWidget( _growth = new QLabel( this ), 5, 1, Qt::AlignRight ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->addLayout( info ); layout->addLayout( stats ); } void DisplayCreature::setCreature( int race, int level , GenericBase * base) { _creature = DataTheme.creatures.at( race , level ); _name->setText( _creature->getName() ); _picture->setPixmap( ImageTheme.getPhotoCreature( race, level ) ); _picture->setFixedSize( 60, 60 ); /// XXX: _building->setText( temp->getBuilding() ); if(!base) { _available->setText( "Available : ??" ); } else { QString tmp = ""; tmp = tr("no building"); if( base->canProduceCreature( _creature ) ) { int prod = base->getCreatureProduction( _creature ); if( prod > 0 ) { tmp = QString::number( prod ); } else { tmp = tr("next week"); } } QString ava = tr("Available : ") + tmp; _available->setText( ava ); } _attack->setText( QString::number( _creature->getAttack() ) ); _defense->setText( QString::number( _creature->getDefense() ) ); _damage->setText( QString::number( _creature->getMinDamages() ) + QString("-") + QString::number( _creature->getMaxDamages() ) ); _health->setText( QString::number( _creature->getMaxHealth() ) ); _speed->setText( QString::number( _creature->getMaxMove() ) ); /// XXX: to change... _growth->setText( QString::number( 4 ) ); } void DisplayCreature::mousePressEvent( QMouseEvent * /*event*/ ) { emit sig_clicked(); } // // ----- BuyCreature ----- // BuyCreature::BuyCreature( QWidget * parent, const char * /* name */ ) :QDialog( parent, Qt::Dialog ) { _socket = NULL; _max = 0; _base = NULL; _player = NULL; _labTitle = new QLabel( this ); _ico = new Icon( this ); _bar = new QScrollBar( Qt::Horizontal, this ); _labAvail = new QLabel( QString::number( 0 ), this ); _labBought = new QLabel( QString::number( 0 ), this ); _individualCost = new CreatureCost( this ); _boughtCost = new CreatureCost( this ); _butAll = new QPushButton( this ); _butAll->setText( tr( "All" ) ); _butBuy = new QPushButton( this ); _butBuy->setText( tr( "Buy" ) ); QPushButton * butCan = new QPushButton( this ); butCan->setText( tr( "Quit" ) ); QGridLayout * layout = new QGridLayout( this ); layout->setSizeConstraint( QLayout::SetFixedSize ); layout->addWidget( _individualCost, 0, 0, 3, 1, Qt::AlignBottom | Qt::AlignRight ); layout->addWidget( _labTitle, 0, 1, 1, 3, Qt::AlignHCenter | Qt::AlignBottom ); _boughtCost->setMinimumWidth( 100 ); layout->addWidget( _boughtCost, 0, 4, 3, 1, Qt::AlignBottom | Qt::AlignLeft ); layout->addWidget( _ico, 1, 1, 1, 3, Qt::AlignHCenter ); layout->addWidget( _labAvail, 2, 1, Qt::AlignRight ); _bar->setMinimumWidth( 120 ); layout->addWidget( _bar, 2, 2 ); layout->setColumnMinimumWidth( 2, 150 ); layout->setColumnStretch( 2, 1 ); layout->addWidget( _labBought , 2, 3, Qt::AlignLeft ); layout->addWidget( _butAll, 3, 0, 1, 2 ); layout->addWidget( _butBuy, 3, 2 ); layout->addWidget( butCan, 3, 3, 1, 2 ); connect( _bar, SIGNAL( valueChanged( int ) ), SLOT( slot_newValue( int ) ) ); connect( parent, SIGNAL( sig_castle() ), SLOT( reinit() ) ); connect( butCan, SIGNAL( clicked() ), SLOT( reject() ) ); connect( _butBuy, SIGNAL( clicked() ), SLOT( slot_buy() ) ); connect( _butAll, SIGNAL( clicked() ), SLOT( slot_all() ) ); } void BuyCreature::init( GenericPlayer * player, GenericBase * base, Creature * creature ) { _player = player; _base = base; _creature = creature; /// XXX: todo int race = creature->getRace(); int level = creature->getLevel(); //Creature * creature = DataTheme.creatures.at( race, level ); setWindowTitle( tr("Recruit ") + creature->getName() ); _labTitle->setText( creature->getName() ); _ico->setPixmap( ImageTheme.getPhotoCreature( race, level ) ); /// XXX: use prodBase when init of base will be done correctly... int prodBase = base->getCreatureProduction( creature ); int prodPlayer = player->computeBuyCreatureMax( creature ); //logDD(" creature %p, prodBase%d, prodPlayer %d", creature, prodBase, prodPlayer ); _max = std::min( prodBase, prodPlayer ); _individualCost->init( creature ); _individualCost->setNumber( 1 ); _boughtCost->init( creature ); _boughtCost->setNumber( 0 ); _bar->setMaximum( _max ); _labAvail->setText( QString::number( _max ) ); // why doesn't prodBase work? _labBought->setText( QString::number( 0 ) ); _butAll->setEnabled( _max ); _butBuy->setEnabled( false ); } void BuyCreature::reinit() { int prodBase = _base->getCreatureProduction( _creature ); int prodPlayer = _player->computeBuyCreatureMax( _creature ); //logDD(" creature %p, prodBase%d, prodPlayer %d", creature, prodBase, prodPlayer ); _max = std::min( prodBase, prodPlayer ); _boughtCost->setNumber( 0 ); _bar->setMaximum( _max ); _bar->setSliderPosition( 0 ); _labAvail->setText( QString::number( _max ) ); // why doesn't prodBase work? _labBought->setText( QString::number( 0 ) ); _butAll->setEnabled( _max ); } void BuyCreature::slot_newValue( int value ) { _boughtCost->setNumber( value ); _labAvail->setText( QString::number( _max - value ) ); _labBought->setText( QString::number( value ) ); _butBuy->setEnabled( value ); } void BuyCreature::slot_all() { if( _base->canAddGarrison( _creature ) ) { if( _player->canBuy( _creature, _max ) ) { _socket->sendBaseUnitBuy( _base, _creature, _max ); } } else { QMessageBox::warning( this, tr("No room left"), tr("No room left for a new unit") ); } } void BuyCreature::slot_buy() { if( _base->canAddGarrison( _creature ) ) { if( _bar->value() > 0 ) { if( _player->canBuy( _creature, _bar->value() ) ) { _socket->sendBaseUnitBuy( _base, _creature, _bar->value() ); } } } else { QMessageBox::warning( this, tr("No room left"), tr("No room left for a new unit") ); } } // // ----- CreatureCost ----- // CreatureCost::CreatureCost( QWidget * parent, const char * /* name */) : QFrame( parent ) { _nb = 0; _creature = 0; QVBoxLayout * layout = new QVBoxLayout( this ); for( int i = 0; i < DataTheme.resources.count(); i++ ) { _res[i] = new ResourceLabel( this ); _res[i]->setResource( i ); layout->addWidget( _res[i] ); _res[i]->hide(); } layout->addStretch( 1 ); layout->activate(); } void CreatureCost::init( Creature * creature ) { _nb = 0; _creature = creature; reinit(); } void CreatureCost::setNumber( unsigned int nb ) { _nb = nb; reinit(); } void CreatureCost::reinit() { if( _creature ) { for( int i = 0; i < DataTheme.resources.count(); i++) { if( _creature->getCost( i ) > 0 ) { _res[i]->setNumber( _creature->getCost( i ) * _nb ); _res[i]->show(); _res[i]->setFixedHeight( 30 ); } else { _res[i]->hide(); } } } } attal-src-1.0-rc2/libClient/displayCreature.h0000644000175000017500000000700410625243300016666 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayCreature.h ** widget for displaying, buying cretaures ** ** Version : $Id: displayCreature.h,v 1.10 2007/05/24 08:03:12 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 01/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef DISPLAYCREATURE_H #define DISPLAYCREATURE_H // generic include files // include files for QT #include #include #include #include #include #include // application specific include files #include "libCommon/creature.h" class QScrollBar; class AttalSocket; class ComputeCost; class CreatureCost; class CreatureInfo; class CreaturePresentation; class GenericPlayer; class GenericBase; class Icon; class InfoFrame; class ResourceLabel; /* ------------------------------ * DisplayCreature * ------------------------------ */ /** comment for the class */ class DisplayCreature : public QFrame { Q_OBJECT public: /** Constructor */ DisplayCreature( QWidget * parent = 0, const char * name = 0 ); /** Initialize creature to display */ void setCreature( int race, int level , GenericBase * base); Creature * getCreature() { return _creature; } signals: /** Signal if clicked */ void sig_clicked(); protected: void mousePressEvent( QMouseEvent * event ); private: CreaturePresentation * _creaturePres; CreatureInfo * _creatureInfo; Creature * _creature; QLabel * _name, * _picture, * _available; QLabel * _attack, * _defense, * _damage; QLabel * _health, * _speed, * _growth; }; /** Dialog for buying a creature */ class BuyCreature : public QDialog { Q_OBJECT public: /** Constructor */ BuyCreature( QWidget * parent = 0, const char * name = 0 ); /** Initialize creature to display */ void init( GenericPlayer * player, GenericBase * base, Creature * creature ); /** Initialize the socket of the dialog for requesting the server */ void initSocket( AttalSocket * socket ) { _socket = socket; } /** Sets max number of creatures allowed to buy */ void setMaxNumber( int max ) { _max = max; } private slots: void reinit(); void slot_all(); void slot_buy(); void slot_newValue( int ); private: QLabel * _labPres, * _labDescr; Icon * _ico; ComputeCost * _cost; Creature * _creature; AttalSocket * _socket; GenericBase * _base; GenericPlayer * _player; int _max; QLabel * _labAvail, * _labBought, * _labTitle; CreatureCost * _individualCost, * _boughtCost; QScrollBar * _bar; QPushButton * _butBuy, * _butAll; }; /** Display cost of a creature */ class CreatureCost : public QFrame { public: /** Constrcutor */ CreatureCost( QWidget * parent = 0, const char * name = 0 ); /** Init widget */ void init( Creature * creature ); /** Sets number of creature */ void setNumber( unsigned int nb ); protected: void reinit(); uint _nb; Creature * _creature; ResourceLabel * _res[MAX_RESS]; }; #endif // DISPLAYCREATURE_H attal-src-1.0-rc2/libClient/displayLord.cpp0000644000175000017500000005735211016036223016361 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayLord.cpp ** show infos about Lord ** ** Version : $Id: displayLord.cpp,v 1.34 2008/05/24 16:04:35 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 24/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "displayLord.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include #include #include // application specific includes #include "conf.h" #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libCommon/genericLord.h" #include "libCommon/attalSocket.h" #include "libClient/attalButton.h" #include "libClient/displayTechnics.h" #include "libClient/graphicalArtefact.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/lord.h" #include "libClient/player.h" #include "libClient/unitExchange.h" #include "libClient/widget.h" // // ----- DisplayLord ----- // DisplayLord::DisplayLord( Player * player, QWidget * parent, char * /*name*/ ) // :QDialog( parent, name, true, WStyle_Customize | WStyle_NoBorder ), :QDialog( parent, Qt::Dialog ), _player( player ) { _socket = 0; QVBoxLayout * layout1 = new QVBoxLayout( this ); layout1->addSpacing( 5 ); QHBoxLayout * layout2 = new QHBoxLayout(); layout2->addSpacing( 5 ); QVBoxLayout * layout3 = new QVBoxLayout(); QHBoxLayout * layout4 = new QHBoxLayout(); _dispGeneral = new DisplayGeneral( player, this ); layout4->addWidget( _dispGeneral, 1 ); layout4->addSpacing( 5 ); QVBoxLayout * layout5 = new QVBoxLayout(); _dispArtefact = new DisplayArtefacts( player, this ); layout5->addWidget( _dispArtefact, 1 ); layout5->addSpacing( 50 + 5 ); layout4->addLayout( layout5, 1 ); layout3->addLayout( layout4, 1 ); _dispUnit = new DisplayUnit( player, this ); layout3->addWidget( _dispUnit ); layout2->addLayout( layout3, 1 ); layout2->addSpacing( 5 ); _dispList = new DisplayListPanel( player, this ); layout2->addWidget( _dispList ); layout1->addLayout( layout2, 1 ); layout1->addSpacing( 5 ); QStatusBar * bar = new QStatusBar( this ); bar->showMessage( tr("Info Lord") ); bar->setFixedHeight( bar->sizeHint().height() ); bar->setSizeGripEnabled( false ); layout1->addWidget( bar ); layout1->activate(); setFixedSize( 800, 600 ); connect( _dispList, SIGNAL( sig_quit() ), SLOT( accept() ) ); connect( _dispList, SIGNAL( sig_lord( int ) ), SLOT( slot_lord( int ) ) ); connect( parent, SIGNAL( sig_updateWidget() ), SLOT( reupdate() ) ); } DisplayLord::~DisplayLord() { } void DisplayLord::initSocket( AttalSocket * socket ) { _socket = socket; _dispUnit->initSocket( socket ); } void DisplayLord::slot_lord( int num ) { _player->setSelectedLord( _player->getLord( num ) ); reupdate(); } void DisplayLord::show() { reinit(); QDialog::show(); } void DisplayLord::reinit() { _dispList->reinit(); _dispUnit->reinit(); _dispArtefact->reinit(); _dispGeneral->reinit(); } void DisplayLord::reupdate() { _dispList->reupdate(); _dispUnit->reupdate(); _dispArtefact->reupdate(); _dispGeneral->reupdate(); } // // ----- DisplayGeneral ----- // DisplayGeneral::DisplayGeneral( Player * player, QWidget * parent, const char * /* name */ ) : QFrame( parent ) { _player = player; _photo = new Icon( this ); _photo->move( 10, 10 ); _title = new QLabel( this ); _title->setAlignment( Qt::AlignCenter ); _title->move( 90, 20 ); Icon * ic1 = new Icon( this ); ic1->move( 10, 140 ); ic1->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( ICO_ATTACK ) ) ); Icon * ic2 = new Icon( this ); ic2->move( 80, 140 ); ic2->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( ICO_DEFENSE ) ) ); Icon * ic3 = new Icon( this ); ic3->move( 150, 140 ); ic3->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( ICO_POWER ) ) ); Icon * ic4 = new Icon( this ); ic4->move( 220, 140 ); ic4->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( ICO_KNOWLEDGE ) ) ); QLabel * titre[4]; for( int i = 0; i < 4; i++ ) { titre[i] = new QLabel( this ); titre[i]->setAlignment( Qt::AlignCenter ); titre[i]->setFixedSize( 60, 20 ); titre[i]->move( 10 + (i*70), 120 ); } titre[0]->setText( tr("Attack") ); titre[1]->setText( tr("Defense") ); titre[2]->setText( tr("Power") ); titre[3]->setText( tr("Knowledge") ); _labAttack = new QLabel( this ); _labAttack->setAlignment( Qt::AlignCenter ); _labAttack->setFixedSize( 60, 20 ); _labAttack->move( 10, 200 ); _labDefense = new QLabel( this ); _labDefense->setAlignment( Qt::AlignCenter ); _labDefense->setFixedSize( 60, 20 ); _labDefense->move( 80, 200 ); _labPower = new QLabel( this ); _labPower->setAlignment( Qt::AlignCenter ); _labPower->setFixedSize( 60, 20 ); _labPower->move( 150, 200 ); _labKnowledge = new QLabel( this ); _labKnowledge->setAlignment( Qt::AlignCenter ); _labKnowledge->setFixedSize( 60, 20 ); _labKnowledge->move( 220, 200 ); _specialty = new InfoLabel( this ); _specialty->move( 10, 240 ); _specialty->setText( tr("Specialty\nNone") ); _experience = new InfoLabel( this ); _experience->move( 10, 300 ); _spellPoints = new InfoLabel( this ); _spellPoints->move( 160, 300 ); reinit(); } void DisplayGeneral::reinit() { Lord * aLord = (Lord*)_player->getSelectedLord(); if( _player->getSelectedLordPixmap() ) { _photo->setPixmap( *_player->getSelectedLordPixmap() ); } if( aLord ) { QString title; title.sprintf( "Lord %s\nLevel %d of %s", qPrintable( aLord->getName() ), aLord->getCharac( LEVEL ), qPrintable( aLord->getCategoryName() ) ); _title->setText( title ); FIXEDSIZE( _title ); _labAttack->setText( QString::number( aLord->getCharac( ATTACK ) ) ); _labDefense->setText( QString::number( aLord->getCharac( DEFENSE ) ) ); _labPower->setText( QString::number( aLord->getCharac( POWER ) ) ); _labKnowledge->setText( QString::number( aLord->getCharac( KNOWLEDGE ) ) ); _specialty->setText( tr("Specialty\nNone") ); QString temp; temp.sprintf( "Experience\n%d", aLord->getCharac( EXPERIENCE ) ); _experience->setText( temp ); temp.sprintf( "Spell Points\n%d/%d", aLord->getCharac( TECHNICPOINT ), aLord->getCharac( MAXTECHNICPOINT ) ); _spellPoints->setText( temp ); } } // // ----- DisplayUnit ----- // DisplayUnit::DisplayUnit( Player * player, QWidget * parent, const char * /* name */ ) : QFrame( parent ) { _unit = -1; _exch = false; _player = player; _unitExchange = 0; _socket = 0; int i; QSignalMapper * sigmap = new QSignalMapper( this ); for( i = 0; i < MAX_UNIT; i++ ) { _buttonUnit[i] = new Icon( this ); _buttonUnit[i]->move( 30 + (i*60), 10 ); _numUnit[i] = new QLabel( this ); _numUnit[i]->setFixedSize( 60, 20 ); _numUnit[i]->setAlignment( Qt::AlignCenter ); _numUnit[i]->move( 30 + (i*60), 70 ); sigmap->setMapping( _buttonUnit[i], i ); connect( _buttonUnit[i], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); } for( i = 0; i < 4; i++ ) { _dispo[i] = new AttalButton( this ); _dispo[i]->setFixedSize( 50, 40 ); } _dispo[0]->move( 480, 5 ); _dispo[1]->move( 480, 55 ); _dispo[2]->move( 560, 5 ); _dispo[3]->move( 560, 55 ); _butExchange = _dispo[2]; _butExchange->setEnabled( false ); _butExchange->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( ICO_EXCHANGE ) ) ); setFixedSize( 640, 100 ); reinit(); connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_unitClicked( int ) ) ); connect( _butExchange, SIGNAL( clicked() ), SLOT( slot_exchange() ) ); connect( _dispo[3], SIGNAL( clicked() ), SLOT( slot_technic() ) ); } void DisplayUnit::reinit() { GenericLord * lord = _player->getSelectedLord(); QString text; if(lord){ for( int i = 0; i < MAX_UNIT; i++ ) { text = ""; if( lord->getUnit( i ) ) { _buttonUnit[i]->setPixmap( ImageTheme.getPhotoCreature( lord->getUnit( i ) ) ); text = lord->getUnit(i)->getUnitDescription(); _buttonUnit[i]->setPopupText( text ); _numUnit[i]->setText( QString::number( lord->getUnit( i )->getNumber() ) ); } else { _buttonUnit[i]->clear(); _numUnit[i]->clear(); } } } } void DisplayUnit::slot_exchange() { _exch = true; } void DisplayUnit::slot_technic() { DisplayTechnics dialog; dialog.exec(); } void DisplayUnit::quitExchange() { deselectUnit(); _exch = false; } void DisplayUnit::selectUnit( int num ) { _unit = num; _butExchange->setEnabled( true ); } void DisplayUnit::deselectUnit() { _unit = -1; _butExchange->setEnabled( false ); } void DisplayUnit::exchangeUnit( int num ) { GenericLord * lord = _player->getSelectedLord(); if( _unit == num ) { /// XXX: something to do ? } else if (lord) { if( lord->getUnit( num ) ) { if( lord->getUnit( _unit )->getCreature() == lord->getUnit( num )->getCreature() ) { if( ! _unitExchange ) { _unitExchange = new UnitExchange( this ); } _unitExchange->setMin( 0 ); _unitExchange->setMax( lord->getUnit( _unit )->getNumber() + lord->getUnit( num )->getNumber() ); _unitExchange->setUnits( lord->getUnit( _unit ), lord->getUnit( num ) ); if( _unitExchange->exec() ) { } } } else { if( ! _unitExchange ) { _unitExchange = new UnitExchange( this ); } _unitExchange->setMin( 0 ); _unitExchange->setMax( lord->getUnit( _unit )->getNumber() ); _unitExchange->setUnits( lord->getUnit( _unit ), 0 ); if( _unitExchange->exec() ) { } } } quitExchange(); } void DisplayUnit::slot_unitClicked( int num ) { GenericLord * lord = _player->getSelectedLord(); if(lord){ if( _exch ) { exchangeUnit( num ); } else { if( _unit == num ) { QMessageBox msb( tr("Unit"), tr("Do you want destroy this unit ?"), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape, 0, this ); if ( msb.exec() == QMessageBox::Yes ) { _socket->sendLordUnit( lord, num , 0); } reinit(); /// XXX: show unit charact deselectUnit(); return; } if( _unit == -1 ) { if( lord->getUnit( num ) ) { selectUnit( num ); } } else { if(_socket){ _socket->sendExchangeUnit( lord, _unit, lord, num ); } deselectUnit(); } } reinit(); } } // // ----- DisplayListPanel ----- // DisplayListPanel::DisplayListPanel( Player * player, QWidget * parent, const char * /* name */ ) : QFrame( parent ) { _player = player; setFrameStyle( QFrame::Panel | QFrame::Sunken ); setLineWidth( 1 ); setFixedWidth( 60 ); QLabel * emblem = new QLabel( this ); emblem->setFixedSize( 58, 58 ); emblem->setPixmap( * ImageTheme.getFlag( 0 ) ); /// XXX: TODO change emblem according to player team _listLord = new DisplayListLord( _player, this ); AttalButton * butOk = new AttalButton( this, AttalButton::BT_OK ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setAlignment( Qt::AlignHCenter ); layout->addWidget( emblem ); layout->addSpacing( 5 ); layout->addWidget( _listLord, 1 ); //layout->addStretch( 1 ); layout->addSpacing( 5 ); layout->addWidget( butOk ); layout->addSpacing( 5 ); layout->setAlignment( butOk, Qt::AlignHCenter ); layout->activate(); connect( butOk, SIGNAL( clicked() ), SIGNAL( sig_quit() ) ); connect( _listLord, SIGNAL( sig_lord( int ) ), SIGNAL( sig_lord( int ) ) ); } void DisplayListPanel::reinit() { _listLord->reinit(); update(); } void DisplayListPanel::reupdate() { _listLord->reupdate(); update(); } // // ----- DisplayListLord ----- // DisplayListLord::DisplayListLord( Player * player, QWidget * parent, const char * /* name */ ) : QWidget( parent ) { _player = player; _sigmap = new QSignalMapper( this ); setFixedWidth( 55 ); connect( _sigmap, SIGNAL( mapped( int ) ), SIGNAL( sig_lord( int ) ) ); } DisplayListLord::~DisplayListLord() { while( ! _listBut.isEmpty() ) { delete _listBut.takeFirst(); } } void DisplayListLord::reupdate() { /// XXX: add border to selected unit } void DisplayListLord::reinit() { AttalButton * button; while( ! _listBut.isEmpty() ) { button = _listBut.takeFirst(); _sigmap->removeMappings( button ); delete button; } for( uint i = 0; i < _player->numLord(); i++ ) { button = new AttalButton( this, AttalButton::BT_LORD ); button->move( 3, 5 + (50 * i) ); button->setLord( _player->getLord( i )->getId() ); button->show(); _sigmap->setMapping( button, i ); connect( button, SIGNAL( clicked() ), _sigmap, SLOT( map() ) ); _listBut.append( button ); } setMinimumHeight( _player->numLord() * 50 ); } // // ----- DisplayLordTab ----- // DisplayLordTab::DisplayLordTab( Player * player, AttalSocket * socket, QWidget * parent, char * /* name */) : QDialog( parent ), _player( player ) { _socket = socket; QWidget * panel = new QWidget( this ); panel->setFixedHeight( 80 ); _photo = new Icon( panel ); _photo->move( 10, 10 ); _title = new QLabel( panel ); _title->setAlignment( Qt::AlignCenter ); _title->move( 90, 20 ); _tabGeneral = new DisplayLordTabGeneral( player ); _tabUnits = new DisplayLordTabUnits( player, socket ); _tabArtefacts = new DisplayLordTabArtefacts( player ); _tabTechnics = new DisplayLordTabTechnics( player ); _tabs = new QTabWidget( this ); _tabs->addTab( _tabGeneral, tr( "General" ) ); _tabs->addTab( _tabUnits, tr( "Units" ) ); _tabs->addTab( _tabArtefacts, tr( "Artefacts" ) ); _tabs->addTab( _tabTechnics, tr( "Technics" ) ); _listPanel = new DisplayListPanel( player, this ); QVBoxLayout * layV1 = new QVBoxLayout(); layV1->addWidget( panel ); layV1->addWidget( _tabs, 1 ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layV1, 1 ); layout->addWidget( _listPanel ); layout->activate(); connect( _listPanel, SIGNAL( sig_lord( int ) ), SLOT( slot_lord( int ) ) ); connect( _listPanel, SIGNAL( sig_quit() ), SLOT( accept() ) ); } void DisplayLordTab::exec() { reinit(); QDialog::exec(); } void DisplayLordTab::reinit() { Lord * aLord = ( Lord * )_player->getSelectedLord(); if( _player->getSelectedLordPixmap() ) { _photo->setPixmap( *_player->getSelectedLordPixmap() ); } if( aLord ) { QString title; title.sprintf( "Lord %s\nLevel %d of %s", qPrintable( aLord->getName() ), aLord->getCharac( LEVEL ), qPrintable( aLord->getCategoryName() ) ); _title->setText( title ); FIXEDSIZE( _title ); } _tabGeneral->reinit(); _tabUnits->reinit(); _tabArtefacts->reinit(); _tabTechnics->reinit(); _listPanel->reinit(); } void DisplayLordTab::reupdate() { _tabGeneral->reinit(); _tabUnits->reinit(); _tabArtefacts->reinit(); _tabTechnics->reinit(); _listPanel->reupdate(); } void DisplayLordTab::slot_lord( int num ) { _player->setSelectedLord( _player->getLord( num ) ); reinit(); } // // ----- DisplayLordTabGeneral ----- // DisplayLordTabGeneral::DisplayLordTabGeneral( Player * player, QWidget * parent, const char * /* name*/ ) : QWidget( parent ) { _player = player; _specialty = new InfoWidget( this ); _specialty->setIcon( QPixmap( *ImageTheme.getWidgetPixmap( ICO_SPECIALITY ) )); _experience = new InfoWidget( this ); _experience->setIcon( QPixmap( *ImageTheme.getWidgetPixmap( ICO_EXPERIENCE ) )); _luck = new InfoWidget( this ); _luck->setIcon( QPixmap( *ImageTheme.getWidgetPixmap( ICO_LUCK ) )); _morale = new InfoWidget( this ); _morale->setIcon( QPixmap( *ImageTheme.getWidgetPixmap( ICO_MORALE ) )); _attack = new InfoWidget( this ); _attack->setIcon( QPixmap( *ImageTheme.getWidgetPixmap( ICO_ATTACK ) ) ); _defense = new InfoWidget( this ); _defense->setIcon( QPixmap( *ImageTheme.getWidgetPixmap( ICO_DEFENSE ) ) ); _charisma = new InfoWidget( this ); _charisma->setIcon( QPixmap( *ImageTheme.getWidgetPixmap( ICO_CHARISM ) )); _knowledge = new InfoWidget( this ); _knowledge->setIcon( QPixmap( *ImageTheme.getWidgetPixmap( ICO_KNOWLEDGE ) ) ); _power = new InfoWidget( this ); _power->setIcon( QPixmap( *ImageTheme.getWidgetPixmap( ICO_POWER ) ) ); _mana = new InfoWidget( this ); _mana->setIcon( QPixmap( *ImageTheme.getWidgetPixmap( ICO_MANA ) )); _move = new InfoWidget( this ); _move->setIcon( QPixmap( *ImageTheme.getWidgetPixmap( ICO_MOVE ) )); _vision = new InfoWidget( this ); _vision->setIcon( QPixmap( *ImageTheme.getWidgetPixmap( ICO_DEFENSE ) ) ); QGridLayout * layout = new QGridLayout( this ); layout->setColumnStretch( 0, 1 ); layout->setColumnStretch( 1, 1 ); layout->addWidget( _specialty, 0, 0 ); layout->addWidget( _experience, 0, 1 ); layout->addWidget( _luck, 1, 0 ); layout->addWidget( _morale, 1, 1 ); layout->addWidget( _attack, 2, 0 ); layout->addWidget( _defense, 2, 1 ); layout->addWidget( _charisma, 3, 0 ); layout->addWidget( _knowledge, 3, 1 ); layout->addWidget( _power, 4, 0 ); layout->addWidget( _mana, 4, 1 ); layout->addWidget( _move, 5, 0 ); layout->addWidget( _vision, 5, 1 ); layout->setRowStretch( 6, 1 ); layout->activate(); } QString DisplayLordTabGeneral::textCharac( GenericLord * lord, LordCharac charac ) { return getCharacName( charac ) + ": " + QString::number( lord->getCharac( charac ) ); } void DisplayLordTabGeneral::reinit() { GenericLord * lord = _player->getSelectedLord(); if( lord ) { //GenericLordModel * model = DataTheme.lords.at( lord->getId() ); _specialty->setText( tr("No specialty") ); int nextLevel = DataTheme.lordExperience.getLevel( lord->getCharac( LEVEL ) + 1 ); _experience->setText( textCharac( lord, EXPERIENCE ) + "\n( next " + QString::number(nextLevel) + " )" ); _luck->setText( textCharac( lord, LUCK ) ); _morale->setText( textCharac( lord, MORALE ) ); _attack->setText( textCharac( lord, ATTACK ) ); _defense->setText( textCharac( lord, DEFENSE ) ); _charisma->setText( textCharac( lord, CHARISMA ) ); _power->setText( textCharac( lord, POWER ) ); _knowledge->setText( textCharac( lord, KNOWLEDGE ) ); _mana->setText( textCharac( lord, TECHNICPOINT ) + " / " + QString::number( lord->getCharac( MAXTECHNICPOINT ) ) ); _move->setText( textCharac( lord, MOVE ) + " / " + QString::number( lord->getCharac( MAXMOVE ) ) ); _vision->setText( textCharac( lord, VISION ) ); } } // // ----- DisplayLordTabUnits ----- // DisplayLordTabUnits::DisplayLordTabUnits( Player * player, AttalSocket * socket, QWidget * parent, const char * /* name */ ) : QWidget( parent ) { _player = player; _socket = socket; _select = -1; _exchange = false; _unitExchange = 0; InfoWidget * unit; _butExchange = new AttalButton( this ); _butExchange->setEnabled( false ); _butExchange->setText( tr( "Split unit" ) ); QSignalMapper * sigmap = new QSignalMapper( this ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addWidget( _butExchange ); for( uint i = 0; i < MAX_UNIT; i++ ) { unit = new InfoWidget( this ); _units.append( unit ); layout->addWidget( unit ); sigmap->setMapping( unit, i ); connect( unit, SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); } layout->addStretch(); layout->activate(); connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_unitClicked( int ) ) ); connect( _butExchange, SIGNAL( clicked() ), SLOT( slot_exchange() ) ); } void DisplayLordTabUnits::reinit() { GenericLord * lord = _player->getSelectedLord(); GenericFightUnit * unit; if( lord ) { for( uint i = 0; i < MAX_UNIT; i++ ) { unit = lord->getUnit( i ); if( unit ) { _units.at( i )->setUnit( unit ); } else { _units.at( i )->clear(); } } } } void DisplayLordTabUnits::slot_exchange() { _exchange = true; _butExchange->setText( tr( "Now click on a free cell or a unit of same type" ) ); } void DisplayLordTabUnits::quitExchange() { deselectUnit(); _exchange = false; _butExchange->setText( tr( "Split unit" ) ); } void DisplayLordTabUnits::selectUnit( int num ) { _select = num; _butExchange->setEnabled( true ); } void DisplayLordTabUnits::deselectUnit() { _select = -1; _butExchange->setEnabled( false ); } void DisplayLordTabUnits::exchangeUnit( int num ) { GenericLord * lord = _player->getSelectedLord(); if( _select == num ) { /// nothing to do } else if (lord) { if( lord->getUnit( num ) ) { if( lord->getUnit( _select )->getCreature() == lord->getUnit( num )->getCreature() ) { if( ! _unitExchange ) { _unitExchange = new UnitExchange( this ); } _unitExchange->setMin( 0 ); _unitExchange->setMax( lord->getUnit( _select )->getNumber() + lord->getUnit( num )->getNumber() ); _unitExchange->setUnits( lord->getUnit( _select ), lord->getUnit( num ) ); if( _unitExchange->exec() ) { _socket->sendExchangeUnitSplit( lord, _select, _unitExchange->getLeftValue() , num, _unitExchange->getRightValue() ); } } } else { if( ! _unitExchange ) { _unitExchange = new UnitExchange( this ); } _unitExchange->setMin( 0 ); _unitExchange->setMax( lord->getUnit( _select )->getNumber() ); _unitExchange->setUnits( lord->getUnit( _select ), 0 ); if( _unitExchange->exec() ) { _socket->sendExchangeUnitSplit( lord, _select, _unitExchange->getLeftValue() , num, _unitExchange->getRightValue() ); } } } quitExchange(); } void DisplayLordTabUnits::slot_unitClicked( int num ) { GenericLord * lord = _player->getSelectedLord(); if( lord ) { if( _exchange ) { exchangeUnit( num ); } else { if( _select == num ) { QMessageBox msb( tr("Unit"), tr("Do you want destroy this unit ?"), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape, 0, this ); if ( msb.exec() == QMessageBox::Yes ) { _socket->sendLordUnit( lord, num , 0 ); } reinit(); /// XXX: show unit charact deselectUnit(); return; } if( _select == -1 ) { if( lord->getUnit( num ) ) { selectUnit( num ); } } else { if( _socket ) { _socket->sendExchangeUnit( lord, _select, lord, num ); } deselectUnit(); } } reinit(); } } // // ----- DisplayLordTabTechnics ----- // DisplayLordTabTechnics::DisplayLordTabTechnics( Player * player, QWidget * parent, const char * /* name */ ) : QWidget( parent ) { _player = player; QLabel * label = new QLabel( this ); label->setText( tr( "Not yet implemented" ) ); label->move( 5, 5 ); FIXEDSIZE( label ); } void DisplayLordTabTechnics::reinit() { } // // ----- InfoWidget ----- // InfoWidget::InfoWidget( QWidget * parent, const char * /* name */ ) : QFrame( parent ) { setFrameStyle( QFrame::Panel | QFrame::Sunken ); setLineWidth( 1 ); setMidLineWidth( 1 ); _photo = new Icon( this ); _label = new Label( this ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addWidget( _photo ); layout->addWidget( _label, 1 ); layout->activate(); connect( _photo, SIGNAL( sig_clicked() ), SIGNAL( sig_clicked() ) ); } void InfoWidget::setIcon( const QPixmap & pixmap ) { _photo->setPixmap( pixmap ); } void InfoWidget::clear() { _photo->clear(); _label->clear(); } void InfoWidget::setText( const QString & text ) { _label->setText( text ); } void InfoWidget::setPopup( const QString & text ) { _label->setPopupText( text ); } void InfoWidget::setUnit( GenericFightUnit * unit ) { if( unit ) { _photo->setPixmap( ImageTheme.getPhotoCreature( unit ) ); QString text = unit->getUnitDescription(); _label->setPopupText( text ); text.sprintf( "%ld %s", unit->getNumber(), unit->getCreature()->getName().toLatin1().constData() ); _label->setText( text ); } else { _photo->clear(); _label->clear(); } } attal-src-1.0-rc2/libClient/displayLord.h0000644000175000017500000001633410777503654016045 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayLord.h ** show infos about Lord ** ** Version : $Id: displayLord.h,v 1.15 2008/04/10 21:33:32 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 24/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef DISPLAYLORD_H #define DISPLAYLORD_H // generic include files // include files for QT #include #include #include #include #include #include // application specific includes #include "libCommon/define.h" #include "libCommon/genericLord.h" #include "libClient/displayArtefacts.h" #include "libClient/widget.h" class QSignalMapper; class QTabWidget; class AttalButton; class AttalSocket; class DisplayUnit; class DisplayGeneral; class DisplayListPanel; class DisplayListLord; class DisplayLordTabGeneral; class DisplayLordTabUnits; class DisplayLordTabTechnics; class InfoWidget; class Lord; class Player; class UnitExchange; /* ------------------------------ * DisplayLord * ------------------------------ */ /** Display info about lord */ class DisplayLord : public QDialog { Q_OBJECT public: /** Construtor */ DisplayLord( Player * player, QWidget * parent = 0, char * name = 0 ); /** Destructor */ ~DisplayLord(); /** Reinit and show dialog */ void show(); /** Reinit info displayed */ void reinit(); void initSocket( AttalSocket * socket ); public slots: /** Slot if lord clicked */ void slot_lord( int num ); /** Update info displayed */ void reupdate(); private: InfoLabelSkill * _infoSkills; Player * _player; DisplayUnit * _dispUnit; DisplayGeneral * _dispGeneral; DisplayArtefacts * _dispArtefact; DisplayListPanel * _dispList; AttalSocket * _socket; }; /** General information about lord */ class DisplayGeneral : public QFrame { public: /** Construtor */ DisplayGeneral( Player * player, QWidget * parent = 0, const char * name = 0 ); /** Reinit info displayed */ void reinit(); /** Update info displayed */ void reupdate() { reinit(); } private: Player * _player; QLabel * _title, * _labAttack, * _labDefense, * _labPower, * _labKnowledge; InfoLabel * _specialty, * _experience, * _spellPoints; Icon * _photo; }; /** Display units of the lord */ class DisplayUnit : public QFrame { Q_OBJECT public: /** Construtor */ DisplayUnit( Player * player, QWidget * parent = 0, const char * name = 0 ); /** Reinit info displayed */ void reinit(); /** Update info displayed */ void reupdate() { reinit(); } /** Quit exchange mode */ void quitExchange(); /** Select unit 'num' */ void selectUnit( int num ); /** Deselect unit */ void deselectUnit(); void initSocket( AttalSocket * socket ) { _socket = socket; } public slots: /** Slot for 'Exchange' button */ void slot_exchange(); /** Slot for units clicked */ void slot_unitClicked( int num ); void slot_technic(); private: void exchangeUnit( int num ); Player * _player; Icon * _buttonUnit[ MAX_UNIT ]; QLabel * _numUnit[ MAX_UNIT ]; AttalButton * _dispo[ 4 ], * _butExchange; UnitExchange * _unitExchange; AttalSocket * _socket; int _unit; bool _exch; }; /** Panel for displaying list of other lords and 'quit' button */ class DisplayListPanel : public QFrame { Q_OBJECT public: /** Construtor */ DisplayListPanel( Player * player, QWidget * parent = 0, const char * name = 0 ); /** Reinit info displayed */ void reinit(); /** Update info displayed */ void reupdate(); signals: /** Signal for quitting */ void sig_quit(); /** Signal for changing lord */ void sig_lord( int ); private: DisplayListLord * _listLord; Player * _player; }; /** Display list of lords */ class DisplayListLord : public QWidget { Q_OBJECT public: /** Construtor */ DisplayListLord( Player * player, QWidget * parent = 0, const char * name = 0 ); /** Destructor */ virtual ~DisplayListLord(); /** Reinit info displayed */ void reinit(); /** Update info displayed */ void reupdate(); signals: /** Signal for changing lord */ void sig_lord( int ); private: Player * _player; QList _listBut; QSignalMapper * _sigmap; }; class DisplayLordTab : public QDialog { Q_OBJECT public: /** Construtor */ DisplayLordTab( Player * player, AttalSocket * socket, QWidget * parent = 0, char * name = 0 ); /** Destructor virtual ~DisplayLordTab(); */ /** Reinit and show dialog */ virtual void exec(); /** Reinit info displayed */ void reinit(); /** Reupdate info displayed */ void reupdate(); public slots: /** Slot if lord clicked */ void slot_lord( int num ); private: Player * _player; AttalSocket * _socket; DisplayListPanel * _listPanel; QTabWidget * _tabs; DisplayLordTabGeneral * _tabGeneral; DisplayLordTabUnits * _tabUnits; DisplayLordTabArtefacts * _tabArtefacts; DisplayLordTabTechnics * _tabTechnics; Icon * _photo; QLabel * _title; }; class DisplayLordTabGeneral : public QWidget { public: /** Constructor */ DisplayLordTabGeneral( Player * player, QWidget * parent = 0, const char * name = 0 ); /** Reinit info displayed */ void reinit(); protected: QString textCharac( GenericLord * lord, LordCharac charac ); Player * _player; InfoWidget * _specialty, * _experience; InfoWidget * _luck, * _morale; InfoWidget * _attack, * _defense; InfoWidget * _charisma, * _knowledge; InfoWidget * _power, * _mana; InfoWidget * _move, * _vision; }; class DisplayLordTabUnits : public QWidget { Q_OBJECT public: /** Constructor */ DisplayLordTabUnits( Player * player, AttalSocket * socket, QWidget * parent = 0, const char * name = 0 ); /** Reinit info displayed */ void reinit(); public slots: /** Slot for 'Exchange' button */ void slot_exchange(); /** Slot for units clicked */ void slot_unitClicked( int num ); protected: void quitExchange(); void selectUnit( int num ); void deselectUnit(); void exchangeUnit( int num ); Player * _player; AttalSocket * _socket; QList _units; AttalButton * _butExchange; UnitExchange * _unitExchange; int _select; bool _exchange; }; class DisplayLordTabTechnics : public QWidget { Q_OBJECT public: /** Constructor */ DisplayLordTabTechnics( Player * player, QWidget * parent = 0, const char * name = 0 ); /** Reinit info displayed */ void reinit(); protected: Player * _player; }; class InfoWidget : public QFrame { Q_OBJECT public: /** Constructor */ InfoWidget( QWidget * parent = 0, const char * name = 0 ); void clear(); void setIcon( const QPixmap & pixmap ); void setText( const QString & text ); void setPopup( const QString & text ); void setUnit( GenericFightUnit * unit ); signals: void sig_clicked(); protected: Icon * _photo; Label * _label; }; #endif // DISPLAYLORD_H attal-src-1.0-rc2/libClient/displayTechnics.cpp0000644000175000017500000000217510404562730017221 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayTechnics.cpp ** Dialog for displaying the technics of a lord ** ** Version : $Id: displayTechnics.cpp,v 1.3 2006/03/11 14:59:36 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/05/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "displayTechnics.h" // generic include files // include files for QT // application specific include files /** add comments here */ DisplayTechnics::DisplayTechnics( QWidget * parent, const char * /*name*/ ) : QDialog( parent, Qt::Dialog ) { } attal-src-1.0-rc2/libClient/displayTechnics.h0000644000175000017500000000255410331243510016656 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayTechnics.h ** Dialog for displaying the technics of a lord ** ** Version : $Id: displayTechnics.h,v 1.2 2005/10/30 22:20:56 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/05/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef DISPLAYTECHNICS_H #define DISPLAYTECHNICS_H // generic include files // include files for QT #include // application specific include files /* ------------------------------ * DisplayTechnics * ------------------------------ */ /** comment for the class */ class DisplayTechnics : public QDialog { public: /** Constructor */ DisplayTechnics( QWidget * parent = 0, const char * name = 0 ); }; #endif // DISPLAYTECHNICS_H attal-src-1.0-rc2/libClient/event.cpp0000644000175000017500000000276610621643651015225 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** event.cpp ** Displays event on map ** ** Version : $Id: event.cpp,v 1.6 2007/05/13 17:15:21 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 23/12/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "event.h" // generic include files // include files for QT // application specific include files #include "libCommon/genericCell.h" #include "libCommon/log.h" #include "libClient/graphicalArtefact.h" #include "libClient/bonus.h" #include "libClient/chest.h" Event::Event() { } void Event::setCell( GenericCell * cell ) { TRACE("Event::setCell "); GenericEvent::setCell( cell ); switch( _type ) { case EventArtefact: ( (Artefact *)_artefact )->setCell( cell ); break; case EventBonus: ( (Bonus *)_bonus )->setCell( cell ); break; case EventChest: ( (Chest *)_chest )->setCell( cell ); break; default: logEE( "Should not happen" ); break; } } attal-src-1.0-rc2/libClient/event.h0000644000175000017500000000245107723126752014670 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** event.h ** Displays events on map ** ** Version : $Id: event.h,v 1.2 2003/08/27 13:11:06 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 23/12/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef EVENT_H #define EVENT_H // generic include files // include files for QT // application specific include files #include "libCommon/genericEvent.h" class GenericCell; /** ------------------------------ * Event ** ------------------------------ */ class Event : public GenericEvent { public: /** Constructor */ Event(); virtual ~Event() {} virtual void setCell( GenericCell * cell ); }; #endif // EVENT_H attal-src-1.0-rc2/libClient/flag.cpp0000644000175000017500000000310010777472215015004 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** flag.cpp ** manage display of flags on map ** ** Version : $Id: flag.cpp,v 1.5 2008/04/10 20:11:57 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 07/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "flag.h" // generic include files // include files for QT #include // application specific include files #include "conf.h" #include "libCommon/genericPlayer.h" #include "libClient/imageTheme.h" /** add comments here */ Flag::Flag( QGraphicsScene * canvas ) : AttalSprite( ImageTheme.getMapFlag( 0, 0 ), canvas ) { _type = 0; _teamId = 0; setFrame( 0 ); setZValue( CAN_LORD + 1 ); } Flag::~Flag() { } void Flag::setFlagType( uint type ) { _type = type; setSequence( ImageTheme.getMapFlag( _type, _teamId ) ); setFrame( 0 ); } void Flag::setOwner( GenericPlayer * player ) { if( player ) { _teamId = player->getTeamId(); setSequence( ImageTheme.getMapFlag( _type, _teamId ) ); setFrame( 0 ); } } attal-src-1.0-rc2/libClient/flag.h0000644000175000017500000000264210510250453014442 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** flag.h ** manage display of flags on map ** ** Version : $Id: flag.h,v 1.4 2006/10/02 17:49:31 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 07/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef FLAG_H #define FLAG_H // generic include files // include files for QT // application specific include files #include "libClient/attalSprite.h" class GenericPlayer; /* ------------------------------ * Flag * ------------------------------ */ class Flag : public AttalSprite { public: /** Constructor */ Flag( QGraphicsScene * canvas ); /** Destructor */ virtual ~Flag(); void setFlagType( uint type ); void setOwner( GenericPlayer * player ); protected: uint _type, _teamId; }; #endif // FLAG_H attal-src-1.0-rc2/libClient/gainLevel.cpp0000644000175000017500000000672110522705150015776 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** gainLevel.cpp ** Dialog when lord gain a new level ** ** Version : $Id: gainLevel.cpp,v 1.6 2006/11/03 18:28:56 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 10/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "gainLevel.h" // generic include files // include files for QT #include #include #include #include #include // application specific include #include "libClient/gui.h" #include "libClient/widget.h" extern QString IMAGE_PATH; /*! Constructs an empty */ GainLevel::GainLevel( QWidget * parent, const char * /* name */) :QDialog( parent, Qt::Dialog ) { _skill = SKI_ATTACK; QVBoxLayout * layout = new QVBoxLayout( this ); _title = new Sentence( this ); _title->setText( "Actarius gain a level" ); layout->addSpacing( 5 ); layout->addWidget( _title ); layout->addSpacing( 10 ); _photo = new Icon( this ); _photo->setPixmap( QPixmap( IMAGE_PATH + "lords/lord_001.png" ) ); Icon * panel1 = new Icon( this ); panel1->setPixmap( QPixmap( IMAGE_PATH + "misc/exp.png" ) ); Icon * panel2 = new Icon( this ); panel2->setPixmap( QPixmap( IMAGE_PATH + "misc/exp.png" ) ); QHBoxLayout * lay1 = new QHBoxLayout(); lay1->addStretch( 1 ); lay1->addWidget( panel1 ); lay1->addStretch( 1 ); lay1->addWidget( _photo ); lay1->addStretch( 1 ); lay1->addWidget( panel2 ); lay1->addStretch( 1 ); layout->addLayout( lay1, 1 ); layout->addSpacing( 10 ); _level = new Sentence( this ); _level->setText( "Actarius is now a level 6 hacker" ); layout->addWidget( _level ); layout->addSpacing( 5 ); layout->addStretch( 1 ); layout->addSpacing( 5 ); _spec = new Sentence( this ); _spec->setText( "Knowledge + 1" ); layout->addWidget( _spec ); layout->addSpacing( 5 ); _choice1 = new QPushButton( this ); _choice1->setIcon( QIcon( QPixmap( IMAGE_PATH + "skills/skill_001.png" ) ) ); _choice1->setFixedSize( 40, 40 ); _choice2 = new QPushButton( this ); _choice2->setIcon( QIcon( QPixmap( IMAGE_PATH + "skills/skill_002.png" ) ) ); _choice2->setFixedSize( 40, 40 ); QHBoxLayout * lay3 = new QHBoxLayout(); lay3->addStretch( 1 ); lay3->addWidget( _choice1 ); lay3->addStretch( 1 ); lay3->addWidget( _choice2 ); lay3->addStretch( 1 ); layout->addLayout( lay3, 1 ); layout->addSpacing( 5 ); QHBoxLayout * lay4 = new QHBoxLayout(); lay4->addStretch( 5 ); _butOk = new AttalButton( this, AttalButton::BT_OK ); lay4->addWidget( _butOk ); lay4->addStretch( 1 ); layout->addLayout( lay4 ); layout->addSpacing( 5 ); layout->activate(); setFixedSize( 420, 480 ); connect( _butOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( _choice1, SIGNAL( clicked() ), SLOT( slot_choice1() ) ); connect( _choice2, SIGNAL( clicked() ), SLOT( slot_choice2() ) ); } void GainLevel::reinit() { _choice = -1; _butOk->setEnabled( false ); } attal-src-1.0-rc2/libClient/gainLevel.h0000644000175000017500000000427110522705150015441 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** gainLevel.h ** Dialog when lord gain a new level ** ** Version : $Id: gainLevel.h,v 1.3 2006/11/03 18:28:56 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 10/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GAINLEVEL_H #define GAINLEVEL_H // generic include files // include files for QT #include #include #include // application specific includes #include "libCommon/genericLord.h" #include "libCommon/skill.h" #include "libClient/attalButton.h" class QLabel; class Icon; class Sentence; /* ------------------------------ * GainLevel * ------------------------------ */ /** comment for the class */ class GainLevel : public QDialog { Q_OBJECT public: /** Constructor */ GainLevel( QWidget * parent = 0, const char * name = 0 ); /** Initialize lord */ void setLord( GenericLord * lord ) { _lord = lord; reinit(); } /** Set the primary skill gained */ void setImprovement( PrimarySkill skill ) { _skill = skill; } /** Return choice */ int getChoice() { return _choice; } /** Reinit info displayed */ void reinit(); private slots: /** Slot if choice_1 clicked */ void slot_choice1() { _choice = 1; _butOk->setEnabled( true ); } /** Slot if choice_2 clicked */ void slot_choice2() { _choice = 2; _butOk->setEnabled( true ); } private: GenericLord * _lord; PrimarySkill _skill; Icon * _photo; Sentence * _title, * _level, * _spec; QPushButton * _choice1, * _choice2; AttalButton * _butOk; int _choice; }; #endif // GAINLEVEL_H attal-src-1.0-rc2/libClient/game.cpp0000644000175000017500000012174711016036223015004 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** game.cpp ** Manages the whole game ** ** Version : $Id: game.cpp,v 1.245 2008/05/24 16:04:35 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo - Forest Darling ** ** Date : 17/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "game.h" // generic include files #include // include files for QT #include #include #include #include #include #include #include #include // application specific includes #include "conf.h" #include "libCommon/artefactManager.h" #include "libCommon/attalSettings.h" #include "libCommon/attalSocket.h" #include "libCommon/calendar.h" #include "libCommon/dataTheme.h" #include "libCommon/genericEvent.h" #include "libCommon/genericInsideBuilding.h" #include "libClient/graphicalPath.h" #include "libCommon/pathFinder.h" #include "libCommon/technic.h" #include "libCommon/unit.h" #include "libCommon/priceMarket.h" #include "libCommon/attalTemplates.h" //#include "libFight/fightUnit.h" #include "libClient/askChest.h" #include "libClient/askDialog.h" #include "libClient/bonus.h" #include "libClient/building.h" #include "libClient/cell.h" #include "libClient/chatWidget.h" #include "libClient/chest.h" #include "libClient/displayLord.h" #include "libClient/displayBase.h" #include "libClient/event.h" #include "libClient/gainLevel.h" #include "libClient/gameInfo.h" #include "libClient/graphicalArtefact.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/lord.h" #include "libClient/lordExchange.h" #include "libClient/mapCreature.h" #include "libClient/mapView.h" #include "libClient/miniMap.h" extern QString DATA_PATH; extern QString VERSION; extern TechnicList techList; extern Map * theMap; Game::Game( QWidget * parent , const char * name ) : QWidget( parent, Qt::MSWindowsFixedSizeDialogHint ), GraphicalGameData() { setWindowTitle( QString ( name )); theMap = new Map( this ); _map = (GenericMap *)theMap; _isPlaying = false; _socket = NULL; _dispLord = NULL; _currentCell = NULL; _lordExchange = NULL; _popup = NULL; _period = 40; _idTime = -1; _local = false; initWidgets(); _player = new Player( this, _map ); _player->setConnectionName( AttalSettings::getInstance()->getStrategyModeSettings().connectionName ); _control->setPlayer( _player ); _scrLord->setPlayer(_player); _scrBase->setPlayer(_player); _scrLord->reinit(); _scrBase->reinit(); GraphicalGameData::reinit(); _control->reinit(); connect( _chat, SIGNAL( sig_message( QString ) ), SLOT( slot_message( QString ) ) ); connect( _scrLord, SIGNAL( sig_lord() ), SLOT( slot_displayLord() ) ); connect( _scrLord, SIGNAL( sig_lordSelected() ), SLOT( slot_lordSelected() ) ); connect( _scrBase, SIGNAL( sig_base() ), SLOT( slot_displayBase() ) ); connect( _scrBase, SIGNAL( sig_baseSelected() ), SLOT( slot_baseSelected() ) ); connect( _control, SIGNAL( sig_endTurn() ), SLOT( endTurn() ) ); connect( _view , SIGNAL( sig_mouseMoved ( GenericCell * ) ), SLOT( slot_mouseMoved( GenericCell * ) ) ); connect( _view , SIGNAL( sig_mouseLeftPressed( GenericCell * ) ), SLOT( slot_mouseLeftPressed( GenericCell * ) ) ); connect( _view , SIGNAL( sig_mouseRightPressed( GenericCell * ) ), SLOT( slot_mouseRightPressed( GenericCell * ) ) ); connect( _view, SIGNAL( sig_mouseReleased() ), SLOT( slot_mouseReleased() ) ); connect( _view, SIGNAL( sig_viewportResized( double, double ) ), _miniMap, SLOT( slot_mapviewResized( double, double ) ) ); connect( _view, SIGNAL( sig_viewportScrolled( double, double ) ), _miniMap, SLOT( slot_mapviewScrolled( double, double ) ) ); connect( this , SIGNAL( sig_Center( int , int ) ), _view , SLOT( slot_Center( int ,int ) ) ); connect( this , SIGNAL( sig_update() ), _view , SLOT( updateMap() ) ); connect( theMap , SIGNAL( sig_cellChanged( int, int )), _miniMap, SLOT( slot_redrawCell( int , int ) ) ); connect( this , SIGNAL( sig_cellChanged( int, int )), _miniMap, SLOT( slot_redrawCell( int , int ) ) ); connect( _miniMap , SIGNAL( sig_mouseReleasedMinimap( double, double ) ), _view, SLOT( slot_Center( double, double ) ) ); } Game::~Game() { TRACE("~Game"); delete _player; if( _layControlH1 ) { delete _layControlH1; } if( _layControlV1 ) { delete _layControlV1; } if( _dispLord ) { delete _dispLord; } if( _lordExchange ) { delete _lordExchange; } } void Game::reinit() { TRACE("Game::reinit"); stopTimer(); /* disable controls */ emit sig_enableGame( false ); _scrLord->deselect(); _scrBase->deselect(); /* clean up player data */ _player->cleanData(); _state = MS_NOTHING; /* redraw various widgets */ if( _dispLord ) { delete _dispLord; _dispLord = NULL; } if( _lordExchange ) { delete _lordExchange; _lordExchange = NULL; } GraphicalGameData::reinit(); /* redraw minimap */ _miniMap->redrawMap( theMap ); /* these are to remove icon from buttons */ emit sig_baseReinit(); emit sig_lordReinit(); emit sig_statusBar(); ImageTheme.endMusic(); } void Game::initWidgets() { theMap->setSceneRect( 0,0, 4000, 3000 ); _view = new MapView( theMap, this ); _control = new GameControl( this ); _scrLord = new ScrollLord( false, 4, this ); _scrBase = new ScrollBase( false, 4, this ); _layControlH1 = 0; _layControlV1 = new QVBoxLayout(); _layControlV1->addWidget( _scrLord, 1, Qt::AlignHCenter ); _layControlV1->addWidget( _control, 0, Qt::AlignHCenter ); _layControlV1->addWidget( _scrBase, 1, Qt::AlignHCenter ); _layH1 = new QHBoxLayout(); _layH1->addWidget( _view, 1 ); _layH1->addLayout( _layControlV1 ); _chat = new ChatWidget( this ); _miniMap = new MiniMap( theMap, this ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addWidget( _chat, 1 ); layH2->addWidget( _miniMap ); _layout = new QVBoxLayout( this ); _layout->addLayout( _layH1 ); _layout->addLayout( layH2 ); _layout->activate(); } void Game::setPlayerName( QString name ) { AttalSettings::StrategyModeSettings settings = AttalSettings::getInstance()->getStrategyModeSettings(); settings.connectionName = name; _player->setConnectionName( name ); AttalSettings::getInstance()->setStrategyModeSettings( settings ); } void Game::slot_mouseMoved( GenericCell *cell ) { QString msg; if( cell != _currentCell ) { if( cell->getLord() ) { msg = tr( "Lord " ) + cell->getLord()->getName(); setCursor( Qt::WaitCursor ); } else if( cell->getBase() ) { msg = cell->getBase()->getBaseDescription(); setCursor( Qt::WaitCursor ); } else if( cell->getBuilding() ) { msg = cell->getBuilding()->getName()+ QString(tr(" - ")) + DataTheme.buildings.at(cell->getBuilding()->getType())->getDescription(); setCursor( Qt::WaitCursor ); } else if( cell->getEvent() ) { setCursor( Qt::WaitCursor ); switch(cell->getEvent()->getType()){ case GenericEvent::EventNone: break; case GenericEvent::EventArtefact: msg = tr("Artefact: ") + cell->getEvent()->getArtefact()->getName(); break; case GenericEvent::EventBonus: { GenericBonus * bonus = cell->getEvent()->getBonus(); msg = bonus->getBonusDescription(); } break; case GenericEvent::EventChest: msg = tr("Chest "); break; default: break; } } else if( cell->getCreature() ) { msg = tr("About ") + QString::number(DataTheme.getRandomInCategory(cell->getCreature()->getCategoryNumber())) + " " + cell->getCreature()->getCreature()->getName(); setCursor( Qt::WaitCursor ); } else { setCursor( Qt::ArrowCursor ); #ifdef QT_DEBUG msg = QString(tr("Cell: row %1, col %2, coordinates x %3, y %4 ")).arg(cell->getRow()).arg(cell->getCol()).arg(cell->getCol() * DataTheme.tiles.getWidth()).arg( cell->getRow() * DataTheme.tiles.getHeight()); #endif } emit sig_statusMsg( msg ); } //Code set aside for future use /* switch( _state ) { * case MS_LORD: * { * GenericLord * selectedLord = _player->getSelectedLord(); * GraphicalPath * gpath = theMap->getGraphicalPath(); * if( selectedLord ) { * gpath->computePath( selectedLord->getCell(), cell, selectedLord->getCharac( MOVE ) ,selectedLord->getCharac( MAXMOVE )); * selectedLord->setDestination( cell ); * } * } * default: * break; * } */ } void Game::slot_mouseLeftPressed( GenericCell * cell ) { if( _popup && _popup->isVisible() ) { _popup->hide(); _popup->setType(); return; } if( !_player ) { return; } switch( _state ) { case MS_NOTHING: handleClickNothing( cell ); break; case MS_LORD: handleClickLord( cell ); break; case MS_BASE: handleClickBase( cell ); break; case MS_TECHNIC: handleClickTechnic( cell ); break; } } void Game::slot_mouseRightPressed( GenericCell * cell ) { if( !_player ) { return; } if( !_popup ) { _popup = new AttalPopup( this ); } QPoint point = (QPoint)(_view->mapFromScene(cell->getCol() * DataTheme.tiles.getWidth(), cell->getRow() * DataTheme.tiles.getHeight())); GenericLord * lord = cell->getLord(); if( lord ) { _popup->setLord( lord ); } GenericBuilding * build = cell->getBuilding(); if( build ) { _popup->setBuilding( build ); } GenericBase * base = cell->getBase(); if( base ) { _popup->setBase( base ); } GenericEvent * event = cell->getEvent(); if( event ) { _popup->setEvent( event ); } GenericMapCreature * crea = cell->getCreature(); if( crea ) { _popup->setCreature( crea ); } _popup->move( point ); _popup->show(); } void Game::slot_mouseReleased() { } void Game::setState( MapState state ) { _state = state; } void Game::handleClickNothing( GenericCell * cell ) { GenericLord * lord = cell->getLord(); if( lord ) { if( _player->hasLord( lord ) ) { _player->setSelectedLord( lord ); slot_lordSelected(); } return; } GenericBase * base = cell->getBase(); if( base ) { if( _player->hasBase( base ) ) { _player->setSelectedBase( base ); slot_baseSelected(); } return; } } void Game::handleClickLord( GenericCell * cell ) { TRACE("Game::handleClickLord row %d col %d", cell->getRow(), cell->getCol() ); GenericLord * selectedLord = _player->getSelectedLord(); GraphicalPath * gpath = theMap->getGraphicalPath(); if( selectedLord && ( cell->getCoeff() >= 0 ) ) { if(cell->getLord()){ emit sig_Center( cell->getRow(), cell->getCol() ); } if( ((Lord*)selectedLord)->getDestination() != cell ) { gpath->computePath( selectedLord->getCell(), cell, selectedLord->getCharac( MOVE ) ,selectedLord->getCharac( MAXMOVE )); selectedLord->setDestination( cell ); } else { if( selectedLord->getCell()->getBuilding() ) { selectedLord->getCell()->getBuilding()->out( selectedLord ); } QList list = gpath->followPath( selectedLord->getCell(), selectedLord->getCharac( MOVE )) ; _socket->sendMvts( selectedLord->getId(), list ); /* _player->setSelectedLord( NULL ); * _scrLord->deselect(); * _state = MS_NOTHING; */ } } } void Game::handleClickBase( GenericCell * cell ) { GenericBase * base = cell->getBase(); if( base ) { if( _player->hasBase( base ) ) { if( base == _player->getSelectedBase() ) { emit sig_base( base ); return; } else { _player->setSelectedBase( base ); emit sig_baseReinit(); emit sig_lordReinit(); return; } } else { return; } } handleClickNothing( cell ); } void Game::handleClickTechnic( GenericCell * /*cell*/ ) { /// XXX: TODO logEE( "not yet implemented" ); } void Game::enter( GenericLord * /*lord*/, GenericBuilding * /*building*/ ) { /// XXX: TODO //logEE( "not yet implemented" ); } void Game::enter( GenericLord * lord, GenericBase * base ) { TRACE("Game::enter lord %p base %p", lord, base); if( base ) { base->enter( lord ); emit sig_base( base ); } } void Game::beginTurn() { _isPlaying = true; emit sig_statusBar(); _player->newTurn(); ImageTheme.playSound( AttalSound::SND_NEWTURN ); _state = MS_NOTHING; if( _scrLord->getListCount() > 0 ) { _scrLord->select( 0 ); } else if( _scrBase->getListCount() > 0 ) { _scrBase->select( 0 ); } emit sig_beginTurn(); if( _calendar->getDay() == 1 ) { QString dayName = _calendar->getDayName(); QString mess = tr( "It is " ) + dayName + tr(", a new week is beginning"); QMessageBox::information( this, dayName, mess); } } void Game::playerActive( char /* num */ ) { //_gameInfo->waitPlayer( num ); } void Game::nextLord() { _player->nextLord(); slot_lordSelected(); } void Game::nextBase() { _player->nextBase(); slot_baseSelected(); } void Game::endTurn() { assert( _socket ); if( _isPlaying ) { if( _player->shouldEnd() ) { sendEndTurn(); } else { int result = QMessageBox::warning( this, tr("Are you sure ?"), tr( "One or more heroes may still move. Are you sure you want to end your turn ?"), QMessageBox::Yes | QMessageBox::No , QMessageBox::No ); if ( result == QMessageBox::Yes ) { sig_update(); sendEndTurn(); } } } } void Game::sendEndTurn() { _isPlaying = false; _socket->sendTurnEnd(); } void Game::beginGame( int nb ) { TRACE("Game::beginGame int nb %d", nb); restartTimer(); setPlayerNumber( nb ); /*enable some widgets */ emit sig_enableGame( true ); ImageTheme.playMusicMap(); } void Game::endGame() { TRACE("Game::endGame"); reinit(); } void Game::handleSocket() { switch( _socket->getCla1() ) { case SO_MSG: socketMsg(); break; case SO_GAME: socketGame(); break; case SO_TURN: socketTurn(); break; case SO_MODIF: socketModif(); break; case SO_QR: socketQR(); break; case SO_MVT: socketMvt(); break; case SO_TECHNIC: break; case SO_EXCH: socketExchange(); break; case SO_CONNECT: socketConnect(); break; case SO_FIGHT: socketFight(); break; default: logEE( "Unknown socket_class" ); } } void Game::socketMsg() { int cla2 = _socket->getCla2(); QString msg; uchar len = _socket->readChar(); for( uint i = 0; i < len; i++ ) { msg[i] = _socket->readChar(); } if( cla2 == C_MSG_FIGHT ) { return; } emit sig_newMessage( msg ); } void Game::slot_message( QString msg ) { if( _socket ) { _socket->sendMessage( _player->getConnectionName() + " : " + msg ); } else { emit sig_newMessage( "(Not connected) : " + msg ); } } void Game::socketGame() { switch( _socket->getCla2() ) { case C_GAME_BEGIN: beginGame( _socket->readChar() ); /// XXX: clear old stuff if necessary break; case C_GAME_LOST: socketGameLost(); break; case C_GAME_WIN: socketGameWin(); break; case C_GAME_END: emit sig_endGame(); break; case C_GAME_INFO: socketGameInfo(); break; case C_GAME_CALENDAR: socketGameCalendar(); break; case C_GAME_TAVERN: break; default: logEE( "case not handled" ); break; } } void Game::socketGameLost() { QString text; AttalMessage msg; int nb = _socket->readChar(); if( nb == _player->getNum() ) { msg.setWindowTitle( tr( "You lose") ); msg.addText(tr( " You lose") ); msg.addPixmap( ImageTheme.getFlag( nb ) ); msg.exec(); emit sig_result( false ); } else { text = tr("Player ") + QString::number( nb ) + tr(" has lost."); msg.setWindowTitle( tr("A player has lost.") ); msg.addText( text ); msg.addPixmap( ImageTheme.getFlag( nb ) ); msg.exec(); } } void Game::socketGameWin() { QString text; AttalMessage msg; int nb = _socket->readChar(); msg.setWindowTitle( tr("A player has Win.") ); if( nb == _player->getNum() ) { msg.addText( tr("You win !!") ); msg.addPixmap( ImageTheme.getFlag( nb ) ); msg.exec(); emit sig_result( true ); } else { text = tr("Player ") + QString::number( nb ) + tr(" has win."); msg.addText( text + tr(" You lose") ); msg.addPixmap( ImageTheme.getFlag( nb ) ); msg.exec(); //emit sig_result( false ); } } void Game::socketGameInfo() { switch( _socket->getCla3() ) { case C_INFOPLAYER_TEAM: socketGameInfoTeam(); break; case C_INFOPLAYER_NAME: break; } } void Game::socketGameInfoTeam() { uchar player = _socket->readChar(); uchar teamId = _socket->readChar(); TRACE("Game::GameInfoTeam player %d, teamId %d", player, teamId); if( getPlayer( player ) ) { getPlayer( player )->setTeam( teamId ); } if( player == _player->getNum() ) { _player->setTeam( teamId ); } } void Game::socketGameCalendar() { _calendar->setDateByType( 0 , _socket->readInt()); _calendar->setDateByType( 1 , _socket->readInt()); _calendar->setDateByType( 2 , _socket->readInt()); _calendar->setDateByType( 3 , _socket->readInt()); _calendar->setDateByType( 4 , _socket->readInt()); emit sig_statusBar(); } void Game::socketTurn() { switch( _socket->getCla2() ) { case C_TURN_PLAY: socketTurnPlay(); break; case C_TURN_LORD: logEE( "Should not happen (Client : SO_TURN/C_TURN_LORD)" ); break; case C_TURN_PLORD: logEE( "Should not happen (Client : SO_TURN/C_TURN_PLORD)" ); break; case C_TURN_END: logEE( "Should not happen (Client : SO_TURN/C_TURN_END)" ); break; } } void Game::socketTurnPlay() { TRACE("Game::socketTurnPlay"); uint num = _socket->readChar(); if( num == (uint)_player->getNum() ) { // casting from int to uint -- getNum,setNum, and _num should all be using uint's beginTurn(); } else { //useful only for gameInfo, now obsolete //playerActive( num ); } } void Game::socketMvt() { // XXX: not finished at all TRACE("Game::socketMvt"); if( _socket->getCla2() == C_MVT_ONE ) { uchar lord = _socket->readChar(); int row = _socket->readInt(); int col = _socket->readInt(); TRACE("Game::socketMvt lord %d, row %d, col %d", lord, row, col); if(!_map->inMap(row,col)) { return; } GenericLord * theLord = _lords.at( lord ); if( theLord ) { GenericCell * oldCell = theLord->getCell(); theLord->setCell( _map->at( row, col ) ); if( oldCell ) { int oldRow = oldCell->getRow(); int oldCol = oldCell->getCol(); emit sig_cellChanged( oldRow, oldCol ); } else { logEE("Should be a cell"); } emit sig_Center( row, col ); if( _map->at( row, col )->getBuilding() != 0 ) { if( _lords.at( lord )->getOwner() == _player ) { enter( _player->getSelectedLord(), _map->at( row, col )->getBuilding() ); } } else if( _map->at( row, col )->getBase() != 0 ) { if( theLord->getOwner() == _player ) { TRACE("Game::socketMvt: EnterBase"); enter( _player->getSelectedLord(), _map->at( row, col )->getBase() ); } } emit sig_cellChanged( row, col ); } else { logEE( "Try to move a non-existent lord %d to cell (%d, %d)", lord, row, col ); } } else { logEE( "Should not happen" ); } } void Game::socketExchange() { switch( _socket->getCla2() ) { case C_EXCH_START: exchangeStart(); break; case C_EXCH_UNIT: exchangeUnits(); break; case C_EXCH_ARTEFACT: exchangeArtefact(); break; case C_EXCH_BASEUNITCL: exchangeBaseUnits(); break; default: break; } } void Game::exchangeStart() { uchar idLord1 = _socket->readChar(); uchar idLord2 = _socket->readChar(); GenericLord * lord1 = (GenericLord * ) _lords.at( idLord1 ); GenericLord * lord2 = (GenericLord * ) _lords.at( idLord2 ); if( _lordExchange == NULL ) { _lordExchange = new LordExchange( this, _socket ); } _lordExchange->initLords( lord1, lord2 ); _lordExchange->show(); } void Game::exchangeUnits() { /*uchar idLord1 = */_socket->readChar(); /*uchar idUnit1 = */_socket->readChar(); /*uchar idLord2 = */_socket->readChar(); /*uchar idUnit2 = */_socket->readChar(); logEE("Should not happen"); } void Game::exchangeArtefact() { uchar idLord1 = _socket->readChar(); int item = _socket->readInt(); uchar idLord2 = _socket->readChar(); exchangeArtefactLord( idLord1, idLord2, item); emit sig_updateWidget(); } void Game::exchangeBaseUnits() { /*int row = */_socket->readInt(); /*int col = */_socket->readInt(); /*uchar idUnit1 = */_socket->readChar(); /*uchar idLord = */_socket->readChar(); /*uchar idUnit2 =*/ _socket->readChar(); } void Game::socketModif() { /// XXX: check number of args below... (?) switch( _socket->getCla2() ) { case C_MOD_MAP: socketModifMap(); break; case C_MOD_CELL: socketModifCell(); break; case C_MOD_LORD: socketModifLord(); break; case C_MOD_PLAYER: socketModifPlayer(); break; case C_MOD_BASE: socketModifBase(); break; case C_MOD_BUILD: socketModifBuilding(); break; case C_MOD_ARTEFACT: socketModifArtefact(); break; case C_MOD_CREATURE: socketModifCreature(); break; case C_MOD_EVENT: socketModifEvent(); break; } } void Game::socketModifMap() { int h = _socket->readInt(); int w = _socket->readInt(); TRACE("Game::socketModifMap h/w %d/%d", h, w ); _map->newUnknownMap( h, w ); _miniMap->redrawMap( theMap ); _miniMap->slot_mapviewResized( _view->width() / theMap->width(), _view->height() / theMap->height() ); // HACK layout()->update(); } void Game::socketModifCell() { int row = _socket->readInt(); int col = _socket->readInt(); int type = _socket->readInt(); uchar diversification = _socket->readChar(); int a4 = _socket->readInt(); int a5 = _socket->readInt(); int a6 = _socket->readInt(); int a7 = _socket->readInt(); //TRACE("Game::socketModifCell row %d, col %d, type %d, diversification %d, a4 %d, a5 %d, a6 %d, a7 %d", row, col, type, diversification, a4, a5, a6, a7 ); _map->changeCell( row, col, type, a4, a5, a6, a7 , diversification ); } void Game::socketModifLord() { switch( _socket->getCla3() ) { case C_LORD_VISIT: socketModifLordVisit(); break; case C_LORD_NEW: socketModifLordNew(); break; case C_LORD_CHARAC: socketModifLordCharac(); break; case C_LORD_UNIT: socketModifLordUnit(); break; case C_LORD_REMOVE: socketModifLordRemove(); break; case C_LORD_GARRISON: socketModifLordGarrison(); break; case C_LORD_MACHINE: socketModifLordMachine(); break; } } void Game::socketModifLordVisit() { /// XXX: not finished, we should use 'num' for the player color uchar num = _socket->readChar(); int row = _socket->readInt(); int col = _socket->readInt(); uchar id = _socket->readChar(); uchar present = _socket->readChar(); Lord * lord = (Lord *) _lords.at( id ); if( present == 1 ) { lord->setAnimated( true ); lord->setEnabled( true ); lord->setSelected( true ); //lord->setActive( true ); /// XXX: change lord->setOwner( getPlayer( num ) ); lord->setCell( _map->at( row, col ) ); } else { if( lord->getCell() ) { lord->getCell()->setLord(NULL); } } } void Game::socketModifLordNew() { int row = _socket->readInt(); int col = _socket->readInt(); uchar id = _socket->readChar(); TRACE("Game::socketModifLordNew row %d, col %d, id %d", row, col ,id ); Lord * lord = (Lord *) _lords.at( id ); lord->setAnimated( true ); lord->setEnabled( true ); lord->setVisible( true ); lord->setSelected( true ); //lord->setActive( true ); lord->setCell( _map->at( row, col ) ); lord->setOwner( _player ); _player->addLord( lord ); GenericBase * base = _map->at( row, col )->getBase(); if( base && base->getOwner() == _player ) { enter( lord , base ); } emit sig_lordReinit(); emit sig_cellChanged( row, col ); } void Game::socketModifLordUnit() { uchar id = _socket->readChar(); uchar pos = _socket->readChar(); uchar race = _socket->readChar(); uchar level = _socket->readChar(); int nb = _socket->readInt(); uchar move = _socket->readChar(); int health = _socket->readInt(); updateLordUnit( id , pos ,race ,level, nb,move, health); emit sig_updateWidget(); emit sig_exchange(); } void Game::socketModifLordRemove() { int idLord = _socket->readChar(); TRACE("Game::socketModifLordRemove idLord %d", idLord ); Lord * lord = ( Lord *)_lords.at( idLord ); if(lord) { lord->removeFromGame(); emit sig_lordReinit(); GraphicalPath * gpath = theMap->getGraphicalPath(); gpath->clearPath(); lord->setVisible( false ); } } void Game::socketModifLordCharac() { char lord = _socket->readChar(); char charac = _socket->readChar(); int nb = _socket->readInt(); if(_lords.at( lord )) { _lords.at( lord )->setBaseCharac( (LordCharac) charac, nb ); } } void Game::socketModifLordGarrison() { uchar lord = _socket->readChar(); uchar state = _socket->readChar(); if(_lords.at( lord )) { _lords.at( lord )->setVisible( state != 1 ); } emit sig_lordReinit(); } void Game::socketModifLordMachine() { uchar lord = _socket->readChar(); uchar id = _socket->readChar(); if(_lords.at( lord )) { _lords.at( lord )->addMachine( id ); } } void Game::socketModifPlayer() { switch( _socket->getCla3() ) { case C_PLAY_RESS: { socketModifRess( _player , _socket); emit sig_statusBar(); } break; case C_PLAY_PRICE: { uchar ress = _socket->readChar(); uint price = _socket->readInt(); _player->getPriceMarket()->setResourcePrice( ress, price); } break; /* case C_PLAY_POPUL: socketModifPlayerPopulation(); break; */ } } /* void Game::socketModifPlayerPopulation() { uint population = _socket->readInt(); TRACE("Game::socketModifPlayer population = %d", population); _player->setPopulation( population ); emit sig_statusBar(); } */ void Game::socketModifBase() { switch( _socket->getCla3() ) { case C_BASE_NEW: socketModifBaseNew(); break; case C_BASE_OWNER: socketModifBaseOwner(); break; case C_BASE_NAME: socketModifBaseName(); break; case C_BASE_BUILDING: socketModifBaseBuilding(); break; case C_BASE_UNIT: socketModifBaseUnit(); break; case C_BASE_POPUL: socketModifBasePopulation(); break; case C_BASE_RESS: socketModifBaseResources(); break; case C_BASE_PRODUCTION: socketModifBaseProduction(); break; } } void Game::socketModifBaseNew() { uchar race = _socket->readChar(); int row = _socket->readInt(); int col = _socket->readInt(); int population = _socket->readInt(); uchar id = _socket->readChar(); int nb = _socket->readChar(); QList forbidlist; for( int i = 0; i < nb; i++ ) { forbidlist.append( _socket->readChar() ); } getNewBase( race, row, col, population, id, nb, forbidlist); } void Game::socketModifBaseOwner() { int row = _socket->readInt(); int col = _socket->readInt(); uchar playerNum = _socket->readChar(); GenericBase * base = _map->at( row, col )->getBase(); TRACE("Game::socketModifBaseOwner row %d, col %d, player num %d", row,col,playerNum); if( playerNum == _player->getNum() ) { _player->addBase( base ); base->setOwner( _player ); } else { /// XXX: improve management of base of other player if( base->getOwner() == _player ) { _player->removeBase( base ); } base->setOwner( getPlayer( playerNum ) ); } emit sig_baseReinit(); } void Game::socketModifBaseName() { int row = _socket->readInt(); int col = _socket->readInt(); uint length = _socket->readInt(); QString name; for( uint i = 0; i < length; i++ ) { name[i] = _socket->readChar(); } GenericBase * base = _map->at( row, col )->getBase(); base->setName( name ); } void Game::socketModifBaseBuilding() { int row = _socket->readInt(); int col = _socket->readInt(); uchar level = _socket->readChar(); bool create = (bool)_socket->readChar(); updateBaseBuilding( row, col, level,create ); } void Game::socketModifBaseUnit() { TRACE("Game::socketModifBaseUnit"); int row = _socket->readInt(); int col = _socket->readInt(); uchar pos = _socket->readChar(); uchar race = _socket->readChar(); uchar level = _socket->readChar(); int number = _socket->readInt(); if( _map->at( row, col )->getBase() ) { GenericBase * base = _map->at( row, col )->getBase(); base->addUnit( pos, race, level, number ); } emit sig_exchange(); } void Game::socketModifBasePopulation() { int row = _socket->readInt(); int col = _socket->readInt(); uint popul = _socket->readInt(); GenericBase * base = _map->at( row, col )->getBase(); if(base){ base->setPopulation(popul); } } void Game::socketModifBaseResources() { int row = _socket->readInt(); int col = _socket->readInt(); GenericBase * base = _map->at( row, col )->getBase(); TRACE("Game::socketModifBaseResources row %d, col %d", row,col ); socketModifRess( base , _socket); emit sig_statusBar(); } void Game::socketModifBaseProduction() { int row = _socket->readInt(); int col = _socket->readInt(); uchar race = _socket->readChar(); uchar level = _socket->readChar(); int number = _socket->readInt(); TRACE("Game::socketModifBaseProduction row %d, col %d, race %d, level %d, number %d", row,col, race, level, number ); if( _map->at( row, col )->getBase() ) { TRACE("base"); GenericBase * base = _map->at( row, col )->getBase(); Creature * creature = DataTheme.creatures.at( race, level ); base->setCreatureProduction( creature, number ); } } void Game::socketModifBuilding() { switch( _socket->getCla3() ) { case C_BUILD_NEW: socketModifBuildingNew(); break; case C_BUILD_OWNER: socketModifBuildingOwner(); break; case C_BUILD_RESS: socketModifBuildingResources(); break; } } void Game::socketModifBuildingNew() { uchar type = _socket->readChar(); int id = _socket->readInt(); int row = _socket->readInt(); int col = _socket->readInt(); getNewBuilding( type, id , row, col); } void Game::socketModifBuildingOwner() { int row = _socket->readInt(); int col = _socket->readInt(); int playNum = _socket->readInt(); TRACE("Game::socketModifBuildingOwner row %d, col %d,player num %d", row,col,playNum); Building * build = (Building*)_map->at( row, col )->getBuilding(); if( playNum == _player->getNum() ) { if( build ) { _player->addBuilding( (GenericBuilding *) build ); build->setOwner( _player ); } } else { if( build ) { if(build->getOwner() == _player){ _player->removeBuilding( (GenericBuilding *) build ); } if( playNum == GenericPlayer::NO_PLAYER ) { build->setOwner( 0 ); } else { build->setOwner( getPlayer(playNum) ); } } } } void Game::socketModifBuildingResources() { int row = _socket->readInt(); int col = _socket->readInt(); TRACE("Game::socketModifBuildingOwner row %d, col %d", row,col); Building * build = (Building*)_map->at( row, col )->getBuilding(); socketModifRess( build , _socket); } void Game::socketModifArtefact() { switch( _socket->getCla3() ) { case C_ART_DELLORD: { uint type = _socket->readInt(); char lord = _socket->readChar(); getLord( lord )->getArtefactManager()->removeArtefactByType( type ); } break; case C_ART_ADDLORD: { ImageTheme.playSound( AttalSound::SND_GOOD ); uint type = _socket->readInt(); char lord = _socket->readChar(); if( ! getLord( lord )->getArtefactManager()->hasArtefactType( type ) ) { getLord( lord )->getArtefactManager()->addArtefact( type ); } } break; } } void Game::socketModifCreature() { switch( _socket->getCla3() ) { case C_CRE_NEW: socketModifCreatureNew(); break; case C_CRE_UPDATE: socketModifCreatureUpdate(); break; case C_CRE_DEL: socketModifCreatureRemove(); break; case C_CRE_RESS: socketModifCreatureRess(); break; } } void Game::socketModifCreatureNew() { int row = _socket->readInt(); int col = _socket->readInt(); uchar race = _socket->readChar(); uchar level = _socket->readChar(); int nb = _socket->readInt(); bool looking = (bool) _socket->readChar(); getNewMapCreature( row, col, race, level, nb, looking); } void Game::socketModifCreatureUpdate() { int row = _socket->readInt(); int col = _socket->readInt(); int nb = _socket->readInt(); GenericMapCreature * creature = _map->at( row, col )->getCreature(); if( creature ) { creature->setCategoryNumber( nb ); } } void Game::socketModifCreatureRemove() { int row = _socket->readInt(); int col = _socket->readInt(); removeMapCreature( row, col ); } void Game::socketModifCreatureRess() { int row = _socket->readInt(); int col = _socket->readInt(); GenericMapCreature * creature = _map->at( row, col )->getCreature(); socketModifRess( creature , _socket); } void Game::socketModifEvent() { switch( _socket->getCla3() ) { case C_EVENT_NEW: socketEventNew(); break; case C_EVENT_DEL: socketEventDel(); break; } } void Game::socketEventNew() { uint i; int row = _socket->readInt(); int col = _socket->readInt(); GenericEvent::EventType type = (GenericEvent::EventType) _socket->readChar(); GenericEvent * event = NULL; if( type == GenericEvent::EventArtefact ) { int id = _socket->readInt(); uchar typeArtefact = _socket->readChar(); event = getNewArtefact( id ); GenericArtefact * artefact = event->getArtefact(); artefact->setType( typeArtefact ); } else if( type == GenericEvent::EventBonus ) { uchar typeBonus = _socket->readChar(); uchar nbParam = _socket->readChar(); event = getNewBonus(); GenericBonus * bonus = event->getBonus(); bonus->setType( (GenericBonus::BonusType) typeBonus ); for( i = 0; i < nbParam; i++ ) { bonus->addParam( _socket->readInt() ); } bonus->setupBonus(); } else if( type == GenericEvent::EventChest ) { uchar nbParam = _socket->readChar(); event = getNewChest(); GenericChest * chest = event->getChest(); for( i = 0; i < nbParam; i++ ) { chest->addParam( _socket->readInt() ); } dynamic_cast(chest)->setupChest(); } event->setCell( _map->at( row, col ) ); _map->at( row, col )->setEvent( event ); } void Game::socketEventDel() { int row = _socket->readInt(); int col = _socket->readInt(); removeEvent( row, col ); } void Game::socketConnect() { switch( _socket->getCla2() ) { case C_CONN_OK: socketConnectOk(); break; case C_CONN_ID: socketConnectId(); break; case C_CONN_NAME: socketConnectName(); break; case C_CONN_PLAYER: break; } } void Game::socketConnectOk() { TRACE("Game::socketConnectOk"); _socket->sendConnectionVersion( VERSION ); _socket->sendConnectionName( _player->getConnectionName() ); if( !_local ) { emit sig_newMessage( QString( tr("Connection established, %1") ).arg( _player->getConnectionName() ) ); emit sig_newMessage( QString( tr("Host address %1") ).arg( _socket->peerAddress().toString())); emit sig_newMessage( QString( tr("Host port %1,") ).arg( _socket->peerPort())+ QString( tr(" Our port %1") ).arg( _socket->peerPort() ) ); } } void Game::socketConnectId() { uchar tmp; tmp=_socket->readChar(); _player->setNum( tmp ); emit sig_newMessage( QString( tr("Connection ID, %1") ).arg( _player->getNum() ) ); } void Game::socketConnectName() { QString res; uint len = _socket->readChar(); for( uint i = 0; i < len; i++) { res.append( _socket->readChar() ); } _player->setConnectionName(res); emit sig_newMessage( QString( tr("Name of player: %1") ).arg( res ) ); } /*! */ void Game::slot_lordSelected() { emit sig_Center(_player->getSelectedLord()->getCell()->getRow(), _player->getSelectedLord()->getCell()->getCol()); _scrBase->deselect(); } void Game::slot_baseSelected() { emit sig_Center(_player->getSelectedBase()->getCell()->getRow(), _player->getSelectedBase()->getCell()->getCol()); _scrLord->deselect(); } void Game::slot_displayLord() { emit sig_Center(_player->getSelectedLord()->getCell()->getRow(), _player->getSelectedLord()->getCell()->getCol()); if( _player->numLord() > 0 ) { if( !_dispLord ) { _dispLord = new DisplayLordTab( _player, _socket, this ); } if( _isPlaying ) { _dispLord->reupdate(); _dispLord->exec(); } } } void Game::slot_displayBase() { if(_player->getSelectedBase()){ emit sig_Center(_player->getSelectedBase()->getCell()->getRow(), _player->getSelectedBase()->getCell()->getCol()); if( _isPlaying ) { emit sig_base( _player->getSelectedBase() ); } } } void Game::socketQR() { switch( _socket->getCla2() ) { case C_QR_MSG_NEXT: socketQRMsgNext(); break; case C_QR_MSG_END: socketQRMsgEnd(); break; case C_QR_LEVEL: socketQRLevel(); break; case C_QR_CHEST: socketQRChest(); break; case C_QR_CREATURE_FLEE: socketQRCreature(QRFLEE); break; case C_QR_CREATURE_MERCENARY: socketQRCreature(QRMERCENARY); break; case C_QR_CREATURE_JOIN: socketQRCreature(QRJOIN); break; case C_QR_ANSWER: logEE( "Should not happen" ); break; } } void Game::socketQRMsgNext() { uchar len = _socket->readChar(); for( uint i = 0; i < len; i++ ) { _msg.append( _socket->readChar() ); } } void Game::socketQRMsgEnd() { //QMessageBox::information( this, "Information", QString( buf+(3*sizeof(char)) ), 0 ); uchar type = _socket->readChar(); socketQRMsgNext(); if( type == QR_SCEN_DESC ) { emit sig_scenInfo( _msg ); } QMessageBox::information( this, tr("Information"), _msg ); _msg = ""; } void Game::socketQRLevel() { GainLevel * level = new GainLevel( this ); level->reinit(); level->exec(); _socket->sendAnswer( level->getChoice() ); delete level; } void Game::socketQRChest() { AskChest * chest = new AskChest(); chest->exec(); _socket->sendAnswerEnum( chest->getResult() ); delete chest; } void Game::socketQRCreature(QRCreature state) { AskDialog dialog; QString text; /// XXX: to improve with name/category of creature switch(state) { case QRFLEE: text = tr("The creatures are fleeing. Do you want to let them flee ?") ; break; case QRMERCENARY: text = tr("You can buy these creatures. Do you want to buy them ?") ; break; case QRJOIN: text = tr("The creatures want to join. Do you accept them ?") ; break; default: break; } dialog.setText( text ); dialog.setYesNo(); if( dialog.exec() ) { _socket->sendAnswerYesNo( true ); } else { _socket->sendAnswerYesNo( false ); } } void Game::socketFight() { switch( _socket->getCla2() ) { case C_FIGHT_INIT: socketFightInit(); break; case C_FIGHT_LORD: //logEE( "Should not happen (FIGHT_LORD)" ); break; case C_FIGHT_UNIT: //logEE( "Should not happen (FIGHT_UNIT)" ); break; case C_FIGHT_END: socketFightEnd(); break; default: //logEE( "Should not happen (FIGHT)" ); break; } } void Game::socketFightInit() { uchar cla = _socket->readChar(); uchar lord = _socket->readChar(); emit sig_fight( getLord( lord ), (CLASS_FIGHTER)cla ); stopTimer(); } void Game::socketFightEnd() { restartTimer(); } void Game::displayMiniMap( bool state ) { if( _miniMap ) { if( state ) { _miniMap->show(); _miniMap->redrawMap( theMap ); } else { _miniMap->hide(); } } } void Game::displayFullScreen( bool state ) { if( _chat && _miniMap) { if( state ) { _chat->show(); _miniMap->show(); } else { _chat->hide(); _miniMap->hide(); } } } void Game::updateOptions() { updateAnimations(); updateDispositionMode(); } void Game::updateAnimations() { AttalSettings::StrategyModeSettings settings = AttalSettings::getInstance()->getStrategyModeSettings(); if( settings.isAnimationEnabled ) { restartTimer(); } else { stopTimer(); } } void Game::updateDispositionMode() { AttalSettings::DispositionMode mode = AttalSettings::getInstance()->getDispositionMode(); _layH1->removeWidget( _view ); if( _layControlV1 ) { _layH1->removeItem( _layControlV1 ); } if( _layControlH1 ) { delete _layControlH1; _layControlH1 = NULL; } _layControlH1 = new QHBoxLayout(); if( _layControlV1 ) { delete _layControlV1; _layControlV1 = NULL; } _layControlV1 = new QVBoxLayout(); switch( mode ) { case AttalSettings::DM_VERYCOMPACT: _scrLord->repaintButtons( 2 ); _scrBase->repaintButtons( 2 ); /* _layControlH1->addStretch( 1 ); _layControlH1->addWidget( _scrLord ); _layControlH1->addStretch( 1 ); _layControlH1->addWidget( _scrBase ); _layControlH1->addStretch( 1 ); _layControlV1->addLayout( _layControlH1, 1 ); _layControlV1->addWidget( _control, 0, Qt::AlignHCenter ); */ _layControlV1->addWidget( _scrLord, 1, Qt::AlignHCenter ); _layControlV1->addWidget( _control, 0, Qt::AlignHCenter ); _layControlV1->addWidget( _scrBase, 1, Qt::AlignHCenter ); break; case AttalSettings::DM_COMPACT: _scrLord->repaintButtons( 3 ); _scrBase->repaintButtons( 3 ); _layControlV1->addWidget( _scrLord, 1, Qt::AlignHCenter ); _layControlV1->addWidget( _control, 0, Qt::AlignHCenter ); _layControlV1->addWidget( _scrBase, 1, Qt::AlignHCenter ); break; case AttalSettings::DM_FULL: _scrLord->repaintButtons( 4 ); _scrBase->repaintButtons( 4 ); _layControlV1->addWidget( _scrLord, 1, Qt::AlignHCenter ); _layControlV1->addWidget( _control, 0, Qt::AlignHCenter ); _layControlV1->addWidget( _scrBase, 1, Qt::AlignHCenter ); break; } _layH1->addWidget( _view, 1 ); _layH1->addLayout( _layControlV1 ); emit sig_baseReinit(); emit sig_lordReinit(); } void Game::timerEvent(QTimerEvent * /* event */) { stopTimer(); advanceAnimations(); restartTimer(); } void Game::setAdvancePeriod( int period ) { stopTimer(); _period = period; restartTimer(); } void Game::restartTimer() { AttalSettings::StrategyModeSettings settings = AttalSettings::getInstance()->getStrategyModeSettings(); if( _idTime == -1 && settings.isAnimationEnabled ) { _idTime = startTimer(_period); } } void Game::stopTimer() { if( _idTime != -1 ) { killTimer( _idTime ); _idTime = -1; } } attal-src-1.0-rc2/libClient/game.h0000644000175000017500000001601011016036223014433 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** game.h ** Manages the whole game ** ** Version : $Id: game.h,v 1.79 2008/05/24 16:04:35 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 17/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GAME_H #define GAME_H // include files for QT #include #include #include // application specific includes #include "libClient/player.h" #include "libCommon/genericCell.h" #include "libClient/map.h" #include "libClient/gameControl.h" #include "libClient/graphicalGameData.h" #include "libClient/mapView.h" #include "libClient/widget.h" #include "libCommon/attalSocket.h" #include "libCommon/log.h" class BaseInfo; class Calendar; class ChatWidget; class DisplayLordTab; class GameInfo; class GenericBase; class InfoStack; class LordExchange; class LordInfo; class MiniMap; class QHBoxLayout; class QPixmap; class QVBoxLayout; /* ------------------------------ * Game * ------------------------------ */ /** comment for the class */ class Game : public QWidget, public GraphicalGameData { Q_OBJECT public: /** Constructor */ Game( QWidget * parent = 0, const char * name = 0 ); /** Destructor : delete player and lord */ ~Game(); /** Reinit */ void reinit(); /** Associate a socket to the Game (for exchange with the server) */ void setSocket( AttalSocket * sock ) { _socket = sock; } /** Lord 'lord' enters in base 'base' */ void enter( GenericLord * lord, GenericBase * base ); /** Lord 'lord' enters in building 'build' */ void enter( GenericLord * lord, GenericBuilding * building ); /** Handle socket data */ void handleSocket(); /** Begin game with 'nb' players */ void beginGame( int nb ); /** End game */ void endGame(); /** Begin turn */ void beginTurn(); /** Player active is player 'num' */ void playerActive( char num ); /** Activate next lord */ void nextLord(); /** Activate next base */ void nextBase(); /** Return the player associated to the game */ Player * getGamePlayer() { return _player; } /** Sets the name of the player */ void setPlayerName( QString name ); enum MapState { MS_NOTHING, MS_LORD, MS_BASE, MS_TECHNIC }; enum QRCreature { QRFLEE, QRMERCENARY, QRJOIN }; void setState( MapState state ); MapState getState() { return _state; } void displayMiniMap( bool state ); void displayFullScreen( bool state ); ChatWidget * getChat() {return (_chat) ? _chat : 0 ; } void updateOptions(); void setAdvancePeriod( int period ); void setLocal( bool local ) { _local = local; } void restartTimer(); void stopTimer(); signals: void sig_base( GenericBase * ); void sig_fight( GenericLord * lord, CLASS_FIGHTER cla ); void sig_statusMsg( const QString & ); void sig_scenInfo( const QString & ); void sig_Center( int , int ); void sig_endGame(); void sig_endTurn(); void sig_beginTurn(); void sig_exchange(); void sig_result(bool); /* signal to enable some buttons */ void sig_enableGame( bool ); void sig_statusBar(); void sig_newMessage( const QString & ); void sig_baseReinit(); void sig_lordReinit(); void sig_cellChanged( int , int ); void sig_updateWidget(); void sig_update(); public slots: /** Slot for displaying lord */ void slot_displayLord(); /** Slot for displaying base */ void slot_displayBase(); void slot_lordSelected(); void slot_baseSelected(); /** */ void slot_message( QString ); void updateAnimations(); void updateDispositionMode(); private slots: void endTurn(); void slot_mouseMoved( GenericCell *cell ); void slot_mouseLeftPressed( GenericCell * cell ); void slot_mouseRightPressed( GenericCell * cell ); void slot_mouseReleased(); protected: void timerEvent(QTimerEvent *event); private: void initWidgets(); void sendEndTurn(); void handleClickNothing( GenericCell * cell ); void handleClickLord( GenericCell * cell ); void handleClickBase( GenericCell * cell ); void handleClickTechnic( GenericCell * cell ); /** Manage socket SO_MSG */ void socketMsg(); /** Manage socket SO_GAME */ void socketGame(); void socketGameLost(); void socketGameWin(); void socketGameInfo(); void socketGameInfoTeam(); void socketGameCalendar(); /** Manage socket SO_TURN */ void socketTurn(); void socketTurnPlay(); /** Manage socket SO_MVT */ void socketMvt(); /** Manage socket SO_MODIF */ void socketModif(); void socketModifCell(); void socketModifLord(); void socketModifBase(); void socketModifBuilding(); void socketModifArtefact(); void socketModifPlayer(); //void socketModifPlayerPopulation(); void socketModifCreature(); void socketModifMap(); void socketModifEvent(); void socketEventNew(); void socketEventDel(); void socketModifLordVisit(); void socketModifLordNew(); void socketModifLordUnit(); void socketModifLordRemove(); void socketModifLordCharac(); void socketModifLordGarrison(); void socketModifLordMachine(); void socketModifBaseNew(); void socketModifBaseOwner(); void socketModifBaseName(); void socketModifBaseBuilding(); void socketModifBaseUnit(); void socketModifBasePopulation(); void socketModifBaseResources(); void socketModifBaseProduction(); void socketModifBuildingNew(); void socketModifBuildingOwner(); void socketModifBuildingResources(); void socketModifCreatureNew(); void socketModifCreatureUpdate(); void socketModifCreatureRemove(); void socketModifCreatureRess(); /** Manage socket SO_CONNECT */ void socketConnect(); void socketConnectOk(); void socketConnectId(); void socketConnectName(); /** Manage socket SO_EXCH */ void socketExchange(); void exchangeStart(); void exchangeUnits(); void exchangeArtefact(); void exchangeBaseUnits(); void socketQR(); void socketQRMsgNext(); void socketQRMsgEnd(); void socketQRLevel(); void socketQRChest(); void socketQRCreature(QRCreature state); void socketFight(); void socketFightInit(); void socketFightEnd(); Player * _player; AttalSocket * _socket; GameControl * _control; AttalPopup * _popup; DisplayLordTab * _dispLord; LordExchange * _lordExchange; MiniMap * _miniMap; MapView * _view; ChatWidget * _chat; ScrollLord * _scrLord; ScrollBase * _scrBase; GenericCell * _currentCell; bool _isPlaying; QString _msg; QVBoxLayout * _layControlV1; QHBoxLayout * _layControlH1; QHBoxLayout * _layH1; QVBoxLayout * _layout; bool _redraw, _local; int _idTime, _period; MapState _state; }; #endif // GAME_H attal-src-1.0-rc2/libClient/gameControl.cpp0000644000175000017500000002332711002651053016337 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** gameConrol.cpp ** Widget on the right, controlling the game ** ** Version : $Id: gameControl.cpp,v 1.30 2008/04/20 14:24:43 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 02/09/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "gameControl.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include #include #include // application specific includes #include "conf.h" #include "libCommon/attalSettings.h" #include "libClient/attalButton.h" #include "libClient/imageTheme.h" GameControl::GameControl( QWidget * parent, const char * /* name*/ ) : QWidget( parent ) { _cen = new CentralControl( this ); QHBoxLayout * lay = new QHBoxLayout( this ); lay->addWidget( _cen ); lay->addStretch( 1 ); lay->activate(); connect( _cen, SIGNAL( sig_endTurn() ), SIGNAL( sig_endTurn() ) ); connect( parent, SIGNAL( sig_enableGame( bool ) ), SIGNAL( sig_enableGame(bool) ) ); } void GameControl::setPlayer( Player * player ) { _player = player; _cen->setPlayer( player ); } void GameControl::reinit() { } void GameControl::selectFirst() { if( ! _player->selectFirstLord() ) { _player->selectFirstBase(); } reinit(); } void GameControl::disableGame() { _cen->disableGame(); } void GameControl::enableGame() { _cen->enableGame(); } void GameControl::slot_baseSelected() { } void GameControl::slot_lordSelected() { } // // ----- CentralControl ----- // CentralControl::CentralControl( QWidget * parent, const char * /* name */ ) :QWidget( parent ) { _player = 0; _pbNext = new QPushButton( this ); _pbNext->setFixedSize( 70, 25 ); _pbNext->setText( tr("Next Lord") ); _pbTurn = new QPushButton( this ); _pbTurn->setFixedSize( 70, 25 ); _pbTurn->setText( tr("End Turn") ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSizeConstraint(QLayout::SetFixedSize); layout->setMargin( 3 ); layout->setSpacing( 5 ); layout->addWidget( _pbNext ); layout->addWidget( _pbTurn ); layout->activate(); connect( _pbNext, SIGNAL( clicked() ), SLOT( slot_nextLord() ) ); connect( _pbTurn, SIGNAL( clicked() ), SIGNAL( sig_endTurn() ) ); setEnabled( false ); //disableGame(); connect( parent, SIGNAL( sig_enableGame( bool ) ), SLOT( setEnabled(bool) ) ); } void CentralControl::disableGame() { _pbTurn->setEnabled( false ); _pbNext->setEnabled( false ); } void CentralControl::enableGame() { _pbTurn->setEnabled( true ); _pbNext->setEnabled( true ); } // // ----- ScrollList ----- // ScrollList::ScrollList( bool horizontal, uint nbItem, QWidget * parent, const char * /* name */) : QWidget( parent ), _player( 0 ), _current( 0 ), _selected( -1 ), _horizontal( horizontal ), _nbItem( nbItem ) { QPushButton * pbDown = new QPushButton( this ); QPushButton * pbUp = new QPushButton( this ); QBoxLayout * layout; if( _horizontal ) { pbUp->setIcon( QIcon(QPixmap( *ImageTheme.getWidgetPixmap( ARROW_LEFT ) ) )); pbUp->setFixedSize( 9, 50 ); //pbUp->move( 265, 0 ); pbDown->setIcon( QIcon(QPixmap( *ImageTheme.getWidgetPixmap( ARROW_RIGHT) ))); pbDown->setFixedSize( 9, 50 ); //pbDown->move( 0, 0 ); layout = new QHBoxLayout( this ); setFixedSize( (_nbItem * 55) + 23, 60 ); } else { pbUp->setIcon( QIcon(QPixmap( *ImageTheme.getWidgetPixmap( ARROW_UP ) ))); pbUp->setFixedSize( 50, 9 ); //pbUp->move( 0, 0 ); pbDown->setIcon( QIcon(QPixmap( *ImageTheme.getWidgetPixmap( ARROW_DOWN ) ))); pbDown->setFixedSize( 50, 9 ); //pbDown->move( 0, 265 ); layout = new QVBoxLayout( this ); setFixedSize( 60, (_nbItem * 55) + 23 ); } layout->addSpacing( 5 ); layout->addWidget( pbUp ); QSignalMapper * sigmap = new QSignalMapper( this ); _buttons = new AttalButton * [ _nbItem ]; for( uint i = 0; i < _nbItem; i++ ) { _buttons[i] = new AttalButton( this ); _buttons[i]->setFixedSize( 50, 40 ); /*if( _horizontal ) { _buttons[i]->move( (i*50) + 10, 5 ); } else { _buttons[i]->move( 0, 10 + (i*50) ); }*/ layout->addWidget( _buttons[ i ] ); sigmap->setMapping( _buttons[ i ], i ); connect( _buttons[i], SIGNAL( clicked() ), sigmap, SLOT( map() ) ); } layout->addWidget( pbDown ); layout->addSpacing( 5 ); setEnabled( false ); connect( parent, SIGNAL( sig_enableGame( bool ) ), SLOT( setEnabled( bool ) ) ); connect( sigmap, SIGNAL( mapped( int ) ), this, SLOT( slot_clicked( int ) ) ); connect( pbDown, SIGNAL( clicked() ), SLOT( slot_down() ) ); connect( pbUp, SIGNAL( clicked() ), SLOT( slot_up() ) ); } ScrollList::~ScrollList( ) { for( uint i = 0; i < _nbItem; i++ ) { if( _buttons[ i ]) { _buttons[i] = new AttalButton( this ); } } delete _buttons; } void ScrollList::enableGame() { setEnabled( true ); } void ScrollList::slot_reinit() { reinit(); } void ScrollList::slot_up() { if( _current > 0 ) { _current--; reinit(); } } void ScrollList::slot_down() { if( ( _current + _nbItem - 1 ) < getListCount() ) { _current++; reinit(); } } void ScrollList::select( int num ) { deselect(); /// XXX: mettre cadre _selected = num + _current; _buttons[num]->setBackgroundColor( Qt::yellow ); } void ScrollList::deselect() { if( _selected != -1 ) { _selected = -1; for( uint i = 0; i < _nbItem; i++ ) { _buttons[i]->setBackgroundColor( Qt::blue ); } } } void ScrollList::repaintButtons(uint num) { uint i; uint len = 23; for( i = 0; i < num; i++ ) { _buttons[i]->show(); len += 55; } if( num < _nbItem ) { for( i = num; i < _nbItem; i++ ) { _buttons[i]->hide(); len += 5; } } if( _horizontal ) { setFixedSize( len, 60 ); } else { setFixedSize( 60, len ); } } // // ----- ScrollLord ----- // ScrollLord::ScrollLord( bool horizontal, uint nbItem, QWidget * parent, const char * name ) : ScrollList( horizontal, nbItem, parent, name ) { connect( parent, SIGNAL( sig_lordReinit() ), SLOT( slot_reinit() ) ); } void ScrollLord::reinit() { if( _player ) { _lordList.clear(); uint i; for( i = 0; i < _player->numLord(); i++ ) { GenericLord * lord = _player->getLord( i ); if( lord && lord->isVisible() ) { _lordList.append( lord ); } } _selected = -1; for( i = 0; i < _nbItem; i++ ) { if( (int)(_current + i) < _lordList.count() ) { _buttons[i]->setEnabled( true ); //_buttons[i]->setPixmap( *_player->getLordSmallPixmapById( _lordList.at( _current + i )->getId() ) ); _buttons[i]->setLord( _lordList.at( _current + i )->getId() ); if( _player->getSelectedLord() && ( _lordList.at( _current + i ) == _player->getSelectedLord() ) ) { _buttons[i]->setBackgroundColor( Qt::yellow ); _selected = _current + i; } } else { _buttons[i]->setBackgroundColor( Qt::blue ); _buttons[i]->setEnabled( false ); /** memory leak? i don't know, if true is little and correct a big graphic bug (if qt will have a function to unselect icon will use that function **/ _buttons[i]->setIcon( QIcon() ); } } } } void ScrollLord::select( int num ) { if( _player ) { _player->unSelectLord(); _player->unSelectBase(); ScrollList::select( num ); if( _selected < (int)_lordList.count() ) { _player->setSelectedLord( _lordList.at( _selected ) ); emit sig_lordSelected(); } else { deselect(); } } } void ScrollLord::deselect() { ScrollList::deselect(); if( _player ) { _player->unSelectLord(); } } void ScrollLord::slot_clicked( int num ) { if( _selected == int( num + _current ) ) { emit sig_lord(); } else { select( num ); } } uint ScrollLord::getListCount() { return _lordList.count(); } // // ----- ScrollBase ----- // ScrollBase::ScrollBase( bool horizontal, uint nbItem, QWidget * parent, const char * name ) : ScrollList( horizontal, nbItem, parent, name ) { connect( parent, SIGNAL( sig_baseReinit() ), SLOT( slot_reinit() ) ); } void ScrollBase::reinit() { if( _player ) { _selected = -1; for( uint i = 0; i < _nbItem; i++ ) { if( _current + i < _player->numBase() ) { _buttons[i]->setEnabled( true ); //_buttons[i]->setPixmap( *_player->getBaseSmallPixmap( _current+i ) ); _buttons[i]->setBase( _player->getBase( _current+i )->getRace() ); if( _player->getBase( _current + i ) == _player->getSelectedBase() ) { _buttons[i]->setBackgroundColor( Qt::yellow ); _selected = _current + i; } } else { _buttons[i]->setBackgroundColor( Qt::blue ); _buttons[i]->setEnabled( false ); _buttons[i]->setIcon( QIcon() ); } } } } void ScrollBase::select( int num ) { if( _player ) { _player->unSelectLord(); _player->unSelectBase(); ScrollList::select( num ); if( _selected < (int)_player->numBase() ) { _player->setSelectedBase( _player->getBase( _selected ) ); emit sig_baseSelected(); } else { deselect(); } } } void ScrollBase::deselect() { ScrollList::deselect(); if( _player ) { _player->unSelectBase(); } } void ScrollBase::slot_clicked( int num ) { if( _selected == int( num + _current ) ) { emit sig_base(); } else { select( num ); } } uint ScrollBase::getListCount() { if( _player ) { return _player->numBase(); } else { return 0; } } attal-src-1.0-rc2/libClient/gameControl.h0000644000175000017500000001171311002651053016000 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** gameControl.h ** Widget on the right, controlling the game ** ** Version : $Id: gameControl.h,v 1.16 2008/04/20 14:24:43 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/09/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GAMECONTROL_H #define GAMECONTROL_H // generic include files // include files for QT #include #include // application specific includes #include "libClient/player.h" class QPushButton; class QSignalMapper; class AttalButton; class CentralControl; class ScrollLord; class ScrollBase; /* ------------------------------ * GameControl * ------------------------------ */ class GameControl : public QWidget { Q_OBJECT public: /** Constructor */ GameControl( QWidget * parent = 0, const char * name = 0 ); /** Associate a player */ void setPlayer( Player * player ); /** Reinit widgets */ void reinit(); /** Select first lord (if none : first base) */ void selectFirst(); /** Disable if no game is running */ void disableGame(); public slots: /** Slot when lord selected */ void slot_lordSelected(); /** Slot when base selected */ void slot_baseSelected(); /** Activate if a game is running */ void enableGame(); signals: /** Signal if lord selected clicked */ void sig_lord(); /** Signal if base selected clicked */ void sig_base(); /** Signal if 'End Turn' button clicked */ void sig_endTurn(); void sig_enableGame( bool ); private: CentralControl * _cen; ScrollLord * _scrL; ScrollBase * _scrB; Player * _player; }; /**Central widget of the GameControl (other actions) */ class CentralControl : public QWidget { Q_OBJECT public: /** Constructor */ CentralControl( QWidget * parent = 0, const char * name = 0 ); /** Initialize player */ void setPlayer( Player * player ) { _player = player; } /** Disable panel (not in game) */ void disableGame(); /** Enable panel (in game) */ void enableGame(); signals: /** Signal if 'End Turn' button is clicked */ void sig_endTurn(); private slots: void slot_nextLord() { _player->nextLord(); } private: Player * _player; QPushButton * _pbNext, * _pbTurn; }; /** Scrolling list of buttons */ class ScrollList : public QWidget { Q_OBJECT public: /** Constructor */ ScrollList( bool horizontal, uint nbItem, QWidget * parent = 0, const char * name = 0 ); ~ScrollList(); /** Initialize player */ void setPlayer( Player * player ) { _player = player; } /** Reinit info displayed */ virtual void reinit() =0; /** Select a button in the list */ void select( int ); /** Deselect all the buttons */ void deselect(); void repaintButtons(uint num); public slots: /** Slot when 'up' arrow is clicked */ void slot_up(); /** Slot when 'down' arrow is clicked */ void slot_down(); void slot_reinit(); /** Enable 'in game' features */ void enableGame(); /** Slot when a button is clicked */ virtual void slot_clicked( int ) {} protected: virtual uint getListCount() = 0; QSignalMapper * _sigmap; AttalButton ** _buttons; Player * _player; uint _current; int _selected; bool _horizontal; uint _nbItem; }; /** Scrolling list of lords */ class ScrollLord : public ScrollList { Q_OBJECT public: /** Constructor */ ScrollLord( bool horizontal, uint nbItem, QWidget * parent = 0, const char * name = 0 ); /** Reinit info displayed */ void reinit(); /** Select button 'num' */ void select( int num ); /** Deselect all buttons */ void deselect(); uint getListCount(); signals: /** Signal when lord is clicked */ void sig_lord(); /** Signal when lord is selected */ void sig_lordSelected(); public slots: /** Slot when a button is clicked */ void slot_clicked( int ); protected: QList _lordList; }; /** Scrolling list of bases */ class ScrollBase : public ScrollList { Q_OBJECT public: /** Constructor */ ScrollBase( bool horizontal, uint nbItem, QWidget * parent = 0, const char * name = 0 ); /** Reinit info displayed */ void reinit(); /** Select button 'num' */ void select( int num ); /** Deselect all the buttons */ void deselect(); uint getListCount(); signals: /** Signal when base is clicked */ void sig_base(); /** Signal when base is selected */ void sig_baseSelected(); public slots: /** Slot when a button is clicked */ void slot_clicked( int ); }; #endif // GAMECONTROL_H attal-src-1.0-rc2/libClient/gameInfo.cpp0000644000175000017500000001476411010170657015624 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** gameInfo.cpp ** Widget giving info during the game ** ** Version : $Id: gameInfo.cpp,v 1.23 2008/05/07 00:02:55 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "gameInfo.h" // generic include files // include files for QT #include #include #include #include #include #include // application specific include files #include "libCommon/calendar.h" #include "libCommon/genericBase.h" #include "libCommon/genericLord.h" #include "libCommon/unit.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/widget.h" // // ----- GameInfo ----- // GameInfo::GameInfo( Calendar * calendar, QWidget * parent, const char * /* name*/ ) :QWidget( parent ) { _calendar = calendar; _nothing = 0; _waitPlayer = 0; QVBoxLayout * layout = new QVBoxLayout( this ); //layout->addStretch( 1 ); _main = new QWidget( this ); layout->addWidget( _main ); _isPlay = new QLabel( this ); _isPlay->setText( "Not your turn" ); layout->addWidget( _isPlay ); QHBoxLayout * layH1 = new QHBoxLayout(); _dateM = new QLabel( this ); layH1->addWidget( _dateM ); layH1->addStretch( 1 ); /* _dateW = new QLabel( this ); layH1->addWidget( _dateW ); layH1->addStretch( 1 ); _dateD = new QLabel( this ); layH1->addWidget( _dateD ); layH1->addStretch( 1 ); */ layout->addLayout( layH1 ); layout->activate(); // setFixedSize( 200, 200 ); nothing(); connect( _calendar, SIGNAL( sig_changed() ), SLOT( slot_dateChanged() ) ); } void GameInfo::nothing() { if( ! _nothing ) { _nothing = new QLabel( this ); _nothing->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( MISC_LOGO ) ) ); FIXEDSIZE( _nothing ); } if( _waitPlayer ) { _waitPlayer->hide(); } _main = _nothing; _nothing->show(); } void GameInfo::setStatePlayer( bool state ) { if( _isPlay ) { if( state ) { _isPlay->setText( "Your turn" ); } else { _isPlay->setText( "Not your turn" ); } } } void GameInfo::slot_dateChanged() { _dateM->setText(_calendar->getDate()); //_dateM->setText( "Month : " + QString::number( _calendar->getMonth() ) ); //FIXEDSIZE( _dateM ); //_dateW->setText( "Week : " + QString::number( _calendar->getWeek() ) ); //FIXEDSIZE( _dateW ); //_dateD->setText( "Day : " + QString::number( _calendar->getDay() ) ); //FIXEDSIZE( _dateD ); } void GameInfo::waitPlayer( uint num ) { if( ! _waitPlayer ) { _waitPlayer = new QLabel( this ); } if( _nothing ) { _nothing->hide(); } //_waitPlayer->setBackgroundColor( color ); _waitPlayer->setPixmap( * ImageTheme.getFlag( num ) ); FIXEDSIZE( _waitPlayer ); _waitPlayer->show(); _main = _waitPlayer; } // // ----- LordInfo ----- // LordInfo::LordInfo( QWidget * parent, const char * /* name */ ) : QWidget( parent ) { _photo = new Icon( this ); _photo->setFixedSize( 50, 60 ); _name = new QLabel( this ); _level = new QLabel( this ); QVBoxLayout * layV1 = new QVBoxLayout(); layV1->setMargin( 5 ); layV1->addWidget( _name ); layV1->addWidget( _level ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addWidget( _photo ); layH1->addLayout( layV1, 1 ); QVBoxLayout * layV[MAX_UNIT]; QHBoxLayout * layH2 = new QHBoxLayout(); layH2->setSpacing( 5 ); for( uint i = 0; i < MAX_UNIT; i++ ) { layV[i] = new QVBoxLayout(); _units[ i ] = new Icon( this ); _numUnit[i] = new QLabel( this ); _numUnit[i]->setFixedSize( 60, 20 ); _numUnit[i]->setAlignment( Qt::AlignCenter ); layV[i]->addWidget( _units[i] ); layV[i]->addWidget( _numUnit[i] ); layH2->addLayout( layV[i] ); } layH2->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addLayout( layH1 ); layout->addSpacing( 3 ); layout->addLayout( layH2 ); //layout->addStretch( 1 ); layout->activate(); } void LordInfo::init( GenericLord * lord ) { QString temp; _name->setText( "Lord " + lord->getName() ); FIXEDSIZE( _name ); temp.sprintf( "Level %d", lord->getCharac( LEVEL ) ); _level->setText( temp ); FIXEDSIZE( _level ); for( uint i = 0; i < MAX_UNIT; i++ ) { GenericFightUnit * unit = lord->getUnit( i ); if( unit ) { _units[ i ]->setPixmap( ImageTheme.getPhotoCreature( unit ) ); _numUnit[i]->setText( QString::number( unit->getNumber() ) ); } else { _numUnit[i]->clear(); _units[i]->clear(); } } if( ImageTheme.getLordPixmap( lord->getId() ) ) { _photo->setPixmap( * ImageTheme.getLordPixmap( lord->getId() ) ); } } // // ----- BaseInfo ----- // BaseInfo::BaseInfo( QWidget * parent, const char * /* name */) : QWidget( parent ) { _name = new QLabel( this ); _info = new QLabel( this ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 3 ); layout->addWidget( _name ); layout->addWidget( _info ); //layout->addStretch( 1 ); layout->activate(); } void BaseInfo::init( GenericBase * base ) { _name->setText( base->getName() ); FIXEDSIZE( _name ); QString text; text.sprintf( "%s (Pop: %d)", base->getModelName().toLatin1().constData(), base->getPopulation() ); _info->setText( text ); FIXEDSIZE( _info ); } // // ----- InfoStack ----- // InfoStack::InfoStack( QWidget * parent ) : QStackedWidget( parent ) { _info = 0; _lord = 0; _base = 0; _current = 0; } void InfoStack::init( QWidget * game, QWidget * lord, QWidget * base ) { _info = game; _lord = lord; _base = base; addWidget( _info ); addWidget( _lord ); addWidget( _base ); raiseInfo(); } void InfoStack::raiseLord() { _current = _lord; setCurrentWidget( _lord ); } void InfoStack::raiseBase() { _current = _base; setCurrentWidget( _base ); } void InfoStack::raiseInfo() { _current = _info; setCurrentWidget( _info ); } void InfoStack::mousePressEvent( QMouseEvent * e ) { if( e->button() == Qt::LeftButton ) { if( currentWidget() == _current ) { setCurrentWidget( _info ); } else { setCurrentWidget( _current ); } } } attal-src-1.0-rc2/libClient/gameInfo.h0000644000175000017500000000535610335442533015272 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** gameInfo.h ** Widget giving info during the game ** ** Version : $Id: gameInfo.h,v 1.8 2005/11/12 19:41:15 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GAMEINFO_H #define GAMEINFO_H // generic include files // include files for QT #include #include #include #include #include #include // application specific include files #include "libCommon/define.h" class QLabel; class Calendar; class GenericLord; class GenericBase; class Icon; /* ------------------------------ * GameInfo * ------------------------------ */ class GameInfo : public QWidget { Q_OBJECT public: /** Constructor */ GameInfo( Calendar * calendar, QWidget * parent = 0, const char * name = 0 ); /** Display the logo */ void nothing(); void setStatePlayer( bool state ); /** Display 'waiting for player' animation */ void waitPlayer( uint num ); private slots: /** Slot for updating date info */ void slot_dateChanged(); private: QWidget * _main; QLabel * _waitPlayer; QLabel * _nothing, *_isPlay; QLabel * _dateM, * _dateW, * _dateD; Calendar * _calendar; }; class LordInfo : public QWidget { public: /** Constructor */ LordInfo( QWidget * parent = 0, const char * name = 0 ); void init( GenericLord * lord ); QLabel * _numUnit[ MAX_UNIT ]; protected: GenericLord * _lord; Icon * _photo; QLabel * _name, * _level; Icon * _units[ MAX_UNIT ]; }; class BaseInfo : public QWidget { public: /** Constructor */ BaseInfo( QWidget * parent = 0, const char * name = 0 ); void init( GenericBase * base ); protected: GenericBase * _base; QLabel * _name; QLabel * _info; }; class InfoStack : public QStackedWidget { public: InfoStack( QWidget * parent ); void init( QWidget * game, QWidget * lord, QWidget * base ); void raiseLord(); void raiseBase(); void raiseInfo(); protected: virtual void mousePressEvent( QMouseEvent * e ); QWidget * _info, * _lord, * _base; QWidget * _current; }; #endif // GAMEINFO_H attal-src-1.0-rc2/libClient/graphicalArtefact.cpp0000644000175000017500000000370310621650464017500 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalArtefact.cpp ** Display artefacts on the map ** ** Version : $Id: graphicalArtefact.cpp,v 1.14 2007/05/13 17:56:04 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 19/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "graphicalArtefact.h" // generic include files // include files for QT // application specific include files #include "conf.h" #include "libCommon/genericCell.h" #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libClient/imageTheme.h" #include "libClient/lord.h" const int Artefact::RTTI = Type; Artefact::Artefact( QGraphicsScene * canvas ) :AttalSprite( ImageTheme.artefacts, canvas ) { TRACE("Artefact::constructor"); setFrame( 0 ); setZValue( CAN_ARTEFACT ); } void Artefact::setCell( GenericCell * cell ) { TRACE("Artefact::setCell"); setPos( cell->getCol() * DataTheme.tiles.getWidth() , (cell->getRow() + 1) * DataTheme.tiles.getHeight() - boundingRect().height() ); } void Artefact::setLord( GenericLord * /*lord*/ ) { /// XXX: remove arg ? //GenericArtefact::setLord( lord ); hide(); // TODO use delete this; instead? } void Artefact::setType( uint type ) { TRACE("Artefact::setType"); GenericArtefact::setType( type ); setFrame( type ); } int Artefact::type() const { // Enable the use of qgraphicsitem_cast with this item. return Type; } attal-src-1.0-rc2/libClient/graphicalArtefact.h0000644000175000017500000000322110510250653017131 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalArtefact.h ** Display artefacts on the map ** ** Version : $Id: graphicalArtefact.h,v 1.4 2006/10/02 17:51:39 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 19/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GRAPHICALARTEFACT_H #define GRAPHICALARTEFACT_H // generic include files // include files for QT // application specific include files #include "libCommon/artefact.h" #include "libClient/attalSprite.h" class GenericCell; class GenericLord; /* ------------------------------ * Artefact * ------------------------------ */ /** comment for the class */ class Artefact : public AttalSprite, public GenericArtefact { public: /** Constructor */ Artefact( QGraphicsScene * canvas ); enum { Type = QGraphicsItem::UserType + 1007 }; void setCell( GenericCell * cell ); void setLord( GenericLord * lord ); virtual void setType( uint type ); static const int RTTI; int type() const; }; #endif // GRAPHICALARTEFACT_H attal-src-1.0-rc2/libClient/graphicalBuilding.cpp0000644000175000017500000000732410671020143017475 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalLord.cpp ** draw bases and buildings on the map ** ** Version : $Id: graphicalBuilding.cpp,v 1.13 2007/09/09 16:33:39 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 26/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "graphicalBuilding.h" // generic include files // include files for QT #include // application specific includes #include "conf.h" #include "libCommon/attalSettings.h" #include "libCommon/genericPlayer.h" #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libClient/imageTheme.h" /** rtti number for GraphicalLord class */ const int GraphicalBuilding::RTTI = Type; // // ----- GraphicalBuilding ----- // /** add comments here */ GraphicalBuilding::GraphicalBuilding( QGraphicsScene * canvas ) : AttalSprite( ImageTheme.buildings[ 0 ], canvas ) { setFrame( 0 ); setAnimated( true ); setZValue( CAN_BUILDING ); _frame = 0; _nbFrame = 1; _freq = 1; _clock = 0; _flag = new Flag( canvas ); _flag->hide(); } GraphicalBuilding::GraphicalBuilding( QList * array, QGraphicsScene * canvas ) : AttalSprite( array, canvas ) { setFrame( 0 ); setZValue( CAN_BUILDING ); _frame = 0; _nbFrame = 1; _freq = 1; _clock = 0; _flag = new Flag( canvas ); _flag->hide(); } GraphicalBuilding::~GraphicalBuilding() { if( _flag ) { delete _flag; } } void GraphicalBuilding::setPosition( GenericCell * cell, int offsetRow, int offsetCol ) { TRACE("void GraphicalBuilding::setPosition( GenericCell * cell row %d, col %d, int offsetRow %d, int offsetCol %d )", cell->getRow(), cell->getCol(), offsetRow, offsetCol); setPos( ( cell->getCol() + offsetCol ) * DataTheme.tiles.getWidth() , ( cell->getRow() + offsetRow + 1 ) * DataTheme.tiles.getHeight() - boundingRect().height()); if( _flag ) { _flag->setPos( ( cell->getCol() + offsetCol ) * DataTheme.tiles.getWidth() , ( cell->getRow() + offsetRow + 1 ) * DataTheme.tiles.getHeight() - boundingRect().height() ); _flag->setZValue( CAN_LORD + cell->getRow() + 1 ); _flag->hide(); } } void GraphicalBuilding::advance( int /*stage*/ ) { _clock++; if( _clock == _freq ) { _clock = 0; _frame++; if( _frame == _nbFrame ) { _frame = 0; } setFrame( _frame ); } } QPixmap GraphicalBuilding::imageAdvanced() { /// logDD("imageAdvanced"); return image(); } void GraphicalBuilding::setType( int type ) { setSequence( ImageTheme.buildings[ type ] ); setFrame( 0 ); } void GraphicalBuilding::setAnimation( int nbFrame, int freq ) { _nbFrame = nbFrame; _freq = freq; if( _nbFrame > 1 ) { setAnimated( true ); } else { setAnimated( false ); } } void GraphicalBuilding::setOwner( GenericPlayer * player ) { if( player ) { _flag->show(); _flag->setOwner( player ); } else { _flag->hide(); } } int GraphicalBuilding::type() const { // Enable the use of qgraphicsitem_cast with this item. return Type; } // // ----- GraphicalBase ----- // GraphicalBase::GraphicalBase( QGraphicsScene * canvas ) : GraphicalBuilding( ImageTheme.bases, canvas ) { setFrame( 0 ); setZValue( CAN_BUILDING ); } void GraphicalBase::setRace( int race ) { setFrame( race ); } attal-src-1.0-rc2/libClient/graphicalBuilding.h0000644000175000017500000000422710522154576017156 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalLord.h ** draw bases and buildings on the map ** ** Version : $Id: graphicalBuilding.h,v 1.5 2006/11/01 17:29:34 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 26/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GRAPHICALBUILDING_H #define GRAPHICALBUILDING_H // generic include files // include files for QT #include // application specific includes #include "libClient/attalSprite.h" #include "libCommon/genericCell.h" #include "libClient/flag.h" class GenericPlayer; /** Build the graphical part of the Lord */ class GraphicalBuilding : public AttalSprite { public: /** Constructor */ GraphicalBuilding( QGraphicsScene * canvas ); GraphicalBuilding( QList * array, QGraphicsScene * canvas ); virtual ~GraphicalBuilding(); enum { Type = QGraphicsItem::UserType + 1000 }; /** Set the Lord on the cell */ virtual void setPosition( GenericCell *cell, int offsetRow=0, int offsetCol=0 ); /** Advance animation */ void advance( int stage ); int type() const; static const int RTTI; void setType( int type ); void setAnimation( int nbFrame, int freq ); virtual void setOwner( GenericPlayer * player ); protected: QPixmap imageAdvanced(); Flag * _flag; int _frame, _nbFrame, _freq, _clock; }; /** Graphical aspect of the base on the map */ class GraphicalBase : public GraphicalBuilding { public: /** Constructor */ GraphicalBase( QGraphicsScene * canvas ); /** Sets the race of the base */ void setRace( int ); }; #endif // GRAPHICALBUILDING_H attal-src-1.0-rc2/libClient/graphicalCell.cpp0000644000175000017500000000555510777472215016645 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalCell.cpp ** this class draws an animated cell ** ** Version : $Id: graphicalCell.cpp,v 1.17 2008/04/10 20:11:57 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier - Sardi Carlo ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "graphicalCell.h" // generic include files // include files for QT #include #include // application specific include #include "libClient/cell.h" #include "libClient/imageTheme.h" #include "libCommon/dataTheme.h" #include "libCommon/genericDecoration.h" #include "libCommon/log.h" #include "conf.h" /** rtti number for Decoration class */ const int Decoration::RTTI = Type; // // ----- GraphicalCell ----- // /** create an animated cell from pixmaps at position row,col */ GraphicalCell::GraphicalCell( int /*row*/, int /*col*/ , QGraphicsScene *canvas) : AttalSprite( ImageTheme.cells[0], canvas ) { hide(); // HACK make invisible to allow drawBackground to handle terrain/transition drawing } // // ----- Decoration ----- // Decoration::Decoration( Cell * parent, QGraphicsScene *canvas) : AttalSprite( ImageTheme.cells[0], canvas ) // HACK why can't a NULL value for frames be passed? { _parent = parent; setZValue( CAN_DECO ); setFrame( 0 ); setPos( QPointF( parent->getCol() * DataTheme.tiles.getWidth(), parent->getRow() * DataTheme.tiles.getHeight() ) ); } /** return if a point is on the cell */ bool Decoration::hit( const QPointF &p ) const { int ix = (int)(p.x())-int(x()); int iy = (int)(p.y())-int(y()); return ( ix < (int)DataTheme.tiles.getWidth() && iy < (int)DataTheme.tiles.getHeight() ) ; } void Decoration::setDecoration( uint group, uint item ) { setSequence( ImageTheme.decoration[ group-1 ] ); setFrame( item ); DecorationGroup * decoGroup = DataTheme.decorations.at( group ); GenericDecoration * decor = decoGroup->at( item ); if( ( decor->getWidth() > 1 ) || ( decor->getHeight() > 1 ) ) { int offsetRow = decor->getHeight() - ( 1 + decor->getDoorRow() ); int offsetCol = 0 - decor->getDoorCol(); QRectF rect = _parent->boundingRect(); setPos( ( _parent->getCol() + offsetCol ) * DataTheme.tiles.getWidth() , ( _parent->getRow() + offsetRow + 1) * DataTheme.tiles.getHeight() - boundingRect().height()); } } attal-src-1.0-rc2/libClient/graphicalCell.h0000644000175000017500000000406210525423231016263 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalCell.h ** this class draws an animated cell ** ** Version : $Id: graphicalCell.h,v 1.9 2006/11/11 19:38:01 fdarling Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier - Sardi Carlo ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GRAPHICALCELL_H #define GRAPHICALCELL_H // generic include files // include files for QT #include // application specific include #include "libCommon/genericCell.h" #include "libCommon/dataTheme.h" #include "libClient/attalSprite.h" class Lord; class Cell; /* ------------------------------ * GraphicalCell * ------------------------------ */ /** create an animated cell from pixmaps at position row,col */ class GraphicalCell : public AttalSprite { public: /** Constructor */ GraphicalCell( int row, int col , QGraphicsScene * canvas); }; /** Manages a decoration on the cell */ class Decoration : public AttalSprite { public: /** Constructor */ Decoration( Cell * parent, QGraphicsScene * canvas); static const int RTTI; enum { Type = QGraphicsItem::UserType + 2345 }; int type() const { return Type; } // Enable the use of qgraphicsitem_cast with this item. /** Return true if the point is on the cell */ bool hit( const QPointF & p ) const; /** Set decoration type */ void setDecoration( uint group, uint item ); private: Cell * _parent; }; #endif // GRAPHICALCELL_H attal-src-1.0-rc2/libClient/graphicalGameData.cpp0000644000175000017500000001440510751372502017411 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalGameData.cpp ** Manage data (graphically) of a whole game ** ** Version : $Id: graphicalGameData.cpp,v 1.15 2008/02/03 17:09:22 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "graphicalGameData.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/artefact.h" #include "libCommon/dataTheme.h" #include "libCommon/genericBase.h" #include "libCommon/genericEvent.h" #include "libCommon/genericPlayer.h" #include "libCommon/log.h" #include "libCommon/questManager.h" #include "libClient/attalSprite.h" #include "libClient/bonus.h" #include "libClient/building.h" #include "libClient/chest.h" #include "libClient/event.h" #include "libClient/graphicalArtefact.h" #include "libClient/lord.h" #include "libClient/map.h" #include "libClient/mapCreature.h" Map * theMap = NULL; GraphicalGameData::GraphicalGameData() :GameData() { } GraphicalGameData::~GraphicalGameData() { _animations.clear(); } void GraphicalGameData::reinit() { while( ! _players.isEmpty() ) { delete _players.takeFirst(); } _animations.clear(); _quests->clear(); GameData::reinit(); } void GraphicalGameData::initLords() { TRACE("GraphicalGameData::initLords"); for( int i = 0; i < DataTheme.lords.count(); i++ ) { Lord * lord = new Lord( theMap ); lord->setId( i ); lord->setVisible( false ); _lords.append( (GenericLord*)lord ); } } void GraphicalGameData::loadMap( QTextStream * stream, int width, int height ) { _map = (GenericMap *)theMap; theMap->clear(); theMap->load( stream, width, height ); } void GraphicalGameData::addPlayer() { _players.append( new GenericPlayer( _map ) ); } GenericBase * GraphicalGameData::getNewBase( uchar race ) { Base * base = new Base( theMap, race ); _bases.append( (GenericBase*)base ); base->setOwner( NULL ); return (GenericBase*)base; } GenericBase * GraphicalGameData::getNewBase( uchar race, int row, int col, int population, uchar id, int nb, const QList & forbidlist) { GenericBase * base = GameData::getNewBase( race, row, col, population, id, nb, forbidlist); dynamic_cast(base)->show(); return base; } void GraphicalGameData::setPlayerNumber( uint nb ) { while( ! _players.isEmpty() ) { delete _players.takeFirst(); } for( uint i = 0; i < nb; i++ ) { /// XXX: theMap = 0... _players.append( new GenericPlayer( 0 ) ); } } GenericEvent * GraphicalGameData::getNewArtefact( int id ) { TRACE("GraphicalGameData::getNewArtefact"); GenericEvent * ret = (GenericEvent*) new Event(); GenericArtefact * artefact = (GenericArtefact*) new Artefact( theMap ); if( id != -1 ) { artefact->setId( id ); } else { artefact->setId( _nbArtefact ); _nbArtefact++; } ret->setArtefact( artefact ); _events.append( ret ); return ret; } GenericEvent * GraphicalGameData::getNewBonus() { TRACE("GraphicalGameData::getNewBonus"); GenericEvent * ret = (GenericEvent*) new Event(); GenericBonus * bonus = (GenericBonus*) new Bonus( theMap ); _nbBonus++; ret->setBonus( bonus ); _events.append( ret ); return ret; } GenericEvent * GraphicalGameData::getNewChest() { TRACE("GraphicalGameData::getNewChest"); GenericEvent * ret = (GenericEvent*) new Event(); GenericChest * chest = (GenericChest*) new Chest( theMap ); _nbBonus++; ret->setChest( chest ); _events.append( ret ); return ret; } GenericBuilding * GraphicalGameData::getNewBuilding( uchar type ) { GenericBuilding * ret = (GenericBuilding *)( new Building( theMap, type ) ); _buildings.append( ret ); return ret; } GenericBuilding * GraphicalGameData::getNewBuilding( uchar type, int id, int row, int col ) { TRACE("GenericBuilding * GraphicalGameData::getNewBuilding( uchar type %d, int id %d, int row %d, int col %d )",type, id, row, col ); Building * building = dynamic_cast (GameData::getNewBuilding( type, id, row, col )); if( building ) { appendAnimation( building ); building->show(); } return building; } void GraphicalGameData::removeBuilding( GenericBuilding * build ) { removeAnimation( dynamic_cast(build) ); GameData::removeBuilding( build ); } GenericMapCreature * GraphicalGameData::getNewMapCreature() { GenericMapCreature * ret = (GenericMapCreature *)( new MapCreature( theMap ) ); _creatures.append( ret ); return ret; } GenericMapCreature * GraphicalGameData::getNewMapCreature( int row, int col, uchar race, uchar level, int nb, bool looking) { MapCreature * creature = dynamic_cast(GameData::getNewMapCreature( row, col, race, level, nb, looking)); if( creature ) { creature->setLookingRight( looking ); } return creature; } void GraphicalGameData::adjustPlayers() { uint oldNbPlayer = _players.count(); uint i; GenericPlayer * player; TRACE("GraphicalGameData::Adjust old %d, new %d ",oldNbPlayer, getNbPlayer()); if( oldNbPlayer > getNbPlayer() ) { for( i = getNbPlayer(); i < oldNbPlayer; i++ ) { player = _players.takeLast(); resetOwnership( player ); delete player; } } else if ( oldNbPlayer < getNbPlayer() ) { for( i = oldNbPlayer; i < getNbPlayer(); i++ ) { player = new GenericPlayer( theMap ); player->setNum( i ); player->setName( QString("Player %1").arg(i) ); _players.append( player ); } } } void GraphicalGameData::appendAnimation( AttalSprite * item) { if( item->animated() ) { _animations.append( item ); } } void GraphicalGameData::removeAnimation( AttalSprite * item) { _animations.removeAll( item ); } void GraphicalGameData::advanceAnimations() { int i; int count; count = _animations.count(); for( i = 0 ; i < count ; i++ ) { _animations.at( i )->advance(1); } } attal-src-1.0-rc2/libClient/graphicalGameData.h0000644000175000017500000000535410751372502017061 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalGameData.h ** Manage data (graphically) of a whole game ** ** Version : $Id: graphicalGameData.h,v 1.11 2008/02/03 17:09:22 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GRAPHICALGAMEDATA_H #define GRAPHICALGAMEDATA_H // generic include files // include files for QT #include // application specific include files #include "libCommon/gameData.h" /* ------------------------------ * GraphicalGameData * ------------------------------ */ class GenericBase; class GenericBuilding; class GenericEvent; class AttalSprite; /** comment for the class */ class GraphicalGameData : public GameData { public: /** Constructor */ GraphicalGameData(); ~GraphicalGameData(); /** Reinits graphical game data */ virtual void reinit(); void initLords(); /** loads map */ virtual void loadMap( QTextStream * stream, int width, int height ); /** Adds a player to the data */ virtual void addPlayer(); /** Creates a new base */ virtual GenericBase * getNewBase( uchar race = 0 ); virtual GenericBase * getNewBase( uchar race, int row, int col, int population, uchar id, int nb, const QList & forbidlist); /** Creates a new event */ virtual GenericEvent * getNewArtefact( int id = -1 ); virtual GenericEvent * getNewBonus(); virtual GenericEvent * getNewChest(); /** Creates a new building */ virtual GenericBuilding * getNewBuilding( uchar type = 0 ); virtual GenericBuilding * getNewBuilding( uchar type, int id, int row, int col ); virtual void removeBuilding( GenericBuilding * building ); /** Creates a new map creature */ virtual GenericMapCreature * getNewMapCreature(); virtual GenericMapCreature * getNewMapCreature( int row, int col, uchar race, uchar level, int nb, bool looking); void adjustPlayers(); void appendAnimation( AttalSprite * item); void removeAnimation( AttalSprite * item); void advanceAnimations(); void setPlayerNumber( uint nb ); protected: QList _animations; }; #endif // GRAPHICALGAMEDATA_H attal-src-1.0-rc2/libClient/graphicalLord.cpp0000644000175000017500000000571710777472215016666 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalLord.cpp ** draw a hero on the map ** ** Version : $Id: graphicalLord.cpp,v 1.26 2008/04/10 20:11:57 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 09/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "graphicalLord.h" // generic include files // include files for QT #include #include #include // application specific include #include "conf.h" #include "libCommon/genericPlayer.h" #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libClient/imageTheme.h" /** rtti number for GraphicalLord class */ const int GraphicalLord::RTTI = Type; GraphicalLord::GraphicalLord( QGraphicsScene * canvas ) : AttalSprite( ImageTheme.lords, canvas ) { setFrame( 0 ); setZValue( CAN_LORD ); setSequence( ImageTheme.lords ); _flag = new Flag( canvas ); } GraphicalLord::~GraphicalLord() { if( _flag ) { delete _flag; } } /** set the hero on the cell */ void GraphicalLord::setCell( GenericCell *cell ) { if( cell ) { TRACE("GraphicalLord::setCell"); setPos( cell->getCol() * DataTheme.tiles.getWidth() , (cell->getRow() + 1) * DataTheme.tiles.getHeight() - boundingRect().height() ); if( _flag ) { _flag->setPos( cell->getCol() * DataTheme.tiles.getWidth() , (cell->getRow() + 1) * DataTheme.tiles.getHeight() - boundingRect().height() ); _flag->setZValue( CAN_LORD + cell->getRow() + 1 ); } setZValue( CAN_LORD + cell->getRow() ); setVisible(true); } else { setVisible(false); } } void GraphicalLord::setVisible( bool state ) { AttalSprite::setVisible( state ); if( _flag ) { _flag->setVisible( state ); } } void GraphicalLord::advance( int /*stage*/ ) { /// XXX: TODO //logEE( "not yet implemented" ); } void GraphicalLord::setOwner( GenericPlayer * player ) { _flag->setOwner( player ); _imabk = image().toImage(); } void GraphicalLord::highlight( bool state) { if( state ) { setFrame(1); } else { setFrame(0); } } /* void GraphicalLord::setColor( QColor color ) { QImage ima = image()->toImage(); uint *p; for( int i = 0; i < 8; i++ ) for( int j = 0; j < 8; j++ ) { p = (uint *)ima.scanLine(i) + j; *p = color.rgb(); } image()->convertFromImage( ima ); }*/ QPixmap GraphicalLord::imageAdvanced() { return image(); } int GraphicalLord::type() const { // Enable the use of qgraphicsitem_cast with this item. return Type; } attal-src-1.0-rc2/libClient/graphicalLord.h0000644000175000017500000000363310776506302016320 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalLord.h ** draw a hero on the map ** ** Version : $Id: graphicalLord.h,v 1.10 2008/04/07 21:06:10 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 09/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GRAPHICALLORD_H #define GRAPHICALLORD_H // generic include files // include files for QT #include #include // application specific includes #include "libClient/attalSprite.h" #include "libCommon/genericCell.h" #include "libClient/flag.h" class GenericPlayer; /* ------------------------------ * GraphicalLord * ------------------------------ */ /** build the graphical part of the Lord */ class GraphicalLord : public AttalSprite { public: /** Constructor */ GraphicalLord( QGraphicsScene * canvas ); virtual ~GraphicalLord(); enum { Type = QGraphicsItem::UserType + 1234 }; /** Set the Lord on the cell */ virtual void setCell( GenericCell *cell ); virtual void setVisible( bool state ); /** Advance animation */ void advance( int stage ); virtual void highlight( bool state); virtual void setOwner( GenericPlayer * player ); int type() const; static const int RTTI; protected: QPixmap imageAdvanced(); Flag * _flag; QImage _imabk; }; #endif // GRAPHICALLORD_H attal-src-1.0-rc2/libClient/graphicalMap.cpp0000644000175000017500000000254610777472216016501 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalMap.cpp ** this class draws a map of cells ** ** Version : $Id: graphicalMap.cpp,v 1.8 2008/04/10 20:11:58 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "graphicalMap.h" // generic include files // include files for QT #include #include #include // application specific includes #include "conf.h" #include "libClient/imageTheme.h" /** this class draws a map of cells */ GraphicalMap::GraphicalMap( QObject * parent , const char * /* name */ ) : QGraphicsScene( parent ) { _shroudImage = QPixmap( *ImageTheme.getShroudPixmap() ); //setAdvancePeriod( 10 ); } GraphicalMap::~GraphicalMap() { } attal-src-1.0-rc2/libClient/graphicalMap.h0000644000175000017500000000271310514750342016126 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalMap.h ** this class draws a map of cells ** ** Version : $Id: graphicalMap.h,v 1.4 2006/10/16 18:35:14 fdarling Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GRAPHICALMAP_H #define GRAPHICALMAP_H // generic include files // include files for QT #include #include // application specific includes /* ------------------------------ * GraphicalMap * ------------------------------ */ /** this class draws a map of cells */ class GraphicalMap : public QGraphicsScene { public: /** Constructor */ GraphicalMap( QObject * parent = 0, const char * name = 0 ); virtual ~GraphicalMap(); protected: QPixmap _shroudImage; }; #endif // GRAPHICALMAP_H attal-src-1.0-rc2/libClient/graphicalPath.cpp0000644000175000017500000002041510773767734016663 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalPath.cpp ** Visible path on the map ** ** Version : $Id: graphicalPath.cpp,v 1.17 2008/03/30 19:54:04 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 07/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "graphicalPath.h" // generic include files // include files for QT #include // application specific include files #include "conf.h" #include "libCommon/pathFinder.h" #include "libCommon/dataTheme.h" #include "libClient/imageTheme.h" ArrowNumber arrow; // // ----- GraphicalPath ----- // GraphicalPath::GraphicalPath( Map * map ) { _map = map; _numCell = NULL; } GraphicalPath::~GraphicalPath() { clearPath(); } void GraphicalPath::initPath( GenericCell * cell ) { if( _map->getPath()->isPath( cell ) ) { QStack * path = _map->getPath()->giveCells( cell ); GenericCell * start; if( ! path->isEmpty() ) { start = path->pop(); while( ! path->isEmpty() ) { GenericCell * movCell = path->pop(); GraphicalPathCell * grCell = new GraphicalPathCell( _map ); grCell->setPosition( movCell ); append( grCell ); } delete path; int prevRow = start->getRow(); int prevCol = start->getCol(); for( int i = 0; i < int( count() - 1 ); i++ ) { at( i )->computeFrame( prevRow, prevCol, at( i+1 )->getRow(), at( i+1 )->getCol() ); prevRow = at( i )->getRow(); prevCol = at( i )->getCol(); } } else { delete path; } } else if( _map->getPath()->isNearPath( cell ) && ( cell->isStoppable() ) ) { QStack * path = _map->getPath()->giveNearCells( cell ); GenericCell * start; if( path->isEmpty() ) { path->push( _map->getPath()->getStartCell() ); } start = path->pop(); while( ! path->isEmpty() ) { GenericCell * movCell = path->pop(); GraphicalPathCell * grCell = new GraphicalPathCell( _map ); grCell->setPosition( movCell ); append( grCell ); } delete path; GraphicalPathCell * grCell = new GraphicalPathCell( _map ); grCell->setPosition( cell ); append( grCell ); int prevRow = start->getRow(); int prevCol = start->getCol(); for( int j = 0; j < int( count() - 1 ); j++ ) { at( j )->computeFrame( prevRow, prevCol, at( j+1 )->getRow(), at( j+1 )->getCol() ); prevRow = at( j )->getRow(); prevCol = at( j )->getCol(); } } } void GraphicalPath::computePath( GenericCell * start, GenericCell * dest, int movePt, int maxMove ) { clearPath(); if( !dest || ( dest == start ) ) { return; } PathFinder * path = _map->getPath(); _numCell = new NumPathCell( _map ); path->reinit( _map ); path->computePath( start ); initPath( dest ); // manage far arrows int cumcost = 0; int oldmovePt = movePt; int cost; int row = start->getRow(); int col = start->getCol(); for( int i = 0; i < count(); i++ ) { GraphicalPathCell * pathCell = at( i ); if( pathCell ) { cost = PathFinder::computeCostMvt( _map->at( row, col ), _map->at( pathCell->getRow(), pathCell->getCol() ) ); cumcost += cost; if( cost > movePt ) { pathCell->setFar( true ); } movePt -= cost; row = pathCell->getRow(); col = pathCell->getCol(); _numCell->setPosition( _map->at( row, col ) ); } } if( maxMove > 0 ) { cumcost -= oldmovePt; int turns = 0; if( cumcost <= 0 ) { turns = 1; } else { turns += (cumcost / maxMove) + 2; } _numCell->setPlainText( QString("%1").arg( turns ) ); _numCell->show(); } } QList GraphicalPath::followPath( GenericCell * start, int movePt ) { /*int cost; int movePt = getCharac( MOVE ); /// XXX: compute movement points... int row = _currentCell->getRow(); int col = _currentCell->getCol(); while( ! _showPath->isEmpty() ) { GraphicalPathCell * cell = _showPath->getFirst(); cost = computeCostMvt( _map->at( row, col ), _map->at( cell->getRow(), cell->getCol() ) ); if( ( cost != -1 ) && ( cost <= movePt ) ) { socket->sendMvt( getId(), cell->getRow(), cell->getCol() ); row = cell->getRow(); col = cell->getCol(); movePt = movePt - cost; } _showPath->removeFirst(); }*/ int cost; /// XXX: compute movement points... int row = start->getRow(); int col = start->getCol(); TRACE("GraphicalPath::followPath movePt %d, row %d, col %d", movePt, row, col); QList list; while( ! isEmpty() ) { GraphicalPathCell * cell = first(); cost = PathFinder::computeCostMvt( _map->at( row, col ), _map->at( cell->getRow(), cell->getCol() ) ); if( ( cost != -1 ) && ( cost <= movePt ) ) { row = cell->getRow(); col = cell->getCol(); list.append( _map->at( row, col ) ); movePt = movePt - cost; } removeFirstCell(); } clearNum(); return list; } void GraphicalPath::clearNum () { if( _numCell ) { delete _numCell; _numCell = NULL; } } void GraphicalPath::clearPath() { TRACE("GraphicalPath::clearPath"); while (!isEmpty()) { removeFirstCell(); } clearNum(); clear(); } void GraphicalPath::removeFirstCell() { GraphicalPathCell * grCell = 0; grCell = takeFirst(); delete grCell; } // // ----- GraphicalPathCell ----- // GraphicalPathCell::GraphicalPathCell( QGraphicsScene * canvas ) : AttalSprite( ImageTheme.pathCells, canvas ) { _row = 0; _col = 0; setFrame( 0 ); setZValue( CAN_ARROW ); } GraphicalPathCell::~GraphicalPathCell() { } int computeNum( int row, int col ) { int ret; if( row == - 1 ) { if( col == -1 ) { ret = 1; } else if( col == 0 ) { ret = 2; } else { ret = 3; } } else if( row == 0 ) { if( col == -1 ) { ret = 4; } else { ret = 5; } } else { if( col == -1 ) { ret = 6; } else if( col == 0 ) { ret = 7; } else { ret = 8; } } return ret; } void GraphicalPathCell::computeFrame( int prevRow, int prevCol, int nextRow, int nextCol ) { int prev = computeNum( prevRow - getRow(), prevCol - getCol() ); int next = computeNum( nextRow - getRow(), nextCol - getCol() ); setFrame( arrow.getFrame( prev, next ) ); } void GraphicalPathCell::setFar( bool state ) { if( state ) { if( frame() < 33 ) { setFrame( frame() + 33 ); } } else { if( frame() > 32 ) { setFrame( frame() - 33 ); } } } void GraphicalPathCell::setPosition( GenericCell * cell ) { setPos( cell->getCol() * DataTheme.tiles.getWidth() , (cell->getRow() + 1) * DataTheme.tiles.getHeight() - boundingRect().height() ); _row = cell->getRow(); _col = cell->getCol(); setZValue( CAN_ARROW ); setVisible(true); } // // ----- NumPathCell ----- // NumPathCell::NumPathCell( QGraphicsScene * scene ) : QGraphicsTextItem(0, scene ) { _row = 0; _col = 0; setZValue( CAN_NUM_ARROW ); setDefaultTextColor ( QColor( 255,255,255) ); } void NumPathCell::setPosition( GenericCell * cell ) { setPos( cell->getCol() * DataTheme.tiles.getWidth() , (cell->getRow() + 1) * DataTheme.tiles.getHeight() - boundingRect().height() ); _row = cell->getRow(); _col = cell->getCol(); setZValue( CAN_NUM_ARROW ); setVisible(true); } // // ----- ArrowNumber ----- // ArrowNumber::ArrowNumber() { for( int i = 0; i < 8; i++ ) { for( int j = 0; j < 8; j++ ) { _arrow[i][j] = 0; } } _arrow[0][2] = 27; _arrow[0][4] = 9; _arrow[0][5] = 30; _arrow[0][6] = 11; _arrow[0][7] = 10; _arrow[1][5] = 14; _arrow[1][6] = 13; _arrow[1][7] = 12; _arrow[2][0] = 31; _arrow[2][3] = 17; _arrow[2][5] = 16; _arrow[2][6] = 15; _arrow[2][7] = 28; _arrow[3][2] = 6; _arrow[3][4] = 7; _arrow[3][7] = 8; _arrow[4][0] = 20; _arrow[4][3] = 19; _arrow[4][5] = 18; _arrow[5][0] = 26; _arrow[5][1] = 3; _arrow[5][2] = 4; _arrow[5][4] = 5; _arrow[5][7] = 29; _arrow[6][0] = 24; _arrow[6][1] = 1; _arrow[6][2] = 2; _arrow[7][0] = 22; _arrow[7][1] = 23; _arrow[7][2] = 32; _arrow[7][3] = 21; _arrow[7][5] = 25; } int ArrowNumber::getFrame( int prev, int next ) { return _arrow[prev-1][next-1]; } attal-src-1.0-rc2/libClient/graphicalPath.h0000644000175000017500000000607410771524011016306 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalPath.h ** Visible path on the map ** ** Version : $Id: graphicalPath.h,v 1.10 2008/03/23 18:57:13 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 07/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GRAPHICALPATH_H #define GRAPHICALPATH_H // generic include files // include files for QT // application specific include files #include "libClient/attalSprite.h" #include "libClient/map.h" #include "libCommon/genericCell.h" class GraphicalPathCell; class NumPathCell; /* ------------------------------ * GraphicalPath * ------------------------------ */ /** comment for the class */ class GraphicalPath : public QList { public: /** Constructor */ GraphicalPath( Map * map ); ~GraphicalPath(); /** Init the pathes for the 'cell' */ void initPath( GenericCell * cell ); /** Compute the path between cell start and cell dest */ void computePath( GenericCell * start, GenericCell * dest, int movePt, int maxMove=0 ); /** Give the path between cell start and cell dest */ QList followPath( GenericCell * start, int movePt ); void clearPath(); void clearNum(); void removeFirstCell(); private: Map * _map; NumPathCell * _numCell; }; /** Sprite for displatying the path on the map */ class GraphicalPathCell : public AttalSprite { public: /** Constructor */ GraphicalPathCell( QGraphicsScene * canvas ); ~GraphicalPathCell(); /** Put it on the map */ void setPosition( GenericCell * cell ); /** Set as the end of path */ void computeFrame( int prevRow, int prevCol, int nextRow, int nextCol ); /** Get the row of the cell */ int getRow() { return _row; } /** Get the col of the cell */ int getCol() { return _col; } void setFar( bool state ); private: int _row, _col; }; /** Computes good arrow for the path */ class ArrowNumber { public: /** Constrcutor */ ArrowNumber(); /** \return Returns the frame number for the good arrow */ int getFrame( int prev, int next ); private: int _arrow[8][8]; }; class NumPathCell : public QGraphicsTextItem { public: /** Constructor */ NumPathCell( QGraphicsScene * canvas ); /** Put it on the map */ void setPosition( GenericCell * cell ); /** Get the row of the cell */ int getRow() { return _row; } /** Get the col of the cell */ int getCol() { return _col; } void setNumber( int num ); private: int _row, _col; }; #endif // GRAPHICALPATH_H attal-src-1.0-rc2/libClient/gui.cpp0000644000175000017500000000156710331243510014652 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** gui.cpp ** macros and usefull function for GUI ** ** Version : $Id: gui.cpp,v 1.6 2005/10/30 22:20:56 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/09/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "gui.h" attal-src-1.0-rc2/libClient/gui.h0000644000175000017500000000216410331243510014311 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** gui.h ** macros and usefull function for GUI ** ** Version : $Id: gui.h,v 1.2 2005/10/30 22:20:56 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/09/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GUI_H #define GUI_H // generic include files // include files for QT // application specific includes class QWidget; class QPushButton; #define FIXEDSIZE( wid ) (wid)->setFixedSize( (wid)->sizeHint() ) /** Initialize pixmaps */ void initPixmap(); #endif // GUI_H attal-src-1.0-rc2/libClient/imageTheme.cpp0000644000175000017500000007434510777503654016165 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** imageTheme.cpp ** manage images in theme ** ** Version : $Id: imageTheme.cpp,v 1.88 2008/04/10 21:33:32 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 10/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #define NO_EXTERN_IMAGETHEME #include "imageTheme.h" // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/genericMapCreature.h" #include "libCommon/log.h" #include "libCommon/unit.h" ImageTheme ImageTheme; extern QString IMAGE_PATH; CreaturePixmap::CreaturePixmap( const QList & pix ) { _pixmaps[0] = NULL; _pixmaps[1] = NULL; _pixmaps[0] = new QList ( pix ); } CreaturePixmap::CreaturePixmap( const QList & pix, const QList & newpix) { _pixmaps[0] = NULL; _pixmaps[1] = NULL; _pixmaps[0] = new QList ( pix ); _pixmaps[1] = new QList ( newpix ); } CreaturePixmap::~CreaturePixmap() { if( _pixmaps[0] ) { delete _pixmaps[0]; } if( _pixmaps[1] ) { delete _pixmaps[1]; } } void CreaturePixmap::loadMirrorImage() { QList * pix = _pixmaps[0]; if( _pixmaps[1]) { delete _pixmaps[1]; } QList newList; int count = pix->count(); for( int i = 0; i < count; i++ ) { if( !pix->at(i).isNull() ) { QImage newImg = (QImage) pix->at(i).toImage().mirrored( true, false ); QPixmap newPix = QPixmap::fromImage( newImg ); newList.append( newPix ) ; } else { newList.append( QPixmap() ); } } _pixmaps[1] = new QList( newList ); } QList * CreaturePixmap::operator[]( uint i ) { int index = i%2; if(index == 1 ) { if( !_pixmaps[1] || _pixmaps[1]->isEmpty()) loadMirrorImage(); } return _pixmaps[index]; } // // ----- MapCreaturePixmap ----- // MapCreaturePixmap::MapCreaturePixmap( const QList & pix) { _pixmaps[0] = new QList( pix ); QList newList; for( int i = 0; i < pix.count(); i++ ) { //QPixmap oldPix( pix[ i ]); QImage newImg; if( !pix.at(i).isNull() ) { newImg = pix.at(i).toImage().mirrored( true, false ); QPixmap newPix = newPix.fromImage(newImg); newList.append( newPix ) ; } else { newList.append( QPixmap() ); } } _pixmaps[1] = new QList( newList); } MapCreaturePixmap::~MapCreaturePixmap() { if( _pixmaps[0] ) { delete _pixmaps[0]; } if( _pixmaps[1] ) { delete _pixmaps[1]; } } QList * MapCreaturePixmap::getList( uint i ) { return _pixmaps[i%2]; } QList * MapCreaturePixmap::operator[]( uint i ) { return _pixmaps[i%2]; } // // ----- ImageTheme ----- // /* ImageTheme: call init() to allocate resource (in class constructor) call explicitly clean() to deallocate resources (in class destructor) */ ImageTheme::ImageTheme() { cells = NULL; lords = NULL; bases = NULL; buildings = NULL; insideBuildings = NULL; insideBuildingsView = NULL; photoCreatures = NULL; skills = NULL; transition = NULL; decoration = NULL; creatures = NULL; artefacts = NULL; events = NULL; chest = NULL; mapCreatures = NULL; pathCells = NULL; deadCreature = NULL; _insideBase = NULL; _artefactIcon = NULL; _resourceIcon = NULL; _resourceSmallIcon = NULL; _flags = NULL; _mapFlags = NULL; _sound = NULL; _okPixmap = NULL; _cancelPixmap = NULL; _shroudImage = NULL; _lordPixmap = NULL; _lordSmallPixmap = NULL; _baseSmallPixmap = NULL; _widgetPixmap = NULL; _isLoaded = false; } ImageTheme::~ImageTheme() { //clear(); } QPixmap * ImageTheme::getInsideBase( uint num ) { QPixmap * ret = NULL; if( (int)num < DataTheme.bases.count() ) { if( !_insideBase[num] ) { QString name = IMAGE_PATH + "base/race_" + QString::number( num ) + "/insideBase.png"; _insideBase[num] = new QPixmap( name ); } ret = _insideBase[num]; } return ret; } QPixmap * ImageTheme::getArtefactIcon( uint num ) { QPixmap * ret; if( (int)num < DataTheme.artefacts.count() ) { if( !_artefactIcon[num] ) { QString name = IMAGE_PATH + "artefacts/artefactIcon_" + QString::number( num ) + ".png"; _artefactIcon[num] = new QPixmap( name ); } ret = _artefactIcon[num]; } else { logEE( "artefact %d pixmap not found", num ); ret = new QPixmap(); /// XXX: memory leak... } return ret; } QPixmap * ImageTheme::getPopulationIcon() { QPixmap * ret; if( !_populIcon ) { QString name = IMAGE_PATH + "misc/population.png"; _populIcon = new QPixmap( name ); } ret = _populIcon; return ret; } QPixmap * ImageTheme::getResourceIcon( uint num ) { QPixmap * ret; if( (int)num < DataTheme.resources.count() ) { if( !_resourceIcon[num] ) { QString name = DataTheme.resources.at( num )->getFileName(); _resourceIcon[num] = new QPixmap( IMAGE_PATH + name ); } ret = _resourceIcon[num]; } else { logEE( "artefact %d pixmap not found", num ); ret = new QPixmap(); } return ret; } QPixmap * ImageTheme::getResourceSmallIcon( uint num ) { QPixmap * ret; if( (int)num < DataTheme.resources.count() ) { if( !_resourceSmallIcon[num] ) { QString name = DataTheme.resources.at( num )->getSmallFileName(); _resourceSmallIcon[num] = new QPixmap( IMAGE_PATH + name ); } ret = _resourceSmallIcon[num]; } else { logEE( "artefact %d pixmap not found", num ); ret = new QPixmap(); } return ret; } bool ImageTheme::init() { QTime timems; timems.start(); _isLoaded = initSkills(); logDD("Load Skills %d ms",timems.restart()); emit sig_loadStep(); _isLoaded = _isLoaded && initResources(); logDD( "Load Resources %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initCreatures(); logDD("Load Creatures %d ms",timems.restart()); emit sig_loadStep(); _isLoaded = _isLoaded && initCells(); logDD( "Load Cells %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initBuildings(); logDD( "Load Buildings %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initDecorations(); logDD( "Load Decorations %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initTransitions(); logDD( "Load Transitions %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initArtefacts(); logDD( "Load Artefacts %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initBonus(); logDD( "Load Bonus %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initChest(); logDD( "Load Chests %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initMapCreatures(); logDD( "Load MapCreatures %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initEvents(); logDD( "Load Events %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initTeams(); logDD( "Load Teams %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initLords(); logDD( "Load Lords %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initBases(); logDD( "Load Bases %d ms", timems.restart() ); emit sig_loadStep(); _isLoaded = _isLoaded && initSound(); return isLoaded(); } void ImageTheme::save() { } void ImageTheme::clear() { int cpt = 0; uint nbCells = DataTheme.tiles.count(); uint nbRaces = DataTheme.countRace(); uint nbLord = DataTheme.lords.count(); uint nbTeams = DataTheme.teams.count(); uint nbBases = DataTheme.bases.count(); uint i,j; if( cells ) { for( i = 0; i < nbCells; i++ ) { delete cells[i]; } delete [] cells; cells = NULL; } if( pathCells ) { delete pathCells ; pathCells = NULL; } if( lords ) { delete lords; lords = NULL; } if( chest ) { delete chest; chest = NULL; } if( bases ) { delete bases; bases = NULL; } if( buildings ) { uint nbBuildings = DataTheme.buildings.count(); for( i = 0; i < nbBuildings; i++ ) { delete buildings[ i ]; } delete [] buildings; buildings = NULL; } if( insideBuildings ) { uint nbBases = DataTheme.bases.count(); for( i = 0; i < nbBases; i++ ) { delete insideBuildings[ i ]; } delete [] insideBuildings; insideBuildings = NULL; } if( insideBuildingsView ) { uint nbBases = DataTheme.bases.count(); for( i = 0; i < nbBases; i++ ) { delete insideBuildingsView[ i ]; } delete [] insideBuildingsView; insideBuildingsView = NULL; } if( photoCreatures ) { uint nbRaces = DataTheme.countRace(); for( i = 0; i < nbRaces; i++ ) { delete [] photoCreatures[ i ]; } delete [] photoCreatures; photoCreatures = NULL; } if( skills ) { delete skills; skills = NULL; } if( transition ) { for( i = 1; i <= nbCells; i++ ) { delete transition[ i - 1 ]; } delete [] transition; transition = NULL; } if( decoration ) { for( i = 1; i < (uint) DataTheme.decorations.count(); i++ ) { delete decoration[ i - 1 ]; } delete [] decoration; decoration = NULL; } if( creatures ) { uint nbCreatures; for( i = 0; i < nbRaces; i++ ) { nbCreatures = DataTheme.creatures.getRace( i )->count(); for( j = 0; j < nbCreatures; j++ ) { delete creatures[cpt]; cpt++; } } delete [] creatures; creatures = NULL; } if( deadCreature ) { delete deadCreature; deadCreature = NULL; } if( artefacts ) { delete artefacts; artefacts = NULL; } if( _artefactIcon ) { uint nbArtefacts = DataTheme.artefacts.count(); for( i = 0; i < nbArtefacts; i++ ) { if( _artefactIcon[i] ) { delete _artefactIcon[i]; } } delete [] _artefactIcon; _artefactIcon = NULL; } if( _resourceIcon ) { uint nbRes = DataTheme.resources.count(); for( i = 0; i < nbRes; i++ ) { if( _resourceIcon[i] ) { delete _resourceIcon[i]; } } delete [] _resourceIcon; _resourceIcon = NULL ; } if( _resourceSmallIcon ) { uint nbRes = DataTheme.resources.count(); for( i = 0; i < nbRes; i++ ) { if( _resourceSmallIcon[i] ) { delete _resourceSmallIcon[i]; } } delete [] _resourceSmallIcon; _resourceSmallIcon = NULL; } if( bonus ) { for( i = 0; i < 4; i++ ) { delete bonus[i]; } delete [] bonus; bonus = NULL; } if( events ) { for( i = 0; i < 3; i++ ) { delete events[i]; } delete [] events; events = NULL; } if( mapCreatures ) { uint nbCreatures; for( i = 0; i < nbRaces; i++ ) { nbCreatures = DataTheme.creatures.getRace( i )->count(); for( j = 0; j < nbCreatures; j++ ) { delete mapCreatures[i][j]; } delete [] mapCreatures[i]; } delete [] mapCreatures; mapCreatures = NULL; } if( _insideBase ) { for( i = 0; i < nbBases; i++ ) { delete _insideBase[i]; } delete [] _insideBase; _insideBase = NULL; } if( _flags ) { for( uint i = 0; i < nbTeams; i++ ) { delete _flags[ i ]; } delete [] _flags; _flags = NULL; } if( _mapFlags ) { for( uint i = 0; i < 1; i++ ) { for( uint j = 0; j < nbTeams; j++ ) { delete _mapFlags[i][j]; } delete [] _mapFlags[i]; } delete [] _mapFlags; _mapFlags = NULL; } if(_lordPixmap) { for( uint i = 0; i < nbLord; i++ ) { delete _lordPixmap[i]; } delete [] _lordPixmap; _lordPixmap = NULL; } if(_lordSmallPixmap) { for( uint i = 0; i < nbLord; i++ ) { delete _lordSmallPixmap[i]; } delete [] _lordSmallPixmap; _lordSmallPixmap = NULL; } if( _sound ) { delete _sound; } _sound = NULL; if( _baseSmallPixmap ) { delete _baseSmallPixmap[ 0 ]; delete [] _baseSmallPixmap; _baseSmallPixmap = NULL; } delete _okPixmap; _okPixmap = NULL; delete _cancelPixmap; _cancelPixmap = NULL; delete _shroudImage; _shroudImage = NULL; if( _widgetPixmap ) { for( int i = 0; i < WIDG_LAST; i++ ) { delete _widgetPixmap[i]; } delete [] _widgetPixmap; _widgetPixmap = NULL; } } QPixmap ImageTheme::getPhotoCreature( GenericFightUnit * unit ) { uint race = unit->getRace(); uint level = unit->getLevel(); return getPhotoCreature( race , level ); } QPixmap ImageTheme::getPhotoCreature( int race, int level ) { if( photoCreatures[ race ][level].isNull() ) { QString pix = IMAGE_PATH + "units/race_" + QString::number( race ) + "/level_" + QString::number( level ) + "/face.png"; //logDD("Pixmap: %s", pix.toLatin1() ); photoCreatures[ race ][level] = pix; } return photoCreatures[race ][level]; } QPixmap * ImageTheme::getFlag( uint num ) { QPixmap * ret = NULL; if( (int)num < DataTheme.teams.count() ) { if( ! _flags[num] ) { _flags[ num ] = new QPixmap( IMAGE_PATH + "players/flag_" + QString::number( num ) + ".png" ); } ret = _flags[num]; } return ret; } QPixmap * ImageTheme::getLordPixmap( uint num ) { if( (int)num <= DataTheme.lords.count() ) { if( ! _lordPixmap[num] ) { QString name; name.sprintf( "lords/lord_%03d.png", num ); _lordPixmap[num] = new QPixmap( IMAGE_PATH + name ); } return _lordPixmap[num]; } else { logEE("There is not so many lords"); } return NULL; } QPixmap * ImageTheme::getLordSmallPixmap( uint num ) { if( (int)num <= DataTheme.lords.count() ) { if( ! _lordSmallPixmap[num] ) { QString name; name.sprintf( "lords/smallLord_%03d.png", num ); _lordSmallPixmap[num] = new QPixmap( IMAGE_PATH + name ); } return _lordSmallPixmap[num]; } else { logEE("There is not so many lords"); } return NULL; } QPixmap * ImageTheme::getBaseSmallPixmap( uint num ) { if( (int)num <= DataTheme.bases.count() ) { if( ! _baseSmallPixmap[num] ) { QString name; name = "base/race_" + QString::number( num ) + "/smallBase.png" ; _baseSmallPixmap[num] = new QPixmap( IMAGE_PATH + name ); } return _baseSmallPixmap[num]; } else { logEE("There is not so many bases"); } return NULL; } QList * ImageTheme::getMapFlag( uint type, uint teamId ) { return _mapFlags[ type ][ teamId ]; } const uint NB_FLAGTYPE = 1; bool ImageTheme::initTeams() { uint i, j; uint nbTeams = DataTheme.teams.count(); QString fileName; _flags = new QPixmap * [ nbTeams ]; for( i = 0; i < nbTeams; i++ ) { _flags[i] = NULL; } /// XXX: NB_FLAGTYPE = 1 = nb of type of flags (only one for the moment but will be extended if managed in dataTheme _mapFlags = new QList ** [ NB_FLAGTYPE ]; for( i = 0; i < NB_FLAGTYPE; i++ ) { _mapFlags[ i ] = new QList * [ nbTeams ]; for( j = 0; j < nbTeams; j++ ) { QList listPixmapFlag; /// XXX: for the moment, only one pixmap, but maybe one day it will be animated... fileName.sprintf( "players/mapFlag_%d_%d_0.png", i, j ); listPixmapFlag.append( QPixmap( IMAGE_PATH + fileName.toLatin1() ) ); _mapFlags[ i ][ j ] = new QList( listPixmapFlag ); } } return true; } bool ImageTheme::initSkills() { QList listPixmapSkill; listPixmapSkill.append( QPixmap( IMAGE_PATH + "technics/technic_1_1.png" ) ); listPixmapSkill.append( QPixmap( IMAGE_PATH + "technics/technic_1_2.png" ) ); skills = new QList( listPixmapSkill ); return true; } bool ImageTheme::initCells() { QString name; cells = new QList* [DataTheme.tiles.count()]; QList listPixmapUnknown; listPixmapUnknown.append( QPixmap( IMAGE_PATH + "tiles/unknown.png" ) ); cells[ 0 ] = new QList( listPixmapUnknown ); for( int i = 1; i < DataTheme.tiles.count(); i++ ) { uint nbTiles = DataTheme.tiles.at( i )->getDiversificationNumber(); cells[i] = new QList(); for( uint j = 0; j < nbTiles; j++ ) { name.sprintf( "tiles/tile_%d_%d.png", i, j ); QPixmap pixmap( IMAGE_PATH + name.toLatin1() ); cells[i]->append( pixmap ); } } QList listPixmapPathCell; for( int i = 0; i < 33; i++ ) { QString name = "misc/arrow-" + QString::number( i ) + ".png"; listPixmapPathCell.append( QPixmap( IMAGE_PATH + name.toLatin1() ) ); } for( int i = 0; i < 33; i++ ) { QString name = "misc/arrowFar-" + QString::number( i ) + ".png"; listPixmapPathCell.append( QPixmap( IMAGE_PATH + name.toLatin1() ) ); } pathCells = new QList( listPixmapPathCell); return true; } bool ImageTheme::initCreatures() { int cpt = 0; creatures = new CreaturePixmap * [DataTheme.creatures.count()]; QString fileName; QPixmap newPix; QImage newImg; QImage tmpImg; uint nbRaces = DataTheme.countRace(); int nbLevels, nbFrames; for( uint i = 0; i < nbRaces; ++i ) { nbLevels = DataTheme.creatures.getRace( i )->count(); for( int j = 0; j < nbLevels; ++j ) { QList listPixmapFightUnit; if ( DataTheme.creatures.at( i ,j )->isAnimated () ) { nbFrames = DataTheme.creatures.at( i ,j )->getNumFrames(); QString numFrame = "00"; QString nrace = QString::number( i ); QString nlevel = QString::number( j ); for( int fr = 1; fr <= nbFrames; ++fr ) { numFrame.sprintf( "%02d", fr ); fileName = IMAGE_PATH + "units/race_" + nrace + "/level_" + nlevel + "/creature_" + numFrame + ".png"; QPixmap creatPix = QPixmap( fileName ); listPixmapFightUnit.append( creatPix ); } /* necessary to have one image in alpha mode */ listPixmapFightUnit.append( newPix ); creatures[cpt] = new CreaturePixmap( listPixmapFightUnit ); } else { QPixmap creatPix = QPixmap( IMAGE_PATH + "units/race_" + QString::number( i ) + "/level_" + QString::number( j ) + "/creature.png" ); listPixmapFightUnit.append( creatPix ); newPix = creatPix; /* necessary to have three images one normal, one highlighted and one in alpha mode */ listPixmapFightUnit.append( newPix ); listPixmapFightUnit.append( newPix ); creatures[cpt] = new CreaturePixmap( listPixmapFightUnit ); } cpt++; } } QList listPixmapDead; listPixmapDead.append( QPixmap( IMAGE_PATH + "units/dead.png" ) ); deadCreature = new QList ( listPixmapDead ); nbRaces = DataTheme.bases.count(); photoCreatures = new QPixmap * [ nbRaces ]; for( uint i = 0; i < nbRaces; i++ ) { photoCreatures[i] = new QPixmap [ MAX_UNIT ]; for( uint j = 0; j < MAX_UNIT; j++ ){ photoCreatures[i][j] = QPixmap(); } } return true; } bool ImageTheme::initLords() { uint nbLord = DataTheme.lords.count(); uint i; QList listPixmapLord; QPixmap lordpix = QPixmap( IMAGE_PATH + "units/lord.png" ); listPixmapLord.append( lordpix ); listPixmapLord.append( highlightHighBorder( lordpix ) ); lords = new QList( listPixmapLord ); _lordPixmap = new QPixmap * [ nbLord ]; for( i = 0; i < nbLord; i++ ) { _lordPixmap[i] = NULL; } _lordSmallPixmap = new QPixmap * [ nbLord ]; for( i = 0; i < nbLord; i++ ) { _lordSmallPixmap[i] = NULL; } return true; } bool ImageTheme::initBases() { uint i; uint nbBases = DataTheme.bases.count(); _insideBase = new QPixmap * [DataTheme.bases.count()]; for( i = 0; i < nbBases; i++ ) { _insideBase[i] = NULL; } QList listPixmapBase; for( i = 0; i < nbBases; i++ ) { listPixmapBase.append( QPixmap( IMAGE_PATH + "base/race_" + QString::number( i ) + "/base.png" ) ); } bases = new QList( listPixmapBase ); _baseSmallPixmap = new QPixmap * [ nbBases ]; for( i = 0; i < nbBases; i++ ) { _baseSmallPixmap[i] = NULL; } return true; } bool ImageTheme::initArtefacts() { uint i; uint nbArtefacts = DataTheme.artefacts.count(); _artefactIcon = new QPixmap * [ nbArtefacts ]; for( i = 0; i < nbArtefacts; i++ ) { _artefactIcon[i] = NULL; } QList listPixmapArtefact; for( i = 0; i < nbArtefacts; i++ ) { listPixmapArtefact.append( QPixmap( IMAGE_PATH + "artefacts/artefactItem_" + QString::number( i ) + ".png" ) ); } artefacts = new QList( listPixmapArtefact ); return true; } bool ImageTheme::initResources() { _resourceIcon = new QPixmap * [DataTheme.resources.count()]; _resourceSmallIcon = new QPixmap * [DataTheme.resources.count()]; for( int i = 0; i < DataTheme.resources.count(); i++ ) { _resourceIcon[i] = NULL; _resourceSmallIcon[i] = NULL; } return true; } bool ImageTheme::initBonus() { uint j; uint nbResources = DataTheme.resources.count(); QString name; bonus = new QList * [ 4 ]; QList listPixmapBonus0; for( j = 0; j < nbResources; j++ ) { listPixmapBonus0.append( QPixmap(*getResourceSmallIcon( j ) ) ); } bonus[0] = new QList ( listPixmapBonus0 ); QList listPixmapBonus1; name = "events/event1.png"; listPixmapBonus1.append( QPixmap( IMAGE_PATH + name ) ); bonus[1] = new QList ( listPixmapBonus1 ); QList listPixmapBonus2; name = "events/event1.png"; listPixmapBonus2.append( QPixmap( IMAGE_PATH + name ) ); bonus[2] = new QList ( listPixmapBonus2 ); QList listPixmapBonus3; name = "events/scroll.png"; listPixmapBonus3.append( QPixmap( IMAGE_PATH + name ) ); bonus[3] = new QList ( listPixmapBonus3 ); return true; } bool ImageTheme::initChest() { QList listPixmapChest; listPixmapChest.append( QPixmap( IMAGE_PATH + "events/chest.png" ) ); chest = new QList( listPixmapChest ); return true; } bool ImageTheme::initBuildings() { uint nbBuildings, nbBases; buildings = new QList * [ DataTheme.buildings.count() ]; for( int i = 0; i < DataTheme.buildings.count(); i++ ) { nbBuildings = DataTheme.buildings.at( i )->getNbFrame(); QList listPixmapBuilding; for( uint j = 0; j < nbBuildings; j++ ) { QString name = "building/building_" + QString::number( i ) + "_" + QString::number( j ) + ".png"; listPixmapBuilding.append( QPixmap( IMAGE_PATH + name ) ); } buildings[i] = new QList( listPixmapBuilding); } nbBases = DataTheme.bases.count(); insideBuildings = new QList* [ nbBases ]; for( uint i = 0; i < nbBases; i++ ) { insideBuildings[i] = NULL; } insideBuildingsView = new QList* [ nbBases ]; for( uint i = 0; i < nbBases; i++ ) { insideBuildingsView[i] = NULL; } return true; } bool ImageTheme::initTransitions() { uint i, j; uint nbTransitions = DataTheme.tiles.count(); transition = new QList * [ nbTransitions ]; for( i = 1; i <= nbTransitions; i++ ) { transition[i-1] = new QList(); for( j = 1; j <= NB_TRANSITION; j++ ) { QString name = "tiles/transi_" + QString::number( i ) + "_" + QString::number( j ) + ".png"; QPixmap pixmap( IMAGE_PATH + name.toLatin1() ); transition[i-1]->append( pixmap ); } } return true; } bool ImageTheme::initDecorations() { uint i, j; uint nbDecoGroups = DataTheme.decorations.count(); uint nbDeco; decoration = new QList* [ nbDecoGroups ]; for( i = 1; i < nbDecoGroups; i++ ) { DecorationGroup * group = DataTheme.decorations.at( i ); nbDeco = group->count(); QList listPixmapDeco; for( j = 0; j < nbDeco; j++ ) { listPixmapDeco.append( QPixmap( IMAGE_PATH + "decor/decoration_" + QString::number( i ) + "_" + QString::number( j ) + ".png" ) ); } decoration[ i-1 ] = new QList( listPixmapDeco); } return true; } bool ImageTheme::initEvents() { uint i; events = new QList* [ 3 ]; QString fileName; QList listPixmapEvent; fileName = "events/event1.png"; listPixmapEvent.append( QPixmap( IMAGE_PATH + fileName ) ); events[ 0 ] = new QList( listPixmapEvent); uint nbRes = DataTheme.resources.count(); QList listPixmapEvent2; for( i = 0; i < nbRes; ++i ) { listPixmapEvent2.append( QPixmap( *getResourceSmallIcon( i ) ) ); } events[ 1 ] = new QList( listPixmapEvent2); QList listPixmapEvent3; fileName = "events/chest.png"; listPixmapEvent3.append( QPixmap( IMAGE_PATH + fileName ) ); events[ 2 ] = new QList( listPixmapEvent3); return true; } bool ImageTheme::initMapCreatures() { mapCreatures = new MapCreaturePixmap ** [ DataTheme.countRace() ]; for( uint i = 0; i < DataTheme.countRace(); i++ ) { mapCreatures[i] = new MapCreaturePixmap * [ DataTheme.creatures.getRace( i )->count() ]; for( int j = 0; j < DataTheme.creatures.getRace( i )->count(); j++ ) { QList listPixmapMapCreature; QString name = "units/race_" + QString::number( i ) + "/level_" + QString::number( j ) + "/creatureMap.png"; listPixmapMapCreature.append( QPixmap( IMAGE_PATH + name ) ); mapCreatures[i][j] = new MapCreaturePixmap( listPixmapMapCreature ); } } return true; } void ImageTheme::loadInsideBuilding( uint race ) { QList listPixmapInside; uint nbBuildings; nbBuildings = DataTheme.bases.at( race )->getBuildingCount(); for( uint j = 0; j < nbBuildings; j++ ) { listPixmapInside.append( QPixmap( IMAGE_PATH + "base/race_" + QString::number( race ) + "/inside_" + QString::number( j ) + ".png" ) ); } insideBuildings[race] = new QList( listPixmapInside); } void ImageTheme::loadInsideBuildingView( uint race ) { QList listPixmapInside; uint nbBuildings; nbBuildings = DataTheme.bases.at( race )->getBuildingCount(); for( uint j = 0; j < nbBuildings; j++ ) { listPixmapInside.append( QPixmap( IMAGE_PATH + "base/race_" + QString::number( race ) + "/buildingView_" + QString::number( j ) + ".png" ) ); } insideBuildingsView[race] = new QList( listPixmapInside); } QPixmap ImageTheme::getInsideBuilding( uint race, uint level ) { if( !insideBuildings[ race ] ) { loadInsideBuilding( race ); } return insideBuildings[ race ]->at( level ); } QPixmap ImageTheme::getInsideBuildingView( uint race, uint level ) { if( !insideBuildingsView[ race ] ) { loadInsideBuildingView( race ); } return insideBuildingsView[ race ]->at( level ); } QPixmap ImageTheme::getMapCreature( uint race, uint level, bool rightLooking ) { QList * list; list = mapCreatures[race][level]->getList( rightLooking?1:0 ); return list->at(0); } QPixmap ImageTheme::getMapCreature( GenericMapCreature * creature, bool rightLooking ) { return getMapCreature( creature->getRace(), creature->getLevel(), rightLooking ); } CreaturePixmap * ImageTheme::getCreature ( uint race, uint level ) { int nCnt = 0; for( uint i = 0; i < race; i++ ) { nCnt += DataTheme.creatures.getRace( i )->count(); } nCnt += level; return ( getCreature(nCnt) ); } CreaturePixmap * ImageTheme::getCreature ( int sequence ) { return ( creatures[sequence] ); } bool ImageTheme::initSound() { _sound = new AttalSound(); _sound->init(); return true; } void ImageTheme::enableSound(bool sound) { _sound->enableSound( sound ); } void ImageTheme::enableMusic(bool sound) { _sound->enableMusic( sound ); } void ImageTheme::playMusicMap() { AttalSoundData soundData; soundData.state = MUSIC_MAP; _sound->playMusic( soundData ); } void ImageTheme::endMusic() { _sound->endMusic(); } void ImageTheme::playMusicBase( uint race ) { AttalSoundData soundData; soundData.race = race; soundData.state = MUSIC_BASE; _sound->playMusic( soundData ); } void ImageTheme::playMusicFight() { AttalSoundData soundData; soundData.state = MUSIC_FIGHT; _sound->playMusic( soundData ); } void ImageTheme::playSound( AttalSound::SoundType snd ) { _sound->playSound( snd ); } QPixmap ImageTheme::highlightHighBorder( QPixmap & pixmap ) { QPixmap pix; QImage ima = pixmap.toImage(); ima.convertToFormat( QImage::Format_ARGB32 ); int h = ima.height(); int w = ima.width(); QImage img( w, h, QImage::Format_ARGB32 ); for ( int x = 0; x < w; x++ ) { for ( int y = 0; y < h; y++ ) { QRgb pixel = ima.pixel( x, y ); img.setPixel( x, y, colorH( pixel ) ); } } pix = QPixmap::fromImage( img ); return pix; } QRgb ImageTheme::colorH( QRgb v ) { int ach = qAlpha(v); if ( ach == 255 ) return v; int r = ( qRed(v) + 255 ) / 2; int g = ( qGreen(v) + 255 ) / 2; int b = ( qBlue(v) + 255 ) / 2; return qRgba(r,g,b,ach); //return qRgba(255,255,255,ach); } QPixmap * ImageTheme::getOkPixmap() { if( ! _okPixmap ) { _okPixmap = new QPixmap( IMAGE_PATH + "misc/yes.png" ); } return _okPixmap; } QPixmap * ImageTheme::getCancelPixmap() { if( ! _cancelPixmap ) { _cancelPixmap = new QPixmap( IMAGE_PATH + "misc/no.png" ); } return _cancelPixmap; } QPixmap * ImageTheme::getShroudPixmap() { if( !_shroudImage ) { _shroudImage = new QPixmap( IMAGE_PATH + "tiles/unknown.png"); } return _shroudImage; } QPixmap * ImageTheme::getWidgetPixmap(WidgetPixmap type) { if( !_widgetPixmap ) { _widgetPixmap = new QPixmap * [WIDG_LAST]; for( int i = 0; i < WIDG_LAST; i++ ) { _widgetPixmap[i] = NULL; } } QString name = IMAGE_PATH + "misc/"; QString tmp; if( _widgetPixmap[ type ] ) { return _widgetPixmap[type]; } switch( type ) { case ICO_ATTACK: tmp = "ico_attack.png"; break; case ICO_DEFENSE: tmp = "ico_defense.png"; break; case ICO_POWER: tmp = "ico_power.png"; break; case ICO_KNOWLEDGE: tmp = "ico_knowledge.png"; break; case ICO_MORALE: tmp = "ico_morale.png"; break; case ICO_SPECIALITY: tmp = "ico_speciality.png"; break; case ICO_CHARISM: tmp = "ico_charism.png"; break; case ICO_LUCK: tmp = "ico_luck.png"; break; case ICO_MANA: tmp = "ico_mana.png"; break; case ICO_MOVE: tmp = "ico_move.png"; break; case ICO_EXCHANGE: tmp = "exchange.png"; break; case ICO_VISION: tmp = "ico_vision.png"; break; case ICO_EXPERIENCE: tmp = "ico_experience.png"; break; case ARROW_LEFT: tmp = "arrow_left.png"; break; case ARROW_RIGHT: tmp = "arrow_right.png"; break; case ARROW_UP: tmp = "arrow_up.png"; break; case ARROW_DOWN: tmp = "arrow_down.png"; break; case BTN_CONTROL: tmp = "btn_control.png"; break; case BTN_SURRENDER: tmp = "btn_surrender.png"; break; case BTN_FLEE: tmp = "btn_flee.png"; break; case BTN_AUTO: tmp = "btn_auto.png"; break; case BTN_SPELL: tmp = "btn_spell.png"; break; case BTN_WAIT: tmp = "btn_wait.png"; break; case BTN_DEFEND: tmp = "btn_defend.png"; break; case EDIT_FREE: tmp = "editorFree.png"; break; case EDIT_OCC: tmp = "editorOccupied.png"; break; case EDIT_DOOR: tmp = "editorDoor.png"; break; case MISC_LOGO: tmp = "logo.png"; break; default: tmp = "none.png"; break; } name += tmp; if( !_widgetPixmap[ type ] ) { _widgetPixmap[type] = new QPixmap( name ); } return _widgetPixmap[type]; } attal-src-1.0-rc2/libClient/imageTheme.h0000644000175000017500000001365610777503654015630 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** imageTheme.h ** manage images in theme ** ** Version : $Id: imageTheme.h,v 1.42 2008/04/10 21:33:32 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 10/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef IMAGETHEME_H #define IMAGETHEME_H // generic include files // include files for QT #include #include #include // application specific include files #include "libClient/attalSound.h" class GenericFightUnit; class GenericMapCreature; #define NB_TRANSITION 16 enum WidgetPixmap { ICO_ATTACK, ICO_DEFENSE, ICO_POWER, ICO_KNOWLEDGE, ICO_MORALE, ICO_SPECIALITY, ICO_CHARISM, ICO_LUCK, ICO_MANA, ICO_MOVE, ICO_EXCHANGE, ICO_VISION, ICO_EXPERIENCE, ARROW_LEFT, ARROW_RIGHT, ARROW_UP, ARROW_DOWN, BTN_CONTROL, BTN_SURRENDER, BTN_FLEE, BTN_AUTO, BTN_SPELL, BTN_WAIT, BTN_DEFEND, EDIT_FREE, EDIT_OCC, EDIT_DOOR, MISC_LOGO, WIDG_LAST }; /** ------------------------------ * ImageTheme ** ------------------------------ */ class CreaturePixmap { public: /** Constrictor */ //obsolete, remove it? //CreaturePixmap( Q3PtrList pix, Q3PtrList hotspots ); /** Constructor */ CreaturePixmap( const QList & pix ); CreaturePixmap( const QList & pix, const QList & newpix); /** destructor */ virtual ~CreaturePixmap(); QList * operator[] ( uint i ); private: void loadMirrorImage(); QList * _pixmaps[2]; }; class MapCreaturePixmap { public: /** Constructor */ MapCreaturePixmap( const QList & pix ); /** Destructor */ virtual ~MapCreaturePixmap(); QList * getList( uint i ); QList * operator[] ( uint i ); private: QList * _pixmaps[2]; }; /** comment for the class */ class ImageTheme : public QObject { Q_OBJECT public: /** Constructor */ ImageTheme(); /** Destructor */ ~ImageTheme(); /** Initializes the images of the theme */ bool init(); /** Saves the images of the theme */ void save(); /** Clears the images of the theme */ void clear(); QPixmap getPhotoCreature( GenericFightUnit * unit ); QPixmap getPhotoCreature( int race, int level ); /** \return Returns the pixmap of inside the base 'num' */ QPixmap * getInsideBase( uint num ); /** \return Returns the icon of the artefcat 'num' */ QPixmap * getArtefactIcon( uint num ); /** \return Returns the flag of the team 'num' */ QPixmap * getFlag( uint num ); QPixmap * getResourceIcon( uint num ); QPixmap * getResourceSmallIcon( uint num ); QPixmap * getPopulationIcon(); QList ** cells; QList* pathCells; QList* lords; QList** buildings; QList* bases; QList* skills; //QCanvasPixmapArray ** creatures[2]; QList * deadCreature; QList** transition; QList** decoration; QList* artefacts; QList ** bonus; QList* chest; MapCreaturePixmap *** mapCreatures; QList** events; /** Return pixmap of a lord */ QPixmap * getLordPixmap( uint num ); /** Return small pixmap of a lord */ QPixmap * getLordSmallPixmap( uint num ); /** Return small pixmap of a base */ QPixmap * getBaseSmallPixmap( uint num ); QPixmap getInsideBuilding( uint race, uint level ); QPixmap getInsideBuildingView( uint race, uint level ); QPixmap getMapCreature( uint race, uint level, bool rightLooking = false ); QPixmap getMapCreature( GenericMapCreature * creature, bool rightLooking = false ); QList * getMapFlag( uint type, uint teamId ); CreaturePixmap * getCreature ( uint race, uint level ); CreaturePixmap * getCreature ( int sequence ); void playMusicMap(); void playMusicBase( uint race ); void playMusicFight(); void playSound( AttalSound::SoundType snd ); void endMusic(); void enableSound (bool sound); void enableMusic (bool sound); bool isLoaded() { return _isLoaded; } static QPixmap highlightHighBorder( QPixmap & pixmap ); static QRgb colorH( QRgb v ); QPixmap * getOkPixmap(); QPixmap * getCancelPixmap(); QPixmap * getShroudPixmap(); QPixmap * getWidgetPixmap(WidgetPixmap type); int getMaxLoadStep() { return 15; } signals: void sig_loadStep(); private: bool initTeams(); bool initSkills(); bool initCells(); bool initCreatures(); bool initLords(); bool initBases(); bool initBuildings(); bool initArtefacts(); bool initResources(); bool initBonus(); bool initChest(); bool initTransitions(); bool initDecorations(); bool initEvents(); bool initMapCreatures(); bool initSound(); void loadInsideBuilding( uint race ); void loadInsideBuildingView( uint race ); QPixmap ** _insideBase; QPixmap ** _artefactIcon; QPixmap ** _resourceIcon; QPixmap ** _resourceSmallIcon; QPixmap ** _flags; QPixmap * _populIcon; QPixmap ** _lordPixmap; QPixmap ** _lordSmallPixmap; QPixmap ** _baseSmallPixmap; QPixmap * _okPixmap; QPixmap * _cancelPixmap; QPixmap * _shroudImage; QPixmap ** _widgetPixmap; CreaturePixmap ** creatures; QList** insideBuildings; QList** insideBuildingsView; QPixmap ** photoCreatures; QList *** _mapFlags; AttalSound * _sound; bool _isLoaded; }; #ifndef NO_EXTERN_IMAGETHEME extern ImageTheme ImageTheme; #else #undef NO_EXTERN_IMAGETHEME #endif #endif // IMAGETHEME_H attal-src-1.0-rc2/libClient/insideAction.cpp0000644000175000017500000002544311016036223016500 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** insideAction.cpp ** Dialogs for actions of inside buildings ** ** Version : $Id: insideAction.cpp,v 1.46 2008/05/24 16:04:35 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 10/05/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "insideAction.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include #include #include // application specific include files #include "libClient/attalButton.h" #include "libClient/displayCreature.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libCommon/attalSocket.h" #include "libCommon/dataTheme.h" #include "libCommon/genericBase.h" #include "libCommon/genericInsideBuilding.h" #include "libCommon/genericPlayer.h" #include "libCommon/genericRessources.h" // // ----- InsideActionAllBuildings ----- // InsideActionAllBuildings::InsideActionAllBuildings( QWidget * parent, GenericBase * base, GenericPlayer * player, AttalSocket * socket ) : QDialog( parent, Qt::Dialog ) { setSocket( socket ); _buildings = NULL; _base = base; setWindowTitle( tr( "Buildings" ) ); _buildings = new BuildingsView( base, NULL ); _scroll = new QScrollArea( this ); _scroll->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); _scroll->setWidget( _buildings ); _scroll->setMinimumWidth( _buildings->width() + 40 ); _scroll->setWidgetResizable( true ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( _scroll, 1 ); layout->addSpacing( 5 ); if( !parent ) { AttalButton * pbOk = new AttalButton( this, AttalButton::BT_OK ); layout->addWidget( pbOk ); layout->setAlignment( pbOk, Qt::AlignHCenter ); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); } setPlayer( player ); layout->activate(); connect( _buildings, SIGNAL( sig_buy( int ) ), SLOT( slot_buy( int ) ) ); connect( _buildings, SIGNAL( sig_sell( int ) ), SLOT( slot_sell( int ) ) ); } void InsideActionAllBuildings::slot_buy( int building ) { // XXX: check if 'buy' is possible... if( _player && _socket ) { if( _player->canBuy( DataTheme.bases.at( _base->getRace() )->getBuildingModel( building ) ) ) { _socket->requestBuilding( _base, building, true ); } else { QMessageBox::warning( this, tr("Can't buy"), tr("Not enough ressources to buy this building") ); } } else { logEE( "Player or socket not initialized for InsideActionAllBuildings" ); } } void InsideActionAllBuildings::slot_sell( int building ) { if( _player && _socket ) { QMessageBox msb( tr( "Building" ), tr( "Are you sure to sell this building?" ), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape, 0, this ); if( msb.exec() == QMessageBox::Yes){ _socket->requestBuilding( _base, building, false ); } } } void InsideActionAllBuildings::updateView() { _buildings->updateView(); } void InsideActionAllBuildings::setPlayer( GenericPlayer * player ) { _player = player; _buildings->setPlayer(_player); updateView(); } // // ----- BuildingsView ----- // BuildingsView::BuildingsView( GenericBase * base, QWidget * parent, const char * /* name */ ) :QWidget( parent ) { _base = base; _player = NULL; QSignalMapper * sigmap = new QSignalMapper( this ); QSignalMapper * sigmap2 = new QSignalMapper( this ); GenericBaseModel * baseModel = DataTheme.bases.at( base->getRace() ); _layout = new QVBoxLayout( this ); _panels = new BuildingPanel * [baseModel->getBuildingCount()]; for( uint i = 0; i < baseModel->getBuildingCount(); i++ ) { InsideBuildingModel * building = baseModel->getBuildingModel( i ); _panels[i] = new BuildingPanel( building, this ); _layout->addWidget( _panels[i] ); if( !building->getAction() || building->getAction()->getType() == INSIDE_NONE || _base->isForbidden( i ) ) { _panels[ i ]->setVisible(false); } else { _panels[ i ]->setVisible(true); } sigmap->setMapping( _panels[i], i ); sigmap2->setMapping( _panels[i], i ); connect( _panels[i], SIGNAL( sig_buy() ), sigmap, SLOT( map() ) ); connect( _panels[i], SIGNAL( sig_sell() ), sigmap2, SLOT( map() ) ); } updateView(); _layout->activate(); connect( sigmap, SIGNAL( mapped( int ) ), SIGNAL( sig_buy( int ) ) ); connect( sigmap2, SIGNAL( mapped( int ) ), SIGNAL( sig_sell( int ) ) ); } void BuildingsView::buy( int building ) { if( _panels[building] ) { _panels[building]->setBuyable( false ); _panels[building]->setSellable( true ); } } void BuildingsView::updateView() { TRACE("BuildingsView::updateView"); GenericBaseModel * baseModel = DataTheme.bases.at( _base->getRace() ); _layout->setEnabled( false ); // list the bought buildings first for( uint i = 0; i < baseModel->getBuildingCount(); i++ ) { if( !_base->hasBuildingType( i ) ) { _layout->addWidget( _panels[i] ); } } for( uint i = 0; i < baseModel->getBuildingCount(); i++ ) { if( _base->hasBuildingType( i ) ) { _layout->addWidget( _panels[i] ); } } for( uint i = 0; i < baseModel->getBuildingCount(); i++ ) { InsideBuildingModel * building = baseModel->getBuildingModel( i ); if( _base->hasBuildingType( i ) ) { _panels[i]->setBuyable( false ); _panels[i]->setSellable( true ); _panels[i]->disable( false ); } else { if( _player ) { if (_player->canBuy( building ) && _base->canBuildBuilding( building )) { _panels[i]->disable( false ); } else { _panels[i]->disable( true ); } } else { _panels[i]->disable( false ); } _panels[i]->setBuyable( true ); _panels[i]->setSellable( false ); } } _layout->setEnabled( true ); } // // ----- BuildingPanel ----- // BuildingPanel::BuildingPanel( InsideBuildingModel * model, QWidget * parent, const char * /* name */) : QFrame( parent ) { _model = model; _buyEnabled = true; setFrameStyle( QFrame::Box | QFrame::Raised ); setLineWidth( 1 ); setMidLineWidth( 1 ); // XXX: add pic of building first... QLabel * smallPic = new QLabel( this ); smallPic->setPixmap( ImageTheme.getInsideBuildingView( _model->getRace() , _model->getLevel()) ); smallPic->setFixedSize( 100, 80 ); QLabel * thename = new QLabel( this ); thename->setText( tr("Name: ") + model->getName() ); FIXEDSIZE( thename ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addSpacing( 5 ); layH1->addWidget( thename ); layH1->addStretch( 1 ); QLabel * desc = new QLabel( this ); desc->setText( model->getBuildDescActions() ); FIXEDSIZE( desc ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addSpacing( 5 ); layH2->addWidget( desc ); layH2->addStretch( 1 ); QVBoxLayout * layV1 = new QVBoxLayout(); layV1->setMargin( 5 ); layV1->setSpacing( 5 ); layV1->addLayout( layH1 ); layV1->addLayout( layH2 ); layV1->addStretch( 1 ); QPushButton * pbInfo = new QPushButton( this ); pbInfo->setText( tr( "Info" ) ); FIXEDSIZE( pbInfo ); _pbBuySell = new QPushButton( this ); updateBuySell(); QVBoxLayout * layV2 = new QVBoxLayout(); layV2->setMargin( 5 ); layV2->setSpacing( 5 ); layV2->addStretch( 1 ); layV2->addWidget( pbInfo ); layV2->addStretch( 1 ); layV2->addWidget( _pbBuySell ); layV2->addStretch( 1 ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( smallPic ); layout->addLayout( layV1 ); layout->addStretch( 1 ); layout->addLayout( layV2 ); layout->activate(); connect( pbInfo, SIGNAL( clicked() ), SLOT( slot_info() ) ); connect( _pbBuySell, SIGNAL( clicked() ), SLOT( slot_buysell() ) ); } void BuildingPanel::slot_info() { QString text = ""; text = _model->getBuildDescActions(); QMessageBox::information( this, tr( "Building informations" ), text, tr( "Ok" ) ); } void BuildingPanel::slot_buysell() { if( _buyEnabled ) { emit sig_buy(); } else { emit sig_sell(); } } void BuildingPanel::disable( bool state ) { _pbBuySell->setDisabled( state ); } void BuildingPanel::setBuyable( bool state ) { _buyEnabled = state; updateBuySell(); } void BuildingPanel::setSellable( bool state ) { _buyEnabled = ! state; updateBuySell(); } void BuildingPanel::updateBuySell() { if( _buyEnabled ) { _pbBuySell->setText( tr( "Buy" ) ); } else { _pbBuySell->setText( tr( "Sell" ) ); } FIXEDSIZE( _pbBuySell ); } // // ----- InsideActionSomeCreature ----- // /* InsideActionSomeCreature::InsideActionSomeCreature( int race, int level, QWidget * parent, const char * name ) : QDialog( parent, Qt::Dialog ) { QGridLayout * layout = new QGridLayout( this ); DisplayCreature * cre = new DisplayCreature( this ); cre->setCreature( race, level ); layout->addWidget( cre, 0, 0 ); layout->setRowStretch( 0, 1 ); layout->setColStretch( 0, 1 ); layout->activate(); }*/ // // ----- DisplayCreatureBase ----- // DisplayCreatureBase::DisplayCreatureBase( QWidget * parent, GenericBase * base , GenericPlayer * player, AttalSocket * socket ) : QDialog( parent, Qt::Dialog ) { _player = player; _socket = socket; _base = base; setWindowTitle( tr("Creatures") ); QGridLayout * layout = new QGridLayout( this ); layout->setSizeConstraint( QLayout::SetFixedSize ); layout->setSpacing( 10 ); QSignalMapper * sigmap = new QSignalMapper( this ); for( int i = 0; i < DataTheme.creatures.getRace(_base->getRace())->count();i++ ) { _buy[i] = new DisplayCreature( this ); _buy[i]->setCreature( _base->getRace(), i , base); layout->addWidget( _buy[i], i / 3, i % 3 ); sigmap->setMapping( _buy[i], i ); connect( _buy[i], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); } slot_reinit(); connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_buyUnit( int ) ) ); connect( parent, SIGNAL( sig_castle() ), SLOT( slot_reinit() ) ); } void DisplayCreatureBase::init( GenericPlayer * player) { _player = player; } void DisplayCreatureBase::slot_buyUnit( int num ) { BuyCreature es( this ); es.initSocket(_socket); es.init( _player, _base, _buy[num]->getCreature() ); es.exec(); QTimer::singleShot( 0, this, SLOT( slot_reinit() ) ); // HACK due to the event loop } void DisplayCreatureBase::slot_reinit() { for( int i = 0; i < DataTheme.creatures.getRace(_base->getRace())->count();i++ ) { _buy[i]->setCreature( _base->getRace(), i , _base); } emit sig_castle(); } attal-src-1.0-rc2/libClient/insideAction.h0000644000175000017500000000736210726042066016156 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** insideAction.h ** Dialogs for actions of inside buildings ** ** Version : $Id: insideAction.h,v 1.15 2007/12/06 18:49:26 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 10/05/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef INSIDEACTION_H #define INSIDEACTION_H // generic include files // include files for QT #include #include #include #include // application specific include files #include "libCommon/creature.h" class QPushButton; class AttalSocket; class BuildingPanel; class DisplayCreature; class GenericBase; class GenericBaseModel; class GenericPlayer; class InsideBuildingModel; class BuildingsView; class QScrollArea; /* ------------------------------ * InsideAction * ------------------------------ */ /** Inside action 'All buildings' */ class InsideActionAllBuildings : public QDialog { Q_OBJECT public: /** Constructor */ InsideActionAllBuildings( QWidget * parent = 0, GenericBase * base = 0, GenericPlayer * player = 0 , AttalSocket * socket = 0 ); void setSocket( AttalSocket * socket ) { _socket = socket; } void setPlayer( GenericPlayer * player ); void updateView(); public slots: void slot_buy( int building ); void slot_sell( int building ); protected: GenericBase * _base; AttalSocket * _socket; GenericPlayer * _player; BuildingsView * _buildings; QScrollArea * _scroll; }; /** View of all buildings */ class BuildingsView : public QWidget { Q_OBJECT public: BuildingsView( GenericBase * model, QWidget * parent = 0, const char * name = 0 ); void buy( int building ); void updateView(); void setPlayer( GenericPlayer * player ) { _player = player;} signals: void sig_buy( int building ); void sig_sell( int building ); protected: BuildingPanel ** _panels; GenericBase * _base; GenericPlayer * _player; QVBoxLayout * _layout; }; /** Panel for displaying the view of a building */ class BuildingPanel : public QFrame { Q_OBJECT public: /** Constructor */ BuildingPanel( InsideBuildingModel * model, QWidget * parent = 0, const char * name = 0 ); void setBuyable( bool state ); void setSellable( bool state ); void disable( bool state ); public slots: void slot_buysell(); void slot_info(); signals: void sig_buy(); void sig_sell(); protected: void updateBuySell(); QPushButton * _pbBuySell; bool _buyEnabled; InsideBuildingModel * _model; }; /** Dialog for buying units */ class DisplayCreatureBase : public QDialog { Q_OBJECT public: /** Constructor */ DisplayCreatureBase( QWidget * parent = 0, GenericBase * base = 0 , GenericPlayer * player = 0, AttalSocket * socket = 0 ); void init( GenericPlayer * player); /** Initialize the socket of the dialog for requesting the server */ void initSocket( AttalSocket * socket ) { _socket = socket; } public slots: /** Slot for buying unit 'num' */ void slot_buyUnit( int num ); void slot_reinit(); signals: void sig_castle(); private: AttalSocket * _socket; GenericBase * _base; GenericPlayer * _player; DisplayCreature * _buy[7]; QHBoxLayout * _layH[7]; }; #endif // INSIDEACTION_H attal-src-1.0-rc2/libClient/insideBase.cpp0000644000175000017500000001577711007640016016147 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** insideBase.cpp ** display the base and its buildings ** ** Version : $Id: insideBase.cpp,v 1.23 2008/05/05 17:12:46 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 28/10/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "insideBase.h" // generic include files // include files for QT #include #include // application specific include files #include "libCommon/genericInsideBuilding.h" #include "libCommon/genericBase.h" #include "libCommon/log.h" #include "libClient/insideBuilding.h" #include "libClient/imageTheme.h" // // ----- InsideBase ----- // InsideBase::InsideBase( QObject * parent, GenericBase * base ) : QGraphicsScene( parent ) { setSceneRect( 0,0, 960, 720 ); _background = 0; if( base ) setBase( base ); } InsideBase::~InsideBase() { TRACE("~InsideBase"); clear(); } void InsideBase::clear() { TRACE("InsideBase::clear"); while( ! _list.isEmpty() ) { delete _list.takeFirst(); } _base = 0; _newBase = true; } void InsideBase::reinit() { TRACE("InsideBase::reinit"); if( _base ) { _background = ImageTheme.getInsideBase( _base->getRace() ); setBackgroundBrush(QBrush ( * _background)); for( uint i = 0; i < _base->getBuildingCount(); i++ ) { addBuilding( _base->getBuilding( i ) ); } } } void InsideBase::setBase( GenericBase * base ) { TRACE("InsideBase::setBase( base %p )", base ); if( _base != base ) { clear(); _base = base; _background = ImageTheme.getInsideBase( _base->getRace() ); setBackgroundBrush( QBrush (* _background ) ); for( uint i = 0; i < base->getBuildingCount(); i++ ) { addBuilding( base->getBuilding( i ) ); } } update(sceneRect()); } void InsideBase::addBuilding( GenericInsideBuilding * building ) { // check if building is already added (remove a bug ) for( int i = 0; i < _list.count(); i++ ) { if( _list.at( i )->getBuilding()->getLevel() == building->getLevel() ) { return; } } InsideBuilding * inside = new InsideBuilding( _base->getRace(), building, this ); inside->move( building->getX(), building->getY() ); inside->show(); _list.append( inside ); } void InsideBase::delBuilding( uint level ) { InsideBuilding * inside = 0; for( int i = 0; i < _list.count(); i++ ) { if( _list.at( i )->getBuilding()->getLevel() == level ) { inside = _list.at( i ); break; } } if( inside ) { _list.removeAll( inside ); delete inside; } } void InsideBase::delBuilding( GenericInsideBuilding * building ) { InsideBuilding * inside = 0; for( int i = 0; i < _list.count(); i++ ) { if( _list.at( i )->getBuilding() == building ) { inside = _list.at( i ); break; } } if( inside ) { _list.removeAll( inside ); delete inside; } } void InsideBase::drawBackground( QPainter * painter, const QRectF& rect ) { if( _background ) { painter->fillRect( rect, Qt::black ); QRectF tmp = rect.intersected( sceneRect() ); painter->drawPixmap( tmp, * _background, tmp ); } else { painter->fillRect( rect, Qt::black ); } } void InsideBase::drawItems( QPainter * painter, int numItems, QGraphicsItem *items[],const QStyleOptionGraphicsItem options[] , QWidget *widget ) { for (int i = 0; i < numItems; ++i) { // Draw the item painter->save(); painter->setMatrix(items[i]->sceneMatrix(), true); items[i]->paint(painter, options, widget); painter->restore(); } } // // ----- InsideBaseView ----- // InsideBaseView::InsideBaseView( InsideBase * base, QWidget * parent, const char * /* name */, Qt::WFlags /* f */ ) : QGraphicsView( base , parent) { TRACE("InsideBaseView base %p", base); viewport()->setMouseTracking( true ) ; _selected = 0; _base = base; update(); } InsideBaseView::~InsideBaseView() { TRACE("~InsideBaseView"); } /** handles mouse move event */ void InsideBaseView::mouseMoveEvent( QMouseEvent * e ) { QPointF pos = mapToScene( e->pos()); QList list; QList list2 = scene()->items( pos ); uint nbItems2 = (uint) list2.count(); for( unsigned int i = 0; i < nbItems2; i++ ) { if( list2[ i ]->type() == InsideBuilding::RTTI ) { if( ( (InsideBuilding*)list2[ i ] )->hit( pos ) ) { list.append( list2[ i ] ); } } } if(_base->getNewBase()==true){ _selected = 0; scene()->update(); _base->setNewBase(false); } uint nbItems = (uint) list.count(); for( unsigned int i = 0; i < nbItems; i++ ) { if( _selected ) { if( _selected != (InsideBuilding*)list[i] ) { _selected->deselect(); _selected = (InsideBuilding*)list[i]; _selected->select(); update(); } } else { _selected = (InsideBuilding*)list[i]; _selected->select(); update(); } } if( ( list.count() == 0 ) && _selected ) { _selected->deselect(); _selected = 0; update(); } } /* * handles mouse press event */ void InsideBaseView::mouseReleaseEvent( QMouseEvent * e ) { QPointF pos = mapToScene( e->pos()); QList list; QList list2 = scene()->items( pos ); uint nbItems2 = (uint) list2.count(); for( unsigned int i = 0; i < nbItems2; i++ ) { if( list2[ i ]->type() == InsideBuilding::RTTI ) { if( ( (InsideBuilding*)list2[ i ] )->hit( pos ) ) { list.append( list2[ i ] ); } } } uint nbItems = (uint) list.count(); for( unsigned int i = 0; i < nbItems; i++ ) { if( e->button() == Qt::LeftButton ) { emit sig_building( ((InsideBuilding *)list[i])->getBuilding() ); } else { } } } /** handles mouse move event */ void InsideBaseView::scrollContentsBy( int dx, int dy ) { scene()->update(); } void InsideBaseView::drawForeground( QPainter * painter , const QRectF & rect ) { QGraphicsView::drawForeground( painter, rect ); painter->setPen(QColor(0,0,0)); //painter->drawRect(0,0,120,60); //painter->fillRect(QRectF(mapToScene(QPoint(0,0)),QSize(120,60)), QBrush(QColor(0,0,0))); painter->setPen(QColor(255,255,255)); for ( int i = 0; i < _listM.count(); ++i) { painter->drawText(mapToScene(QPoint(10 ,12 + 12 * i)), _listM.at( i ) ); } //painter->drawText(rect, Qt::AlignLeft, tr("Qt by\nTrolltech")); } void InsideBaseView::newMessage( QString string) { TRACE("message %s", qPrintable( string ) ); if( _listM.count() > 6 ) { _listM.removeFirst(); } _listM.append( string ); QTimer::singleShot( 15000, this, SLOT( slot_removeMessage() ) ); scene()->update(); } void InsideBaseView::slot_removeMessage() { TRACE("count %d", _listM.count()); if( !_listM.isEmpty() ) { _listM.removeFirst(); } scene()->update(); } attal-src-1.0-rc2/libClient/insideBase.h0000644000175000017500000000625310724363422015611 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** insideBase.h ** display the base and its buildings ** ** Version : $Id: insideBase.h,v 1.11 2007/12/01 22:58:26 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 28/10/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef INSIDEBASE_H #define INSIDEBASE_H // generic include files // include files for QT #include #include #include #include #include #include #include // application specific include files #include "libClient/insideBuilding.h" class GenericInsideBuilding; class GenericBase; class QPixmap; /* ------------------------------ * InsideBase * ------------------------------ */ /** Canvas for inside base */ class InsideBase : public QGraphicsScene { public: /** Constructor */ InsideBase( QObject * parent = 0, GenericBase * base = 0 ); /** Destructor */ virtual ~InsideBase(); /** Clear the canvas */ void clear(); void reinit(); /** Set base to this object */ void setBase( GenericBase * base ); /** Adds a building to the base (graphics) */ void addBuilding( GenericInsideBuilding * building ); /** Delete building of a base (graphics) */ void delBuilding( GenericInsideBuilding * building ); /** Delete building of a base (graphics) */ void delBuilding( uint level ); void setNewBase( bool newBase ) { _newBase = newBase; } bool getNewBase() { return _newBase; } protected: void drawBackground( QPainter * painter, const QRectF & rect ); void drawItems( QPainter * painter, int numItems, QGraphicsItem *items[],const QStyleOptionGraphicsItem options[] , QWidget *widget); private: QList _list; QPixmap * _background; GenericBase * _base; bool _newBase; }; /** canvas view for inside base */ class InsideBaseView : public QGraphicsView { Q_OBJECT public: /** Constructor */ InsideBaseView( InsideBase * base, QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0 ); /** Destructor */ ~InsideBaseView(); void newMessage( QString string); signals: /** Signal if a building is clicked */ void sig_building( GenericInsideBuilding * ); public slots: void slot_removeMessage(); protected: /** reimplemented : handles mouse event */ void mouseMoveEvent( QMouseEvent * e ); void mouseReleaseEvent( QMouseEvent * e ); void scrollContentsBy( int dx, int dy ); void drawForeground( QPainter * painter , const QRectF & rect ); QList _listM; InsideBuilding * _selected; InsideBase * _base; }; #endif // INSIDEBASE_H attal-src-1.0-rc2/libClient/insideBuilding.cpp0000644000175000017500000000713110610177044017020 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** insideBuilding.cpp ** display building on the inside view ** ** Version : $Id: insideBuilding.cpp,v 1.14 2007/04/14 16:15:32 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 04/11/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "insideBuilding.h" // generic include files #include // include files for QT #include #include #include // application specific include files #include "conf.h" #include "libCommon/log.h" #include "libCommon/genericInsideBuilding.h" #include "libClient/imageTheme.h" const int InsideBuilding::RTTI = Type; InsideBuilding::InsideBuilding( int type, GenericInsideBuilding * build, QGraphicsScene * canvas ) : QGraphicsRectItem( 0, canvas ) { _type = type; _building = build; //collisions( true ); //setFrame( 2 * _building->getLevel() ); _oldpix = ImageTheme.getInsideBuilding( _type , _building->getLevel()); _pixmap = _oldpix; _image = _pixmap.toImage(); QImage image = highlight( _image ); _newpix = QPixmap(); _newpix = QPixmap::fromImage(image , Qt::AutoColor); setRect(QRectF( 0 , 0, _pixmap.width(), _pixmap.height())); setZValue( InsideBuilding::RTTI); setEnabled( true ); } InsideBuilding::~InsideBuilding() { } /* ImageItem::ImageItem( QImage img, QCanvas *canvas ) : QCanvasRectangle( canvas ), image(img) { setSize( image.width(), image.height() ); #if !defined(Q_WS_QWS) pixmap = QPixmap::fromImage(image, OrderedAlphaDither); #endif } */ int InsideBuilding::type() const { // Enable the use of qgraphicsitem_cast with this item. return Type; } void InsideBuilding::paint( QPainter *p , const QStyleOptionGraphicsItem * /* option */, QWidget * /* widget */) { p->drawPixmap( rect() , _pixmap, rect() ); } bool InsideBuilding::hit( const QPointF & p ) const { bool ret = false; int ix = (int)(p.x())-int(x()); int iy = (int)(p.y())-int(y()); if ( _image.valid( ix , iy ) ) { QRgb pixel = _image.pixel( ix, iy ); ret = ( qAlpha( pixel ) != 0 ); } return ret; } void InsideBuilding::move( int x, int y ) { setPos( x, y ); setZValue( int( y / 10 ) ); } void InsideBuilding::select() { //setFrame( (_building->getLevel() * 2) + 1 ); _pixmap = _newpix; update(); } void InsideBuilding::deselect() { //setFrame( _building->getLevel() * 2 ); _pixmap = _oldpix; update(); } QImage InsideBuilding::highlight(QImage image) { image.convertToFormat( QImage::Format_ARGB32 ); int w = image.width(); int h = image.height(); QImage img( w, h, QImage::Format_ARGB32 ); for ( int x = 0; x < w; x++ ) { for ( int y = 0; y < h; y++ ) { QRgb pixel = (x #include #include #include // application specific include files class GenericInsideBuilding; /* ------------------------------ * InsideBuilding * ------------------------------ */ class InsideBuilding : public QGraphicsRectItem { public: /** Constructor */ InsideBuilding( int type, GenericInsideBuilding * build, QGraphicsScene * canvas ); ~InsideBuilding(); enum { Type = QGraphicsItem::UserType + 35 }; //ImageItem( QImage img, QCanvas *canvas ); bool hit( const QPointF & ) const; void select(); void deselect(); virtual void move( int x, int y ); GenericInsideBuilding * getBuilding() { return _building; } static const int RTTI; QRgb colorH( QRgb v, double grade ); QImage highlight(QImage image); int type() const; protected: void paint( QPainter * p , const QStyleOptionGraphicsItem * option, QWidget * widget ); GenericInsideBuilding * _building; QPixmap _pixmap, _newpix, _oldpix; QImage _image; uint _type; }; #endif // INSIDEBUILDING_H attal-src-1.0-rc2/libClient/libClient.pro0000644000175000017500000000655511015367573016033 0ustar aaaaTEMPLATE = lib include( ../config.pro ) INCLUDEPATH += .. LIBS += -L.. unix:LIBS += -lAttalCommon win32:LIBS += -lAttalCommon9 contains( DEFINES, WITH_SOUND ) { win32 { contains( CONFIG, crosslinwin ) { INCLUDEPATH += "$$quote($${SDL_DIR})/include" LIBS += -L"$$quote($${SDL_DIR})/lib" } else { INCLUDEPATH += "$$quote($${SDL_DIR})\include" LIBS += -L"$$quote($${SDL_DIR})\lib" } } LIBS += -lSDL LIBS += -lSDL_mixer } VERSION = 10.0.0 SOURCES += aboutDialog.cpp SOURCES += askChest.cpp SOURCES += askCost.cpp SOURCES += askDialog.cpp SOURCES += askWidget.cpp SOURCES += attalButton.cpp SOURCES += attalSound.cpp SOURCES += attalSprite.cpp SOURCES += attalStyle.cpp SOURCES += bonus.cpp SOURCES += building.cpp SOURCES += cell.cpp SOURCES += chatWidget.cpp SOURCES += chest.cpp SOURCES += displayArtefacts.cpp SOURCES += displayBase.cpp SOURCES += displayCreature.cpp SOURCES += displayLord.cpp SOURCES += displayTechnics.cpp SOURCES += event.cpp SOURCES += flag.cpp SOURCES += gainLevel.cpp SOURCES += game.cpp SOURCES += gameControl.cpp SOURCES += gameInfo.cpp SOURCES += graphicalArtefact.cpp SOURCES += graphicalBuilding.cpp SOURCES += graphicalCell.cpp SOURCES += graphicalGameData.cpp SOURCES += graphicalLord.cpp SOURCES += graphicalMap.cpp SOURCES += graphicalPath.cpp SOURCES += gui.cpp SOURCES += imageTheme.cpp SOURCES += insideAction.cpp SOURCES += insideBase.cpp SOURCES += insideBuilding.cpp SOURCES += lord.cpp SOURCES += lordExchange.cpp SOURCES += map.cpp SOURCES += mapCreature.cpp SOURCES += mapView.cpp SOURCES += market.cpp SOURCES += miniMap.cpp SOURCES += optionsDialog.cpp SOURCES += pixmapSpinBox.cpp SOURCES += player.cpp SOURCES += ressourceBar.cpp SOURCES += ressourceWin.cpp SOURCES += unitExchange.cpp SOURCES += tavern.cpp SOURCES += widget.cpp HEADERS += aboutDialog.h HEADERS += askChest.h HEADERS += askCost.h HEADERS += askDialog.h HEADERS += askWidget.h HEADERS += attalButton.h HEADERS += attalSound.h HEADERS += attalSprite.h HEADERS += attalStyle.h HEADERS += bonus.h HEADERS += building.h HEADERS += cell.h HEADERS += chatWidget.h HEADERS += chest.h HEADERS += displayArtefacts.h HEADERS += displayBase.h HEADERS += displayCreature.h HEADERS += displayLord.h HEADERS += displayTechnics.h HEADERS += event.h HEADERS += flag.h HEADERS += gainLevel.h HEADERS += game.h HEADERS += gameControl.h HEADERS += gameInfo.h HEADERS += graphicalArtefact.h HEADERS += graphicalBuilding.h HEADERS += graphicalCell.h HEADERS += graphicalGameData.h HEADERS += graphicalLord.h HEADERS += graphicalMap.h HEADERS += graphicalPath.h HEADERS += gui.h HEADERS += imageTheme.h HEADERS += insideAction.h HEADERS += insideBase.h HEADERS += insideBuilding.h HEADERS += lord.h HEADERS += lordExchange.h HEADERS += map.h HEADERS += mapCreature.h HEADERS += mapView.h HEADERS += market.h HEADERS += miniMap.h HEADERS += optionsDialog.h HEADERS += pixmapSpinBox.h HEADERS += player.h HEADERS += ressourceBar.h HEADERS += ressourceWin.h HEADERS += unitExchange.h HEADERS += tavern.h HEADERS += widget.h TRANSLATIONS += ../i18n/de/attal_libclient_de.ts TRANSLATIONS += ../i18n/fr/attal_libclient_fr.ts TRANSLATIONS += ../i18n/ru/attal_libclient_ru.ts TRANSLATIONS += ../i18n/it/attal_libclient_it.ts DESTDIR = .. OBJECTS_DIR=./obj MOC_DIR=./moc TARGET = AttalClient unix { target.path = $${ATT_LIB_PREFIX} INSTALLS += target } #The following line was inserted by qt3to4 QT += xml network attal-src-1.0-rc2/libClient/lord.cpp0000644000175000017500000000274110644705512015035 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** lord.cpp ** ** ** Version : $Id: lord.cpp,v 1.19 2007/07/10 13:36:10 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 25/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "lord.h" // generic include files // include files for QT #include // application specific include files /** add comments here */ Lord::Lord( Map * map ) :GraphicalLord( (QGraphicsScene *)map ), GenericLord() { } Lord::~Lord() { } void Lord::setCell( GenericCell * cell ) { GenericLord::setCell( cell ); GraphicalLord::setCell( cell ); } void Lord::highlight( bool state) { GraphicalLord::highlight( state ); } void Lord::setVisible( bool state ) { GenericLord::setVisible( state ); GraphicalLord::setVisible( state ); } void Lord::setOwner( GenericPlayer * player ) { GenericLord::setOwner( player ); GraphicalLord::setOwner( player ); } attal-src-1.0-rc2/libClient/lord.h0000644000175000017500000000315410644705512014501 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** lord.h ** ** ** Version : $Id: lord.h,v 1.8 2007/07/10 13:36:10 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 25/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef LORD_H #define LORD_H // generic include files // include files for QT // application specific includes #include "libCommon/genericLord.h" #include "libCommon/genericCell.h" #include "libClient/graphicalLord.h" #include "libClient/map.h" /* ------------------------------ * Lord * ------------------------------ */ /** comment for the class */ class Lord : public GraphicalLord, public GenericLord { public: /** Constructor */ Lord( Map * map ); /** Destructor */ ~Lord( ); /** Set position of a lord */ void setCell( GenericCell * cell ); virtual void highlight( bool state); /** Set the lord visible on the map (or not) */ void setVisible( bool state ); virtual void setOwner( GenericPlayer * player ); }; #endif // LORD_H attal-src-1.0-rc2/libClient/lordExchange.cpp0000644000175000017500000004134311010170657016473 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** lordExchange.cpp ** this is a template for all .cpp files ** ** Version : $Id: lordExchange.cpp,v 1.20 2008/05/07 00:02:55 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 11/08/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "lordExchange.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/artefact.h" #include "libCommon/artefactManager.h" #include "libCommon/attalSocket.h" #include "libCommon/dataTheme.h" #include "libCommon/genericLord.h" #include "libCommon/warMachine.h" #include "libClient/attalButton.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/widget.h" /** add comments here */ LordExchange::LordExchange( QWidget * parent, AttalSocket * socket, const char * /* name */ ) :QDialog( parent, Qt::Dialog ) { _lordLeft = 0; _lordRight = 0; _socket = socket; _presentation = new PresentationWidget( this ); QTabWidget * tab = new QTabWidget( this ); _generalities = new DisplayBothGeneralities(); _units = new DisplayBothUnits(); _artefacts = new DisplayBothArtefacts(); _machines = new DisplayBothMachines(); _units->initSocket( socket ); _artefacts->initSocket( _socket ); tab->insertTab( 0, _generalities, "Generalities" ); tab->insertTab( 1,_units, "Units" ); tab->insertTab( 2,_artefacts, "Artefacts" ); tab->insertTab( 3,_machines, "War Machines" ); tab->setCurrentIndex( 0 ); AttalButton * butOk = new AttalButton( this, AttalButton::BT_OK ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( butOk ); layH1->addStretch( 1 ); QGridLayout * layout = new QGridLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _presentation, 0 , 0 ); layout->setRowStretch( 1, 1 ); layout->addWidget( tab, 1, 0 ); layout->addLayout( layH1, 2, 0 ); layout->activate(); connect( butOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( parent, SIGNAL( sig_updateWidget() ), SLOT( reinit() ) ); } void LordExchange::initLords( GenericLord * lordLeft, GenericLord * lordRight ) { _lordLeft = lordLeft; _lordRight = lordRight; _presentation->initLords( lordLeft, lordRight ); _generalities->initLords( lordLeft, lordRight ); _units->initLords( lordLeft, lordRight ); _artefacts->initLords( lordLeft, lordRight ); _machines->initLords( lordLeft, lordRight ); } void LordExchange::reinit() { initLords( _lordLeft, _lordRight ); } void LordExchange::initSocket( AttalSocket * socket ) { _socket = socket; _units->initSocket( socket ); _artefacts->initSocket( _socket ); } // // -- PresentationWidget -- // PresentationWidget::PresentationWidget( QWidget * parent, const char * /* name */ ) :QWidget( parent ) { _photoLeft = new Icon( this ); _photoRight = new Icon( this ); _titleLeft = new QLabel( this ); _titleLeft->setAlignment( Qt::AlignCenter ); _titleRight = new QLabel( this ); _titleRight->setAlignment( Qt::AlignCenter ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setSpacing( 5 ); layout->addWidget( _photoLeft ); layout->addWidget( _titleLeft ); layout->addStretch( 1 ); layout->addWidget( _titleRight ); layout->addWidget( _photoRight ); layout->activate(); } void PresentationWidget::initLords( GenericLord * lordLeft, GenericLord * lordRight ) { _photoLeft->setPixmap( * ImageTheme.getLordPixmap( lordLeft->getId() ) ); _photoRight->setPixmap( * ImageTheme.getLordPixmap( lordRight->getId() ) ); QString title; title.sprintf( "Lord %s\nLevel %d of %s", qPrintable( lordLeft->getName()), lordLeft->getCharac( LEVEL ), qPrintable( lordLeft->getCategoryName()) ); _titleLeft->setText( title ); FIXEDSIZE( _titleLeft ); title.sprintf( "Lord %s\nLevel %d of %s", qPrintable( lordRight->getName()), lordRight->getCharac( LEVEL ), qPrintable( lordRight->getCategoryName() ) ); _titleRight->setText( title ); FIXEDSIZE( _titleRight ); } // // -- DisplayBothGeneralities -- // DisplayBothGeneralities::DisplayBothGeneralities( QWidget * parent, const char * /* name */ ) :QWidget( parent ) { _listLeft = new QListWidget( this ); _listRight = new QListWidget( this ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addSpacing( 5 ); layH1->addWidget( _listLeft, 1 ); layH1->addSpacing( 10 ); layH1->addWidget( _listRight, 1 ); layH1->addSpacing( 5 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addSpacing( 5 ); layout->addLayout( layH1, 1 ); layout->addSpacing( 5 ); layout->activate(); } void DisplayBothGeneralities::initLords( GenericLord * lordLeft, GenericLord * lordRight ) { _lordLeft = lordLeft; _lordRight = lordRight; reinit(); } void DisplayBothGeneralities::reinit() { _listLeft->clear(); _listRight->clear(); fillList( _listLeft, _lordLeft ); fillList( _listRight, _lordRight ); } void DisplayBothGeneralities::fillList( QListWidget * list, GenericLord * lord ) { QString item; item = "Spell points: " + QString::number( lord->getCharac( TECHNICPOINT ) ) + "/" + QString::number( lord->getCharac( MAXTECHNICPOINT ) ); list->addItem( item ); item = "Morale: " + QString::number( lord->getCharac( MORALE ) ); list->addItem( item ); item = "Luck: " + QString::number( lord->getCharac( LUCK ) ); list->addItem( item ); item = "Attack: " + QString::number( lord->getCharac( ATTACK ) ); list->addItem( item ); item = "Defense: " + QString::number( lord->getCharac( DEFENSE ) ); list->addItem( item ); item = "Power: " + QString::number( lord->getCharac( POWER ) ); list->addItem( item ); item = "Knowledge: " + QString::number( lord->getCharac( KNOWLEDGE ) ); list->addItem( item ); } // // -- PresentUnit -- // PresentUnit::PresentUnit( QWidget * parent, const char * /* name */ ) : QWidget( parent ) { _icon = new Icon( this ); _label = new Label( this ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setSpacing( 5 ); layout->addWidget( _icon ); layout->addWidget( _label, 1 ); layout->activate(); connect( _icon, SIGNAL( sig_clicked() ), SIGNAL( sig_clicked() ) ); connect( _label, SIGNAL( sig_clicked() ), SIGNAL( sig_clicked() ) ); } void PresentUnit::setUnit( GenericFightUnit * unit ) { if( unit ) { _icon->setPixmap( ImageTheme.getPhotoCreature( unit ) ); _label->setText( QString::number( unit->getNumber() ) ); } else { _icon->setPixmap( QPixmap( "" ) ); _label->setText( "" ); } } void PresentUnit::select( bool /*state*/ ) { /// XXX: TODO //logEE( "not yet implemented" ); } // // -- DisplayBothUnits -- // DisplayBothUnits::DisplayBothUnits( QWidget * parent, const char * /* name */ ) :QWidget( parent ) { _currentSide = -1; _currentNum = -1; _exchange = false; _lordLeft = 0; _lordRight = 0; _socket = 0; QSignalMapper * sigmapLeft = new QSignalMapper( this ); QSignalMapper * sigmapRight = new QSignalMapper( this ); QVBoxLayout * layV1 = new QVBoxLayout(); QVBoxLayout * layV2 = new QVBoxLayout(); layV1->addStretch( 1 ); layV2->addStretch( 1 ); for( int i = 0; i < MAX_UNIT; i++ ) { _unitLeft[i] = new PresentUnit( this ); layV1->addWidget( _unitLeft[i] ); layV1->addStretch( 1 ); sigmapLeft->setMapping( _unitLeft[i], i ); connect( _unitLeft[i], SIGNAL( sig_clicked() ), sigmapLeft, SLOT( map() ) ); _unitRight[i] = new PresentUnit( this ); layV2->addWidget( _unitRight[i] ); layV2->addStretch( 1 ); sigmapRight->setMapping( _unitRight[i], i ); connect( _unitRight[i], SIGNAL( sig_clicked() ), sigmapRight, SLOT( map() ) ); } QHBoxLayout * layout = new QHBoxLayout( this ); layout->setSpacing( 5 ); layout->addLayout( layV1, 1 ); layout->addLayout( layV2, 1 ); layout->activate(); connect( sigmapLeft, SIGNAL( mapped( int ) ), SLOT( slot_unitLeft( int ) ) ); connect( sigmapRight, SIGNAL( mapped( int ) ), SLOT( slot_unitRight( int ) ) ); } void DisplayBothUnits::initLords( GenericLord * lordLeft, GenericLord * lordRight ) { _lordLeft = lordLeft; _lordRight = lordRight; for( int i = 0; i < MAX_UNIT; i++ ) { _unitLeft[i]->setUnit( lordLeft->getUnit( i ) ); _unitLeft[i]->select( false ); _unitRight[i]->setUnit( lordRight->getUnit( i ) ); _unitRight[i]->select( false ); } if( ( _currentSide != - 1 ) && ( _currentNum != -1 ) ) { if( _currentSide == 0 ) { _unitLeft[ _currentNum ]->select(); } else { _unitRight[ _currentNum ]->select(); } } } void DisplayBothUnits::reinit() { initLords( _lordLeft, _lordRight ); } void DisplayBothUnits::slot_unitLeft( int num ) { manageClick( 0, num ); } void DisplayBothUnits::slot_unitRight( int num ) { manageClick( 1, num ); } void DisplayBothUnits::manageClick( int side, int num ) { if( ( ! _lordLeft ) || ( ! _lordRight ) ) { return; } if( ( _currentSide == - 1 ) && ( _currentNum == -1 ) ) { if( side == 0 ) { if( _lordLeft->getUnit( num ) ) { _unitLeft[num]->select(); _currentSide = side; _currentNum = num; } } else { if( _lordRight->getUnit( num ) ) { _unitRight[num]->select(); _currentSide = side; _currentNum = num; } } } else { GenericFightUnit * orig = 0; GenericLord * origLord = 0; if( _currentSide == 0 ) { orig = _lordLeft->getUnit( _currentNum ); origLord = _lordLeft; } else { orig = _lordRight->getUnit( _currentNum ); origLord = _lordRight; } GenericFightUnit * dest = 0; GenericLord * destLord = 0; if( side == 0 ) { dest = _lordLeft->getUnit( num ); destLord = _lordLeft; } else { dest = _lordRight->getUnit( num ); destLord = _lordRight; } if( ( destLord == origLord ) && ( dest == orig ) ) { _currentSide = -1; _currentNum = -1; initLords( _lordLeft, _lordRight ); } else { if( orig ) { if( dest ) { if( ( orig->getRace() == dest->getRace() ) && orig->getLevel() == dest->getLevel() ) { //dest->addNumber( orig->getNumber() ); //origLord->setUnit( _currentNum, 0 ); //delete orig; } else { //origLord->setUnit( _currentNum, dest ); //destLord->setUnit( num, orig ); } } else { //destLord->setUnit( num, orig ); //origLord->setUnit( _currentNum, 0 ); } } } if( _socket && _currentNum > -1 ) { _socket->sendExchangeUnit( origLord, _currentNum, destLord, num ); } _currentNum = -1; _currentSide = -1; reinit(); } } // // -- DisplayBothArtefacts -- // DisplayBothArtefacts::DisplayBothArtefacts( QWidget * parent, const char * /* name */ ) :QWidget( parent ) { _socket = 0; _lordLeft = 0; _lordRight = 0; QPushButton * pbToRight = new QPushButton( this ); pbToRight->setText( "->" ); FIXEDSIZE( pbToRight ); QPushButton * pbToLeft = new QPushButton( this ); pbToLeft->setText( "<-" ); FIXEDSIZE( pbToLeft ); QVBoxLayout * layV1 = new QVBoxLayout(); layV1->addStretch( 1 ); layV1->addWidget( pbToRight ); layV1->addStretch( 1 ); layV1->addWidget( pbToLeft ); layV1->addStretch( 1 ); _artefactsLeft = new QListWidget( this ); _artefactsRight = new QListWidget( this ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _artefactsLeft ); layout->addLayout( layV1 ); layout->addWidget( _artefactsRight ); layout->activate(); connect( pbToRight, SIGNAL( clicked() ), SLOT( slot_exchangeToRight() ) ); connect( pbToLeft, SIGNAL( clicked() ), SLOT( slot_exchangeToLeft() ) ); } void DisplayBothArtefacts::initSocket( AttalSocket * socket ) { _socket = socket; //connect( _socket, SIGNAL( readyRead() ), SLOT( slot_readSocket() ) ); } void DisplayBothArtefacts::initLords( GenericLord * lordLeft, GenericLord * lordRight ) { uint i; uint nbArtefacts; uint type; QString artefactName; QPixmap * artefactPixmap; ArtefactManager * artefactManager; GenericLordArtefact * artefact; _lordLeft = lordLeft; _lordRight = lordRight; artefactManager = lordLeft->getArtefactManager(); nbArtefacts = artefactManager->getArtefactNumber(); _artefactsLeft->clear(); for( i = 0; i < nbArtefacts; i++ ) { artefact = artefactManager->getArtefact( i ); type = artefact->getType(); artefactName = DataTheme.artefacts.at( type )->getName(); artefactPixmap = ImageTheme.getArtefactIcon( type ); //_artefactsLeft->insertItem( new QListBoxPixmap( _artefactsLeft, * artefactPixmap, artefactName ) ); _artefactsLeft->addItem( artefactName ); } artefactManager = lordRight->getArtefactManager(); nbArtefacts = artefactManager->getArtefactNumber(); _artefactsRight->clear(); for( i = 0; i < nbArtefacts; i++ ) { artefact = artefactManager->getArtefact( i ); type = artefact->getType(); artefactName = DataTheme.artefacts.at( type )->getName(); artefactPixmap = ImageTheme.getArtefactIcon( type ); //_artefactsRight->insertItem( new QListBoxPixmap( _artefactsRight, * artefactPixmap, artefactName ) ); _artefactsRight->addItem( artefactName ); } } void DisplayBothArtefacts::slot_exchangeToRight() { int item = _artefactsLeft->currentRow(); if( item != -1 ) { if( _socket ) { _socket->sendExchangeArtefact( _lordLeft, item, _lordRight ); ArtefactManager * manag1 = _lordLeft->getArtefactManager(); ArtefactManager * manag2 = _lordRight->getArtefactManager(); GenericLordArtefact * artefact = manag1->getArtefact( item ); manag1->removeArtefact( item ); manag2->addArtefact( artefact ); initLords( _lordLeft, _lordRight ); } } } void DisplayBothArtefacts::slot_exchangeToLeft() { int item = _artefactsRight->currentRow(); if( item != -1 ) { if( _socket ) { _socket->sendExchangeArtefact( _lordRight, item, _lordLeft ); ArtefactManager * manag1 = _lordRight->getArtefactManager(); ArtefactManager * manag2 = _lordLeft->getArtefactManager(); GenericLordArtefact * artefact = manag1->getArtefact( item ); manag1->removeArtefact( item ); manag2->addArtefact( artefact ); initLords( _lordLeft, _lordRight ); } } } void DisplayBothArtefacts::slot_readSocket() { _socket->readData(); if( ( _socket->getCla1() == SO_EXCH ) && ( _socket->getCla2() == C_EXCH_ARTEFACT ) ) { uchar idLord1 = _socket->readChar(); int item = _socket->readInt(); /* XXX: unused ?? uchar idLord2 = */ _socket->readChar(); GenericLord * lord1 = 0; GenericLord * lord2 = 0; if( idLord1 == _lordRight->getId() ) { lord1 = _lordRight; lord2 = _lordLeft; } else { lord2 = _lordRight; lord1 = _lordLeft; } if( lord1 && lord2 ) { ArtefactManager * manag1 = lord1->getArtefactManager(); ArtefactManager * manag2 = lord2->getArtefactManager(); GenericLordArtefact * artefact = manag1->getArtefact( item ); manag1->removeArtefact( item ); manag2->addArtefact( artefact ); initLords( _lordLeft, _lordRight ); } } if( _socket->bytesAvailable() > 0 ) { slot_readSocket(); } } // // ----- PresentMachines ----- // PresentMachines::PresentMachines( QWidget * parent, const char * /* name*/ ) :QWidget( parent ) { _lord = 0; } PresentMachines::~PresentMachines() { while( ! _labels.isEmpty() ) { delete _labels.takeFirst(); } } void PresentMachines::initLord( GenericLord * lord ) { _lord = lord; reinit(); } void PresentMachines::reinit() { while( ! _labels.isEmpty() ) { delete _labels.takeFirst(); } if( _lord ) { for( uint i = 0; i < _lord->getMachineNumber(); i++ ) { WarMachine * machine = DataTheme.machines.at( _lord->getMachine( i ) ); if( machine ) { InfoLabel * label = new InfoLabel( this ); label->move( 0, (70 * i) + 5 ); label->setText( machine->getName() ); _labels.append( label ); } } } } // // -- DisplayBothMachines -- // DisplayBothMachines::DisplayBothMachines( QWidget * parent, const char * /* name */) :QWidget( parent ) { _machineLeft = new PresentMachines( this ); _machineRight = new PresentMachines( this ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setMargin( 5 ); layout->addSpacing( 5 ); layout->addWidget( _machineLeft ); layout->addSpacing( 10 ); layout->addWidget( _machineRight ); layout->addSpacing( 5 ); layout->activate(); } void DisplayBothMachines::initLords( GenericLord * lordLeft, GenericLord * lordRight ) { _machineLeft->initLord( lordLeft ); _machineRight->initLord( lordRight ); } attal-src-1.0-rc2/libClient/lordExchange.h0000644000175000017500000001204110536340612016133 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** lordExchange.h ** Dialog for exchnagiong units and artefacts between two lords. ** ** Version : $Id: lordExchange.h,v 1.8 2006/12/08 19:48:26 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 11/08/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef LORDEXCHANGE_H #define LORDEXCHANGE_H // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/define.h" #include "libCommon/unit.h" class QLabel; class QListWidget; class AttalSocket; class GenericLord; class Icon; class InfoLabel; class Label; /* ------------------------------ * LordExchange * ------------------------------ */ class DisplayBothArtefacts; class DisplayBothGeneralities; class DisplayBothMachines; class DisplayBothUnits; class PresentationWidget; class PresentUnit; /** Dialog for exchanges between two lords */ class LordExchange : public QDialog { public: /** Constructor */ LordExchange( QWidget * parent = 0, AttalSocket * socket = 0 ,const char * name = 0 ); /** Init dialog with the two lords */ void initLords( GenericLord * lordLeft, GenericLord * lordRight ); /** Reinit display */ void reinit(); /** Init socket for requesting exchanges to the server */ void initSocket( AttalSocket * socket ); private: GenericLord * _lordLeft, * _lordRight; AttalSocket * _socket; PresentationWidget * _presentation; DisplayBothGeneralities * _generalities; DisplayBothUnits * _units; DisplayBothArtefacts * _artefacts; DisplayBothMachines * _machines; }; /** Main widget of the dialog */ class PresentationWidget : public QWidget { public: PresentationWidget( QWidget * parent = 0, const char * name = 0 ); void initLords( GenericLord * lordLeft, GenericLord * lordRight ); protected: Icon * _photoLeft, * _photoRight; QLabel * _titleLeft, * _titleRight; }; /** Display general info about the two lords */ class DisplayBothGeneralities : public QWidget { public: /** Constructor */ DisplayBothGeneralities( QWidget * parent = 0, const char * name = 0 ); void initLords( GenericLord * lordLeft, GenericLord * lordRight ); void reinit(); protected: void fillList( QListWidget * list, GenericLord * lord ); GenericLord * _lordLeft, * _lordRight; QListWidget * _listLeft, * _listRight; }; /** Display a unit of a lord */ class PresentUnit : public QWidget { Q_OBJECT public: PresentUnit( QWidget * parent = 0, const char * name = 0 ); void setUnit( GenericFightUnit * unit ); void select( bool state = true ); signals: void sig_clicked(); private: Icon * _icon; Label * _label; }; /** Display all units of lords */ class DisplayBothUnits : public QWidget { Q_OBJECT public: /** Constructor */ DisplayBothUnits( QWidget * parent = 0, const char * name = 0 ); void initLords( GenericLord * lordLeft, GenericLord * lordRight ); void reinit(); void initSocket( AttalSocket * socket ) { _socket = socket; } public slots: void slot_unitLeft( int ); void slot_unitRight( int ); protected: void manageClick( int side, int num ); PresentUnit * _unitLeft[MAX_UNIT], * _unitRight[MAX_UNIT]; int _currentNum, _currentSide; bool _exchange; GenericLord * _lordRight, * _lordLeft; AttalSocket * _socket; }; /** Displays artefacts of two lords */ class DisplayBothArtefacts : public QWidget { Q_OBJECT public: /** Constructor */ DisplayBothArtefacts( QWidget * parent = 0, const char * name = 0 ); void initLords( GenericLord * lordLeft, GenericLord * lordRight ); void initSocket( AttalSocket * socket ); public slots: void slot_exchangeToRight(); void slot_exchangeToLeft(); void slot_readSocket(); protected: QListWidget * _artefactsRight, * _artefactsLeft; GenericLord * _lordRight, * _lordLeft; AttalSocket * _socket; }; /** */ class PresentMachines : public QWidget { public: /** Constructor */ PresentMachines( QWidget * parent = 0, const char * name = 0 ); /** Destructor */ virtual ~PresentMachines(); void initLord( GenericLord * lord ); void reinit(); protected: GenericLord * _lord; QList _labels; }; /** Displays war machines of two lords */ class DisplayBothMachines : public QWidget { public: /** Constructor */ DisplayBothMachines( QWidget * parent = 0, const char * name = 0 ); void initLords( GenericLord * lordLeft, GenericLord * lordRight ); protected: PresentMachines * _machineLeft, * _machineRight; }; #endif // LORDEXCHANGE_H attal-src-1.0-rc2/libClient/map.cpp0000644000175000017500000001733510776155630014665 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** map.cpp ** Manage the global view ** ** Version : $Id: map.cpp,v 1.36 2008/04/06 14:18:00 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier - Sardi Carlo ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "map.h" // generic include files #include // include files for QT #include #include #include // application specific includes #include "libCommon/log.h" #include "libCommon/pathFinder.h" #include "libCommon/dataTheme.h" #include "libClient/cell.h" #include "libClient/lord.h" #include "libClient/building.h" #include "libClient/graphicalPath.h" #include "libClient/mapCreature.h" #include "libClient/event.h" #include "libClient/imageTheme.h" // // ----- Map ----- // Map::Map( QObject * parent , const char * name ) : GraphicalMap( parent , name ), GenericMap() { _isGrid = false; _showPath = new GraphicalPath( this ); } Map::~Map() { clear(); if(_path) { delete _path; _path = NULL; } if( _showPath ) { _showPath->clearPath(); delete _showPath; } } void Map::clear() { TRACE("Map::clear"); if( _theCells != NULL ) { for( uint i = 0 ; i < _height ; i++ ) { for( uint j = 0; j < _width; j++ ) { delete (Cell*)_theCells[i][j]; } delete [] _theCells[i]; } delete [] _theCells; } _theCells = NULL; _height = 0; _width = 0; if(_path) { _path->clear(); } _isGrid = false; _showPath->clearPath(); updateMap(); } void Map::newUnknownMap( int h, int w ) { newMapType( h, w, 0 ); } void Map::newMapType( int h, int w, int typ ) { clear(); _height = h; _width = w; _theCells = new GenericCell **[_height]; uint i; for( i = 0; i < _height; i++ ) { _theCells[i] = new GenericCell *[_width]; } for( i = 0; i < _height; i++ ) { for( uint j = 0; j < _width; j++ ) { _theCells[i][j] = (GenericCell *)( new Cell( i, j, this ) ); ((Cell*)_theCells[i][j])->setType( typ ); } } _path->newMap( _height, _width, (GenericMap*)this ); autoSize(); } void Map::changeCell( int i, int j, int typ, int transition, int typtra, uint decorationGroup, uint decorationItem , uchar diversification) { GenericMap::changeCell( i, j, typ, transition, typtra, decorationGroup, decorationItem, diversification ); ((Cell*)at( i, j ))->setDiversification( diversification ); //use signal changed instead directly update int width = DataTheme.tiles.getWidth(); int height = DataTheme.tiles.getHeight(); emit sig_cellChanged( i , j ); updateMapRect(QRectF( j * width, i * height, width, height )); } bool Map::load( QTextStream * ts, int width, int heigth ) { _width = width; _height = heigth; uint i, j; _theCells = (GenericCell ***) ( new Cell **[_height] ); for( i = 0; i < _height; i++ ) { _theCells[i] = (GenericCell**) ( new Cell *[_width] ); } int val; uint item; // Loading base cell for( i = 0; i < _height; i++ ) { for( j = 0; j < _width; j++ ) { if( ! ts->atEnd() ) { *ts >> val; _theCells[i][j] = (GenericCell *)( new Cell( i, j, this ) ); ((Cell*)_theCells[i][j])->setType( val ); } else { logEE("Stream too short"); return false; } } } // Loading diversification cell for( i = 0; i < _height; i++ ) { for( j = 0; j < _width; j++ ) { if( ! ts->atEnd() ) { *ts >> val; _theCells[i][j]->setDiversification( val ); } else { logEE("Stream too short"); return false; } } } // Loading transition type for( i = 0; i < _height; i++ ) { for( j = 0; j < _width; j++ ) { if( ! ts->atEnd() ) { *ts >> val; _theCells[i][j]->setTransition( val ); } else { logEE("Stream too short"); return false; } } } // Loading transition cell for( i = 0; i < _height; i++ ) { for( j = 0; j < _width; j++ ) { if( ! ts->atEnd() ) { *ts >> val; _theCells[i][j]->setTransitionCellType( val ); } else { logEE("Stream too short"); return false; } } } // Loading decoration of the ground for( i = 0; i < _height; i++ ) { for( j = 0; j < _width; j++ ) { if( ! ts->atEnd() ) { *ts >> val; if( val ) { *ts >> item; _theCells[i][j]->setDecoration( val, item ); } } else { logEE("Stream too short"); return false; } } } _path = new PathFinder( _width, _height, this ); updateMap(); autoSize(); return true; } void Map::activateGrid() { // TODO implement a boolean toggle for drawBackground to draw a grid //((Cell *) _theCells[i][j])->activateGrid(!_isGrid); _isGrid = !_isGrid; updateMap(); } void Map::drawBackground( QPainter * painter , const QRectF & rect ) { //mantain optimized int tileh = DataTheme.tiles.getHeight(); int tilew = DataTheme.tiles.getWidth(); int iwidth = (int)_width; int iheight = (int)_height; int rowinit =std::max(0, (int)(rect.y() / tileh )); int colinit =std::max(0, (int)(rect.x() / tilew )); int rowend = std::min(iheight, (int)(rect.bottom() / tileh ) + 1); int colend = std::min(iwidth, (int)(rect.right() / tilew ) + 1); for (int row = rowinit; row < rowend; row++) { for (int col = colinit; col < colend; col++) { GenericCell * cell = at( row,col ); int type = cell->getType(); if (row < iheight && col < iwidth && type ) { // possibly unnecessary inside-of-map tests painter->drawPixmap(col * tilew, row * tileh, tilew , tileh , (*ImageTheme.cells[type])[cell->getDiversification()]); if ( cell->getTransitionCellType()) painter->drawPixmap(col * tilew, row * tileh, tilew, tileh, (*ImageTheme.transition[cell->getTransitionCellType() - 1])[std::max(0, cell->getTransition() - 1)]); // HACK std::max used to workaround a bug /*if (at(row, col)->getDecorationGroup()) painter->drawPixmap(col * DataTheme.tiles.getWidth(), row * DataTheme.tiles.getHeight(), DataTheme.tiles.getWidth(), DataTheme.tiles.getHeight(), (*ImageTheme.decoration[at(row, col)->getDecorationGroup() - 1])[at(row, col)->getDecorationItem()]);*/ } } } } void Map::drawForeground( QPainter * painter , const QRectF & rect ) { painter->setPen(Qt::darkRed); int tileh, tilew; if (getHeight() && getWidth()) { tileh = (int)height() / _height; tilew = (int)width() / _width; } else { tileh = _shroudImage.height(); tilew = _shroudImage.width(); } int iwidth = (int)_width; int iheight = (int)_height; int rowinit =std::max(0, (int)(rect.y() / tileh )); int colinit =std::max(0, (int)(rect.x() / tilew )); int rowend = std::min(iheight, (int)(rect.bottom() / tileh ) + 1); int colend = std::min(iwidth, (int)(rect.right() / tilew ) + 1); for (int row = rowinit; row < rowend; row++) { for (int col = colinit; col < colend; col++) { if (row < iheight && col < iwidth && !at(row, col)->getType() ) { // possibly unnecessary inside-of-map tests painter->drawPixmap(col * tilew, row * tileh, tileh, tilew, _shroudImage); } if (_isGrid) { painter->drawRect(col * tilew, row * tileh, tileh, tilew); } } } } void Map::updateMap() { //TRACE("update map"); updateMapRect(sceneRect()); } void Map::updateMapRect( QRectF rect ) { //TRACE("update map rect"); QList rectlist; rectlist.append( rect ); emit changed( rectlist ); } attal-src-1.0-rc2/libClient/map.h0000644000175000017500000000504710644710003014310 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** map.h ** Manage the global view ** ** Version : $Id: map.h,v 1.17 2007/07/10 13:56:19 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef MAP_H #define MAP_H // generic include files // include files for QT #include #include #include // application specific includes #include "libCommon/genericMap.h" #include "libCommon/dataTheme.h" #include "libClient/graphicalMap.h" class GraphicalPath; /* ------------------------------ * Map * ------------------------------ */ /** comment for the class */ class Map : public GraphicalMap , public GenericMap { Q_OBJECT public: /** Construtor */ Map( QObject * parent = 0 , const char * name = 0 ); /// XXX: Does we need a destructor for theCells ?? /** Destructor */ ~Map(); bool load( QTextStream * ts, int width, int heigth ); /** Clear the map */ virtual void clear(); /** Change the type of cell on the map */ void changeCell( int i, int j, int typ, int transition, int typtra, uint decorationGroup, uint decorationItem , uchar diversification ); /** Create new unknown map */ void newUnknownMap( int h, int w ); /** Create new map */ void newMapType( int h, int w, int typ ); void updateMap(); void updateMapRect( QRectF rect ); /** Resize the map to the right size */ void autoSize() { setSceneRect( QRectF ( 0 , 0, _width * DataTheme.tiles.getWidth(), _height * DataTheme.tiles.getHeight()) ); } void activateGrid(); /** Return the graphical path finder */ GraphicalPath * getGraphicalPath() { return _showPath; } signals: void sig_cellChanged( int , int ); protected: void drawBackground( QPainter * painter , const QRectF & rect ); void drawForeground( QPainter * painter , const QRectF & rect ); private: bool _isGrid; GraphicalPath * _showPath; }; #endif // MAP_H attal-src-1.0-rc2/libClient/mapCreature.cpp0000644000175000017500000000365610522705151016345 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** mapCreature.cpp ** Manages creatures on map ** ** Version : $Id: mapCreature.cpp,v 1.7 2006/11/03 18:28:57 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 11/09/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "mapCreature.h" // generic include files // include files for QT // application specific include files #include "conf.h" #include "libCommon/genericCell.h" #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libClient/imageTheme.h" MapCreature::MapCreature( QGraphicsScene * map ) :AttalSprite( (*(ImageTheme.mapCreatures[ 0 ][ 0 ]))[0], map ) { setFrame( 0 ); setZValue( CAN_CREATURE ); } void MapCreature::setCell( GenericCell * cell ) { GenericMapCreature::setCell( cell ); setPos( cell->getCol() * DataTheme.tiles.getWidth() , ( cell->getRow() + 1 ) * DataTheme.tiles.getHeight() - boundingRect().height() ); } void MapCreature::setCreature( int race, int level ) { GenericMapCreature::setCreature( race, level ); setSequence( ImageTheme.mapCreatures[ race ][ level ]->getList(_lookingRight?1:0) ); setFrame( 0 ); } void MapCreature::setLookingRight( bool state ) { GenericMapCreature::setLookingRight( state ); setSequence( ImageTheme.mapCreatures[ _creature->getRace() ][ _creature->getLevel() ]->getList(_lookingRight?1:0) ); setFrame( 0 ); } attal-src-1.0-rc2/libClient/mapCreature.h0000644000175000017500000000304210510251100015762 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** mapCreature.h ** Manages creatures on map ** ** Version : $Id: mapCreature.h,v 1.4 2006/10/02 17:54:08 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 11/09/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef MAPCREATURE_H #define MAPCREATURE_H // generic include files // include files for QT // application specific include files #include "libCommon/genericMapCreature.h" #include "libClient/attalSprite.h" /* ------------------------------ * MapCreature * ------------------------------ */ /** comment for the class */ class MapCreature : public AttalSprite, public GenericMapCreature { public: /** Constructor */ MapCreature( QGraphicsScene * map ); virtual ~MapCreature() {} virtual void setCell( GenericCell * cell ); virtual void setCreature( int race, int level ); virtual void setLookingRight( bool state ); }; #endif // MAPCREATURE_H attal-src-1.0-rc2/libClient/mapView.cpp0000644000175000017500000001000210644533227015474 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** mapView.cpp ** subclass of QCanvasSprite that handles mouse event ... ** ** Version : $Id: mapView.cpp,v 1.17 2007/07/09 22:28:39 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 08/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "mapView.h" // generic include files // include files for QT #include // application specific includes #include "libCommon/log.h" #include "libCommon/genericCell.h" //#include "libClient/lord.h" /** subclass of QCanvasSprite that handles mouse event ... */ MapView::MapView( Map * map, QWidget * parent, const char * /* name */, Qt::WFlags /* f */ ) : QGraphicsView( map, parent ) { viewport()->setMouseTracking( true ) ; _press = false; _map = map; } /** handles mouse event */ void MapView::mouseMoveEvent( QMouseEvent * event ) { QPointF pos = mapToScene(event->pos()); if (scene()->sceneRect().contains( pos )) { // possibly unnecessary, but for safety... uint row = (uint)pos.y() / DataTheme.tiles.getHeight(); uint col = (uint)pos.x() / DataTheme.tiles.getWidth() ; if( ((Map*)scene())->inMap( row, col )) { GenericCell * cell = ((Map*)scene())->at( row, col ); emit sig_mouseMoved( cell ); } } //logDD(" pos x %d, y %d", (int) pos.x(),(int) pos.y()); //logDD(" view pos x %d, y %d", (int) event->pos().x(),(int) event->pos().y()); } void MapView::mousePressEvent( QMouseEvent * event ) { QPointF pos = mapToScene(event->pos()); if (scene()->sceneRect().contains( pos )) { // possibly unnecessary, but for safety... uint row = (uint)pos.y() / DataTheme.tiles.getHeight(); uint col = (uint)pos.x() / DataTheme.tiles.getWidth() ; if( ((Map*)scene())->inMap( row, col )) { GenericCell * cell = ((Map*)scene())->at( row, col ); if( event->button() == Qt::RightButton ) { emit sig_mouseRightPressed( cell ); } else { emit sig_mouseLeftPressed( cell ); } _press = true; } } updateMap(); } void MapView::mouseReleaseEvent( QMouseEvent * ) { _press = false; emit sig_mouseReleased(); updateMap(); } void MapView::mouseDoubleClickEvent( QMouseEvent * event ) { mousePressEvent( event ); mouseReleaseEvent( event ); } void MapView::slot_Center( int row, int col) { if( _map->inMap( row, col )) { this->centerOn( col * DataTheme.tiles.getWidth(), row * DataTheme.tiles.getHeight() ); } } void MapView::slot_Center(double x, double y) { centerOn(_map->width() * x, _map->height() * y); } void MapView::resizeEvent( QResizeEvent * event ) { QGraphicsView::resizeEvent( event ); //emit sig_viewportResized( viewport()->width() / sceneRect().width(), viewport()->height() / sceneRect().height() ); // NOTE correct way of doing it emit sig_viewportResized( width() / sceneRect().width(), height() / sceneRect().height() ); // HACK to workaround a stupid Qt 4.2 bug... They released it too early... } void MapView::scrollContentsBy(int dx, int dy) { QGraphicsView::scrollContentsBy( dx, dy ); emit sig_viewportScrolled( std::max(0.0, (double)mapToScene(rect()).boundingRect().x() / (double)sceneRect().width()), std::max(0.0, (double)mapToScene(rect()).boundingRect().y() / (double)sceneRect().height())); updateMap(); } void MapView::updateMap() { TRACE("MapView::updateMap"); updateMapRect(sceneRect()); } void MapView::updateMapRect( QRectF rect ) { TRACE("MapView::updateMapRect"); QList rectlist; rectlist.append( rect ); _map->updateMapRect(sceneRect()); } attal-src-1.0-rc2/libClient/mapView.h0000644000175000017500000000474111006433302015140 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** mapView.cpp ** subclass of QCanvasSprite that handles mouse event ... ** ** Version : $Id: mapView.h,v 1.12 2008/05/01 21:31:46 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef MAPVIEW_H #define MAPVIEW_H // generic include files // include files for QT #include #include // application specific includes #include "libClient/map.h" #include "libCommon/genericCell.h" /* ------------------------------ * MapView * ------------------------------ */ /** subclass of QCanvasSprite that handles mouse event ... in the map */ class MapView : public QGraphicsView { Q_OBJECT public: /** Constructor */ MapView( Map * map, QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0 ); void goToPosition(GenericCell * cell); public slots: void slot_Center(double x, double y); void slot_Center(int row, int col); void updateMap(); void updateMapRect( QRectF rect ); signals: /** Signal if the mouse has moved */ void sig_mouseMoved( GenericCell *cell ); /** Signal if the mouse has been pressed (right button)*/ void sig_mouseRightPressed( GenericCell *cell ); /** Signal if the mouse has been pressed (left button)*/ void sig_mouseLeftPressed( GenericCell *cell ); void sig_mouseReleased(); void sig_viewportResized( double, double ); void sig_viewportScrolled( double, double ); protected: /** reimplemented : handles mouse event */ void mouseMoveEvent ( QMouseEvent * event ); void mouseReleaseEvent( QMouseEvent * event ); void mousePressEvent( QMouseEvent * event ); void mouseDoubleClickEvent( QMouseEvent * event ); void resizeEvent( QResizeEvent * event ); void scrollContentsBy( int dx, int dy ); bool _press; Map * _map; }; #endif // MAPVIEW_H attal-src-1.0-rc2/libClient/market.cpp0000644000175000017500000002412711016036224015351 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** market.cpp ** display market place ** ** Version : $Id: market.cpp,v 1.23 2008/05/24 16:04:36 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 14/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "market.h" // generic include files // include files for QT #include #include #include #include #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/log.h" #include "libCommon/attalSocket.h" #include "libClient/attalButton.h" #include "libClient/gui.h" #include "libClient/widget.h" Market::Market( QWidget * parent, GenericPlayer * player, AttalSocket * socket ) : QDialog( parent, Qt::Dialog ) { _socket = socket; _player = player; setWindowTitle( tr("Marketplace") ); QVBoxLayout * layout = new QVBoxLayout( this ); QHBoxLayout * layH1 = new QHBoxLayout(); _own = new DisplayResources( this ); _own->setTitle( tr("Kingdom resources") ); layH1->addWidget( _own, 1 ); _other = new DisplayResources( this ); _other->setTitle( tr("Available for trade") ); layH1->addWidget( _other, 1 ); layout->addLayout( layH1, 1 ); _exchange = new ExchangeResources( this , player ); layout->addWidget( _exchange ); layout->setMargin( 2 ); layout->activate(); connect( _exchange, SIGNAL( sig_buy(int , int , int ) ), SLOT( slot_buy(int , int,int) ) ); connect( _exchange, SIGNAL( sig_quit() ), SLOT( accept() ) ); connect( _own, SIGNAL( sig_resource( int ) ), SLOT( slot_ownResource( int ) ) ); connect( _other, SIGNAL( sig_resource( int ) ), SLOT( slot_otherResource( int ) ) ); connect( parent, SIGNAL( sig_resource() ), SLOT( slot_reinit() ) ); } void Market::slot_reinit() { if(_player) { _own->setResources(_player); } } void Market::setPrices( PriceMarket * prices ) { _prices = prices; _exchange->setPrices( prices ); } void Market::slot_ownResource( int num ) { _exchange->slot_ownResource( num ); if(_player) _own->setResources(_player); _other->setPrices( _prices, num ); } void Market::slot_otherResource( int num ) { _exchange->slot_otherResource( num ); } void Market::slot_buy( int own,int other, int value ) { //logDD("own %d, other %d, value %d",own,other,value); _socket->sendBaseMarket(own,other,value); } /*! Constructs an empty */ DisplayResources::DisplayResources( QWidget * parent, const char * /* name */) : QWidget( parent ) { uint nbResources = DataTheme.resources.count(); QVBoxLayout * layout = new QVBoxLayout( this ); _title = new Sentence( this ); layout->addWidget( _title ); layout->addStretch( 1 ); _resources = new ResourceIcon * [ nbResources ]; QSignalMapper * sigmap = new QSignalMapper( this ); for( uint i = 0; i < nbResources; i+=3 ) { if( nbResources-i == 1 ) { _resources[i] = new ResourceIcon( this ); _resources[i]->setResource( i ); layout->addWidget( _resources[i] ); sigmap->setMapping( _resources[i], i ); connect( _resources[i], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); } else if( nbResources-i == 2 ) { QHBoxLayout * layH = new QHBoxLayout(); _resources[i] = new ResourceIcon( this ); _resources[i]->setResource( i ); layH->addStretch( 1 ); layH->addWidget( _resources[i] ); layH->addStretch( 1 ); sigmap->setMapping( _resources[i], i ); connect( _resources[i], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); _resources[i+1] = new ResourceIcon( this ); _resources[i+1]->setResource( i+1 ); layH->addWidget( _resources[i+1] ); layH->addStretch( 1 ); sigmap->setMapping( _resources[i+1], i+1 ); connect( _resources[i+1], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); layout->addLayout( layH ); } else { QHBoxLayout * layH = new QHBoxLayout(); _resources[i] = new ResourceIcon( this ); _resources[i]->setResource( i ); layH->addWidget( _resources[i] ); sigmap->setMapping( _resources[i], i ); connect( _resources[i], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); _resources[i+1] = new ResourceIcon( this ); _resources[i+1]->setResource( i+1 ); layH->addWidget( _resources[i+1] ); sigmap->setMapping( _resources[i+1], i+1 ); connect( _resources[i+1], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); _resources[i+2] = new ResourceIcon( this ); _resources[i+2]->setResource( i+2 ); layH->addWidget( _resources[i+2] ); sigmap->setMapping( _resources[i+2], i+2 ); connect( _resources[i+2], SIGNAL( sig_clicked() ), sigmap, SLOT( map() ) ); layout->addLayout( layH ); } } layout->activate(); connect( sigmap, SIGNAL( mapped( int ) ), SIGNAL( sig_resource( int ) ) ); } void DisplayResources::setResources( GenericPlayer * player ) { uint nbResources = DataTheme.resources.count(); for( uint i = 0; i < nbResources; i++ ) { _resources[i]->setValue( QString::number( player->getResourceList()->getValue( i ) ) ); } } void DisplayResources::setPrices( PriceMarket * prices, uchar resource ) { QString text; ResourceModel * model = DataTheme.resources.get( resource ); uint nbResources = DataTheme.resources.count(); for( uint i = 0; i < nbResources; i++ ) { ResourceModel * model2 = DataTheme.resources.get( i ); if( resource == i || model->isPreservable() || model2->isPreservable() ) { //text = QString("n/a %1").arg( prices->getResourcePrice( i ) ); text = QString("n/a"); } else if ( prices->getResourcePrice( i ) >= prices->getResourcePrice( resource ) ){ //text = QString::number( prices->getResourceInResource( resource,i ) ) + " " + QString::number(prices->getResourcePrice( i ) ); text = QString::number( prices->getResourceInResource( i, resource ) ); } else { //text = QString("1/%1 %2").arg( prices->getResourceInResource( i, resource ) ).arg( prices->getResourcePrice( i ) ); text = QString("1/%1").arg( prices->getResourceInResource( resource, i ) ); } _resources[i]->setValue( text ); } } void DisplayResources::setTitle( QString title ) { _title->setText( title ); } /*! Constructs an empty */ ExchangeResources::ExchangeResources( QWidget * parent, GenericPlayer * player ) : QWidget( parent ) { _player = player; setFixedHeight( 200 ); QVBoxLayout * layout = new QVBoxLayout( this ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 2 ); _icoLeft = new ResourceIcon( this ); layH1->addWidget( _icoLeft ); layH1->addSpacing( 25 ); _scroll = new QScrollBar( Qt::Horizontal, this ); layH1->addWidget( _scroll, 1 ); layH1->addSpacing( 25 ); _icoRight = new ResourceIcon( this ); layH1->addWidget( _icoRight ); layH1->addStretch( 2 ); layout->addLayout( layH1 ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addStretch( 1 ); _butAll = new QPushButton( this ); _butAll->setText( tr("All") ); _butAll->setFixedSize( 50, 40 ); layH2->addWidget( _butAll ); layH2->addSpacing( 50 ); _butBuy = new QPushButton( this ); _butBuy->setText( tr("Buy") ); _butBuy->setFixedSize( 50, 40 ); layH2->addWidget( _butBuy ); layH2->addStretch( 1 ); AttalButton * butOk = new AttalButton( this, AttalButton::BT_OK ); layH2->addWidget( butOk ); layout->addLayout( layH2 ); layout->activate(); connect( butOk, SIGNAL( clicked() ), SIGNAL( sig_quit() ) ); connect( _butAll, SIGNAL( clicked() ), SLOT( slot_all() ) ); connect( _butBuy, SIGNAL( clicked() ), SLOT( slot_buy() ) ); connect( _scroll, SIGNAL( valueChanged( int ) ), SLOT( slot_value( int ) ) ); clear(); } void ExchangeResources::slot_all() { setValue( 99 ); } void ExchangeResources::slot_buy() { emit sig_buy(_resource, _other, _value); clear(); } void ExchangeResources::slot_ownResource( int num ) { ResourceModel * model = DataTheme.resources.get( num ); if( model->isPreservable() ){ return; } _icoLeft->setResource( num ); _isLeft = true; _resource = num; setValue( 0 ); _icoRight->setValue( QString::number( 0 ) ); if( _isRight ) { if(_prices->getResourcePrice( _resource ) > _prices->getResourcePrice( _other )){ _cost = _prices->getResourceInResource( _resource ,_other); } else { _cost = _prices->getResourceInResource( _other,_resource); } _scroll->setEnabled( true ); _butBuy->setEnabled( true ); _butAll->setEnabled( true ); } } void ExchangeResources::slot_otherResource( int num ) { ResourceModel * model = DataTheme.resources.get( num ); if( model->isPreservable() ){ return; } _other= num; _icoRight->setResource( num ); _isRight = true; _icoRight->setValue( QString::number( 0 ) ); _icoLeft->setValue( QString::number( 0 ) ); if( _isLeft ) { if(_prices->getResourcePrice( _other ) > _prices->getResourcePrice( _resource )){ _cost = _prices->getResourceInResource( _other , _resource); _first=false; } else { _cost = _prices->getResourceInResource( _resource ,_other); _first=true; } _scroll->setEnabled( true ); _butBuy->setEnabled( true ); _butAll->setEnabled( true ); } } void ExchangeResources::clear() { _icoRight->clear(); _icoLeft->clear(); _scroll->setEnabled( false ); _butBuy->setEnabled( false ); _butAll->setEnabled( false ); _isRight = false; _isLeft = false; } void ExchangeResources::setValue( int val ) { if( _player->getResourceList()->getValue( _resource ) < val ) { val = _player->getResourceList()->getValue( _resource ); } _value=val; _scroll->setValue( val ); if(_first==false){ _icoLeft->setValue( QString::number( val * _cost ) ); _icoRight->setValue( QString::number( val ) ); } else { _icoRight->setValue( QString::number( val * _cost ) ); _icoLeft->setValue( QString::number( val ) ); } } attal-src-1.0-rc2/libClient/market.h0000644000175000017500000000742710725110362015024 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** market.h ** Display market place ** ** Version : $Id: market.h,v 1.8 2007/12/03 23:27:46 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 14/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef MARKET_H #define MARKET_H // generic include files // include files for QT #include // application specific include files #include "libCommon/priceMarket.h" class AttalSocket; class QScrollBar; class QPushButton; class Sentence; class DisplayResources; class ExchangeResources; class ResourceIcon; /* ------------------------------ * Market * ------------------------------ */ /** comment for the class */ class Market : public QDialog { Q_OBJECT public: /** Constructor */ Market( QWidget * parent = 0, GenericPlayer * player = 0, AttalSocket * socket = 0 ); /** Initialize prices of the market */ void setPrices( PriceMarket * prices ); /** Initialize the socket of the dialog for requesting the server */ void initSocket( AttalSocket * socket ) { _socket = socket; } void initPlayer( GenericPlayer * player ) { _player = player; } public slots: /** Slot when own resource is clicked */ void slot_ownResource( int num ); /** Slot when other resource is clicked */ void slot_otherResource( int num ); void slot_buy( int own,int other, int value ); void slot_reinit(); private: int _nbResources; PriceMarket * _prices; GenericPlayer * _player; DisplayResources * _own, * _other; ExchangeResources * _exchange; AttalSocket * _socket; }; /** Display resources (of the market or of the player) */ class DisplayResources : public QWidget { Q_OBJECT public: /** Constructor */ DisplayResources( QWidget * parent = 0, const char * name = 0 ); /** Set the title of the widget */ void setTitle( QString title ); /** Initializes resources */ void setResources( GenericPlayer * player ); /** Initializes prices */ void setPrices( PriceMarket * prices, uchar resource ); signals: /** Signal when resource clicked */ void sig_resource( int num ); private: ResourceIcon ** _resources; Sentence * _title; }; /** Exchanges resources between player and market */ class ExchangeResources : public QWidget { Q_OBJECT public: /** Constructor */ ExchangeResources( QWidget * parent = 0, GenericPlayer * player = 0 ); /** Clear widget */ void clear(); /** Initializes prices */ void setPrices( PriceMarket * prices ) { _prices = prices; } public slots: /** Slot when own resource is clicked */ void slot_ownResource( int num ); /** Slot when other resource is clicked */ void slot_otherResource( int num ); signals: /** Signal when quitting */ void sig_quit(); /** Signal when buying */ //void sig_buy( char, int, char, int ); void sig_buy( int own ,int other, int value ); private slots: void slot_buy(); void slot_all(); void slot_value( int val ) { setValue( val ); } private: void setValue( int ); bool _first; bool _isLeft, _isRight; PriceMarket * _prices; QPushButton * _butAll, * _butBuy; ResourceIcon * _icoLeft, * _icoRight; QScrollBar * _scroll; GenericPlayer * _player; int _resource, _cost, _other,_value; }; #endif // MARKET_H attal-src-1.0-rc2/libClient/miniMap.cpp0000644000175000017500000001462210776155633015501 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** miniMap.cpp ** draw and manage the mini-map ** ** Version : $Id: miniMap.cpp,v 1.37 2008/04/06 14:18:03 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo - Forest Darling ** ** Date : 05/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "miniMap.h" // generic include files // include files for QT ////#include ////#include // application specific includes #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libCommon/genericPlayer.h" QPen MiniMap::_pen = QPen( Qt::white, 1, Qt::DashLine ); const int MiniMap::_defaultHeight = 150; const int MiniMap::_defaultWidth = 150; MiniMap::MiniMap( Map * map, QWidget * /*parent*/, const char * /*name*/ ) { _map = map; // it gets set anyways in redrawMap(); _minimap = NULL; _oldHeight = _map->getHeight(); _oldWidth = _map->getWidth(); redrawMap( _map ); _viewportrect.setRect( 0, 0, 1, 1 ); // TODO possible set the background to black? fill the _minimap with black? /*QPalette palette; palette.setColor( backgroundRole(), Qt::black ); setPalette( palette ); setAutoFillBackground( true );*/ //setAttribute( Qt::WA_PaintOutsidePaintEvent, true ); // TODO is it needed? } MiniMap::~MiniMap( ) { if( _minimap ) delete _minimap; } void MiniMap::redrawMap(Map * map) { _map = map; uint width = _map->getWidth(); uint height = _map->getHeight(); setMapSize( width , height ); if (_minimap) delete _minimap; _minimap = new QPixmap( width , height ); if ( !_minimap->isNull() ) { _mappainter.begin( _minimap ); for( uint row = 0; row < height; row++ ) { for( uint col = 0; col < width; col++ ) { _repaintMapPoint( row, col ); } } _mappainter.end(); } update(); } void MiniMap::slot_redrawCell( int row, int col ) { redrawCell( row, col ); } void MiniMap::redrawCell( int row, int col ) { int mwidth =_map->getWidth(); int mheight =_map->getHeight(); if( /*!isHidden() && */ mwidth && mheight ) { // TODO is the !isHidden() really needed? _mappainter.begin( _minimap ); _repaintMapPoint( row , col ); _mappainter.end(); update( col * width() / mwidth, row * height() / mheight, width() / mwidth + 1, height() / mheight + 1 ); } } void MiniMap::_repaintMapPoint( uint row, uint col ) { static QColor c = Qt::red; // to show unimplemented colors if( _map->getHeight() && _map->getWidth() ) { GenericCell * cell = _map->at( row, col ); int type = cell->getType(); if( type < DataTheme.tiles.count() ) { if( type ) { c = DataTheme.tiles.at( type )->getColor(); if( !cell->isStoppable() ) { //c = c.dark(); } } else { c = Qt::black; } } else { logEE( "Each cell should have a type" ); } if( cell->getBase() ) { if( cell->getBase()->getOwner() ) { c = DataTheme.teams.at( cell->getBase()->getOwner()->getTeamId() )->getColor(); } else { c = Qt::gray; } } if( cell->getBuilding() ) { if( cell->getBuilding()->getOwner() ) { c = DataTheme.teams.at( cell->getBuilding()->getOwner()->getTeamId() )->getColor(); } else { c = Qt::gray; } } if( cell->getLord() ) { if( cell->getLord()->getOwner() ) { c = DataTheme.teams.at( cell->getLord()->getOwner()->getTeamId() )->getColor(); } } if( cell->getCreature() ) { c = Qt::gray; } } _mappainter.setPen( c ); _mappainter.drawPoint( col, row ); } void MiniMap::paintEvent(QPaintEvent * /*event*/) { QPainter p( this ); p.setPen( _pen ); if( _minimap->isNull() ) { p.fillRect( 0, 0, width(), height(), Qt::black); } else { p.drawPixmap( 0, 0, width(), height(), *_minimap ); } p.drawRect( _viewportrect.x(), _viewportrect.y(), _viewportrect.width() - 1, _viewportrect.height() - 1 ); } void MiniMap::mousePressEvent( QMouseEvent * event ) { emit sig_mouseReleasedMinimap( (double)event->x() / (double)width(), (double)event->y() / (double)height() ); } void MiniMap::mouseMoveEvent( QMouseEvent * event ) { mousePressEvent( event ); } void MiniMap::slot_mapviewScrolled(double x_percent, double y_percent) { update( _viewportrect ); _viewportrect.moveTo( (int)(width() * x_percent), (int)(height() * y_percent) ); update( _viewportrect ); } void MiniMap::slot_mapviewResized( double width_percent, double height_percent ) { // TODO fix the rect overlapping for a slight performance gain int newheight, newwidth; if( width_percent >= 1.0 ) { newwidth = width(); } else { newwidth = (int)( width() * width_percent ); } if( height_percent >= 1.0 ) { newheight = height(); } else { newheight = (int)( height() * height_percent ); } if( newwidth != _viewportrect.width() || newheight != _viewportrect.height() ) { update( _viewportrect ); _viewportrect.setWidth( newwidth ); _viewportrect.setHeight( newheight ); update( _viewportrect ); } } void MiniMap::setMapSize( uint width, uint height ) { // In either case, I doubt the "std::max( 0..." is necessary because there aren't any negative numbers involved and it would never round to below zero, but it can't hurt. It's possible that uint<-->int casting could be causing problems? // This one does the calculation based on the GenericMap's aspect ratio. /*setFixedSize( std::max( 0, (int)std::min( (double)width / (double)height * (double)_defaultWidth, (double)_defaultWidth ) ), std::max( 0, (int)std::min( (double)height / (double)width * (double)_defaultHeight, (double)_defaultHeight ) ) );*/ // This one does it based on the GraphicalMap's aspect ratio, which can be set while the GenericMap is still empty. The MapView has a scrollable area before a map is even loaded... setFixedSize( std::max( 0, (int)std::min( (double)_map->width() / (double)_map->height() * (double)_defaultWidth, (double)_defaultWidth ) ), std::max( 0, (int)std::min( (double)_map->height() / (double)_map->width() * (double)_defaultHeight, (double)_defaultHeight ) ) ); } attal-src-1.0-rc2/libClient/miniMap.h0000644000175000017500000000436510642276760015146 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** miniMap.h ** draw and manage the mini-map ** ** Version : $Id: miniMap.h,v 1.17 2007/07/02 22:36:32 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo - Forest Darling ** ** Date : 05/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef MINIMAP_H #define MINIMAP_H // generic include files // include files for QT #include #include #include #include #include #include #include // application specific include files #include "libCommon/genericCell.h" #include "libClient/map.h" /* ------------------------------ * MiniMap * ------------------------------ */ class MiniMap : public QWidget { Q_OBJECT public: MiniMap( Map * map, QWidget * parent = NULL, const char * name = NULL ); ~MiniMap(); void redrawMap( Map * map ); public slots: void slot_mapviewScrolled( double x_percent, double y_percent ); void slot_mapviewResized( double x_percent, double y_percent ); void slot_redrawCell( int row, int col ); signals: void sig_mouseReleasedMinimap( double, double ); protected: void _repaintMapPoint( uint row, uint col ); void paintEvent( QPaintEvent * event ); void mousePressEvent( QMouseEvent * event ); void mouseMoveEvent( QMouseEvent * event ); void redrawCell( int row, int col ); static const int _defaultHeight; static const int _defaultWidth; private: void setMapSize( uint width, uint height ); uint _oldHeight; // HACK uint _oldWidth; // HACK Map * _map; QPixmap * _minimap; static QPen _pen; QPainter _mappainter; QRect _viewportrect; }; #endif // MINIMAP_H attal-src-1.0-rc2/libClient/optionsDialog.cpp0000644000175000017500000000753111016036224016701 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** optionsDialog.cpp ** ** Author(s) : Nickolay Semenov ** ** Date : 23/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "optionsDialog.h" // generic include files // include files for QT #include #include #include // application specific includes #include "libCommon/attalSettings.h" #include "libCommon/log.h" #include "libClient/askWidget.h" #include "libClient/attalButton.h" #include "libClient/gui.h" OptionsDialog::OptionsDialog ( QWidget* parent, const char * /* name */ ) : QDialog ( parent, Qt::Dialog | Qt::CustomizeWindowHint ) { _animationCheckBox = new QCheckBox ( tr( "Enable animation" ), this ); FIXEDSIZE( _animationCheckBox ); #ifdef WITH_SOUND _musicCheckBox = new QCheckBox ( tr( "Enable music" ), this ); FIXEDSIZE( _musicCheckBox ); _soundCheckBox = new QCheckBox ( tr( "Enable sound" ), this ); FIXEDSIZE( _musicCheckBox ); #endif _dispositionMode = new AskCombo( tr( "Disposition: " ), this ); _dispositionMode->insertItem( tr( "Extra compact" ) ); // DM_VERYCOMPACT _dispositionMode->insertItem( tr( "Compact" ) ); // DM_COMPACT _dispositionMode->insertItem( tr( "Normal" ) ); // DM_FULL FIXEDSIZE( _dispositionMode ); QVBoxLayout * vlayout = new QVBoxLayout(); vlayout->setMargin( 5 ); vlayout->setSpacing( 5 ); vlayout->addWidget( _animationCheckBox ); #ifdef WITH_SOUND vlayout->addWidget( _musicCheckBox ); vlayout->addWidget( _soundCheckBox ); #endif vlayout->addWidget( _dispositionMode ); AttalButton * pbOk = new AttalButton ( this, AttalButton::BT_OK ); AttalButton * pbCancel = new AttalButton ( this, AttalButton::BT_CANCEL ); QHBoxLayout * hlayout = new QHBoxLayout(); hlayout->setMargin( 5 ); hlayout->addStretch( 1 ); hlayout->addWidget( pbCancel ); hlayout->addStretch( 1 ); hlayout->addWidget( pbOk ); hlayout->addStretch( 1 ); QVBoxLayout * mainlayout = new QVBoxLayout( this ); mainlayout->addLayout( vlayout ); mainlayout->addLayout( hlayout ); mainlayout->activate(); connect( pbOk, SIGNAL( clicked () ), this, SLOT( accept () ) ); connect( pbCancel, SIGNAL( clicked () ), this, SLOT( reject () ) ); connect( _animationCheckBox, SIGNAL( stateChanged( int ) ), this, SIGNAL( sig_animation( int ) ) ); #ifdef WITH_SOUND connect( _musicCheckBox, SIGNAL( stateChanged( int ) ), this, SIGNAL( sig_music( int ) ) ); connect( _soundCheckBox, SIGNAL( stateChanged( int ) ), this, SIGNAL( sig_sound( int ) ) ); #endif FIXEDSIZE ( this ); init(); } void OptionsDialog::init() { _animationCheckBox->setChecked( AttalSettings::getInstance()->getStrategyModeSettings().isAnimationEnabled ); #ifdef WITH_SOUND _musicCheckBox->setChecked( AttalSettings::getInstance()->getStrategyModeSettings().isMusicOn ); _soundCheckBox->setChecked( AttalSettings::getInstance()->getStrategyModeSettings().isSoundOn ); #endif _dispositionMode->setCurrentItem( (int) AttalSettings::getInstance()->getDispositionMode() ); } void OptionsDialog::accept() { if( AttalSettings::getInstance()->getDispositionMode() != (AttalSettings::DispositionMode) _dispositionMode->currentItem() ) { AttalSettings::getInstance()->setDispositionMode( (AttalSettings::DispositionMode) _dispositionMode->currentItem() ); emit sig_dispositions(); } QDialog::accept (); } attal-src-1.0-rc2/libClient/optionsDialog.h0000644000175000017500000000276011016036224016345 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** optionsDialog.h ** Options Dialog in main window of client ** ** Author(s) : Nickolay Semenov ** ** Date : 23/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef OPTIONSDIALOG_H #define OPTIONSDIALOG_H // include files for QT #include class QCheckBox; class AskCombo; /* ------------------------------ * Options Dialog * ------------------------------ */ class OptionsDialog: public QDialog { Q_OBJECT public: OptionsDialog ( QWidget* parent = 0, const char * name = 0 ); public slots: void accept(); signals: void sig_music( int ); void sig_sound( int ); void sig_animation( int ); void sig_dispositions(); private: void init(); QCheckBox * _animationCheckBox; QCheckBox * _musicCheckBox, * _soundCheckBox; AskCombo * _dispositionMode; }; #endif // OPTIONSDIALOG_H attal-src-1.0-rc2/libClient/pixmapSpinBox.cpp0000644000175000017500000000422110510304466016664 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** pixmapSpinBox ** ** Version 0.1 ** ** Author(s) : Nick Semenov ** ** Date : 13/05/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "pixmapSpinBox.h" // include files for QT #include #include #include #include #include #include // application specific include files #include "libClient/gui.h" PixmapSpinBox::PixmapSpinBox( QWidget * parent ) : QFrame( parent ) { } void PixmapSpinBox::init( QPixmap * pixmap, const QString & text, bool isToolTip ) { QHBoxLayout* layout = new QHBoxLayout (this); layout->setMargin( 5 ); /** Layout for widgets */ _pixmap = new QLabel( this ); if( pixmap ) { _pixmap->setPixmap( *pixmap ); _pixmap->adjustSize(); layout->addWidget( _pixmap ); layout->addSpacing( 5 ); } else { delete _pixmap; } _value = new QSpinBox( this ); _value->setFixedWidth( 150 ); if (isToolTip) { _pixmap->setToolTip( text ); _value->setToolTip( text ); } else { _text = new QLabel( this ); _text->setText( text ); _text->setFixedWidth( 125 ); layout->addWidget( _text ); layout->addSpacing( 5 ); } layout->addWidget ( _value ); layout->addStretch( 1 ); layout->addSpacing( 5 ); layout->activate (); } void PixmapSpinBox::setRange( int minValue, int maxValue ) { _value->setRange( minValue, maxValue ); } void PixmapSpinBox::setValue( int newValue ) { _value->setValue( newValue ); } int PixmapSpinBox::getValue() { return _value->value(); } QSpinBox * PixmapSpinBox::getSpinBox() { return _value; } attal-src-1.0-rc2/libClient/pixmapSpinBox.h0000644000175000017500000000341110335210172016324 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** PixmapSpinBox - widget, similar to QSpinBox with Pixmap and tooltip ** Version : 0.1 ** ** Author(s) : Nick Semenov ** ** Date : 13/05/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PIXMAPSPINBOX_H #define PIXMAPSPINBOX_H // include files for QT #include #include #include /* ------------------------------ * PixmapSpinBox * ------------------------------ */ class QSpinBox; class QLabel; /** I like QFrame, almost all my widgets are Frames (setFrameStyle.. setLineWidth..)*/ class PixmapSpinBox : public QFrame { Q_OBJECT public: /** Constructor */ PixmapSpinBox( QWidget* parent = NULL ); void init( QPixmap* pixmap, const QString & text, bool isToolTip = true ); /** sets Range */ void setRange( int minValue, int maxValue ); /** sets current Value for SpinBox */ void setValue( int newValue ); /** returns current Value for SpinBox */ int getValue(); QSpinBox* getSpinBox (); private: QSpinBox* _value; QLabel* _pixmap; QLabel* _text; /** text can be used as a comment for value or as a tooltip */ }; #endif // PIXMAPSPINBOX_H attal-src-1.0-rc2/libClient/player.cpp0000644000175000017500000000600310771665466015402 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** player.cpp ** manage player ** ** Version : $Id: player.cpp,v 1.8 2008/03/24 08:49:58 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "player.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/log.h" #include "libClient/game.h" #include "libClient/graphicalPath.h" #include "libClient/imageTheme.h" #include "libClient/lord.h" /** add comments here */ Player::Player( Game * game, GenericMap * theMap ) : GenericPlayer( theMap ) { _game = game; } /*! */ GenericLord * Player::nextLord() { unSelectLord(); GenericLord * lord = GenericPlayer::nextLord(); selectLord( lord ); return _selectedLord; } void Player::setSelectedLord( GenericLord * lord ) { unSelectLord(); selectLord( lord ); } void Player::unSelectLord() { Map * gmap = dynamic_cast(_map); if( !gmap ) { return; } if( _selectedLord ){ GraphicalPath * gpath = gmap->getGraphicalPath(); gpath->clearPath(); ((Lord *)_selectedLord)->highlight( false ); } GenericPlayer::unSelectLord(); } void Player::selectLord( GenericLord * lord ) { Map * gmap = dynamic_cast(_map); if( !gmap ) { return; } if( lord ) { GraphicalPath * gpath = gmap->getGraphicalPath(); gpath->computePath( lord->getCell(), lord->getDestination(), lord->getCharac( MOVE ), lord->getCharac( MAXMOVE )); ((Lord *)lord)->highlight( true ); GenericPlayer::setSelectedLord( lord ); _game->setState( Game::MS_LORD ); } } void Player::setSelectedBase( GenericBase * base ) { GenericPlayer::setSelectedBase( base ); _game->setState( Game::MS_BASE ); } QPixmap * Player::getLordPixmapByNum( int num ) { return ImageTheme.getLordPixmap( getLord( num )->getId() ); } QPixmap * Player::getLordPixmapById( int id ) { return ImageTheme.getLordPixmap( id ); } QPixmap * Player::getSelectedLordPixmap() { if( _selectedLord == 0 ) { logEE( "No selected Lord !"); return 0; } else { return ImageTheme.getLordPixmap( _selectedLord->getId() ); } } QPixmap * Player::getLordSmallPixmapByNum( int num ) { return ImageTheme.getLordSmallPixmap( getLord( num )->getId() ); } QPixmap * Player::getLordSmallPixmapById( int id ) { return ImageTheme.getLordSmallPixmap( id ); } QPixmap * Player::getBaseSmallPixmap( int num ) { return ImageTheme.getBaseSmallPixmap( num ); } attal-src-1.0-rc2/libClient/player.h0000644000175000017500000000442710771665466015057 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** player.h ** manage player ** ** Version : $Id: player.h,v 1.6 2008/03/24 08:49:58 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PLAYER_H #define PLAYER_H // generic include files // include files for QT #include // application specific include files #include "libCommon/genericPlayer.h" #include "libCommon/genericLord.h" #include "libCommon/genericMap.h" class Game; class QPixmap; /* ------------------------------ * Player * ------------------------------ */ /** comment for the class */ class Player : public GenericPlayer { public: /** Constructor */ Player( Game * game, GenericMap * theMap = 0 ); /** Select a lord */ virtual void setSelectedLord( GenericLord * lord ); /** Select a base */ virtual void setSelectedBase( GenericBase * base ); /** Unselect the lord (if any) */ virtual void unSelectLord(); /** Cycle to the next lord of the player */ virtual GenericLord * nextLord(); /** Return pixmap of the num-th lord */ QPixmap * getLordPixmapByNum( int num ); /** Return pixmap of the lord 'id' */ QPixmap * getLordPixmapById( int id ); /** Return the pixmap of the selected lord */ QPixmap * getSelectedLordPixmap(); /** Return small pixmap of the num-th lord */ QPixmap * getLordSmallPixmapByNum( int num ); /** Return small pixmap of the lord 'id' */ QPixmap * getLordSmallPixmapById( int id ); /** Return small pixmap of the num-th base */ QPixmap * getBaseSmallPixmap( int num ); private: void selectLord( GenericLord * lord ); Game * _game; }; #endif // PLAYER_H attal-src-1.0-rc2/libClient/ressourceBar.cpp0000644000175000017500000000473710776155634016555 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** ressourceBar.cpp ** show ressources of the player (gold, ...) ** ** Version : $Id: ressourceBar.cpp,v 1.15 2008/04/06 14:18:04 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/09/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "ressourceBar.h" // generic include files // include files for QT #include #include #include // application specific includes #include "libCommon/dataTheme.h" #include "libClient/imageTheme.h" #include "libClient/gui.h" RessourceBar::RessourceBar( QWidget * parent, const char * /* name */) :QWidget( parent ) { _player = 0; QHBoxLayout * lay = new QHBoxLayout( this ); lay->addStretch( 1 ); //_labPopul = new QLabel( this ); //_totPopul = new QLabel( this ); //lay->addWidget( _labPopul ); //lay->addWidget( _totPopul ); for( int i = 0; i < DataTheme.resources.count(); i++ ) { _labRessource[i] = new QLabel( this ); lay->addWidget( _labRessource[i] ); lay->addStretch( 1 ); } lay->activate(); } void RessourceBar::setPlayer( GenericPlayer * p ) { _player = p; reinit(); } void RessourceBar::reinit() { if( _player != 0 ) { QString s; //QPixmap pix = ImageTheme.getPopulationIcon()->copy(ImageTheme.getPopulationIcon()->rect()); //_labPopul->setPixmap( pix ); //_labPopul->setToolTip( "Population" ); //s.sprintf( " %d ", _player->getPopulation() ); //_totPopul->setText( s ); //FIXEDSIZE( _totPopul ); int count = DataTheme.resources.count(); GenericResourceList * rlist = _player->getResourceList(); for( int i = 0; i < count ; i++ ) { int value = rlist->getValue( i ); s.sprintf( "%s : %d", qPrintable ( DataTheme.resources.getRessource( i ) ), value ); _labRessource[i]->setText( s ); if( value > 0 ) { _labRessource[i]->show(); } else { _labRessource[i]->hide(); } FIXEDSIZE( _labRessource[i] ); } } } attal-src-1.0-rc2/libClient/ressourceBar.h0000644000175000017500000000315010703765273016202 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** ressourceBar.h ** show ressources of the player (gold, ...) ** ** Version : $Id: ressourceBar.h,v 1.4 2007/10/12 21:44:27 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/09/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef RESSOURCEBAR_H #define RESSOURCEBAR_H // generic include files // include files for QT #include #include // application specific includes #include "libCommon/genericPlayer.h" /* ------------------------------ * RessourceBar * ------------------------------ */ /** comment for the class */ class RessourceBar : public QWidget { public: /** Construtcor */ RessourceBar( QWidget * parent = 0, const char * name = 0 ); /** Initialize player */ void setPlayer( GenericPlayer * ); /** Reinit info displayed */ void reinit(); private: GenericPlayer * _player; QLabel * _labRessource[MAX_RESS], * _totPopul; QLabel * _labPopul; }; #endif // RESSOURCEBAR_H attal-src-1.0-rc2/libClient/ressourceWin.cpp0000644000175000017500000001063711007640016016557 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** ressourceWin.cpp ** show ressources of the player (gold, ...) ** ** Version : $Id: ressourceWin.cpp,v 1.20 2008/05/05 17:12:46 lusum Exp $ ** ** Author(s) : Pascal Audoux - Carlo Sardi ** ** Date : 06/09/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "ressourceWin.h" // generic include files // include files for QT #include #include #include #include // application specific includes #include "libCommon/dataTheme.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" /** add comments here */ TabRessourceWin::TabRessourceWin( QWidget * parent, WinResType type, GenericPlayer * player, GenericResourceList * list) { _ressW = new RessourceWin( this, type, player, list ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( _ressW ); layout->addStretch( 2 ); } void TabRessourceWin::reinit() { _ressW->reinit(); } RessourceWin::RessourceWin( QWidget * parent, WinResType type, GenericPlayer * player, GenericResourceList * list) :QWidget( parent ) { TRACE("RessourceWin QWidget * parent %p, Player * player %p, GenericResourceList * list %p )", parent, player, list ); _player = player; _list = list; int k = 1; QGridLayout * lay = new QGridLayout( this ); lay->setRowStretch(0,1); lay->setColumnStretch( 0, 0 ); lay->setColumnStretch( 1, 1 ); for( int i = 0; i < DataTheme.resources.count(); i++ ) { _labIcon[i] = new QLabel( this ); _labRessource[i] = new QLabel( this ); if(type == RS_GRID) { if((i%2) == 0){ k=i/2+1; lay->addWidget( _labIcon[i] , k, 0); lay->addWidget( _labRessource[i] , k, 1); } else { lay->addWidget( _labIcon[i] , k, 2); lay->addWidget( _labRessource[i] , k, 3); } } else if (type == RS_VERT) { lay->addWidget( _labIcon[i] , i, 0, Qt::AlignLeft); lay->addWidget( _labRessource[i] , i, 1, Qt::AlignLeft); k = i; } } if( _list ) { int m = 1; for( int i = 0; i < DataTheme.resources.count(); i++ ) { _labIconl[i] = new QLabel( this ); _labRessourcel[i] = new QLabel( this ); if(type == RS_GRID) { if((i%2) == 0){ m=i/2+1 + k; lay->addWidget( _labIconl[i] , m, 0); lay->addWidget( _labRessourcel[i] , m, 1); } else { lay->addWidget( _labIconl[i] , m, 2); lay->addWidget( _labRessourcel[i] , m, 3); } } else { m = i + k; lay->addWidget( _labIconl[i] , m , 0, Qt::AlignLeft); lay->addWidget( _labRessourcel[i] , m, 1, Qt::AlignLeft); } } } if (type == RS_VERT) { setMaximumWidth( 100 ); } reinit(); lay->activate(); } void RessourceWin::reinit() { TRACE("void RessourceWin::reinit"); if( _player != 0 ) { QString s; int value; for( int i = 0; i < DataTheme.resources.count(); i++ ) { //s.sprintf( "%s : %d", DataTheme.resources.getRessource( i ).toLatin1(), _player->getResource( i ) ); value = _player->getResourceList()->getValue( i ); s.sprintf( " %d", value ); QPixmap pix = ImageTheme.getResourceSmallIcon( i )->copy(ImageTheme.getResourceSmallIcon( i )->rect()); _labIcon[i]->setPixmap( pix ); _labIcon[i]->setToolTip( DataTheme.resources.getRessource( i ).toLatin1() ); _labRessource[i]->setText( s ); bool global = DataTheme.resources.get( i )->isGlobal(); _labIcon[i]->setVisible( global ); _labRessource[i]->setVisible( global ); FIXEDSIZE( _labRessource[i] ); if( _list ) { value = _list->getValue( i ); s.sprintf( " %d", value ); QPixmap pix = ImageTheme.getResourceSmallIcon( i )->copy(ImageTheme.getResourceSmallIcon( i )->rect()); _labIconl[i]->setPixmap( pix ); _labIconl[i]->setToolTip( DataTheme.resources.getRessource( i ).toLatin1() ); _labRessourcel[i]->setText( s ); _labIconl[i]->setVisible( !global ); _labRessourcel[i]->setVisible( !global ); FIXEDSIZE( _labRessourcel[i] ); } } } } attal-src-1.0-rc2/libClient/ressourceWin.h0000644000175000017500000000443310747466730016244 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** ressourceWin.h ** show ressources of the player (gold, ...) ** ** Version : $Id: ressourceWin.h,v 1.7 2008/01/29 00:05:44 lusum Exp $ ** ** Author(s) : Pascal Audoux - Carlo Sardi ** ** Date : 06/09/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef RESSOURCEWIN_H #define RESSOURCEWIN_H // generic include files // include files for QT #include #include #include // application specific includes #include "libCommon/genericPlayer.h" enum WinResType { RS_GRID, RS_VERT }; class RessourceWin; /* ------------------------------ * TabRessourceWin * ------------------------------ */ /** comment for the class */ class TabRessourceWin : public QWidget { public: /** Construtcor */ TabRessourceWin( QWidget * parent = 0, WinResType type = RS_GRID, GenericPlayer * player = NULL, GenericResourceList * list = NULL ); /** Reinit info displayed */ void reinit(); private: RessourceWin * _ressW; }; /* ------------------------------ * RessourceWin * ------------------------------ */ /** comment for the class */ class RessourceWin : public QWidget { public: /** Construtcor */ RessourceWin( QWidget * parent = 0, WinResType type = RS_GRID, GenericPlayer * player = NULL, GenericResourceList * list = NULL ); /** Reinit info displayed */ void reinit(); private: GenericPlayer * _player; QLabel * _labRessource[MAX_RESS]; QLabel * _labIcon[MAX_RESS]; QLabel * _labRessourcel[MAX_RESS]; QLabel * _labIconl[MAX_RESS]; GenericResourceList * _list; //QHBoxLayout * _layh[MAX_RESS/2]; }; #endif // RESSOURCEWIN_H attal-src-1.0-rc2/libClient/tavern.cpp0000644000175000017500000001373111016036224015364 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** tavern.cpp ** Manage tavern building ** ** Version : $Id: tavern.cpp,v 1.15 2008/05/24 16:04:36 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 04/02/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "tavern.h" // generic include files // include files for QT #include #include #include #include #include #include #include // application specific include files #include "libCommon/attalSocket.h" #include "libCommon/dataTheme.h" #include "libCommon/genericLord.h" #include "libCommon/genericPlayer.h" #include "libCommon/log.h" #include "libClient/attalButton.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/widget.h" // // ----- Tavern ----- // Tavern::Tavern( QWidget * parent ) : QDialog( parent, Qt::Dialog ) { _player = 0; _base = 0; _signalMapper = 0; QLabel * labIntro = new QLabel( this ); labIntro->setWordWrap( true ); labIntro->setText( tr("Some lords are visiting your base and are available in your tavern. Here is the list:") ); AttalButton * pbOk = new AttalButton( this, AttalButton::BT_OK ); QHBoxLayout * layHOk = new QHBoxLayout(); layHOk->addStretch( 1 ); layHOk->addWidget( pbOk ); layHOk->addStretch( 1 ); _scroll = new QScrollArea( this ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addWidget( labIntro ); layout->addWidget( _scroll, 1 ); layout->addLayout( layHOk ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); resize( 400, 300 ); } Tavern::~Tavern() { while( ! _lords.isEmpty() ) { delete _lords.takeFirst(); } } void Tavern::initSocket( AttalSocket * socket ) { _socket = socket; } void Tavern::initPlayer( GenericPlayer * player ) { _player = player; } void Tavern::handleSocket() { if( ( _socket->getCla1() == SO_GAME ) and ( _socket->getCla2() == C_GAME_TAVERN ) ) { switch( _socket->getCla3() ) { case C_TAVERN_INFO: handleTavernInfo(); break; case C_TAVERN_LORD: handleTavernLord(); break; default: logEE( "Should not happen" ); } } } void Tavern::handleTavernInfo() { _nbLord = _socket->readChar(); _nbLordRead = 0; while( ! _lords.isEmpty() ) { delete _lords.takeFirst(); } if( _signalMapper ) { delete _signalMapper; } _signalMapper = new QSignalMapper( this ); connect( _signalMapper, SIGNAL( mapped( int ) ), SLOT( slot_buy( int ) ) ); if( _nbLordRead >= _nbLord ) { QDialog::exec(); } else { _socket->askTavernLord( _base, _nbLordRead ); } } void Tavern::handleTavernLord() { _nbLordRead++; /// XXX: reads lord info and displays it uint idLord = _socket->readInt(); GenericLord * lord = new GenericLord(); lord->setId( idLord ); TavernLord * widget = new TavernLord( _scroll->viewport() ); widget->initPlayer( _player ) ; widget->init( lord ); _signalMapper->setMapping( widget, _lords.count() ); _lords.append( widget ); _scroll->setWidget( widget ); widget->resize( 400, 70); connect( widget, SIGNAL( sig_buy() ), _signalMapper, SLOT( map() ) ); if( _nbLordRead >= _nbLord ) { QDialog::exec(); } } void Tavern::start( GenericBase * base ) { _base = base; /// XXX: test if we need ask server info... _socket->askTavernInfo( base ); } void Tavern::restart() { _socket->askTavernInfo( _base ); } void Tavern::slot_buy( int numLord ) { if(_player && _socket && _lords.value( numLord ) && _base) { /// XXX: not finished if(_player->canBuy(DataTheme.lords.at(numLord)) && !_base->isVisitorLord()) { int col = _base->getCell()->getCol(); int row = _base->getCell()->getRow(); //logDD(" row %d ,col %d", row, col); _socket->sendLordBuy( _lords.at(numLord)->getLord() , row, col); TRACE( "buy %d", numLord ); } } } // // ----- TavernLord ----- // TavernLord::TavernLord( QWidget * parent ) : QWidget( parent ) { _player = 0; _lord = 0; _photo = new Icon( this ); _info = new QLabel( this ); _price = new QLabel( this ); QVBoxLayout * layV1 = new QVBoxLayout(); layV1->setMargin( 5 ); layV1->setSpacing( 5 ); layV1->addWidget( _info ); layV1->addWidget( _price ); layV1->addStretch( 1 ); _pbBuy = new QPushButton( this ); _pbBuy->setText( tr( "Buy" ) ); FIXEDSIZE( _pbBuy ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addWidget( _photo ); layout->addLayout( layV1,1 ); layout->addWidget( _pbBuy ); layout->activate(); connect( _pbBuy, SIGNAL( clicked() ), this, SIGNAL( sig_buy() ) ); } TavernLord::~TavernLord() { if(_lord){ delete _lord; _lord = NULL; } } void TavernLord::initPlayer( GenericPlayer * player ) { _player = player; } void TavernLord::init( GenericLord * lord ) { _pbBuy->setEnabled( false ); QString temp; if(_lord){ delete _lord; _lord = NULL; } _lord = lord; if( ImageTheme.getLordPixmap( lord->getId() ) ) { _photo->setPixmap( * ImageTheme.getLordPixmap( lord->getId() ) ); } temp.sprintf( "Lord %s (%s)", lord->getName().toLatin1().constData(), lord->getCategoryName().toLatin1().constData() ); _info->setText( temp ); FIXEDSIZE( _info ); GenericLordModel * lordModel = DataTheme.lords.at(_lord->getId()); if(_player) { if(_player->canBuy(lordModel)) { _pbBuy->setEnabled( true ); } } _price->setText( lordModel->getLordDescription() ); FIXEDSIZE( _price ); } attal-src-1.0-rc2/libClient/tavern.h0000644000175000017500000000443210627372533015044 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** tavern.h ** Manage tavern building ** ** Version : $Id: tavern.h,v 1.8 2007/05/30 22:06:19 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 04/02/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef TAVERN_H #define TAVERN_H // generic include files // include files for QT #include #include // application specific include files class QLabel; class QScrollArea; class QSignalMapper; class AttalSocket; class GenericBase; class GenericLord; class GenericPlayer; class Icon; class TavernLord; /* ------------------------------ * Tavern * ------------------------------ */ class Tavern : public QDialog { Q_OBJECT public: /** Constructor */ Tavern( QWidget * parent = 0 ); ~Tavern(); void start( GenericBase * base ); void restart(); void initSocket( AttalSocket * socket ); void initPlayer( GenericPlayer * player ); void handleSocket(); public slots: void slot_buy( int numLord ); protected: void handleTavernInfo(); void handleTavernLord(); AttalSocket * _socket; QScrollArea * _scroll; uchar _nbLord, _nbLordRead; GenericBase * _base; GenericPlayer * _player; QList _lords; QSignalMapper * _signalMapper; }; class TavernLord : public QWidget { Q_OBJECT public: TavernLord( QWidget * parent ); ~TavernLord(); void init( GenericLord * lord ); GenericLord * getLord() { return _lord; } void initPlayer( GenericPlayer * player ); signals: void sig_buy(); protected: Icon * _photo; QLabel * _info, * _price; GenericLord * _lord; GenericPlayer * _player; QPushButton * _pbBuy; }; #endif // TAVERN_H attal-src-1.0-rc2/libClient/unitExchange.cpp0000644000175000017500000000716510777503654016536 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** unitExchange.cpp ** dialog for creature exchange between units ** ** Version : $Id: unitExchange.cpp,v 1.9 2008/04/10 21:33:32 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 04/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "unitExchange.h" // generic include files // include files for QT #include #include #include #include #include #include // application specific include files #include "libCommon/unit.h" #include "libClient/attalButton.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/widget.h" /*! Constructs an empty */ UnitExchange::UnitExchange( QWidget * parent, const char * /* name */) : QDialog( parent, Qt::Dialog ) { QVBoxLayout * layout = new QVBoxLayout( this ); layout->addStretch( 1 ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); _icoLeft = new Icon( this ); layH1->addWidget( _icoLeft ); layH1->addStretch( 2 ); _icoRight = new Icon( this ); layH1->addWidget( _icoRight ); layH1->addStretch( 1 ); layout->addLayout( layH1 ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addStretch( 1 ); _leftLCD = new QLCDNumber( this ); layH2->addWidget( _leftLCD ); layH2->addStretch( 2 ); _rightLCD = new QLCDNumber( this ); layH2->addWidget( _rightLCD ); layH2->addStretch( 1 ); layout->addLayout( layH2 ); QHBoxLayout * layH3 = new QHBoxLayout(); layH3->addStretch( 1 ); _scroll = new QScrollBar( Qt::Horizontal, this ); layH3->addWidget( _scroll, 2 ); layH3->addStretch( 1 ); layout->addLayout( layH3 ); layout->addSpacing( 5 ); layout->addStretch( 1 ); QHBoxLayout * layH4 = new QHBoxLayout(); layH4->addStretch( 1 ); AttalButton * pbCancel = new AttalButton( this, AttalButton::BT_CANCEL ); layH4->addWidget( pbCancel ); layH4->addStretch( 1 ); AttalButton * pbOk = new AttalButton( this, AttalButton::BT_OK ); layH4->addWidget( pbOk ); layH4->addStretch( 1 ); layout->addLayout( layH4 ); layout->addSpacing( 5 ); layout->activate(); connect( _scroll, SIGNAL( valueChanged( int ) ), SLOT( slot_barScrolled( int ) ) ); connect( pbOk, SIGNAL( clicked() ), SLOT( slot_ok() ) ); connect( pbCancel, SIGNAL( clicked() ), SLOT( slot_cancel() ) ); setFixedSize( 190, 220 ); } void UnitExchange::setMin( int val ) { _scroll->setMinimum( val ); } void UnitExchange::setMax( int val ) { _scroll->setMaximum( val ); } void UnitExchange::setUnits( GenericFightUnit * uniLeft, GenericFightUnit * uniRight ) { if( uniLeft == 0 ) { return; } int valLeft, valRight; if( uniRight == 0 ) { valRight = 0; } else { valRight = uniRight->getNumber(); } valLeft = uniLeft->getNumber(); _sum = valLeft + valRight; _scroll->setValue( valRight ); slot_barScrolled( valRight ); _icoRight->setPixmap( ImageTheme.getPhotoCreature( uniLeft ) ); _icoLeft->setPixmap( ImageTheme.getPhotoCreature( uniLeft ) ); } void UnitExchange::slot_barScrolled( int val ) { _rightLCD->display( val ); _leftLCD->display( _sum - val ); } attal-src-1.0-rc2/libClient/unitExchange.h0000644000175000017500000000432710331243510016152 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** unitExchange.h ** dialog for creature exchange between units ** ** Version : $Id: unitExchange.h,v 1.2 2005/10/30 22:20:56 audoux Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 04/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef UNITEXCHANGE_H #define UNITEXCHANGE_H // generic include files // include files for QT #include #include // application specific include files class QScrollBar; class Icon; class GenericFightUnit; /* ------------------------------ * UnitExchange * ------------------------------ */ /** comment for the class */ class UnitExchange : public QDialog { Q_OBJECT public: /** Constructor */ UnitExchange( QWidget * parent = 0, const char * name = 0 ); /** Set the min value */ void setMin( int val ); /** Set the max value */ void setMax( int val ); /** Set the nb of unith at left and at right */ void setUnits( GenericFightUnit * uniLeft, GenericFightUnit * uniRight ); /** Return the value on the rigth side */ int getRightValue() { return _rightLCD->intValue(); } /** Return the value on the left side */ int getLeftValue() { return _leftLCD->intValue(); } public slots: /** Slot when 'Ok' button is clicked */ void slot_ok() { accept(); } /** Slot when 'Cancel' button is clicked */ void slot_cancel() { reject(); } /** Slot when the ScrollBar is moved */ void slot_barScrolled( int val ); private: QScrollBar * _scroll; QLCDNumber * _leftLCD, * _rightLCD; Icon * _icoLeft, * _icoRight; int _sum; }; #endif // UNITEXCHANGE_H attal-src-1.0-rc2/libClient/widget.cpp0000644000175000017500000002240710777472217015373 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** widget.cpp ** a set of widget used in Attal ** ** Version : $Id: widget.cpp,v 1.22 2008/04/10 20:11:59 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 09/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "widget.h" // generic include files // include files for QT #include #include #include #include #include #include // application specific include file #include "libCommon/dataTheme.h" #include "libCommon/genericBase.h" #include "libCommon/genericBonus.h" #include "libCommon/genericBuilding.h" #include "libCommon/genericEvent.h" #include "libCommon/genericLord.h" #include "libCommon/genericMapCreature.h" #include "libCommon/log.h" #include "libCommon/skill.h" #include "libCommon/unit.h" #include "libClient/attalButton.h" #include "libClient/imageTheme.h" #include "libClient/gui.h" PopupMessage::PopupMessage( QWidget * parent, const char * /* name */ ) :QLabel( parent, Qt::Popup ) { setFrameStyle( QFrame::Box | QFrame::Raised ); setLineWidth( 2 ); setMidLineWidth( 0 ); setAttribute( Qt::WA_NoMouseReplay ); setMouseTracking(true); } void PopupMessage::mouseReleaseEvent( QMouseEvent * event ) { if( event->button() == Qt::RightButton ) { hide(); } } // // ----- Label ----- // Label::Label( QWidget *parent, const char * /* name */) : QLabel( parent ) { setFrameStyle( QFrame::Panel | QFrame::Raised ); setLineWidth( 1 ); setMidLineWidth( 1 ); _popup = 0; _popupText = ""; } void Label::showPopup( QPoint p ) { if( _popupText != "" ) { if( ! _popup ) { _popup = new PopupMessage( this ); } _popup->setText( _popupText ); _popup->move( p ); _popup->show(); } } void Label::mousePressEvent( QMouseEvent *e ) { if( e->button() == Qt::RightButton ) { showPopup( e->globalPos() ); } else { emit sig_clicked(); } } void Label::mouseReleaseEvent( QMouseEvent * event ) { if( event->button() == Qt::RightButton ) { if( _popup ) { _popup->hide(); } } } void Label::clear() { _popupText = ""; QLabel::clear(); } // // ----- Icon ----- // Icon::Icon( QWidget * parent, const char * /* name */) : Label( parent ) { setFixedSize( 60, 60 ); } // // ----- IconArtefact ----- // IconArtefact::IconArtefact( QWidget * parent, const char *name ) : Icon( parent, name ) { _type = -1; } void IconArtefact::setType( int type ) { _type = type; setPixmap( * ImageTheme.getArtefactIcon( _type ) ); } void IconArtefact::clear() { setPixmap( QPixmap() ); _type = -1; } void IconArtefact::showPopup( QPoint p ) { if( _type != -1 ) { if( ! _popup ) { _popup = new PopupMessage( this ); } _popup->setText( DataTheme.artefacts.at( _type )->getName() ); _popup->move( p ); _popup->show(); } } // // ----- InfoLabel ----- // InfoLabel::InfoLabel( QWidget *parent, const char * /*name */) : QFrame( parent ) { setFrameStyle( QFrame::Panel | QFrame::Sunken ); setLineWidth( 1 ); setMidLineWidth( 1 ); _icon = new Icon( this ); _label = new Label( this ); _label->move( 60, 0 ); _label->setFixedSize( 90, 60 ); setFixedSize( 150 , 60 ); } void InfoLabel::setText( QString text ) { _label->setText( text ); } // // ----- InfoLabelSkill ----- // InfoLabelSkill::InfoLabelSkill( QWidget * parent, const char * name ) : InfoLabel( parent, name ) { } void InfoLabelSkill::setSkill( SkillModel::SkillType type, int level ) { /// XXX: use _icon instead of _pixmap ?? switch( type ) { case SKI_ATTACK: _pixmap = ImageTheme.skills->at( 0 ); break; case SKI_DEFENSE: _pixmap = ImageTheme.skills->at( 1 ); break; default: _pixmap = NULL; break; } QString s; switch( level ) { case 0: s = "Basic" ; break; case 1: s = "Advanced"; break; case 2: s = "Expert" ; break; } _label = s ; update(); } void InfoLabelSkill::drawContents( QPainter *p ) { QRect rect = p->boundingRect ( 0,0, 50,10, Qt::AlignHCenter, _label ); p->drawText( rect.x(),rect.height(), _label); p->drawPixmap( 0,rect.height(), _pixmap ); } // // ----- Sentence ----- // Sentence::Sentence( QWidget * parent, const char * /* name*/ ) : QLabel( parent ) { setFrameStyle( QFrame::Box | QFrame::Raised ); setLineWidth( 1 ); setMidLineWidth( 1 ); setAlignment( Qt::AlignCenter ); setFixedHeight( 25 ); } // // ----- ResourceIcon ----- // ResourceIcon::ResourceIcon( QWidget * parent, const char * /* name*/ ) : QWidget( parent ) { _icon = new Icon( this ); _value = new QLabel( this ); _value->setFixedSize( 50, 25 ); _value->move( 0, 50 ); connect( _icon, SIGNAL( sig_clicked() ), SIGNAL( sig_clicked() ) ); setFixedSize( 50, 75 ); } void ResourceIcon::setResource( int num ) { _icon->setPixmap( * ( ImageTheme.getResourceIcon( num ) ) ); } void ResourceIcon::clear() { _icon->clear(); _value->clear(); } // // ----- ResourceLabel ----- // ResourceLabel::ResourceLabel( QWidget * parent, const char * /* name */ ) : QWidget( parent ) { _icon = new QLabel( this ); _label = new QLabel( this ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->addWidget( _icon ); layout->addSpacing( 5 ); layout->addWidget( _label, 1, Qt::AlignRight ); layout->activate(); } void ResourceLabel::setResource( int num ) { QPixmap pix = ImageTheme.getResourceSmallIcon( num )->copy(ImageTheme.getResourceSmallIcon( num )->rect()); _icon->setPixmap( pix ); } void ResourceLabel::setNumber( int nb ) { _label->setText( QString::number( nb ) ); } // // ----- PopupUnit ----- // AttalPopup::AttalPopup( QWidget * parent ) : QFrame( parent ) { _unit = NULL; _lord = NULL; _type = PT_NONE; _labParams = new QLabel( "?", this ); _labParams->setFrameStyle( QFrame::Box | QFrame::Raised ); _labParams->setAutoFillBackground ( true ); _labParams->setLineWidth (2); } void AttalPopup::update() { QString params = "?"; switch( _type ) { case PT_NONE: break; case PT_LORD: { if( _lord ) { params = _lord->getLordDescription(); } } break; case PT_BUILD: { if( _build ) { params = _build->getBuildDescription(); } } break; case PT_BASE: { if( _base ) { params = _base->getBaseDescription(); } } break; case PT_FIGHTUNIT: { if( _unit ) { params = _unit->getUnitDescription(); } } break; case PT_EVENT: { if( _event ) { switch( _event->getType() ) { case GenericEvent::EventArtefact: { GenericArtefact * artefact = _event->getArtefact(); uint type = artefact->getType(); params = DataTheme.artefacts.at( type )->getName(); } break; case GenericEvent::EventBonus: { GenericBonus * bonus = _event->getBonus(); params = bonus->getBonusDescription(); } break; case GenericEvent::EventChest: params = "Chest"; break; default: break; } } } break; case PT_CREA: if( _crea ) { params = tr("About ") + QString::number(DataTheme.getRandomInCategory( _crea->getCategoryNumber())) + " " + _crea->getCreature()->getName(); } break; default: break; } _labParams->setText( params ); _labParams->adjustSize(); adjustSize (); QFrame::update(); } void AttalPopup::setType( PopupType type ) { _type = type; update(); } void AttalPopup::setUnit( GenericFightUnit * unit ) { _unit = unit; setType( PT_FIGHTUNIT ); update(); } void AttalPopup::setLord( GenericLord * lord ) { _lord = lord; setType( PT_LORD ); update(); } void AttalPopup::setBuilding( GenericBuilding * build ) { _build = build; setType( PT_BUILD ); update(); } void AttalPopup::setBase( GenericBase * base ) { _base = base; setType( PT_BASE ); update(); } void AttalPopup::setCreature( GenericMapCreature * crea ) { _crea = crea; setType( PT_CREA ); update(); } void AttalPopup::setEvent( GenericEvent * event ) { _event = event; setType( PT_EVENT ); update(); } // // ----- AttalMessage ----- // AttalMessage::AttalMessage( QWidget * parent, bool ok ) :QDialog( parent, Qt::Dialog ) { _ok = ok; _layout = new QVBoxLayout( this ); _layout->addStretch( 1 ); if( _ok ) { AttalButton * butOk = new AttalButton( this, AttalButton::BT_OK ); _layout->addWidget( butOk ); connect( butOk, SIGNAL( clicked() ), SLOT( accept() ) ); } _layout->activate(); } void AttalMessage::addText( QString text ) { QLabel * label = new QLabel( this ); label->setText( text ); FIXEDSIZE( label ); _layout->insertWidget( _layout->count()-2 , label ); _layout->insertStretch( _layout->count()-1, 1 ); } void AttalMessage::addPixmap( QPixmap * pixmap ) { QLabel * label = new QLabel( this ); label->setPixmap( * pixmap ); FIXEDSIZE( label ); _layout->insertWidget( _layout->count()-1 , label ); _layout->insertStretch( _layout->count()-1, 1 ); } attal-src-1.0-rc2/libClient/widget.h0000644000175000017500000001565310704762603015034 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** widget.h ** a set of widget used in Attal ** ** Version : $Id: widget.h,v 1.11 2007/10/15 22:11:15 lusum Exp $ ** ** Author(s) : Cyrille Verrier - Sardi Carlo ** ** Date : 29/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef WIDGET_H #define WIDGET_H // generic include files // include files for QT #include #include #include #include #include #include // application specific includes #include "libCommon/skill.h" class AttalButton; class GenericFightUnit; class GenericLord; class GenericBase; class GenericBuilding; class GenericEvent; class GenericMapCreature; class QVBoxLayout; /** ------------------------------ * PopupMessage ** ------------------------------ */ class PopupMessage : public QLabel { public: /** constructor */ PopupMessage( QWidget * parent = 0, const char * name = 0 ); protected: void mouseReleaseEvent( QMouseEvent * event ); }; /* ------------------------------ * Label * ------------------------------ */ /** * A Label * display a popup when right button is pressed * * this is an abstract class !! * */ class Label : public QLabel { Q_OBJECT public: /** Constructor */ Label( QWidget * parent = 0, const char * name = 0 ); /** sets the text of the popup */ void setPopupText( QString text ) { _popupText = text; } /** Clears the label */ virtual void clear(); signals: /** Signal when Label is clicked */ void sig_clicked(); protected: /** Subclass must implement this function */ virtual void showPopup( QPoint p ); /** Right button event for popup menus */ virtual void mousePressEvent( QMouseEvent *e ); virtual void mouseReleaseEvent( QMouseEvent * event ); PopupMessage * _popup; QString _popupText; }; /* ------------------------------ * Icon * ------------------------------ */ /** * An Icon is a Label but * it has a fixed size * used to display a pixmap * */ class Icon : public Label { public: /** Construct an Icon */ Icon( QWidget * parent = 0, const char * name = 0 ); }; /** ------------------------------ * IconArtefact ** ------------------------------ */ class IconArtefact : public Icon { public: /* Constructor */ IconArtefact( QWidget * parent = 0, const char * name = 0 ); /** Sets type of icon */ void setType( int type ); /** Clears the icon */ void clear(); protected: virtual void showPopup( QPoint p ); //virtual void mouseReleaseEvent( QMouseEvent * event ); private: int _type; }; /* ------------------------------ * InfoLabel * ------------------------------ */ /** * InfoLabel display informations * contains an Icon and a Label * must be reimplmented * */ class InfoLabel : public QFrame { public: /** Constructor */ InfoLabel( QWidget * parent, const char * name = 0 ); /** Set text to this InfoLabel */ void setText( QString text ); protected: Icon * _icon ; Label * _label ; }; /* ------------------------------ * InfoLabelSkill * ------------------------------ */ /** * InfoLabelSkill display informations about skills * */ class InfoLabelSkill : public InfoLabel { public: /** Constructor */ InfoLabelSkill( QWidget * parent, const char * name = 0 ); /** Set skill type and level to this Label */ void setSkill( SkillModel::SkillType type, int level ); protected: void drawContents( QPainter * ) ; private: QPixmap _pixmap; QString _label; }; /** ------------------------------ * Sentence ** ------------------------------ */ class Sentence : public QLabel { public: /** Constructor */ Sentence( QWidget * parent = 0, const char * name = 0 ); }; /** ------------------------------ * ResourceIcon ** ------------------------------ */ class ResourceIcon : public QWidget { Q_OBJECT public: /** Constructor */ ResourceIcon( QWidget * parent = 0, const char * name = 0 ); /** Set num of the ressource for this Icon */ void setResource( int num ); /** Set value to the Icon */ void setValue( QString text ) { _value->setText( text ); } /** Clear datas */ void clear(); signals: /** Signal when clicked */ void sig_clicked(); private: Icon * _icon; QLabel * _value; }; /** Label for displaying ressources */ class ResourceLabel : public QWidget { public: /** Constructor */ ResourceLabel( QWidget * parent = 0, const char * name = 0 ); /** Sets the ressources of this label */ void setResource( int num ); /** Sets the number of ressources */ void setNumber( int nb ); protected: QLabel * _icon, * _label; }; /** ------------------------------ * AttalPopup ** ------------------------------ */ class AttalPopup : public QFrame { public: enum PopupType { PT_NONE, PT_LORD, PT_BASE, PT_BUILD, PT_EVENT, PT_FIGHTUNIT, PT_CREA }; /** Constructor */ AttalPopup( QWidget * parent = 0 ); void setType( PopupType type = PT_NONE ); /** Sets the unit of the popup */ void setUnit( GenericFightUnit * unit ); /** Sets the lord of the popup */ void setLord( GenericLord * lord ); void setBuilding( GenericBuilding * build ); void setCreature( GenericMapCreature * crea ); void setEvent( GenericEvent * event ); void setBase( GenericBase * base ); /** Update info */ void update(); protected: PopupType _type; private: GenericFightUnit * _unit; GenericLord * _lord; GenericBuilding * _build; GenericBase * _base; GenericEvent * _event; GenericMapCreature * _crea; QLabel * _labParams; }; /** ------------------------------ * AttalMessage ** ------------------------------ */ /** Dialog for displaying message*/ class AttalMessage : public QDialog { public: /** Constructor */ AttalMessage( QWidget * parent = 0, bool ok = true ); /** Adds text to the dialog */ void addText( QString text ); /** Adds pixmap to the dialog */ void addPixmap( QPixmap * pixmap ); protected: QVBoxLayout * _layout; bool _ok; }; #endif // WIDGET_H attal-src-1.0-rc2/libCommon/0000755000175000017500000000000011016113672013371 5ustar aaaaattal-src-1.0-rc2/libCommon/.cvsignore0000644000175000017500000000022310331243511015361 0ustar aaaamoc obj moc_* *.moc.cpp *.o *.opt *.plg *.dsp *.bak .deps Makefile.in Makefile Makefile.Release Makefile.Debug libattal.a Common.plg Debug Release attal-src-1.0-rc2/libCommon/action.cpp0000644000175000017500000001504310743510436015362 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** action.cpp ** Manage actions of 'buildings' ** ** Version : $Id: action.cpp,v 1.13 2008/01/16 23:19:58 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 23/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "action.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" // // ----- Action ----- // Action::Action() { _type = Action::DATE; _coeff = 0; } Action::~Action() { while( ! _list.isEmpty() ) { delete _list.takeFirst(); } } QString Action::getActionTypeString( ActionType type ) { QString ret = tr("Unknown"); switch( type ) { case DATE: ret = tr("date"); break; case FIRSTTIME: ret = tr("first time"); break; case FIRSTTIMELORD: ret = tr("first time lord"); break; case NEXTTIME: ret = tr("next time"); break; case CHANGEOWNER: ret = tr("change owner"); default: break; } return ret; } QString Action::getDescription( bool vert ) { QString string = ""; string = Action::getActionTypeString( getType() ); string.replace( 0, 1, string[0].toUpper() ); switch( getType() ) { case DATE : string += tr( " every " ) + QString::number( getCoeff() ) + " turns"; break; default: break; } string += vert ? "\n" : " "; for( int j = 0; j < getElementaryNumber(); j++ ) { ElementaryAction * elementary = getElementaryAction( j ); string += elementary->getDescription(); string += vert ? "\n" : " "; } return string; } bool Action::save( QTextStream * ts, uint indent ) { indentation( ts, indent ); *ts << "\t" << endl; indentation( ts, indent ); for( uint j = 0; j < (uint) getElementaryNumber(); ++j ) { ElementaryAction * elea = getElementaryAction(j); indentation( ts, indent ); *ts << "\tgetType() ) << "\" arg=\"" << (uint) (elea->getArg() ) <<"\" arg1=\"" << (uint) (elea->getArg1() )<< "\">"; *ts << ( elea->getCoeff() ) << "" << endl; } indentation( ts, indent ); *ts << "\t" << endl; return true; } // // ----- Elementary Action ----- // ElementaryAction::ElementaryAction() { _type = ElementaryAction::ATTACK; _arg = 0; _arg1 = 0; _coeff = 0; } QString ElementaryAction::getElemTypeString( ElementaryType type ) { QString ret = tr("Unknown"); switch( type ) { case ATTACK: ret = tr("attack"); break; case DEFENSE: ret = tr("defense"); break; case POWER: ret = tr("power"); break; case KNOWLEDGE: ret = tr("knowledge"); break; case MOVE: ret = tr("move"); break; case MAXMOVE: ret = tr("maxmove"); break; case TECHNICPOINT: ret = tr("techpoint"); break; case MAXTECHNICPOINT: ret = tr("maxtechpoint"); break; case MORALE: ret = tr("morale"); break; case LUCK: ret = tr("luck"); break; case VISION: ret = tr("vision"); break; case EXPERIENCE: ret = tr("experience"); break; case SKILL: ret = tr("skill"); break; case ARTEFACT: ret = tr("artefact"); break; case UNIT: ret = tr("unit"); break; case RESSOURCE: ret = tr("resource"); break; case RANDRESSOURCE: ret = tr("random resource"); break; case RESOURCEPERC: ret = tr("percentage resource"); break; case RESOURCEFROM: ret = tr("resource from resource"); break; case CHARISMA: ret = tr("charisma"); break; case POPULATION: ret = tr("population"); break; default: break; } return ret; } QString ElementaryAction::getDescription() { QString tmp = ""; QString string = ""; QString add1 = tr("add %1 "); ElementaryAction::ElementaryType etype = getType(); switch( etype ) { case ElementaryAction::ATTACK: case ElementaryAction::DEFENSE: case ElementaryAction::POWER: case ElementaryAction::KNOWLEDGE: case ElementaryAction::MOVE: case ElementaryAction::MAXMOVE: case ElementaryAction::TECHNICPOINT: case ElementaryAction::MAXTECHNICPOINT: case ElementaryAction::MORALE: case ElementaryAction::LUCK: case ElementaryAction::VISION: case ElementaryAction::EXPERIENCE: case ElementaryAction::CHARISMA: string = ElementaryAction::getElemTypeString( etype ); string.replace( 0, 1, string[0].toUpper() ); tmp = tr("add %1 ").arg( getCoeff()).append( string ); break; case ElementaryAction::SKILL: break; case ElementaryAction::ARTEFACT: break; case ElementaryAction::UNIT: tmp = "produce " + QString::number( getCoeff() ) + " " + DataTheme.creatures.at( getArg() , getArg1() )->getName(); break; case ElementaryAction::RESSOURCE: { QString tmp1 =DataTheme.resources.getRessource( getArg() ); tmp = tr("give %1").arg( getCoeff()).append(" ").append(tmp1); } break; case ElementaryAction::RANDRESSOURCE: { QString tmp1 = DataTheme.resources.getRessource( getArg() ); tmp = tr("give between 0 and %1").arg( getCoeff()*2).append(" ").append(tmp1); } break; case ElementaryAction::RESOURCEPERC: { QString tmp1 = DataTheme.resources.getRessource( getArg() ); tmp = tr("modify ") + tmp1 + tr(" by ") + QString::number( getCoeff() ) + tr(" percentage"); } break; case ElementaryAction::RESOURCEFROM: { QString tmp1 = DataTheme.resources.getRessource( getArg() ); QString tmp2 = DataTheme.resources.getRessource( getArg1() ); tmp = tr("for every %1").arg( getCoeff() ).append(" ").append(tmp1).append( tr(" give one ") ).append( tmp2 ) ; } break; case ElementaryAction::POPULATION: tmp = add1.arg( getCoeff() ).append( tr(" people")); break; default: break; } return tmp; } // // ----- InsideAction ----- // InsideAction::InsideAction() { _type = 0; } void InsideAction::addParam( int param ) { _params.append( param ); } int InsideAction::getParam( uint num ) { int ret = 0; if( (int)num < _params.count() ) { ret = _params.at( num ); } return ret; } attal-src-1.0-rc2/libCommon/action.h0000644000175000017500000001042310717374346015035 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** action.h ** Manage actions of 'buildings' ** ** Version : $Id: action.h,v 1.16 2007/11/16 20:09:10 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 23/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ACTION_H #define ACTION_H // generic include files // include files for QT #include #include #include // application specific include files class Calendar; class GenericLord; class ElementaryAction; class QTextStream; /** ------------------------------ * Action ** ------------------------------ */ class Action { Q_DECLARE_TR_FUNCTIONS(Action) public: enum ActionType { DATE = 0, FIRSTTIME, FIRSTTIMELORD, NEXTTIME, CHANGEOWNER, LAST }; /** Constructor */ Action(); /** Destructor */ virtual ~Action(); /** \return Returns the type of action */ ActionType getType() { return _type; } /** Sets the type of action */ void setType( ActionType type ) { _type = type; } /** \return Returns the coefficient */ int getCoeff() { return _coeff; } /** Sets the coefficient */ void setCoeff( int coeff ) { _coeff = coeff; } /** Adds an elementary action */ void addElementaryAction( ElementaryAction * action ) { _list.append( action ); } /** \return Returns the nb of elementary actions */ int getElementaryNumber() { return _list.count(); } /** \return Returns the elementary action nb 'i' */ ElementaryAction * getElementaryAction( int i ) { return _list.at( i ); } bool save( QTextStream * ts, uint indent ); static QString getActionTypeString( ActionType type ); QString getDescription( bool vert ); protected: ActionType _type; QList _list; int _coeff; }; /** Describes an elementary action */ class ElementaryAction { Q_DECLARE_TR_FUNCTIONS(ElementaryAction) public: enum ElementaryType { ATTACK = 1, DEFENSE, POWER, KNOWLEDGE, MOVE, MAXMOVE, TECHNICPOINT, MAXTECHNICPOINT, MORALE, LUCK, VISION, EXPERIENCE, SKILL, ARTEFACT, UNIT, RESSOURCE, RANDRESSOURCE, RESOURCEPERC, RESOURCEFROM, CHARISMA, POPULATION, LAST }; /** Constructor */ ElementaryAction(); /** \return Returns the type of elementary action */ ElementaryType getType() { return _type; } /** Sets the type of elementary action */ void setType( ElementaryType type ) { _type = type; } /** \return Returns the arg */ int getArg() { return _arg; } /** Sets the arg of the action */ void setArg( int arg ) { _arg = arg; } /** \return Returns the arg1 */ int getArg1() { return _arg1; } /** Sets the arg of the action */ void setArg1( int arg ) { _arg1 = arg; } /** \return Returns the coefficient */ int getCoeff() { return _coeff; } /** Sets the coefficient */ void setCoeff( int coeff ) { _coeff = coeff; } QString getDescription(); static QString getElemTypeString( ElementaryType type ); private: ElementaryType _type; int _arg, _arg1; int _coeff; }; enum INSIDE_ACTION { INSIDE_NONE = 0, INSIDE_VILLAGE = 1, INSIDE_CASTLE = 2, INSIDE_CREA = 3, INSIDE_MARKET = 4, INSIDE_TAVERN = 5 }; /** Describe the actions inside bases */ class InsideAction { public: /** Constructor */ InsideAction(); /** \return Returns the type of action */ int getType() { return _type; } /** Sets the type of action */ void setType( int type ) { _type = type; } /** \return Returns the number of parameters of this action */ uint getParamNumber() { return _params.count(); } /** Add a parameter to this action */ void addParam( int param ); /** \return Returns the parameter 'num' */ int getParam( uint num ); protected: int _type; QList _params; }; #endif // ACTION_H attal-src-1.0-rc2/libCommon/artefact.cpp0000644000175000017500000002174710522705151015701 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** artefact.cpp ** manages artefacts ** ** Version : $Id: artefact.cpp,v 1.14 2006/11/03 18:28:57 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 18/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "artefact.h" // generic include files // include files for QT #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/genericCell.h" #include "libCommon/genericLord.h" extern QString DATA_PATH; // // ----- GenericArtefact ----- // GenericArtefact::GenericArtefact() : _id( 0 ), _type( 0 ) { } GenericArtefact::~GenericArtefact() { } void GenericArtefact::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent ); *ts << "" << endl; *ts << flush; } QString GenericArtefact::getName() { return DataTheme.artefacts.at( _type )->getName(); } // // ----- GenericLordArtefact ----- // GenericLordArtefact::GenericLordArtefact() { _type = 0; _pos = 0; _lord = 0; } GenericLordArtefact::~GenericLordArtefact() { } void GenericLordArtefact::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent ); *ts << "" << endl; *ts << flush; } GenericLord * GenericLordArtefact::getLord() { return _lord; } void GenericLordArtefact::setLord( GenericLord * lord ) { _lord = lord; } int GenericLordArtefact::getModelPosition() { return DataTheme.artefacts.at( _type )->getPosition(); } int GenericLordArtefact::getPosition() { int ret = -1; ret = _pos; return ret; } void GenericLordArtefact::setPosition( int position ) { _pos = position; } QString GenericLordArtefact::getName() { return DataTheme.artefacts.at( _type )->getName(); } int GenericLordArtefact::computeCharacModif( LordCharac charac, int value, ArtefactElementaryAction::ModifType modif ) { int ret = value; GenericArtefactModel * model = DataTheme.artefacts.at( _type ); ArtefactElementaryAction * action; for( uint i = 0; i < model->getActionNumber(); ++i ) { action = model->getAction( i ); if( action->getActionType() == ArtefactElementaryAction::AT_CHARAC ) { if( ( action->getModifType() == modif ) and ( action->getParam() == (uint)charac ) ) { ret = action->computeModif( value ); } } } return ret; } // // ----- ArtefactElementaryAction ----- // ArtefactElementaryAction::ArtefactElementaryAction( ActionType action, ModifType modif ) { _type = action; _modif = modif; _value = 0; } int ArtefactElementaryAction::computeModif( int value ) { int ret = value; if( _type == AT_CHARAC ) { if( _modif == MT_VALUE ) { ret += _value; } else { ret = (int)( (ret * _value) / 100 ); } } return ret; } void ArtefactElementaryAction::save( QTextStream * ts, int indent ) { indentation( ts, indent ); if( _type == ArtefactElementaryAction::AT_CHARAC ) { *ts << ""; *ts << _value << "" << endl; } // // ----- GenericArtefactModel ----- // GenericArtefactModel::GenericArtefactModel() :_name( "" ), _position( 0 ) { } GenericArtefactModel::~GenericArtefactModel() { clearActions(); } ArtefactElementaryAction * GenericArtefactModel::getAction( uint num ) { ArtefactElementaryAction * ret = 0; if( (int)num < _actions.count() ) { ret = _actions.at( num ); } return ret; } void GenericArtefactModel::addAction( ArtefactElementaryAction * action ) { _actions.append( action ); } void GenericArtefactModel::clearActions() { while( ! _actions.isEmpty() ) { delete _actions.takeFirst(); } } void GenericArtefactModel::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent ); *ts << "\t" << _name << "" << endl; indentation( ts, indent ); *ts << "\t" << _position << "" << endl; indentation( ts, indent ); *ts << "\t" << endl; for( int i = 0; i < _actions.count(); i++ ) { _actions.at( i )->save( ts, indent+2 ); } indentation( ts, indent ); *ts << "\t" << endl; indentation( ts, indent ); *ts << "" << endl; } // // ----- ArtefactList ----- // ArtefactList::ArtefactList() { } ArtefactList::~ArtefactList() { clear(); } void ArtefactList::clear() { while( ! isEmpty() ) { delete takeFirst(); } } bool ArtefactList::init() { clear(); ArtefactHandler handler( this ); QFile file( DATA_PATH + "artefacts.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "artefacts.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } bool ArtefactList::save() { QString filename = DATA_PATH + "artefacts.dat"; QFile file( filename ); if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writing\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; for( int i = 0; i < count(); i++ ) { at( i )->save( &ts, 1 ); } ts << "" << endl; file.close(); return true; } // // ----- ArtefactHandler ----- // ArtefactHandler::ArtefactHandler( ArtefactList * list ) { _list = list; } bool ArtefactHandler::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _list->clear(); _state = StateInit; return true; } bool ArtefactHandler::startElement( const QString&, const QString&, const QString& qName, const QXmlAttributes & atts) { if( qName == "artefacts" && _state == StateInit ) { _state = StateDocument; } else if( qName == "artefact" && _state == StateDocument ) { _state = StateArtefact; _artefact = new GenericArtefactModel(); } else if( qName == "name" && _state == StateArtefact ) { _state = StateName; } else if( qName == "position" && _state == StateArtefact ) { _state = StatePosition; } else if( qName == "action" && _state == StateArtefact ) { _state = StateAction; } else if( qName == "elementary" && _state == StateAction ) { ArtefactElementaryAction::ActionType action; ArtefactElementaryAction::ModifType modif; _state = StateActionElementary; if( atts.value( "type" ).toUpper() == "CHARAC" ) { action = ArtefactElementaryAction::AT_CHARAC; } else { action = ArtefactElementaryAction::AT_SKILL; } if( atts.value( "modif" ).toUpper() == "VALUE" ) { modif = ArtefactElementaryAction::MT_VALUE; } else { modif = ArtefactElementaryAction::MT_RATIO; } _action = new ArtefactElementaryAction( action, modif ); _action->setParam( atts.value( "param" ).toInt() ); } else { // error return false; } return true; } bool ArtefactHandler::endElement( const QString&, const QString&, const QString& ) { switch ( _state ) { case StateArtefact: _list->append( _artefact ); _state = StateDocument; break; case StateName: _state = StateArtefact; break; case StatePosition: _state = StateArtefact; break; case StateAction: _state = StateArtefact; break; case StateActionElementary: _artefact->addAction( _action ); _state = StateAction; break; default: // do nothing break; } return true; } bool ArtefactHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) return true; switch( _state ) { case StateName: _artefact->setName( ch_simplified ); break; case StatePosition: _artefact->setPosition( ch_simplified.toInt() ); break; case StateActionElementary: _action->setValue( ch_simplified.toInt() ); break; default: return false; } return true; } bool ArtefactHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/artefact.h0000644000175000017500000001345110335201564015340 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** artefact.h ** manages artefacts ** ** Version : $Id: artefact.h,v 1.9 2005/11/11 20:47:48 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 18/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICARTEFACT_H #define GENERICARTEFACT_H // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/define.h" class QTextStream; class GenericCell; class GenericLord; /** ------------------------------ * GenericArtefact ** ------------------------------ */ class GenericArtefact { public: /** Constrcutor */ GenericArtefact(); /** Destructor */ virtual ~GenericArtefact(); /** Saves the artefact data */ void save( QTextStream * ts, int indent = 0 ); /** \return Returns the id of the artefact */ int getId() { return _id; } /** Sets the id of the artefact */ void setId( int id ) { _id = id; } /** \return Returns the type of the artefact */ uint getType() { return _type; } /** Sets the type of the artefact */ virtual void setType( uint type ) { _type = type; } /** Get the name of the artefact */ QString getName(); protected: int _id; uint _type; }; /** Action of artefact model */ class ArtefactElementaryAction { public: enum ActionType { AT_CHARAC, AT_SKILL }; enum ModifType { MT_VALUE, MT_RATIO }; ArtefactElementaryAction( ActionType action, ModifType modif ); ActionType getActionType() { return _type; } ModifType getModifType() { return _modif; } uint getParam() { return _param; } void setParam( uint param ) { _param = param; } int getValue() { return _value; } void setValue( int value ) { _value = value; } int computeModif( int value ); void save( QTextStream * ts, int indent ); protected: ActionType _type; ModifType _modif; uint _param; int _value; }; class GenericLordArtefact { public: GenericLordArtefact(); virtual ~GenericLordArtefact(); /** Saves the artefact data */ void save( QTextStream * ts, int indent = 0 ); /** \return Returns the type of the artefact */ uint getType() { return _type; } /** Sets the type of the artefact */ virtual void setType( uint type ) { _type = type; } /** \return Returns the lord who owns this artefact (if any) */ GenericLord * getLord(); /** Sets the lord who owns this artefact (if any) */ virtual void setLord( GenericLord * lord ); /** Get the position of the artefact */ int getModelPosition(); /** \return Returns the position on the lord of this artefact */ int getPosition(); /** Sets the position on the lord of this artefact */ void setPosition( int pos ); /** Get the name of the artefact */ QString getName(); int computeCharacModif( LordCharac charac, int value, ArtefactElementaryAction::ModifType modif ); protected: uint _type, _pos; GenericLord * _lord; }; /** Model for artefact */ class GenericArtefactModel { public: /** Constructor */ GenericArtefactModel(); /** Destructor */ virtual ~GenericArtefactModel(); /** Get the name of the artefact */ QString getName() { return _name; } /** Set the name of the artefact */ void setName( const QString & name ) { _name = name; } /** Get type of the artefact */ int getPosition() { return _position; } /** Set type of the artefact */ void setPosition( int position ) { _position = position; } void addAction( ArtefactElementaryAction * action ); uint getActionNumber() { return _actions.count(); } ArtefactElementaryAction * getAction( uint num ); void clearActions(); /** Save this model on file */ void save( QTextStream * ts, int indent ); private: QString _name; int _position; QList _actions; }; /** List of GenericArtefactModel */ class ArtefactList : public QList { public: /** Constructor */ ArtefactList(); /** Destructor */ virtual ~ArtefactList(); /** Return base corresponding to 'type' */ GenericArtefactModel * at( int type ) { return QList::at( type ); } /** Init list */ bool init(); bool save(); void clear(); }; /** Parser of artefact list */ class ArtefactHandler : public QXmlDefaultHandler { public: /** Construtor */ ArtefactHandler( ArtefactList * list ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: QString _errorProt; ArtefactList * _list; GenericArtefactModel * _artefact; ArtefactElementaryAction * _action; enum State { StateInit, StateDocument, StateArtefact, StateName, StateAction, StateActionElementary, StatePosition, }; State _state; }; #endif // GENERICARTEFACT_H attal-src-1.0-rc2/libCommon/artefactManager.cpp0000644000175000017500000000740010663654263017177 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** artefactManger.cpp ** Manages artefacts of a lord ** ** Version : $Id: artefactManager.cpp,v 1.10 2007/08/24 22:16:19 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 30/11/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "artefactManager.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/genericLord.h" /// XXX: very strange memory management -> should be memory leaks in artefact management because of the 2 different addArtefact() ArtefactManager::ArtefactManager( GenericLord * lord ) { _lord = lord; } ArtefactManager::~ArtefactManager() { clearArtefacts(); } void ArtefactManager::save( QTextStream * ts, int indent ) { for( int i = 0; i < _artefacts.count (); i++ ) { _artefacts.at(i)->save( ts, indent + 1 ); } } uint ArtefactManager::getArtefactNumber() { return _artefacts.count(); } bool ArtefactManager::addArtefact( int /*position*/, int /*num*/, GenericLordArtefact * /*artefact*/ ) { return false; } GenericLordArtefact * ArtefactManager::getArtefact( int /*position*/, int /*num*/ ) { return 0; } bool ArtefactManager::removeArtefact( int /*position*/, int /*num*/ ) { return false; } void ArtefactManager::addArtefact( GenericLordArtefact * artefact ) { _artefacts.append( artefact ); } void ArtefactManager::addArtefact( uint type ) { GenericLordArtefact * artefact = new GenericLordArtefact(); artefact->setType( type ); artefact->setLord( _lord ); _artefacts.append( artefact ); } GenericLordArtefact * ArtefactManager::getArtefact( int num ) { return _artefacts.at( num ); } GenericLordArtefact * ArtefactManager::getArtefactByType( uint type ) { GenericLordArtefact * ret = 0; uint nb = _artefacts.count(); for( uint i = 0; i < nb; i++ ) { GenericLordArtefact * artefact = _artefacts.at( i ); if( artefact->getType() == type ) { ret = artefact; break; } } return ret; } void ArtefactManager::removeArtefact( int num ) { _artefacts.removeAt( num ); } void ArtefactManager::removeArtefact( GenericLordArtefact * artefact ) { _artefacts.removeAll( artefact ); } void ArtefactManager::removeArtefactByType( uint type ) { uint nb = _artefacts.count(); for( uint i = 0; i < nb; i++ ) { GenericLordArtefact * artefact = _artefacts.at( i ); if( artefact->getType() == type ) { _artefacts.removeAll( artefact ); } } } bool ArtefactManager::hasArtefactType( uint type ) { bool ret = false; uint nb = _artefacts.count(); for( uint i = 0; i < nb; i++ ) { GenericLordArtefact * artefact = _artefacts.at( i ); if( artefact->getType() == type ) { ret = true; } } return ret; } void ArtefactManager::clearArtefacts() { while( ! _artefacts.isEmpty() ) { delete _artefacts.takeFirst(); } } int ArtefactManager::computeCharacModif( LordCharac charac, int value ) { int ret = value; for( int i = 0; i < _artefacts.count(); ++i ) { ret = _artefacts.at( i )->computeCharacModif( charac, ret, ArtefactElementaryAction::MT_VALUE ); } for( int i = 0; i < _artefacts.count(); ++i ) { ret = _artefacts.at( i )->computeCharacModif( charac, ret, ArtefactElementaryAction::MT_RATIO ); } return ret; } attal-src-1.0-rc2/libCommon/artefactManager.h0000644000175000017500000000450310335201564016631 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** artefactManager.h ** Manages artefacts of a lord ** ** Version : $Id: artefactManager.h,v 1.5 2005/11/11 20:47:48 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 30/11/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ARTEFACTMANAGER_H #define ARTEFACTMANAGER_H // generic include files // include files for QT #include // application specific include files #include "libCommon/artefact.h" #include "libCommon/define.h" class QTextStream; class GenericLord; /* ------------------------------ * ArtefactManager * ------------------------------ */ class ArtefactManager { public: /** Constructor */ ArtefactManager( GenericLord * lord ); /** Destructor */ ~ArtefactManager(); void save( QTextStream * ts, int indent ); /** Add artefact */ void addArtefact( GenericLordArtefact * artefact ); /** Add artefact */ void addArtefact( uint type ); /** Get artefact 'num' */ GenericLordArtefact * getArtefact( int num ); /** Get artefact 'num' */ GenericLordArtefact * getArtefactByType( uint type ); /** Remove artefact */ void removeArtefact( int num ); void removeArtefact( GenericLordArtefact * artefact ); void removeArtefactByType( uint type ); bool hasArtefactType( uint type ); void clearArtefacts(); /** Return the nb of artefacts */ uint getArtefactNumber(); bool addArtefact( int position, int num, GenericLordArtefact * artefact ); GenericLordArtefact * getArtefact( int position, int num ); bool removeArtefact( int position, int num ); int computeCharacModif( LordCharac type, int value ); protected: QList _artefacts; GenericLord * _lord; }; #endif // ARTEFACTMANAGER_H attal-src-1.0-rc2/libCommon/attalCommon.cpp0000644000175000017500000001717511015360076016367 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalCommon.cpp ** Manage common data for everyone ** ** Version : $Id: attalCommon.cpp,v 1.25 2008/05/22 21:06:06 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 26/07/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "attalCommon.h" // generic include files #include #include #include // include files for QT #include #include #include // application specific include files #include "conf.h" #include "libCommon/log.h" using namespace std; QString IMAGE_PATH( IMAGE_DEFAULT_PATH ); QString MUSIC_PATH( MUSIC_DEFAULT_PATH ); QString SOUND_PATH( SOUND_DEFAULT_PATH ); QString DATA_PATH( DATA_DEFAULT_PATH ); QString CAMPAIGN_PATH( CAMPAIGN_DEFAULT_PATH ); QString SCENARIO_PATH( SCENARIO_DEFAULT_PATH ); QString CONFIG_PATH( CONFIG_DEFAULT_PATH ); QString THEME( THEME_DEFAULT ); QString SAVE_PATH; QString THEME_CONFIG_PATH; QString VERSION(ATTAL_VERSION); QString THEME_PATH; QString PORT = "1717"; bool FAST = false; bool HIDE = false; #ifdef WITH_SOUND bool ATT_SOUND = true; #endif using namespace AttalCommon; int parseArgs(int argc, char** argv, AttalProgramType prog ) { #ifdef WITH_SOUND if( prog != ATTALCLIENT /* && prog != ATTALTHEMEEDITOR */ ) { ATT_SOUND = false; } #endif for( int i = 1; i < argc; i++ ) { if( ( strcmp( argv[i], "-theme" ) == 0 ) || ( strcmp( argv[i], "--theme" ) == 0 ) ) { i++; if( i < argc ) THEME = QString( argv[i] ); } else if( (strcmp( argv[i], "-port" ) == 0 ) || ( strcmp( argv[i], "--port" ) == 0) ) { i++; if( i < argc ){ PORT = QString( argv[i] ); } } else if( ( strcmp( argv[i], "-d" ) == 0 ) ) { int level; i++; if( i < argc ){ level = atoi(argv[i]) ; setLogLevel((LogLevel) level ); } } else if( strcmp( argv[i], "--hide" ) == 0 ) { HIDE = true; } else if( ( strcmp( argv[i], "--themepath" ) == 0 ) ) { i++; if( i < argc ) THEME_PATH = QString( argv[i] ); } else if( ( strcmp( argv[i], "-fast" ) == 0 ) || ( strcmp( argv[i], "--fast" ) == 0 ) ) { FAST = true; } else if( strcmp( argv[i], "--nosound") == 0 ) { #ifdef WITH_SOUND ATT_SOUND = false; #endif } else if( ( strcmp( argv[i], "-help" ) == 0 ) || ( strcmp( argv[i], "--help" ) == 0 ) ) { switch( prog ) { case ATTALSERVER: cout << "Usage: attal-server [OPTION]" << endl; cout << "Start the server " << endl; cout << endl; break; case ATTALCLIENT: cout << "Usage: attal-client [OPTION]" << endl; cout << "Start client " << endl; cout << endl; break; case ATTALCAMPAIGNEDITOR: cout << "Usage: campaignEditor [OPTION]" << endl; cout << "Start campaignEditor " << endl; cout << endl; break; case ATTALSCENARIOEDITOR: cout << "Usage: scenarioEditor [OPTION]" << endl; cout << "Start scenarioEditor " << endl; cout << endl; break; case ATTALTHEMEEDITOR: cout << "Usage: themeEditor [OPTION]" << endl; cout << "Start themeEditor " << endl; cout << endl; break; case ATTALAI: cout << "Usage: attal-ai [OPTION]" << endl; cout << "Start ai robot " << endl; cout << endl; cout << " --hide Hide ai (remember to kill)" << endl; break; } switch( prog ) { case ATTALSERVER: case ATTALAI: cout << " -port --port [PORT] Used to use a particular port" << endl; cout << " -fast --fast Fast start use: localhost:1717" << endl; break; case ATTALCLIENT: case ATTALTHEMEEDITOR: #ifdef WITH_SOUND cout << " --nosound Disable totally sound (ex: for hardware problems)" << endl; #endif break; default: break; }; cout << " -theme --theme [NAME] Load a particular theme (Medieval by default)" << endl; cout << " --themepath [NAME] Get the path of theme (local directory or hardcoded path will be the default)" << endl; cout << " -d [LEVEL] Level of debug messages (0-5) (default 4)" << endl; cout << " --version -v Prints attal's version and exits." << endl; cout << " -help --help This screen" << endl; return 1; } else if( ( strcmp( argv[i], "--version" ) == 0 ) || ( strcmp( argv[i], "-v" ) == 0) ) { cout << "Attal Lords of Doom " << VERSION.toLatin1().constData() << endl; #ifdef __GNUC__ cout << "Compiler:" << "\tGCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__ << "\n"; #endif return 1; } } return 0; } void useTheme() { QDir folder; folder = setThemePath( THEME_PATH ); if( ! folder.exists() ) { QString envpath = getenv("ATTAL_THEME_PATH"); TRACE("EnvPath %s", envpath.toLatin1().constData()); folder = setThemePath( envpath ); } if( ! folder.exists() ) { folder = setThemePath( "./themes" ); } #ifndef WIN32 QString qConfigPath; qConfigPath = ATT_THEMES_DIR; if( ! folder.exists() ) { folder = setThemePath( qConfigPath ); } #endif if( ! folder.exists() ) { logEE( "Theme %s not found", THEME.toLatin1().constData() ); THEME = THEME_DEFAULT; } THEME_PATH = folder.absolutePath() + "/"; TRACE("ThemePath %s", THEME_PATH.toLatin1().constData()); IMAGE_PATH = THEME_PATH + IMAGE_DEFAULT_PATH; SOUND_PATH = THEME_PATH + SOUND_DEFAULT_PATH; MUSIC_PATH = THEME_PATH + MUSIC_DEFAULT_PATH; DATA_PATH = THEME_PATH + DATA_DEFAULT_PATH; CAMPAIGN_PATH = THEME_PATH + CAMPAIGN_DEFAULT_PATH; TRACE("Campaign Path %s", CAMPAIGN_PATH.toLatin1().constData()); SCENARIO_PATH = THEME_PATH + SCENARIO_DEFAULT_PATH; QDir tmpdir = QDir::home(); if( tmpdir.isRoot() ) { CONFIG_PATH = QDir::homePath() + CONFIG_DEFAULT_PATH; } else { CONFIG_PATH = QDir::homePath() + QDir::separator() + CONFIG_DEFAULT_PATH; } folder.setPath(CONFIG_PATH); if( ! folder.exists() ) { if(!folder.mkdir(CONFIG_PATH)) { logEE( "Cannot create config dir %s", CONFIG_PATH.toLatin1().constData() ); } } THEME_CONFIG_PATH = CONFIG_PATH + THEME; folder.setPath(THEME_CONFIG_PATH); if( ! folder.exists() ) { if(!folder.mkdir(THEME_CONFIG_PATH)) { logEE( "Cannot create theme config dir %s", THEME_CONFIG_PATH.toLatin1().constData() ); } } SAVE_PATH = THEME_CONFIG_PATH + "/saves/"; TRACE("ThemeConfigPath %s, savepath %s", THEME_CONFIG_PATH.toLatin1().constData(), SAVE_PATH.toLatin1().constData()); folder.setPath(SAVE_PATH); if( ! folder.exists() ) { if(!folder.mkdir(SAVE_PATH)) { logEE( "Cannot create save dir %s", SAVE_PATH.toLatin1().constData() ); } } /// XXX: need more tests of existence } QDir translationsDir() { QDir trfolder; trfolder.setPath( "./i18n/" + QLocale::system().name() .section('_', 0,0 ) ); #ifndef WIN32 QString qConfigPath; qConfigPath = ATT_TRANSL_DIR; //logDD("attalCommon %s", qConfigPath.toLatin1().constData()); if( ! trfolder.exists() ) { trfolder.setPath( qConfigPath ); } #endif return trfolder; } QDir setThemePath( QString path ) { QDir tmpfolder; tmpfolder.setPath( path + QDir::separator() + THEME ); return tmpfolder; } attal-src-1.0-rc2/libCommon/attalCommon.h0000644000175000017500000000313710616061307016026 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalCommon.h ** Manage common data for everyone ** ** Version : $Id: attalCommon.h,v 1.6 2007/05/02 10:07:03 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 26/07/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ATTALCOMMON_H #define ATTALCOMMON_H // generic include files // include files for QT // application specific include files class QDir; class QString; namespace AttalCommon { enum TypeFightCell { UNKNOWN_TYPE, NORMAL, OBSTACLE }; enum FightCellAccess { UNKNOWN_ACCESS, NONE, NEAR_FREE, NEAR_OCCUPIED, FAR_FREE, FAR_OCCUPIED }; enum AttalProgramType { ATTALCLIENT, ATTALSERVER, ATTALAI, ATTALCAMPAIGNEDITOR, ATTALSCENARIOEDITOR, ATTALTHEMEEDITOR }; } /** For setting theme pathes */ void useTheme(); int parseArgs(int argc, char** argv, AttalCommon::AttalProgramType prog ); /** For setting translations pathes */ QDir translationsDir(); QDir setThemePath( QString path ); #endif // ATTALCOMMON_H attal-src-1.0-rc2/libCommon/attalSettings.cpp0000644000175000017500000000560511015371664016737 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** Date : 05/12/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "attalSettings.h" // generic include files // include files for QT // application specific include files #include "libCommon/log.h" AttalSettings * AttalSettings::_instance = 0; AttalSettings * AttalSettings::getInstance() { if( _instance == 0 ) { _instance = new AttalSettings(); } return _instance; } void AttalSettings::load() { QSettings settings( "Attal", "attal-client" ); _fightSettings.isAnimationEnabled = settings.value( "FightSettings/isAnimationEnabled", true ).toBool(); _fightSettings.areCellsVisible = settings.value( "FightSettings/areCellsVisible", true ).toBool(); _fightSettings.animationSpeed = settings.value( "FightSettings/animationSpeed", 7 ).toInt(); _strategyModeSettings.isAnimationEnabled = settings.value( "StrategyModeSettings/isAnimationEnabled", true ).toBool(); _strategyModeSettings.isMapVisible = settings.value( "StrategyModeSettings/isMapVisible", true ).toBool(); _strategyModeSettings.isSoundOn = settings.value( "StrategyModeSettings/isSoundOn", true ).toBool(); _strategyModeSettings.isMusicOn = settings.value( "StrategyModeSettings/isMusicOn", true ).toBool(); _strategyModeSettings.connectionName = settings.value( "StrategyModeSettings/connectionName", "New Player" ).toString(); _mode = (DispositionMode) settings.value( "Display/dispositionMode", (int) DM_FULL ).toInt(); } void AttalSettings::save() { QSettings settings( "Attal", "attal-client" ); settings.setValue( "FightSettings/isAnimationEnabled", _fightSettings.isAnimationEnabled ); settings.setValue( "FightSettings/areCellsVisible", _fightSettings.areCellsVisible ); settings.setValue( "FightSettings/animationSpeed", _fightSettings.animationSpeed ); settings.setValue( "StrategyModeSettings/isAnimationEnabled", _strategyModeSettings.isAnimationEnabled ); settings.setValue( "StrategyModeSettings/isMapVisible", _strategyModeSettings.isMapVisible ); settings.setValue( "StrategyModeSettings/isSoundOn", _strategyModeSettings.isSoundOn ); settings.setValue( "StrategyModeSettings/isMusicOn", _strategyModeSettings.isMusicOn ); settings.setValue( "StrategyModeSettings/connectionName", _strategyModeSettings.connectionName ); settings.setValue( "Display/dispositionMode", (int) _mode ); } attal-src-1.0-rc2/libCommon/attalSettings.h0000644000175000017500000000432610605767421016407 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalSettings.h ** ** Author(s) : Nick Semenov ** ** Date : 05/12/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ATTALSETTINGS_H #define ATTALSETTINGS_H // generic include files // include files for QT #include // application specific include files /* ------------------------------ * AttalSettings * ------------------------------ */ class AttalSettings { public: virtual ~AttalSettings() { save(); } static AttalSettings * getInstance(); void load(); void save(); struct FightSettings { bool isAnimationEnabled; bool areCellsVisible; int animationSpeed; }; const FightSettings & getFightSettings() { return _fightSettings; } void setFightSettings( const FightSettings & fightSettings ) { _fightSettings = fightSettings; } struct StrategyModeSettings { bool isAnimationEnabled; bool isMapVisible; bool isSoundOn; bool isMusicOn; QString connectionName; }; const StrategyModeSettings & getStrategyModeSettings() { return _strategyModeSettings; } void setStrategyModeSettings( const StrategyModeSettings & strategyModeSettings ) { _strategyModeSettings = strategyModeSettings; } enum DispositionMode { DM_VERYCOMPACT, DM_COMPACT, DM_FULL }; const DispositionMode & getDispositionMode() { return _mode; } void setDispositionMode( const DispositionMode & mode ) { _mode = mode; } protected: AttalSettings() { load(); } static AttalSettings * _instance; FightSettings _fightSettings; StrategyModeSettings _strategyModeSettings; DispositionMode _mode; }; #endif // ATTALSETTINGS_H attal-src-1.0-rc2/libCommon/attalSocket.cpp0000644000175000017500000007001110763100242016347 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalSocket.cpp ** socket for Attal over network ** ** Version : $Id: attalSocket.cpp,v 1.59 2008/03/03 22:50:10 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 31/10/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "attalSocket.h" // generic include files #include // include files for QT // application specific includes #include "libCommon/artefact.h" #include "libCommon/calendar.h" #include "libCommon/creature.h" #include "libCommon/genericBonus.h" #include "libCommon/genericCell.h" #include "libCommon/genericChest.h" #include "libCommon/genericEvent.h" #include "libCommon/genericFightCell.h" #include "libCommon/genericInsideBuilding.h" #include "libCommon/genericLord.h" #include "libCommon/genericMapCreature.h" #include "libCommon/genericPlayer.h" #include "libCommon/unit.h" // // ----- AttalSocket ----- // AttalSocket::AttalSocket() { } AttalSocket::~AttalSocket() { } void AttalSocket::send() { _bufOut[0] = _lenOut-1; write( _bufOut, _lenOut ); _bufOut[1] = 0; _bufOut[2] = 0; _bufOut[3] = 0; _lenOut = 4; } void AttalSocket::readData() { uchar len; getChar( (char *) & len ); _lenIn = 3; read( _bufIn, len ); } AttalSocketData AttalSocket::readBufferData() { AttalSocketData data; uchar len; getChar( (char *) & len ); read( data._bufIn, len ); setData( &data ); return data; } void AttalSocket::internalSendMessage( QString msg ) { appendChar( (uchar) std::min( msg.length(), 250 ) ); /// XXX: we suppose small messages for the moment <= 250 for( int i = 0; i < std::min( msg.length(), 250 ); i++ ) { appendChar( (uchar) (msg.toLatin1())[i] ); } send(); } void AttalSocket::sendMessage( QString msg ) { init( (uchar) SO_MSG, ( uchar)C_MSG_NORM ); internalSendMessage( msg ); } void AttalSocket::sendFightMessage( QString msg ) { init( (uchar) SO_MSG, ( uchar)C_MSG_FIGHT ); internalSendMessage( msg ); } void AttalSocket::sendConnMessage( QString msg ) { init( (uchar) SO_MSG, ( uchar)C_MSG_CONN ); internalSendMessage( msg ); } void AttalSocket::sendConnectionOk() { init( (uchar)SO_CONNECT, (uchar)C_CONN_OK ); send(); } void AttalSocket::sendConnectionId( char id ) { init( (uchar)SO_CONNECT, (uchar)C_CONN_ID ); appendChar( id ); send(); } void AttalSocket::sendConnectionName( QString name ) { init( (uchar) SO_CONNECT, (uchar) C_CONN_NAME ); appendChar( (uchar) std::min( name.length(), 250 ) ); for( int i = 0; i < std::min( name.length(), 250 ); i++ ) { appendChar( (uchar) (name.toLatin1())[i] ); } send(); } void AttalSocket::sendConnectionVersion( QString name ) { init( (uchar) SO_CONNECT, (uchar) C_CONN_VERSION ); appendChar( (uchar) std::min( name.length(), 250 ) ); for( int i = 0; i < std::min( name.length(), 250 ); i++ ) { appendChar( (uchar) (name.toLatin1())[i] ); } send(); } void AttalSocket::sendConnectionPlayer( GenericPlayer * player ) { init( (uchar) SO_CONNECT, (uchar) C_CONN_PLAYER ); appendChar( (uchar) player->getNum() ); QString name = player->getName(); appendChar( (uchar) std::min( name.length(), 250 ) ); for( int i = 0; i < std::min( name.length(), 250 ); i++ ) { appendChar( (uchar) (name.toLatin1())[i] ); } send(); } void AttalSocket::sendExchangeStart( GenericLord * lord1, GenericLord * lord2 ) { init( (uchar)SO_EXCH, (uchar) C_EXCH_START ); appendChar( (uchar)lord1->getId(), (uchar) lord2->getId() ); send(); } /* NOTE: if regroup 2 same units remember that the server * regroup the units on position unit2 not unit1 */ void AttalSocket::sendExchangeUnit( GenericLord * lord1, int unit1, GenericLord * lord2, int unit2 ) { init( (uchar)SO_EXCH, (uchar)C_EXCH_UNIT ); if( lord1 ) { appendChar( (uchar)lord1->getId() ); } else { appendChar( (uchar)-1 ); } appendChar( (uchar)unit1 ); if( lord2 ) { appendChar( (uchar)lord2->getId() ); } else { appendChar( (uchar)-1 ); } appendChar( (uchar)unit2 ); send(); } void AttalSocket::sendExchangeArtefact( GenericLord * lord1, int item, GenericLord * lord2 ) { if( lord1 && lord2) { init( (uchar)SO_EXCH, (uchar)C_EXCH_ARTEFACT ); appendChar( (uchar)lord1->getId() ); appendInt( item ); appendChar( (uchar)lord2->getId() ); send(); } } void AttalSocket::sendExchangeBaseUnit( GenericBase * base, int unit1, GenericLord * lord2, int unit2 ) { init( (uchar)SO_EXCH, (uchar)C_EXCH_BASEUNIT ); if( base ) { appendChar( (uchar)base->getId() ); } else { appendChar( (uchar)-1 ); } appendChar( (uchar)unit1 ); if( lord2 ) { appendChar( (uchar)lord2->getId() ); } else { appendChar( (uchar)-1 ); } appendChar( (uchar)unit2 ); send(); } void AttalSocket::sendExchangeBaseLordUnit( GenericLord * lord1, int unit1, GenericLord * lord2, int unit2, uchar direction ) { init( (uchar)SO_EXCH, (uchar)C_EXCH_UNIT ); if( lord1 ) { appendChar( (uchar)lord1->getId() ); } else { appendChar( (uchar)-1 ); } appendChar( (uchar)unit1 ); if( lord2 ) { appendChar( (uchar)lord2->getId() ); } else { appendChar( (uchar)-1 ); } appendChar( (uchar)unit2 ); appendChar( (uchar)direction ); send(); } void AttalSocket::sendExchangeUnitSplit( GenericLord * lord, int unit, int num1, int pos2, int num2 ) { init( (uchar)SO_EXCH, (uchar)C_EXCH_UNIT_SPLIT ); if( lord ) { appendChar( (uchar)lord->getId() ); } else { appendChar( (uchar)-1 ); } appendChar( (uchar)unit ); appendChar( (uchar)num1 ); appendChar( (uchar)pos2 ); appendChar( (uchar)num2 ); send(); } void AttalSocket::sendExchangeBaseUnitCl( GenericBase * base, int unit1 , GenericLord * lord2, int unit2 ) { init( (uchar)SO_EXCH, (uchar)C_EXCH_BASEUNITCL ); if( base ) { appendInt( base->getCell()->getRow() ); appendInt( base->getCell()->getCol() ); } else { appendChar( (uchar)-1 ); } appendChar( (uchar)unit1 ); if( lord2 ) { appendChar( (uchar)lord2->getId() ); } else { appendChar( (uchar)-1 ); } appendChar( (uchar)unit2 ); send(); } void AttalSocket::sendPlayerResource( char res, int nb ) { init( (uchar)SO_MODIF, (uchar)C_MOD_PLAYER, (uchar)C_PLAY_RESS ); appendChar( res ); appendInt( nb ); send(); } /* void AttalSocket::sendPlayerPopulation( uint population ) { init( (uchar)SO_MODIF, (uchar)C_MOD_PLAYER, (uchar)C_PLAY_POPUL ); appendInt( population ); send(); } */ void AttalSocket::sendPlayerPrice( char res, int price ) { init( (uchar)SO_MODIF, (uchar)C_MOD_PLAYER, (uchar)C_PLAY_PRICE ); appendChar( res ); appendInt( price ); send(); } void AttalSocket::sendAskNone( const QString & msg, uchar type ) { uint len = msg.length(); while( len > 250 ) { init( (uchar) SO_QR, (uchar) C_QR_MSG_NEXT ); appendChar( (uchar) 250 ); /// XXX: we suppose small messages for the moment for( uint i = 0; i < 250; i++ ) { appendChar( (uchar) (msg.toLatin1())[i] ); } send(); len -= 250; } init( (uchar) SO_QR, (uchar) C_QR_MSG_END ); appendChar( type ); appendChar( (uchar) len ); /// XXX: we suppose small messages for the moment for( uint i = 0; i < len; i++ ) { appendChar( (uchar) (msg.toLatin1())[i] ); } send(); } void AttalSocket::sendAskChest() { init( (uchar) SO_QR, (uchar) C_QR_CHEST ); send(); } void AttalSocket::sendAskCreatureJoin( GenericMapCreature * creature ) { init( (uchar) SO_QR, (uchar) C_QR_CREATURE_JOIN ); appendChar( creature->getRace() ); appendChar( creature->getLevel() ); appendInt( creature->getCategoryNumber() ); send(); } void AttalSocket::sendAskCreatureMercenary( GenericMapCreature * creature ) { init( (uchar) SO_QR, (uchar) C_QR_CREATURE_MERCENARY ); appendChar( creature->getRace() ); appendChar( creature->getLevel() ); appendInt( creature->getCreatureNumber() ); send(); } void AttalSocket::sendAskCreatureFlee( GenericMapCreature * creature ) { init( (uchar) SO_QR, (uchar) C_QR_CREATURE_FLEE ); appendChar( creature->getRace() ); appendChar( creature->getLevel() ); appendInt( creature->getCategoryNumber() ); send(); } void AttalSocket::sendBegGame( char nb ) { init( (uchar)SO_GAME, (uchar)C_GAME_BEGIN ); appendChar( nb ); send(); } void AttalSocket::sendGameCalendar( Calendar * calendar ) { init( (uchar)SO_GAME, (uchar)C_GAME_CALENDAR ); appendInt( (int) calendar->getDay() ); appendInt( (int) calendar->getDayNumber() ); appendInt( (int) calendar->getWeek() ); appendInt( (int) calendar->getMonth() ); appendInt( (int) calendar->getYear() ); send(); } void AttalSocket::askTavernInfo( GenericBase * base ) { init( (uchar)SO_GAME, (uchar)C_GAME_TAVERN, (uchar)C_TAVERN_INFO ); GenericCell * cell = base->getCell(); appendInt( (int) cell->getRow() ); appendInt( (int) cell->getCol() ); send(); } void AttalSocket::sendTavernInfo( uchar nb ) { init( (uchar)SO_GAME, (uchar)C_GAME_TAVERN, (uchar)C_TAVERN_INFO ); appendChar( nb ); send(); } void AttalSocket::askTavernLord( GenericBase * base, uchar numLord ) { init( (uchar)SO_GAME, (uchar)C_GAME_TAVERN, (uchar)C_TAVERN_LORD ); GenericCell * cell = base->getCell(); appendInt( (int) cell->getRow() ); appendInt( (int) cell->getCol() ); appendChar( numLord ); send(); } void AttalSocket::sendTavernLord( GenericLord * lord ) { init( (uchar)SO_GAME, (uchar)C_GAME_TAVERN, (uchar)C_TAVERN_LORD ); appendInt( lord->getId() ); /// XXX: all info must be sent send(); } void AttalSocket::sendAskLevel( char lord, char level, char primSkill, char skill1, char skill2 ) { init((uchar) SO_QR, (uchar) C_QR_LEVEL ); appendChar( (uchar) lord ); appendChar( (uchar) level ); appendChar( (uchar) primSkill ); appendChar( (uchar) skill1 ); appendChar( (uchar) skill2 ); send(); } void AttalSocket::sendLostGame( GenericPlayer * player ) { init( (uchar)SO_GAME, (uchar)C_GAME_LOST ); appendChar( player->getNum() ); send(); } void AttalSocket::sendWinGame( GenericPlayer * player ) { init( (uchar)SO_GAME, (uchar)C_GAME_WIN ); appendChar( player->getNum() ); send(); } void AttalSocket::sendEndGame() { init( (uchar)SO_GAME, (uchar)C_GAME_END ); send(); } void AttalSocket::sendGameInfoPlayerName( GenericPlayer * player ) { init( (uchar)SO_GAME, (uchar)C_GAME_INFO, (uchar)C_INFOPLAYER_NAME ); appendChar( player->getNum() ); /// XXX: add name send(); } void AttalSocket::sendGameInfoPlayerTeam( GenericPlayer * player ) { init( (uchar)SO_GAME, (uchar)C_GAME_INFO, (uchar)C_INFOPLAYER_TEAM ); appendChar( player->getNum() ); appendChar( player->getTeamId() ); send(); } void AttalSocket::sendTurnPlaying( GenericPlayer * player ) { init( (uchar)SO_TURN, (uchar)C_TURN_PLAY ); appendChar( player->getNum() ); send(); } void AttalSocket::sendLordPlTurn(int count) { init( (uchar)SO_TURN, (uchar) C_TURN_PLORD ); appendInt( count ); send(); } void AttalSocket::sendLordTurn(int flag) { init( (uchar)SO_TURN, (uchar) C_TURN_LORD ); appendInt( flag ); send(); } void AttalSocket::sendTurnEnd() { init( (uchar)SO_TURN, (uchar) C_TURN_END ); send(); } void AttalSocket::sendSizeMap( int h, int w ) { init( (uchar)SO_MODIF, (uchar) C_MOD_MAP ); appendInt( h ); appendInt( w ); send(); } void AttalSocket::sendCell( GenericCell * cell ) { init( (uchar) SO_MODIF, (uchar) C_MOD_CELL ); appendInt( (int) cell->getRow() ); appendInt( (int) cell->getCol() ); appendInt( (int) cell->getType() ); appendChar( (int) cell->getDiversification() ); appendInt( (int) cell->getTransition() ); appendInt( (int) cell->getTransitionCellType() ); appendInt( (int) cell->getDecorationGroup() ); appendInt( (int) cell->getDecorationItem() ); send(); } void AttalSocket::sendMvt( int lord, int cell_i, int cell_j ) { init( (uchar) SO_MVT, (uchar) C_MVT_ONE ); appendChar( lord ); appendInt( cell_i ); appendInt( cell_j ); send(); } void AttalSocket::sendMvts( int lord, QList & list ) { init( (uchar) SO_MVT, (uchar) C_MVT_MULTI ); appendChar( lord ); uint nbList = list.count(); appendInt( nbList ); for( uint i = 0; i < nbList; i++ ) { appendInt( list.at( i )->getRow() ); appendInt( list.at( i )->getCol() ); } send(); } void AttalSocket::sendTechnic( int lord, int numTechnic ) { init( (uchar)SO_TECHNIC ); appendInt( lord ); appendInt( numTechnic ); send(); } void AttalSocket::sendFightInit( CLASS_FIGHTER fighter, GenericLord * lord ) { init( (uchar)SO_FIGHT, (uchar)C_FIGHT_INIT ); appendChar( (uchar)fighter ); appendChar( lord->getId() ); send(); } void AttalSocket::sendFightCreature() { init( (uchar)SO_FIGHT, (uchar)C_FIGHT_CREATURE ); send(); } void AttalSocket::sendFightCell( GenericFightCell * cell ) { init( (uchar)SO_FIGHT, (uchar)C_FIGHT_CELL ); appendInt( cell->getRow() ); appendInt( cell->getCol() ); appendChar(cell->getType() ); send(); } void AttalSocket::sendFightLord( CLASS_FIGHTER, GenericLord * lord ) { /// XXX: CLASS_FIGHTER not used ? init( (uchar) SO_FIGHT, (uchar) C_FIGHT_LORD ); appendChar( (uchar) lord->getId() ); appendChar( (uchar) lord->getCharac( ATTACK ) ); appendChar( (uchar) lord->getCharac( DEFENSE ) ); send(); } void AttalSocket::sendFightNewUnit( CLASS_FIGHTER fighter, char num, GenericFightUnit * unit ) { init( (uchar) SO_FIGHT, (uchar) C_FIGHT_UNIT ); appendChar( (uchar) fighter ); appendChar( (uchar) num ); appendChar( (uchar) unit->getRace() ); appendChar( (uchar) unit->getLevel() ); appendInt( unit->getNumber() ); appendChar( (uchar) unit->getMove() ); appendInt( unit->getHealth() ); send(); } void AttalSocket::sendFightModifyUnit( CLASS_FIGHTER fighter, char num, GenericFightUnit * unit ) { init( (uchar) SO_FIGHT, (uchar) C_FIGHT_MODUNIT ); appendChar( (uchar) fighter ); appendChar( (uchar) num ); appendChar( (uchar) unit->getRace() ); appendChar( (uchar) unit->getLevel() ); appendInt( unit->getNumber() ); appendChar( (uchar) unit->getMove() ); appendInt( unit->getHealth() ); send(); } void AttalSocket::sendFightDamageUnit( CLASS_FIGHTER attacker, char numAttacker, CLASS_ATTACK_TYPE attackType, CLASS_FIGHTER defender, char numDefender, uint damage ) { init( (uchar) SO_FIGHT, (uchar) C_FIGHT_DAMAGE ); appendChar( (uchar) attacker ); appendChar( (uchar) numAttacker ); appendChar( (uchar) attackType ); appendChar( (uchar) defender ); appendChar( (uchar) numDefender ); appendInt( (int)damage ); send(); } void AttalSocket::sendFightUnitMove( CLASS_FIGHTER fighter, int num, GenericFightCell * cell ) { init( (uchar)SO_FIGHT, (uchar)C_FIGHT_MOVE ); appendChar( (uchar) fighter ); appendChar( (uchar) num ); appendInt( (int) cell->getRow() ); appendInt( (int) cell->getCol() ); send(); } void AttalSocket::sendFightUnitEndMove() { init( (uchar)SO_FIGHT, (uchar) C_FIGHT_ENDMOVE ); send(); } void AttalSocket::sendFightActivate( CLASS_FIGHTER fighter, char unit ) { init( (uchar)SO_FIGHT, (uchar)C_FIGHT_ACTIVE ); appendChar( fighter, (uchar) unit ); send(); } void AttalSocket::sendFightUnitDamage( CLASS_FIGHTER fighter, char unit, int damage ) { init( (uchar)SO_FIGHT, (uchar) C_FIGHT_DAMAGE ); appendChar( (uchar) fighter, (uchar) unit ); appendInt( damage ); send(); } void AttalSocket::sendFightDistAttack( CLASS_FIGHTER fighter, char unit ) { init( (uchar)SO_FIGHT, (uchar) C_FIGHT_DISTATTACK ); appendChar( (uchar) fighter, (uchar) unit ); send(); } void AttalSocket::sendFightWait() { init( (uchar)SO_FIGHT, (uchar) C_FIGHT_WAIT ); send(); } void AttalSocket::sendFightFlee() { init( (uchar)SO_FIGHT, (uchar) C_FIGHT_FLEE ); send(); } void AttalSocket::sendFightDefend() { init( (uchar)SO_FIGHT, (uchar) C_FIGHT_DEFEND ); send(); } void AttalSocket::sendFightEnd( FightResultStatus result ) { init( (uchar)SO_FIGHT, (uchar) C_FIGHT_END ); appendChar( result.toUChar() ); send(); } void AttalSocket::sendAnswer( char resp ) { init( SO_QR, (uchar) C_QR_ANSWER ); appendChar( (uchar) resp ); send(); } void AttalSocket::sendAnswerYesNo( bool answer ) { init( SO_QR, (uchar) C_QR_ANSWER, (uchar) ANSWER_YESNO ); appendChar( (uchar) answer ); send(); } void AttalSocket::sendAnswerEnum( char answer ) { init( SO_QR, (uchar) C_QR_ANSWER, (uchar) ANSWER_ENUM ); appendChar( (uchar) answer ); send(); } void AttalSocket::sendLordVisit( GenericLord * lord, bool state ) { init( (uchar) SO_MODIF, (uchar)C_MOD_LORD, (uchar) C_LORD_VISIT ); appendChar( lord->getOwner()->getNum() ); appendInt( lord->getCell()->getRow() ); appendInt( lord->getCell()->getCol() ); appendChar( lord->getId() ); if( state ) { appendChar( 1 ); } else { appendChar( 0 ); } send(); } void AttalSocket::sendLordNew( GenericLord * lord ) { init( (uchar)SO_MODIF, (uchar) C_MOD_LORD, (uchar) C_LORD_NEW ); if( lord->getCell() ) { appendInt( lord->getCell()->getRow() ); appendInt( lord->getCell()->getCol() ); } else { appendInt( 0 ); appendInt( 0 ); } appendChar( lord->getId() ); send(); } void AttalSocket::sendLordBuy( GenericLord * lord , uint row, uint col) { init( (uchar)SO_MODIF, (uchar) C_MOD_LORD, (uchar) C_LORD_BUY ); appendChar( (uchar) lord->getId() ); appendInt( (uint) row ); appendInt( (uint) col ); send(); } void AttalSocket::sendLordBaseCharac( GenericLord * lord, LordCharac charac ) { if( charac >= LAST ) { logEE( "sendLordCharac with unknown charac lord %p , charac %d", lord, charac ); return; } init( (uchar)SO_MODIF, (uchar) C_MOD_LORD, C_LORD_CHARAC ); appendChar( (uchar) lord->getId() ); appendChar( (uchar) charac ); appendInt( lord->getBaseCharac( charac ) ); send(); } void AttalSocket::sendLordUnits( GenericLord * lord ) { for( int i = 0; i < MAX_UNIT; i++ ) { sendLordUnit( lord, i ); } } void AttalSocket::sendLordUnit( GenericLord * lord, int num ) { GenericFightUnit * temp = lord->getUnit( num ); init( (uchar)SO_MODIF, (uchar)C_MOD_LORD, (uchar)C_LORD_UNIT ); if( temp ) { appendChar( lord->getId() ); appendChar( num ); appendChar( temp->getRace() ); appendChar( temp->getLevel() ); appendInt( temp->getNumber() ); appendChar( temp->getMove() ); appendInt( temp->getHealth() ); } else { appendChar( lord->getId() ); appendChar( num ); appendChar( 0 ); appendChar( 0 ); appendInt( 0 ); appendChar( 0 ); appendInt( 0 ); } send(); } void AttalSocket::sendLordUnit( GenericLord * lord, int num , int value) { GenericFightUnit * temp = lord->getUnit( num ); if( temp ) { init( (uchar)SO_MODIF, (uchar)C_MOD_LORD, (uchar)C_LORD_UNIT ); appendChar( lord->getId() ); appendChar( num ); appendChar( temp->getRace() ); appendChar( temp->getLevel() ); appendInt( value ); appendChar( temp->getMove() ); appendInt( temp->getHealth() ); send(); } } void AttalSocket::sendLordRemove( GenericLord * lord ) { init( (uchar) SO_MODIF, (uchar) C_MOD_LORD, (uchar) C_LORD_REMOVE ); appendChar( (uchar) lord->getId() ); send(); } void AttalSocket::sendLordGarrison( GenericLord * lord, bool state ) { init( (uchar) SO_MODIF, (uchar) C_MOD_LORD, (uchar) C_LORD_GARRISON ); appendChar( (uchar) lord->getId() ); if( state ) { appendChar( (uchar) 1 ); } else { appendChar( (uchar) 0 ); } send(); } void AttalSocket::sendLordMachine( GenericLord * lord, int id ) { init( (uchar) SO_MODIF, (uchar) C_MOD_LORD, (uchar) C_LORD_MACHINE ); appendChar( (uchar) lord->getId() ); appendChar( (uchar) id ); send(); } void AttalSocket::sendBaseNew( GenericBase * base ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_NEW ); if( base->getCell() ) { appendChar( base->getRace() ); appendInt( base->getCell()->getRow() ); appendInt( base->getCell()->getCol() ); appendInt( base->getPopulation() ); } else { appendChar( 0 ); appendInt( 0 ); appendInt( 0 ); appendInt( 0 ); } appendChar( base->getId() ); appendChar( (uchar)base->getForbiddenBuildingsNumber() ); for( uint i = 0; i < base->getForbiddenBuildingsNumber(); i++ ) { appendChar( base->getForbiddenBuilding( i ) ); } send(); } void AttalSocket::sendBaseName( GenericBase * base ) { QString name; name = base->getName(); init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_NAME ); appendInt( base->getCell()->getRow() ); appendInt( base->getCell()->getCol() ); appendInt( name.length() ); for( int i = 0; i < name.length(); i++ ) { appendChar( (uchar) (name.toLatin1())[i] ); } send(); } void AttalSocket::sendBaseOwner( GenericBase * base, GenericPlayer * player ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_OWNER ); // TODO x,y --> getId appendInt( base->getCell()->getRow() ); appendInt( base->getCell()->getCol() ); appendChar( player->getNum() ); send(); } void AttalSocket::sendBasePopulation( GenericBase * base ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_POPUL ); appendInt( base->getCell()->getRow() ); appendInt( base->getCell()->getCol() ); appendInt( base->getPopulation() ); send(); } void AttalSocket::sendBaseResource( GenericBase * base , char res, int nb ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_RESS ); appendInt( base->getCell()->getRow() ); appendInt( base->getCell()->getCol() ); appendChar( res ); appendInt( nb ); send(); } void AttalSocket::sendBaseProduction( GenericBase * base, Creature * creature ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_PRODUCTION ); appendInt( base->getCell()->getRow() ); appendInt( base->getCell()->getCol() ); appendChar( creature->getRace() ); appendChar( creature->getLevel() ); appendInt( base->getCreatureProduction( creature ) ); send(); } void AttalSocket::sendBaseBuilding( GenericBase * base, GenericInsideBuilding * building, bool create ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_BUILDING ); if( base && building ) { appendInt( base->getCell()->getRow() ); appendInt( base->getCell()->getCol() ); appendChar( building->getLevel() ); appendChar( (uchar)create ); send(); } else { logEE( "Base and Building should not be null in sendBaseBuilding" ); } } void AttalSocket::sendBuildingNew( GenericBuilding * build ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BUILD, (uchar)C_BUILD_NEW ); appendChar( build->getBuildingType() ); appendInt( build->getId() ); appendInt( build->getCell()->getRow() ); appendInt( build->getCell()->getCol() ); send(); } void AttalSocket::sendBuildingResource( GenericBuilding * build , char res, int nb ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BUILD, (uchar)C_BUILD_RESS ); appendInt( build->getCell()->getRow() ); appendInt( build->getCell()->getCol() ); appendChar( res ); appendInt( nb ); send(); } void AttalSocket::sendBaseUnit( GenericBase * base, GenericFightUnit * unit, int pos ) { if(unit){ init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_UNIT ); appendInt( base->getCell()->getRow() ); appendInt( base->getCell()->getCol() ); appendChar( pos ); appendChar( unit->getRace() ); appendChar( unit->getLevel() ); appendInt( unit->getNumber() ); send(); } } void AttalSocket::sendBaseUnit( GenericBase * base, Creature * creature, int number, int pos ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_UNIT ); appendInt( base->getCell()->getRow() ); appendInt( base->getCell()->getCol() ); appendChar( pos ); if( creature ) { appendChar( creature->getRace() ); appendChar( creature->getLevel() ); appendInt( number ); } else { //race and level are not important if not exist creature of number is 0 cause we simply destroy every unit in position pos appendChar( 0 ); appendChar( 0 ); appendInt( 0 ); } send(); } void AttalSocket::sendBaseUnitBuy( GenericBase * base, GenericFightUnit * unit ) { if(unit){ init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_UNIT_BUY ); appendInt( base->getCell()->getRow() ); appendInt( base->getCell()->getCol() ); appendChar( unit->getRace() ); appendChar( unit->getLevel() ); appendInt( unit->getNumber() ); send(); } } void AttalSocket::sendBaseUnitBuy( GenericBase * base, Creature * creature, int number ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_UNIT_BUY ); appendInt( base->getCell()->getRow() ); appendInt( base->getCell()->getCol() ); appendChar( creature->getRace() ); appendChar( creature->getLevel() ); appendInt( number ); send(); } void AttalSocket::sendBaseMarket( int ownRes, int otherRes, int valueFirstRes ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_MARKET ); appendInt( ownRes ); appendInt( otherRes ); appendInt( valueFirstRes ); send(); } void AttalSocket::sendBuildingOwner( GenericBuilding * build, GenericPlayer * player ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BUILD, (uchar)C_BUILD_OWNER ); appendInt( build->getCell()->getRow() ); appendInt( build->getCell()->getCol() ); if( player ) { appendInt( player->getNum() ); } else { appendInt( GenericPlayer::NO_PLAYER ); } send(); } /* void AttalSocket::sendNewLordArtefact( GenericLordArtefact * artefact ) { init( (uchar)SO_MODIF, (uchar)C_MOD_ARTEFACT, (uchar)C_ART_NEWLORD ); appendChar( artefact->getType() ); appendChar( artefact->getLord()->getId() ); send(); } */ void AttalSocket::sendArtefactLord( GenericLordArtefact * artefact, bool state ) { if( state ) { init( (uchar)SO_MODIF, (uchar)C_MOD_ARTEFACT, (uchar)C_ART_ADDLORD ); } else { init( (uchar)SO_MODIF, (uchar)C_MOD_ARTEFACT, (uchar)C_ART_DELLORD ); } appendInt( artefact->getType() ); appendChar( artefact->getLord()->getId() ); send(); } void AttalSocket::sendNewCreature( GenericMapCreature * creature ) { init( (uchar)SO_MODIF, (uchar)C_MOD_CREATURE, (uchar)C_CRE_NEW ); appendInt( creature->getCell()->getRow() ); appendInt( creature->getCell()->getCol() ); appendChar( creature->getRace() ); appendChar( creature->getLevel() ); appendInt( creature->getCategoryNumber() ); appendChar( (uchar)creature->isLookingRight() ); send(); } void AttalSocket::sendUpdateCreature( GenericMapCreature * creature ) { init( (uchar)SO_MODIF, (uchar)C_MOD_CREATURE, (uchar)C_CRE_UPDATE ); appendInt( creature->getCell()->getRow() ); appendInt( creature->getCell()->getCol() ); appendInt( creature->getCategoryNumber() ); send(); } void AttalSocket::sendDelCreature( GenericCell * cell ) { init( (uchar)SO_MODIF, (uchar)C_MOD_CREATURE, (uchar)C_CRE_DEL ); appendInt( cell->getRow() ); appendInt( cell->getCol() ); send(); } void AttalSocket::sendCreatureResource( GenericMapCreature * creature, char res, int nb ) { init( (uchar)SO_MODIF, (uchar)C_MOD_CREATURE, (uchar)C_CRE_RESS ); appendInt( creature->getCell()->getRow() ); appendInt( creature->getCell()->getCol() ); appendChar( res ); appendInt( nb ); send(); } void AttalSocket::sendNewEvent( GenericEvent * event ) { uint i; init( (uchar)SO_MODIF, (uchar)C_MOD_EVENT, (uchar)C_EVENT_NEW ); appendInt( event->getCell()->getRow() ); appendInt( event->getCell()->getCol() ); appendChar( event->getType() ); switch( event->getType() ) { case GenericEvent::EventArtefact: { GenericArtefact * artefact = event->getArtefact(); appendInt( artefact->getId() ); appendChar( artefact->getType() ); } break; case GenericEvent::EventBonus: { GenericBonus * bonus = event->getBonus(); appendChar( bonus->getType() ); appendChar( (uchar) bonus->getParamNumber() ); for( i = 0; i < bonus->getParamNumber(); i++ ) { appendInt( bonus->getParam( i ) ); } } break; case GenericEvent::EventChest: { GenericChest * chest = event->getChest(); appendChar( (uchar) chest->getParamNumber() ); for( i = 0; i < chest->getParamNumber(); i++ ) { appendInt( chest->getParam( i ) ); } } break; default: logEE( "Should not happen" ); break; } send(); } void AttalSocket::sendDelEvent( GenericEvent * event ) { init( (uchar)SO_MODIF, (uchar)C_MOD_EVENT, (uchar)C_EVENT_DEL ); appendInt( event->getCell()->getRow() ); appendInt( event->getCell()->getCol() ); send(); } void AttalSocket::requestBuilding( GenericBase * base, int building, bool isBuy ) { init( (uchar)SO_MODIF, (uchar)C_MOD_BASE, (uchar)C_BASE_BUILDING ); appendChar( base->getId() ); appendChar( building ); appendChar( isBuy ); send(); } attal-src-1.0-rc2/libCommon/attalSocket.h0000644000175000017500000002216210763100242016020 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalSocket.h ** socket for Attal over network ** ** Version : $Id: attalSocket.h,v 1.39 2008/03/03 22:50:10 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 31/10/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ATTALSOCKET_H #define ATTALSOCKET_H // generic include files // include files for QT #include #include // application specific include #include "libCommon/attalSocketData.h" #include "libCommon/fightResultStatus.h" #include "libCommon/genericLord.h" class Creature; class Calendar; class GenericArtefact; class GenericBase; class GenericBuilding; class GenericCell; class GenericEvent; class GenericFightCell; class GenericFightUnit; class GenericInsideBuilding; class GenericLord; class GenericLordArtefact; class GenericMapCreature; class GenericPlayer; /* ------------------------------ * AttalSocket * ------------------------------ */ class AttalSocket : public QTcpSocket,public AttalSocketData { public: /** Constructor */ AttalSocket(); ~AttalSocket(); /** Send message trough socket */ void sendMessage( QString msg ); void sendFightMessage( QString msg ); void sendConnMessage( QString msg ); /** Send connection ok */ void sendConnectionOk(); /** Send connection id */ void sendConnectionId( char id ); /** Send connection name */ void sendConnectionName( QString name ); /** Send connection player */ void sendConnectionPlayer( GenericPlayer * player ); void sendConnectionVersion( QString name ); /** Start exchange between lords */ void sendExchangeStart( GenericLord * lord1, GenericLord * lord2 ); /** Exchange 2 units between one or two lords */ void sendExchangeUnit( GenericLord * lord1, int unit1, GenericLord * lord2, int unit2 ); /** Exchange 2 artefacts between one or two lords */ void sendExchangeArtefact( GenericLord * lord1, int item, GenericLord * lord2 ); /** Exchange 2 units inside a base */ void sendExchangeBaseUnit( GenericBase * base, int unit1, GenericLord * lord2, int unit2 ); /** Split unit */ void sendExchangeUnitSplit( GenericLord * lord, int unit, int num1, int pos2, int num2 ); /** Exchange 2 units between one base and a lord */ void sendExchangeBaseLordUnit( GenericLord * lord1, int unit1, GenericLord * lord2, int unit2, uchar direction ); void sendExchangeBaseUnitCl( GenericBase * base, int unit1, GenericLord * lord2, int unit2 ); /** Send ressources of a player */ void sendPlayerResource( char res, int nb ); /** Send prices of a player */ void sendPlayerPrice( char res, int price ); //void sendPlayerPopulation( uint population ); /** Send 'Game begins' info */ void sendBegGame( char nb ); /** XXX: */ void askTavernInfo( GenericBase * base ); void sendTavernInfo( uchar nb ); void askTavernLord( GenericBase * base, uchar numLord ); void sendTavernLord( GenericLord * lord ); /** Send the 'Player lost' info */ void sendLostGame( GenericPlayer * player ); /** Send the 'Player win' info */ void sendWinGame( GenericPlayer * player ); /** Send the 'Game ends' info */ void sendEndGame(); void sendGameInfoPlayerName( GenericPlayer * player ); void sendGameInfoPlayerTeam( GenericPlayer * player ); void sendGameCalendar( Calendar * calendar); /** Send info about who's playing */ void sendTurnPlaying( GenericPlayer * player ); /** Send 'Turn ends' info */ void sendTurnEnd(); void sendLordPlTurn(int count); void sendLordTurn(int flag); /** Send the size of the map */ void sendSizeMap( int h, int w ); /** Send a cell */ void sendCell( GenericCell * cell ); /** Send a movement of a lord */ void sendMvt( int lord, int cell_i, int cell_j ); /** Send all the movements of a lord */ void sendMvts( int lord, QList & list ); /** A lord is using a technic */ void sendTechnic( int lord, int numTechnic ); /** Fight is starting */ void sendFightInit( CLASS_FIGHTER fighter, GenericLord * lord ); void sendFightCreature(); /** Send a fight cell */ void sendFightCell( GenericFightCell * cell ); void sendFightLord( CLASS_FIGHTER fighter, GenericLord * lord ); void sendFightNewUnit( CLASS_FIGHTER fighter, char num, GenericFightUnit * unit ); void sendFightModifyUnit( CLASS_FIGHTER fighter, char num, GenericFightUnit * unit ); void sendFightDamageUnit( CLASS_FIGHTER attacker, char numAttacker, CLASS_ATTACK_TYPE attackType, CLASS_FIGHTER defender, char numDefender, uint damage ); void sendFightUnitMove( CLASS_FIGHTER fighter, int num, GenericFightCell * cell ); /** End of a movement */ void sendFightUnitEndMove(); /** Activate a unit for fighting */ void sendFightActivate( CLASS_FIGHTER fighter, char unit ); /** Damages for the unit */ void sendFightUnitDamage( CLASS_FIGHTER fighter, char unit, int damage ); void sendFightDistAttack( CLASS_FIGHTER fighter, char unit ); void sendFightWait(); void sendFightFlee(); void sendFightDefend(); /** Fight ends */ void sendFightEnd( FightResultStatus result ); /** Send message of info */ void sendAskNone( const QString & msg, uchar type ); void sendAskChest(); void sendAskCreatureJoin( GenericMapCreature * creature ); void sendAskCreatureMercenary( GenericMapCreature * creature ); void sendAskCreatureFlee( GenericMapCreature * creature ); /** Ask skill when level upgrade */ void sendAskLevel( char lord, char level, char primSkill, char skill1, char skill2 ); /** Send answer to question */ void sendAnswer( char resp ); /** Send answer to enum question */ void sendAnswerYesNo( bool answer ); /** Send answer to enum question */ void sendAnswerEnum( char answer ); /** Lord is visiting */ void sendLordVisit( GenericLord * lord, bool state = true ); /** New lord */ void sendLordNew( GenericLord * lord ); /** Buy lord */ void sendLordBuy( GenericLord * lord , uint row, uint col ); void sendLordBaseCharac( GenericLord * lord, LordCharac charac ); /** Send units */ void sendLordUnits( GenericLord * lord ); /** Send unit 'num' */ void sendLordUnit( GenericLord * lord, int num ); /** Send unit 'num' */ void sendLordUnit( GenericLord * lord, int num , int value); void sendLordRemove( GenericLord * lord ); void sendLordGarrison( GenericLord * lord, bool state ); void sendLordMachine( GenericLord * lord, int id ); /** New base */ void sendBaseNew( GenericBase * base ); /** Base name */ void sendBaseName( GenericBase * base ); /** New owner for the base */ void sendBaseOwner( GenericBase * base, GenericPlayer * player ); void sendBaseBuilding( GenericBase * base, GenericInsideBuilding * building, bool create ); /** New building */ void sendBuildingNew( GenericBuilding * build ); void sendBuildingResource( GenericBuilding * build, char res, int nb ); /** New unit to base */ void sendBaseUnit( GenericBase * base, GenericFightUnit * unit, int pos ); /** New unit to base */ void sendBaseUnit( GenericBase * base, Creature * creature, int number, int pos ); /** Request to buy new unit */ void sendBaseUnitBuy( GenericBase * base, Creature * creature, int number ); /** Request to buy new unit */ void sendBaseUnitBuy( GenericBase * base, GenericFightUnit * unit ); /** Update population of a base */ void sendBasePopulation( GenericBase * base ); void sendBaseResource( GenericBase * base, char res, int nb ); /** Update production of a base */ void sendBaseProduction( GenericBase * base , Creature * creature); /** Marker value */ void sendBaseMarket( int ownRes, int otherRes, int valueFirstRes ); /** New owner for the building */ void sendBuildingOwner( GenericBuilding * build, GenericPlayer * player ); /** New artefact */ //void sendNewLordArtefact( GenericLordArtefact * artefact ); void sendArtefactLord( GenericLordArtefact * artefact, bool state ); /** new creature on map */ void sendNewCreature( GenericMapCreature * creature ); /** updates creature on map */ void sendUpdateCreature( GenericMapCreature * creature ); /** delete creature of map */ void sendDelCreature( GenericCell * cell ); void sendCreatureResource( GenericMapCreature * creature, char res, int nb ); /** new event on map */ void sendNewEvent( GenericEvent * event ); /** delete event on map */ void sendDelEvent( GenericEvent * event ); // Request client -> server void requestBuilding( GenericBase * base, int building, bool isBuy); void readData(); AttalSocketData readBufferData(); protected: virtual void send(); private: void internalSendMessage( QString msg ); }; #endif // ATTALSOCKET_H attal-src-1.0-rc2/libCommon/attalSocketData.cpp0000644000175000017500000000424510671321061017151 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalSocketData.cpp ** socket data for Attal over network ** ** Version : $Id: attalSocketData.cpp,v 1.2 2007/09/10 19:59:45 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 31/10/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "attalSocketData.h" // generic include files //#include // include files for QT // application specific includes // // ----- AttalSocketData ----- // AttalSocketData::AttalSocketData() { _lenOut = 4; _lenIn = 3; } AttalSocketData::~AttalSocketData() { } void AttalSocketData::init( uchar c1, uchar c2, uchar c3 ) { _bufOut[1] = c1; _bufOut[2] = c2; _bufOut[3] = c3; } void AttalSocketData::appendInt( int i ) { memcpy( _bufOut + _lenOut, &i, 4 ); _lenOut += 4; } void AttalSocketData::appendChar( unsigned char c ) { _bufOut[_lenOut] = c; _lenOut++; } void AttalSocketData::reReadData() { _lenIn = 3; } int AttalSocketData::readInt() { int ret; memcpy( &ret, _bufIn + _lenIn, 4 ); _lenIn += 4; return ret; } unsigned char AttalSocketData::readChar() { unsigned char ret = _bufIn[_lenIn]; _lenIn++; return ret; } void AttalSocketData::setData( AttalSocketData * data ) { for( int i = 0; i < 256; i++ ) { _bufIn[i] = data->_bufIn[i]; _bufOut[i] = data->_bufOut[i]; } _lenIn = data->_lenIn; _lenOut = data->_lenOut; } AttalSocketData AttalSocketData::getData() { AttalSocketData data; for( int i = 0; i < 256; i++ ) { data._bufIn[i] = _bufIn[i]; data._bufOut[i] = _bufOut[i]; } data._lenIn = _lenIn; data._lenOut = _lenOut; return data; } attal-src-1.0-rc2/libCommon/attalSocketData.h0000644000175000017500000001126010763100242016607 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalSocketData.h ** socket data for Attal over network ** ** Version : $Id: attalSocketData.h,v 1.11 2008/03/03 22:50:10 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 31/10/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ATTALSOCKETDATA_H #define ATTALSOCKETDATA_H // generic include files // include files for QT // application specific include #include "libCommon/log.h" /* ------------------------------ * AttalSocketData * ------------------------------ */ enum SOCKET_CLASS { SO_MSG, // C-S : For messages (chat) SO_CONNECT, // C-S SO_MVT, // C-S SO_TECHNIC, // C-S SO_FIGHT, // C-S SO_QR, // C-S SO_EXCH, // C-S SO_MODIF, // C-S SO_TURN, // C-S SO_GAME // C-S }; enum CLASS_MVT { C_MVT_ONE, C_MVT_MULTI }; enum CLASS_MODIF { C_MOD_MAP, C_MOD_CELL, C_MOD_PLAYER, C_MOD_LORD, C_MOD_BASE, C_MOD_BUILD, C_MOD_ARTEFACT, C_MOD_CREATURE, C_MOD_EVENT }; enum CLASS_CONNECT { C_CONN_OK, C_CONN_ID, C_CONN_NAME, C_CONN_VERSION, C_CONN_PLAYER }; enum CLASS_MSG { C_MSG_NORM, C_MSG_FIGHT, C_MSG_CONN }; enum CLASS_EXCH { C_EXCH_START, C_EXCH_UNIT, C_EXCH_ARTEFACT, C_EXCH_BASEUNIT, C_EXCH_BASEUNITCL, C_EXCH_UNIT_SPLIT }; enum CLASS_QR { C_QR_MSG_NEXT, C_QR_MSG_END, C_QR_LEVEL, C_QR_CHEST, C_QR_QUEST, C_QR_CREATURE_FLEE, C_QR_CREATURE_MERCENARY, C_QR_CREATURE_JOIN, C_QR_ANSWER }; enum CLASS_PLAYER { C_PLAY_RESS, C_PLAY_PRICE //C_PLAY_POPUL }; enum CLASS_LORD { C_LORD_VISIT, C_LORD_NEW, C_LORD_BUY, C_LORD_UNIT, C_LORD_REMOVE, C_LORD_GARRISON, C_LORD_MACHINE, C_LORD_CHARAC }; enum CLASS_BASE { C_BASE_NEW, C_BASE_OWNER, C_BASE_NAME, C_BASE_BUILDING, C_BASE_UNIT, C_BASE_UNIT_BUY, C_BASE_MARKET, C_BASE_POPUL, C_BASE_RESS, C_BASE_PRODUCTION }; enum CLASS_BUILD { C_BUILD_NEW, C_BUILD_OWNER, C_BUILD_RESS }; enum CLASS_FIGHT { C_FIGHT_INIT, C_FIGHT_CREATURE, C_FIGHT_LORD, C_FIGHT_CELL, C_FIGHT_UNIT, C_FIGHT_MODUNIT, C_FIGHT_MOVE, C_FIGHT_ENDMOVE, C_FIGHT_ACTIVE, C_FIGHT_DISTATTACK, C_FIGHT_WAIT, C_FIGHT_FLEE, C_FIGHT_DEFEND, C_FIGHT_DAMAGE, C_FIGHT_END, }; enum CLASS_TURN { C_TURN_PLAY, C_TURN_END, C_TURN_LORD, C_TURN_PLORD }; enum CLASS_GAME { C_GAME_BEGIN, C_GAME_LOST, C_GAME_WIN, C_GAME_END, C_GAME_INFO, C_GAME_TAVERN, C_GAME_CALENDAR }; enum CLASS_FIGHTER { FIGHTER_ATTACK, FIGHTER_DEFENSE }; enum CLASS_ATTACK_TYPE { ATTACK_SHOOT, ATTACK_FIGHT }; enum CLASS_ANSWER { ANSWER_YESNO, ANSWER_ENUM }; enum CLASS_GAME_INFO { C_INFOPLAYER_TEAM, C_INFOPLAYER_NAME }; enum CLASS_GAME_TAVERN { C_TAVERN_INFO, C_TAVERN_LORD }; enum CLASS_ARTEFACT { C_ART_DELLORD, C_ART_ADDLORD }; enum CLASS_CREATURE { C_CRE_NEW, C_CRE_UPDATE, C_CRE_RESS, C_CRE_DEL }; enum CLASS_EVENT { C_EVENT_NEW, C_EVENT_DEL }; enum CLASS_ANALYST { C_ANALYST_NEXT_LORD, C_ANALYST_SAME_LORD }; enum QR_TYPE { QR_SCEN_DESC, QR_INFO }; class AttalSocketData { public: /** Constructor */ AttalSocketData(); ~AttalSocketData(); uchar getCla1() { return _bufIn[0]; } uchar getCla2() { return _bufIn[1]; } uchar getCla3() { return _bufIn[2]; } int readInt(); unsigned char readChar(); void reReadData(); void setData( AttalSocketData * data ); AttalSocketData getData(); void printIn(); void printOut(); char _bufIn[256], _bufOut[256] ; int _lenIn, _lenOut; protected: void appendInt( int ); void appendChar( unsigned char ); void appendChar( uchar c1, uchar c2 ) { appendChar( c1 ); appendChar( c2 ); } void appendChar( uchar c1, uchar c2, uchar c3 ) { appendChar( c1 ); appendChar( c2 ); appendChar( c3 ); } void appendChar( uchar c1, uchar c2, uchar c3, uchar c4 ) { appendChar( c1, c2 ); appendChar( c3, c4 ); } void appendChar( uchar c1, uchar c2, uchar c3, uchar c4, uchar c5 ) { appendChar( c1, c2, c3, c4 ); appendChar( c5 ); } void appendChar( uchar c1, uchar c2, uchar c3, uchar c4, uchar c5, uchar c6 ) { appendChar( c1, c2 ); appendChar( c3, c4 ); appendChar( c5, c6 ); } void init( uchar c1, uchar c2 = 0, uchar c3 = 0 ); }; #endif // ATTALSOCKETDATA_H attal-src-1.0-rc2/libCommon/attalTemplates.h0000644000175000017500000000202210747742611016535 0ustar aaaa/**************************************************************** ** ** attal : lords of doom ** ** attalTemplates.h ** some useful templates ** ** version : $id: engine.cpp,v 1.109 2008/01/16 23:19:58 lusum exp $ ** ** author(s) : sardi carlo ** ** date : 22/01/2008 ** ** licence : ** this program is free software; you can redistribute it and/or modify ** it under the terms of the gnu general public license as published by ** the free software foundation; either version 2, or (at your option) ** any later version. ** ** this program is distributed in the hope that it will be useful, ** but without any warranty; without even the implied warranty of ** merchantability or fitness for a particular purpose. see the ** gnu general public license for more details. ** ****************************************************************/ template void socketModifRess( T * obj , AttalSocket * socket ) { char ress = socket->readChar(); if( obj ) obj->getResourceList()->setValue( ress, socket->readInt() ); } attal-src-1.0-rc2/libCommon/calendar.cpp0000644000175000017500000001414510605441452015656 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** calendar.cpp ** class for managing days, weeks, months ** ** Version : $Id: calendar.cpp,v 1.21 2007/04/06 12:55:06 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 02/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ // generic include files // include files for QT #include // application specific include files #include "calendar.h" #include "libCommon/dataTheme.h" /** add comments here */ Calendar::Calendar() :_day( 0 ), _week( 1 ), _month( 1 ), _year( 1044 ), _turn ( 0 ) { } void Calendar::reinit() { _day = 0; _daynum = 0; _month = 1; _week = 1; _year = 1044; _turn = 0; } void Calendar::newDay() { _day++; _daynum++; _turn++; if( _day > FIRST_LEVEL ) { _day = 1; _week++; } if( _week > SECOND_LEVEL ) { _week = 1; _month++; _daynum = 1; } if( _month > THIRD_LEVEL ) { _month = 1; _year++; } emit sig_changed(); } uint Calendar::getCurrentAbsoluteDate() { uint absoluteDate; absoluteDate = getAbsoluteDate( _day , _week , _month , _year); return absoluteDate; } uint Calendar::getStartAbsoluteDate() { uint absoluteDate; absoluteDate = getAbsoluteDate( _startday , _startweek , _startmonth , _startyear); return absoluteDate; } uint Calendar::getAbsoluteDate( uint day, uint week, uint month, uint year ) { uint absoluteDate = 0; absoluteDate = day + ( week * 7 ) + ( month * 4 * 7 ) + year * 365; return absoluteDate; } QString Calendar::getDate() { CalendarModel * tmpCal = DataTheme.general.getCalendar(); Q_CHECK_PTR(tmpCal); //return ""; return tmpCal->getLevelName(0,(_day-1)) + QString( ", %1 " ).arg( _daynum ) + tmpCal->getLevelName(2,(_month-1)) + QString( ", %1 " ).arg( _year ); } QString Calendar::getDayName() { CalendarModel * tmpCal = DataTheme.general.getCalendar(); Q_CHECK_PTR(tmpCal); return tmpCal->getLevelName(0,(_day-1)); } void Calendar::setDateByType(uint type, uint value) { switch(type) { case 0: if (value <= FIRST_LEVEL ) _day = value ; break; case 1: _daynum = value; break; case 2: if (value <= SECOND_LEVEL ) _week = value; break; case 3: if (value <= THIRD_LEVEL ) _month = value; break; case 4: _year = value; break; default: break; } //date is set before initial date, so when initial date is set, a valid data is present setInitialDateByType(type, value); } void Calendar::setInitialDateByType(uint type, uint value) { switch(type) { case 0: if (value <= FIRST_LEVEL ) _startday = value ; break; case 1: _startdaynum = value; break; case 2: if (value <= SECOND_LEVEL ) _startweek = value; break; case 3: if (value <= THIRD_LEVEL ) _startmonth = value; break; case 4: _startyear = value; break; default: break; } } uint Calendar::getDateByType( uint type ) { switch(type) { case 0: return _day; break; case 1: return _daynum; break; case 2: return _week; break; case 3: return _month; break; case 4: return _year; break; default: logEE( "Error, unknow type of date" ); return _day; break; } } uint Calendar::getInitialDateByType( uint type ) { switch(type) { case 0: return _startday; break; case 1: return _startdaynum; break; case 2: return _startweek; break; case 3: return _startmonth; break; case 4: return _startyear; break; default: logEE( "Error, unknow type of date" ); return _startday; break; } } void Calendar::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; for( uint i = 0; i < 5; i++ ) { indentation( ts, indent + 1 ); *ts << ""; *ts << getDateByType( i ) << "" << endl; } indentation( ts, indent + 1 ); *ts << "" << endl; for( uint i = 0; i < 5; i++ ) { indentation( ts, indent + 2 ); *ts << ""; *ts << getInitialDateByType( i ) << "" << endl; } indentation( ts, indent + 1 ); *ts << "" << endl; indentation( ts, indent + 1 ); *ts << "" << getTurn() << "" << endl; indentation( ts, indent ); *ts << "" << endl; *ts << flush; } // // ----- CalendarModel ----- // CalendarModel::CalendarModel() { _name = 0; _level[0] = 7; _level[1] = 4; _level[2] = 12; _name = new QVector(MAX_NAME * MAX_LEVEL); } CalendarModel::~CalendarModel() { if (_name) { for (int i = 0; i < _name->size(); ++i) { QString * ptr = _name->at(i); (*_name)[i] = 0; delete ptr; } delete _name; _name = 0; } } QString CalendarModel::getLevelName (uint level, uint num ) { if( level < MAX_LEVEL){ if( num < _level[level] ) { if( _name->at( level * MAX_NAME + num ) ) { //logDD(" level %d, num %d",level,num); //logDD("name %s",_name->at(level * 30 +num)->toLatin1()); return *_name->at(level * MAX_NAME +num); } } } return ""; } void CalendarModel::setLevelName (uint level, uint num, const QString & name ) { //logDD("level %d, num %d",level,num); //logDD("name %s",_name->at(level * 30 +num)->toLatin1()); if( ( level < MAX_LEVEL ) && ( name != "" ) ) { if( num < _level[level] ) { int tmp = level * MAX_NAME + num; if((*_name)[tmp]) { delete (*_name)[tmp]; } (*_name)[ tmp ] = new QString(name); } } } uint CalendarModel::getLevelValue( uint level) { if( level < MAX_LEVEL) return _level[level]; return 0; } void CalendarModel::setLevelValue( uint level, uint value ) { if( level < MAX_LEVEL) _level[level] = value; } attal-src-1.0-rc2/libCommon/calendar.h0000644000175000017500000000674510605441452015332 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** calendar.h ** class for managing days, weeks, months ** ** Version : $Id: calendar.h,v 1.17 2007/04/06 12:55:06 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 02/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CALENDAR_H #define CALENDAR_H // generic include files // include files for QT #include #include // application specific include files #define FIRST_LEVEL 7 #define SECOND_LEVEL 4 #define THIRD_LEVEL 12 #define MAX_NAME 30 #define MAX_LEVEL 3 class QTextStream; /* ------------------------------ * Calendar * ------------------------------ */ /** comment for the class */ class Calendar : public QObject { Q_OBJECT public: /** Constructor */ Calendar(); /** Set date before first day (first week, first month) */ void reinit(); /** Go to next day */ void newDay(); /** Return the current day */ uint getDay() { return _day; } /** Return the current number of day */ uint getDayNumber() { return _daynum; } /** Return the current week */ uint getWeek() { return _week; } /** Return the current month */ uint getMonth() { return _month; } /** Return the current year */ uint getYear() { return _year; } /** Set the current day */ void setDay(uint day) { if (day <= FIRST_LEVEL ) _day = day ;} /** Set the current day number */ void setDayNumber(uint daynum) { _daynum = daynum; } /** Set the current week */ void setWeek(uint week) { if (week <= SECOND_LEVEL ) _week = week; } /** Set the current month */ void setMonth(uint month) { if (month <= THIRD_LEVEL ) _month = month; } /** Set the current year */ void setYear(uint year) { _year = year; } //set and get current date void setDateByType(uint type, uint value); uint getDateByType(uint type); //set and get starting scenario date void setInitialDateByType(uint type, uint value); uint getInitialDateByType( uint type ); QString getDate(); QString getDayName(); int getTurn() { return _turn; } void setTurn( uint turn ) { _turn = turn; } uint getCurrentAbsoluteDate(); uint getStartAbsoluteDate(); static uint getAbsoluteDate( uint day, uint week, uint month, uint year ); void save( QTextStream * ts, int indent ); signals: /** Signal when date change */ void sig_changed(); private: uint _day, _daynum, _week, _month, _year, _turn; uint _startday, _startweek, _startmonth, _startyear, _startdaynum; }; /** comment for the class */ class CalendarModel { public: /** Constructor */ CalendarModel(); /** Destructor */ virtual ~CalendarModel(); QString getLevelName(uint level, uint num); void setLevelName(uint level, uint num, const QString & name); uint getLevelValue(uint level); void setLevelValue( uint level , uint value ); protected: uint _level[3]; QVector * _name; }; #endif // CALENDAR_H attal-src-1.0-rc2/libCommon/campaign.cpp0000644000175000017500000001106710531030057015655 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** campaign.cpp ** manage campaign ** ** Version : $Id: campaign.cpp,v 1.1 2006/11/22 11:10:39 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 21/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "campaign.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/log.h" // // ----- Campaign ----- // Campaign::Campaign() { _current = 0; } Campaign::~Campaign() { } uint Campaign::getScenarioNumber() { return _listScenarii.count(); } void Campaign::addScenario( const QString & scenarioName ) { _listScenarii.append( scenarioName ); } void Campaign::clearScenarii() { _listScenarii.clear(); } QString Campaign::getScenario( uint num ) { QString ret = ""; if( (int)num < _listScenarii.count() ) { ret = _listScenarii.at(num); } return ret; } void Campaign::save( QTextStream * ts ) { (*ts) << "" << endl; (*ts) << "" << endl; (*ts) << "\t" << _name << "" << endl; (*ts) << "\tmedieval" << endl; (*ts) << "\t" << endl; (*ts) << "\t\t" << _description << endl; (*ts) << "\t" << endl; (*ts) << "\t" << _current << "" << endl; for( int i = 0; i < _listScenarii.count(); i++ ) { (*ts) << "\t" << _listScenarii.at( i ) << "" << endl; } (*ts) << "" << endl; } // // ----- CampaignParser ----- // CampaignParser::CampaignParser( Campaign * campaign ) { _campaign = campaign; } bool CampaignParser::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _state = StateInit; return true; } bool CampaignParser::startElement( const QString & /* namespaceURI */, const QString & /* localName */, const QString & qName, const QXmlAttributes & /* atts */ ) { bool ret = true; if( qName == "campaign" && _state == StateInit ) { _state = StateDocument; } else if( qName == "name" && _state == StateDocument ) { _state = StateName; } else if( qName == "description" && _state == StateDocument ) { _state = StateDescription; } else if( qName == "current" && _state == StateDocument ) { _state = StateCurrent; } else if( qName == "theme" && _state == StateDocument ) { _state = StateTheme; } else if( qName == "scenario" && _state == StateDocument ) { _state = StateScenario; } else { logEE( "Not found %s", qName.toLatin1().constData() ); return false; } return ret; } bool CampaignParser::endElement( const QString & /* namespaceURI */, const QString & /* localName */, const QString & /* qName */ ) { bool ret = true; switch ( _state ) { case StateName: _state = StateDocument; break; case StateDescription: _state = StateDocument; break; case StateCurrent: _state = StateDocument; break; case StateTheme: _state = StateDocument; break; case StateScenario: _state = StateDocument; break; default: break; } return ret; } bool CampaignParser::characters( const QString & ch ) { bool ret = true; QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) { return true; } switch( _state ) { case StateName: _campaign->setName( ch_simplified ); break; case StateDescription: _campaign->setDescription( ch_simplified ); break; case StateCurrent: _campaign->setCurrentScenario( ch_simplified.toInt() ); break; case StateTheme: _campaign->setTheme( ch_simplified ); break; case StateScenario: _campaign->addScenario( ch_simplified ); break; default: ret = false; } return ret; } bool CampaignParser::fatalError( const QXmlParseException & exception ) { logEE( "state %d", _state ); _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/campaign.h0000644000175000017500000000616410531031540015322 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** campaign.h ** manage campaign ** ** Version : $Id: campaign.h,v 1.1 2006/11/22 11:24:16 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 21/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CAMPAIGN_H #define CAMPAIGN_H // generic include files // include files for QT #include #include #include // application specific include files class QTextStream; /* ------------------------------ * Campaign * ------------------------------ */ class Campaign { public: /** Constructor */ Campaign(); /** Destructor */ virtual ~Campaign(); void setName( const QString & name ) { _name = name; } const QString & getName() { return _name; } void setDescription( const QString & desc ) { _description = desc; } const QString & getDescription() { return _description; } void setTheme( const QString & theme ) { _theme = theme; } const QString & getTheme() { return _theme; } uint getScenarioNumber(); uint getCurrentScenario() { return _current; } void setCurrentScenario(uint current) { _current = current; } void addScenario( const QString & scenarioName ); QString getScenario( uint num ); void clearScenarii(); void save( QTextStream * ts ); protected: QString _name, _description, _theme; QList _listScenarii; uint _current; }; /* ------------------------------ * CampaignParser * ------------------------------ */ class CampaignParser : public QXmlDefaultHandler { public: /** Constructor */ CampaignParser( Campaign * campaign ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: Campaign * _campaign; QString _errorProt; enum State { StateInit, StateDocument, StateName, StateDescription, StateCurrent, StateTheme, StateScenario }; State _state; }; #endif // CAMPAIGN_H attal-src-1.0-rc2/libCommon/categoryManager.cpp0000644000175000017500000001454210522705151017213 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** categoryManager.cpp ** Manages category for number of creatures ** ** Version : $Id: categoryManager.cpp,v 1.9 2006/11/03 18:28:57 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 16/09/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "categoryManager.h" // generic include files #include // include files for QT #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/genericPlayer.h" #include "libCommon/log.h" extern QString DATA_PATH; // // ----- CategoryManager ----- // CategoryManager::CategoryManager() { _max = "Maximum"; //_list.setAutoDelete( true ); } CategoryManager::~CategoryManager() { } int CategoryManager::count() { return _list.count() + 1; } int CategoryManager::getCategoryLimit( uchar num ) { int ret = -1; if( num < _list.count() ) { ret = _list.at( num )->getNumber(); } return ret; } QString CategoryManager::getCategoryName( uchar num ) { QString ret = _max; if( num < _list.count() ) { ret = _list.at( num )->getCategory(); } return ret; } int CategoryManager::getRandomInCategory( uchar num ) { int ret = 0; if( num < _list.count() ) { int min = 0; if( num > 0 ) { min = _list.at( num-1 )->getNumber(); } int max = _list.at( num )->getNumber(); int delta = max - min; ret = 1 + min + ( rand() % delta ); } else { ret = _list.last()->getNumber(); } return ret; } void CategoryManager::addCategory( QString name, int val ) { bool inserted = false; for( int i = 0; i < _list.count(); i++ ) { if( ( val < _list.at( i )->getNumber() ) && (! inserted ) ) { _list.insert( i, new CategoryNumber( name, val ) ); inserted = true; } } if( ! inserted ) { _list.append( new CategoryNumber( name, val ) ); } } void CategoryManager::addMaxCategory( QString name ) { _max = name; } int CategoryManager::computeCategory( int val ) { int ret = 0; bool found = false; for( int i = 0; i < _list.count(); i++ ) { if( ( val < _list.at( i )->getNumber() ) && ( ! found ) ) { ret = i; found = true; } } if( ! found ) { ret = _list.count(); } return ret; } bool CategoryManager::init() { clear(); CategoryHandler handler( this ); QFile file( DATA_PATH + "categories.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "categories.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } void CategoryManager::clear() { while (!_list.isEmpty()) delete _list.takeFirst(); _max = "Maximum"; } bool CategoryManager::save() { QString filename = DATA_PATH + "categories.dat"; QFile file( filename ); if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writng\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; for( int i = 0; i < _list.count(); i++ ) { CategoryNumber * category = _list.at( i ); ts << "\t" << endl; ts << "\t\t" << category->getCategory() << "" << endl; ts << "\t\t" << category->getNumber() << "" << endl; ts << "\t" << endl; } ts << "\t" << endl; ts << "\t\t" << _max << "" << endl; ts << "\t" << endl; ts << "" << endl; file.close(); return true; } // // ----- CategoryNumber ----- // CategoryManager::CategoryNumber::CategoryNumber( QString name, int val ) { _category = name; _number = val; } // // ----- CategoryHandler ----- // CategoryHandler::CategoryHandler( CategoryManager * category ) { _category = category; } bool CategoryHandler::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _category->clear(); _state = StateInit; return true; } bool CategoryHandler::startElement( const QString &, const QString &, const QString& qName, const QXmlAttributes& atts ) { if( qName == "categories" && _state == StateInit ) { _state = StateDocument; } else if ( qName == "category" && _state == StateDocument ) { _state = StateCategory; if( atts.value( "type" ) == "max" ) { _isMax = true; } else { _isMax = false; } _value = 0; _name = ""; } else if ( qName == "name" && _state == StateCategory ) { _state = StateName; } else if ( qName == "value" && _state == StateCategory ) { _state = StateValue; } else { // error return false; } return true; } bool CategoryHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateCategory: _state = StateDocument; if( _isMax ) { _category->addMaxCategory( _name ); } else { _category->addCategory( _name, _value ); } break; case StateName: _state = StateCategory; break; case StateValue: _state = StateCategory; break; default: // do nothing break; } return true; } bool CategoryHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) return true; switch( _state ) { case StateName: _name = ch_simplified; break; case StateValue: _value = ch_simplified.toInt(); break; default: return false; } return true; } bool CategoryHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/categoryManager.h0000644000175000017500000000721210401044117016646 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** categoryManager.h ** Manages category for number of creatures ** ** Version : $Id: categoryManager.h,v 1.4 2006/02/28 12:55:43 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 16/09/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CATEGORYMANAGER_H #define CATEGORYMANAGER_H // generic include files // include files for QT #include #include #include // application specific include files /** ------------------------------ * CategoryManager ** ------------------------------ */ class CategoryManager { public: /** Constructor */ CategoryManager(); virtual ~CategoryManager(); bool init(); void clear(); bool save(); /** \return Returns the nb of category */ int count(); /** \return Returns the upper limit of the category, or -1 if max category */ int getCategoryLimit( uchar num ); /** \return Returns the name of the category 'num' */ QString getCategoryName( uchar num ); /** \return Computes a random number in the category 'num' */ int getRandomInCategory( uchar num ); /** Adds a new category with a name and an upper limit */ void addCategory( QString name, int val ); /** Sets the name of the max category */ void addMaxCategory( QString name ); /** \return Compute the category of this number of creatures */ int computeCategory( int val ); protected: /** class for managing numbers in category */ class CategoryNumber { public: /** Constructor */ CategoryNumber( QString name = "", int val = 0 ); /** \return Returns the nb */ int getNumber() { return _number; } /** Sets the nb */ void setNumber( int number ) { _number = number; } /** \return Returns the category name */ QString getCategory() { return _category; } /** Sets the category name */ void setCategory( QString category ) { _category = category; } protected: int _number; QString _category; }; QString _max; QList _list; }; /** Parser for CategoryManager */ class CategoryHandler : public QXmlDefaultHandler { public: /** this is the construtor */ CategoryHandler( CategoryManager * list ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: QString _errorProt; CategoryManager * _category; bool _isMax; QString _name; int _value; enum State { StateInit, StateDocument, StateCategory, StateName, StateValue }; State _state; }; #endif // CATEGORYMANAGER_H attal-src-1.0-rc2/libCommon/condition.cpp0000644000175000017500000000210207673141257016074 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** condition.cpp ** Manage condition for events/enter building ** ** Version : $Id: condition.cpp,v 1.1.1.1 2003/06/15 19:02:07 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 23/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "condition.h" // generic include files // include files for QT // application specific include files /** add comments here */ Condition::Condition() { /// XXX: to change... _state = true; } attal-src-1.0-rc2/libCommon/condition.h0000644000175000017500000000256107673141257015552 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** condition.h ** Manage condition for events/enter building ** ** Version : $Id: condition.h,v 1.1.1.1 2003/06/15 19:02:07 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 23/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CONDITION_H #define CONDITION_H // generic include files // include files for QT // application specific include files /* ------------------------------ * Condition * ------------------------------ */ /** comment for the class */ class Condition { public: /** Constructor */ Condition(); bool isValidated() { return _state; } void setValidated( bool state ) { _state = state; } private: bool _state; }; #endif // CONDITION_H attal-src-1.0-rc2/libCommon/creature.cpp0000644000175000017500000005204510620345321015713 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** template.cpp ** this is a template for all .cpp files ** ** Version : $Id: creature.cpp,v 1.32 2007/05/09 13:21:21 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/09/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "creature.h" // generic include files // include files for QT // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/genericFightCell.h" #include "libCommon/log.h" extern QString DATA_PATH; Creature::CreatureAnimation::CreatureAnimation( CreatureAnimationType type, uint first, uint last ) : _type( type ), _first( first ), _last( last ) { } // // ----- Creature ----- // Creature::Creature() : _ptAttack ( 0 ), _ptDefense ( 0 ), _maxHealth ( 0 ), _maxMove ( 0 ), _distAttack( 0 ), _minDamages( 0 ), _maxDamages( 0 ), _morale ( 0 ), _luck ( 0 ), _size( 1 ), _numFrames ( 0 ), _XOffset ( 0 ), _XOffsetMirror ( 0 ), _YOffset ( 0 ) { _name = ""; _building = ""; _race = 0; _level = 0; for( int i = 0; i < MAX_RESS; i++ ) { _cost[i] = 0; _mcost[i] = 0; } } Creature::~Creature() { while( ! _animations.isEmpty() ) { delete _animations.takeFirst(); } } uint Creature::getCost( uint res ) { uint ret = 0; if( (int)res < DataTheme.resources.count() ) { ret = _cost[res]; } return ret; } void Creature::setCost( uint res, uint cost ) { if( (int)res < DataTheme.resources.count() ) { _cost[res] = cost; } } uint Creature::getMantCost( uint res ) { uint ret = 0; if( (int)res < DataTheme.resources.count() ) { ret = _mcost[res]; } return ret; } void Creature::setMantCost( uint res, uint cost ) { if( (int)res < DataTheme.resources.count() ) { _mcost[res] = cost; } } void Creature::setAnimation( CreatureAnimationType type, uint first, uint last ) { Creature::CreatureAnimation * animation = 0; animation = new Creature::CreatureAnimation( type, first, last ); _animations.append( animation ); } int Creature::getFirstAnimationFrame( CreatureAnimationType type ) { int ret = -1; uint nbAnim = _animations.count(); Creature::CreatureAnimation * animation; for( uint i = 0; i < nbAnim; i++ ) { animation = _animations.at( i ); if( animation->getType() == type ) { // frames of attalSprite start by 0 , frames in theme data start by 1 ret = animation->getFirst() - 1; break; } } return ret; } int Creature::getLastAnimationFrame( CreatureAnimationType type ) { int ret = _numFrames; uint nbAnim = _animations.count(); Creature::CreatureAnimation * animation; for( uint i = 0; i < nbAnim; i++ ) { animation = _animations.at( i ); if( animation->getType() == type ) { // frames of attalSprite start by 0 , frames in theme data start by 1 ret = animation->getLast() - 1; break; } } return ret; } int Creature::getNumberAnimationFrame( CreatureAnimationType type ) { int ret = 0; uint nbAnim = _animations.count(); Creature::CreatureAnimation * animation; for( uint i = 0; i < nbAnim; i++ ) { animation = _animations.at( i ); if( animation->getType() == type ) { ret = animation->getLast() - animation->getFirst() + 1; break; } } return ret; } void Creature::save( QTextStream & ts, int indent ) { uint nbAnim = _animations.count(); indentation( &ts, indent ); ts << "" << endl; indentation( &ts, indent ); ts << "\t" << getAttack() << "" << endl; indentation( &ts, indent ); ts << "\t" << getDefense() << "" << endl; indentation( &ts, indent ); ts << "\t" << getDistAttack() << "" << endl; indentation( &ts, indent ); ts << "\t" << getMinDamages() << "" << endl; indentation( &ts, indent ); ts << "\t" << getMaxDamages() << "" << endl; indentation( &ts, indent ); ts << "\t" << getMaxHealth() << "" << endl; indentation( &ts, indent ); ts << "\t" << getMaxMove() << "" << endl; indentation( &ts, indent ); ts << "\t" << getMorale() << "" << endl; indentation( &ts, indent ); ts << "\t" << getLuck() << "" << endl; indentation( &ts, indent ); ts << "\t" << getSize() << "" << endl; indentation( &ts, indent ); ts << "\t" << endl; Creature::CreatureAnimation * animation; for( uint k = 0; k < nbAnim; k++ ) { indentation( &ts, indent+2 ); animation = _animations.at( k ); ts << "<" << getAnimationTypeName( animation->getType() ); ts << " first=\"" << animation->getFirst() << "\""; ts << " last=\"" << animation->getLast() << "\">"; ts << "getType() ) << ">" << endl; } indentation( &ts, indent ); ts << "\t" << endl; indentation( &ts, indent ); ts << "\t" << getXOffset() << "" << endl; indentation( &ts, indent ); ts << "\t" << getXOffsetMirror() << "" << endl; indentation( &ts, indent ); ts << "\t" << getYOffset() << "" << endl; for( int k = 0; k < DataTheme.resources.count(); k++ ) { if( getCost( k ) > 0 ) { indentation( &ts, indent ); ts << "\t"; ts << getCost( k ) << "" << endl; } } for( int k = 0; k < DataTheme.resources.count(); k++ ) { if( getMantCost( k ) > 0 ) { indentation( &ts, indent ); ts << "\t"; ts << getMantCost( k ) << "" << endl; } } indentation( &ts, indent ); ts << "" << endl; ts << flush; } QString Creature::getAnimationTypeName( CreatureAnimationType type ) { QString ret; switch( type ) { case Moving: ret = "moving"; break; case Fighting: ret = "fighting"; break; case Shooting: ret = "shooting"; break; case ShootHigh: ret = "shoothigh"; break; case ShootLow: ret = "shootlow"; break; case Defending: ret = "defending"; break; case StartMoving: ret = "startmoving"; break; case EndMoving: ret = "endmoving"; break; case Dying: ret = "dying"; break; case Dead: ret = "dead"; break; case AttackHigh: ret = "attackhigh"; break; case AttackLow: ret = "attacklow"; break; case Selecting: ret = "selecting"; break; } return ret; } // // ----- CreatureStack ----- // CreatureStack::CreatureStack( Creature * creature, int nb ) { _creature = creature; _nb = nb; } void CreatureStack::increase( int nb ) { _nb += nb; } void CreatureStack::decrease( int nb ) { _nb -= nb; if( _nb < 0 ) { _nb = 0; } } // // ----- CreatureCounter ----- // CreatureCounter::CreatureCounter() { } CreatureCounter::~CreatureCounter() { clear(); } void CreatureCounter::clear() { while( ! _list.isEmpty() ) { delete _list.takeFirst(); } } void CreatureCounter::addCreature( Creature * creature, int nb ) { bool added = false; if( creature ) { for( int i = 0; i < _list.count(); i++ ) { Creature * temp = _list.at( i )->getCreature(); if( ( temp->getRace() == creature->getRace() ) && ( temp->getLevel() == creature->getLevel() ) ) { _list.at( i )->increase( nb ); added = true; i = _list.count(); } } if( ! added ) { CreatureStack * stack = new CreatureStack( creature, nb ); _list.append( stack ); } } } void CreatureCounter::decreaseCreature( Creature * creature, int number ) { if( creature ) { for( int i = 0; i < _list.count(); i++ ) { Creature * temp = _list.at( i )->getCreature(); if( ( temp->getRace() == creature->getRace() ) && ( temp->getLevel() == creature->getLevel() ) ) { _list.at( i )->decrease( number ); i = _list.count(); } } } } int CreatureCounter::getCreatureNumber() { return _list.count(); } int CreatureCounter::getCreatureCount( int num ) { int ret = 0; if( num < _list.count() ) { ret = _list.at( num )->getNumber(); } return ret; } void CreatureCounter::setCreatureCount( int num ,int value) { if( num < _list.count() ) { _list.at( num )->setNumber(value); } } int CreatureCounter::getCreatureCount( Creature * creature ) { int ret = 0; for( int i = 0; i < _list.count(); i++ ) { Creature * temp = _list.at( i )->getCreature(); if( ( temp->getRace() == creature->getRace() ) && ( temp->getLevel() == creature->getLevel() ) ) { ret = _list.at( i )->getNumber(); } } return ret; } void CreatureCounter::setCreatureCount( Creature * creature , int value) { bool added = false; if( creature ) { for( int i = 0; i < _list.count(); i++ ) { Creature * temp = _list.at( i )->getCreature(); if( ( temp->getRace() == creature->getRace() ) && ( temp->getLevel() == creature->getLevel() ) ) { _list.at( i )->setNumber(value); added = true; i = _list.count(); } } if( ! added ) { CreatureStack * stack = new CreatureStack( creature, value ); _list.append( stack ); } } } Creature * CreatureCounter::getCreature( int num ) { Creature * ret = 0; if( num < _list.count() ) { ret = _list.at( num )->getCreature(); } return ret; } // // ----- CreatureHandler ----- // CreatureHandler::CreatureHandler( CreatureList * list ) { _list = list; } bool CreatureHandler::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _list->clear(); _state = StateInit; return true; } bool CreatureHandler::startElement( const QString &, const QString &, const QString& qName, const QXmlAttributes& atts ) { if( qName == "creatures" && _state == StateInit ) { _state = StateDocument; } else if ( qName == "race" && _state == StateDocument ) { _state = StateRace; _race = atts.value( "name" ); } else if ( qName == "creature" && _state == StateRace ) { _state = StateCreature; _creature = new Creature(); _creature->setName( atts.value( "name" ) ); } else if ( qName == "attack" && _state == StateCreature ) { _state = StateAttack; } else if ( qName == "defense" && _state == StateCreature ) { _state = StateDefense; } else if ( qName == "health" && _state == StateCreature ) { _state = StateHealth; } else if ( qName == "move" && _state == StateCreature ) { _state = StateMove; } else if ( qName == "range" && _state == StateCreature ) { _state = StateRange; } else if ( qName == "mindamages" && _state == StateCreature ) { _state = StateMinDamages; } else if ( qName == "maxdamages" && _state == StateCreature ) { _state = StateMaxDamages; } else if ( qName == "morale" && _state == StateCreature ) { _state = StateMorale; } else if ( qName == "luck" && _state == StateCreature ) { _state = StateLuck; } else if( qName == "cost" && _state == StateCreature ) { _state = StateCost; _resource = atts.value( "resource" ).toInt(); } else if( qName == "mcost" && _state == StateCreature ) { _state = StateMantCost; _resource = atts.value( "resource" ).toInt(); } else if( qName == "size" && _state == StateCreature ) { _state = StateSize; } else if( qName == "animations" && _state == StateCreature ) { _creature->setNumFrames( atts.value( "nbFrames" ).toInt() ); _state = StateAnimations; } else if( qName == "moving" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( Moving, first, last ); _state = StateAnimation; } else if( qName == "fighting" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( Fighting, first, last ); _state = StateAnimation; } else if( qName == "shooting" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( Shooting, first, last ); _state = StateAnimation; } else if( qName == "shoothigh" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( ShootHigh, first, last ); _state = StateAnimation; } else if( qName == "shootlow" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( ShootLow, first, last ); _state = StateAnimation; } else if( qName == "defending" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( Defending, first, last ); _state = StateAnimation; } else if( qName == "startmoving" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( StartMoving, first, last ); _state = StateAnimation; } else if( qName == "endmoving" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( EndMoving, first, last ); _state = StateAnimation; } else if( qName == "dying" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( Dying, first, last ); _state = StateAnimation; } else if( qName == "dead" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( Dead, first, last ); _state = StateAnimation; } else if( qName == "attackhigh" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( AttackHigh, first, last ); _state = StateAnimation; } else if( qName == "attacklow" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( AttackLow, first, last ); _state = StateAnimation; } else if( qName == "selecting" && _state == StateAnimations ) { uint first = atts.value( "first" ).toInt(); uint last = atts.value( "last" ).toInt(); _creature->setAnimation( Selecting, first, last ); _state = StateAnimation; } else if( qName == "xoffset" && _state == StateCreature ) { _state = StateXOffset; } else if( qName == "xoffsetmirr" && _state == StateCreature ) { _state = StateXOffsetMirror; } else if( qName == "yoffset" && _state == StateCreature ) { _state = StateYOffset; } else { // error return false; } return true; } bool CreatureHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateRace: _state = StateDocument; break; case StateCreature: _state = StateRace; _list->append( _race, _creature ); break; case StateAttack: case StateDefense: case StateHealth: case StateMove: case StateRange: case StateMinDamages: case StateMaxDamages: case StateMorale: case StateLuck: case StateCost: case StateSize: case StateAnimations: case StateXOffset: case StateXOffsetMirror: case StateYOffset: _state = StateCreature; break; case StateMantCost: _state = StateCreature; break; case StateAnimation: _state = StateAnimations; break; default: // do nothing break; } return true; } bool CreatureHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) return true; switch( _state ) { case StateAttack: _creature->setAttack( ch_simplified.toInt() ); break; case StateDefense: _creature->setDefense( ch_simplified.toInt() ); break; case StateHealth: _creature->setMaxHealth( ch_simplified.toInt() ); break; case StateMove: _creature->setMaxMove( ch_simplified.toInt() ); break; case StateRange: _creature->setDistAttack( ch_simplified.toInt() ); break; case StateMinDamages: _creature->setMinDamages( ch_simplified.toInt() ); break; case StateMaxDamages: _creature->setMaxDamages( ch_simplified.toInt() ); break; case StateMorale: _creature->setMorale( ch_simplified.toInt() ); break; case StateLuck: _creature->setLuck( ch_simplified.toInt() ); break; case StateCost: _creature->setCost( _resource, ch_simplified.toInt() ); break; case StateMantCost: _creature->setMantCost( _resource, ch_simplified.toInt() ); break; case StateSize: _creature->setSize( ch_simplified.toInt() ); break; case StateXOffset: _creature->setXOffset ( ch_simplified.toInt() ); break; case StateXOffsetMirror: _creature->setXOffsetMirror ( ch_simplified.toInt() ); break; case StateYOffset: _creature->setYOffset ( ch_simplified.toInt() ); break; default: return false; } return true; } bool CreatureHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } // // ----- Race ----- // Race::Race() { } Race::~Race() { while( ! isEmpty() ) { delete takeFirst(); } } // // ----- CreatureList ----- // CreatureList::CreatureList() { } CreatureList::~CreatureList() { while( ! isEmpty() ) { delete takeFirst(); } } void CreatureList::clear() { while( ! isEmpty() ) { delete takeFirst(); } } Creature * CreatureList::at( int race, int level ) { Race * raceList = QList::at( race ); return raceList->at( level ); } bool CreatureList::init() { clear(); CreatureHandler handler( this ); QFile file( DATA_PATH + "creatures.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "creatures.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } bool CreatureList::save() { QString filename = DATA_PATH + "creatures.dat"; QFile file( filename ); if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writng\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; for( uint i = 0; i < countRace(); i++ ) { Race * race = QList::at( i ); ts << "\tgetName() << "\">" << endl; for( int j = 0; j < race->count(); j++ ) { Creature * creature = race->at( j ); if( creature ) { creature->save( ts, 2 ); } } ts << "\t" << endl; } ts << "" << endl; file.close(); return true; } void CreatureList::append( const QString & race, Creature * creature ) { QListIterator iteRace( *this ); int numRace = -1; int cpt = 0; if( findRace( creature->getName() ) != -1 ) { logEE( "Creature already existing" ); return; } while( iteRace.hasNext() ) { if( race == iteRace.next()->getName() ) { numRace = cpt; } cpt++; } if( numRace == -1 ) { Race * aRace = new Race(); aRace->setName( race ); aRace->append( creature ); QList::append( aRace ); numRace = QList::count() - 1; } else { QList::at( numRace )->append( creature ); } creature->setRace( numRace ); creature->setLevel( QList::at( numRace )->count() - 1 ); } int CreatureList::findRace( const QString & name ) { int ret = 0; QListIterator iteRace( *this ); while( iteRace.hasNext() ) { QListIterator iteCreature( *( iteRace.next() ) ); while( iteCreature.hasNext() ) { if( iteCreature.next()->getName() == name ) { return ret; } } ret++; } return -1; } int CreatureList::findLevel( const QString & name ) { int ret = 0; QListIterator iteRace( *this ); while( iteRace.hasNext() ) { QListIterator iteCreature( *( iteRace.next() ) ); while( iteCreature.hasNext() ) { if( iteCreature.next()->getName() == name ) { return ret; } ret++; } ret = 0; } logDD( "Level not found : %s", name.toLatin1().constData() ); return -1; } int CreatureList::count() { int ret = 0; QListIterator iteRace( *this ); while( iteRace.hasNext() ) { ret += iteRace.next()->count(); } return ret; } int CreatureList::giveNumRace( const QString & race ) { int ret = 0, cpt = 0; QListIterator iteRace( *this ); while( iteRace.hasNext() ) { if( iteRace.next()->getName() == race ) { ret = cpt; } cpt++; } return ret; } int CreatureList::computeSequence( GenericFightUnit * unit ) { int ret = 0; for( uint i = 0; i < unit->getRace(); i++ ) { ret += DataTheme.creatures.getRace( i )->count(); } return ret + unit->getLevel(); } attal-src-1.0-rc2/libCommon/creature.h0000644000175000017500000002326011000754011015346 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** creature.h ** Manages creatures ** ** Version : $Id: creature.h,v 1.27 2008/04/14 22:17:45 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/09/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CREATURE_H #define CREATURE_H // generic include files // include files for QT #include #include #include #include // application specific include files #include "libCommon/define.h" class CreatureHandler; class GenericFightUnit; /** Manage a creature */ enum CreatureAnimationType { Moving = 1, Fighting, Shooting, ShootHigh, ShootLow, Defending, StartMoving, EndMoving, Dying, Dead, AttackHigh, AttackLow, Selecting }; class Creature { public: /** Constructor */ Creature(); /** Destructor */ virtual ~Creature(); /** \return Returns the race of the creature */ uint getRace() { return _race; } /** Sets the race of the creature */ void setRace( uint race ) { _race = race; } /** \return Returns the level of the creature */ uint getLevel() { return _level; } /** Sets the level of the creature */ void setLevel( uint level ) { _level = level; } /** Set name of the creature */ void setName( const QString & name ) { _name = name; } /** Return name of the creature */ QString getName() { return _name; } /** Set attack points */ void setAttack( int nb ) { _ptAttack = nb; } /** Return attack points */ int getAttack() { return _ptAttack; } /** Set defense points */ void setDefense( int nb ) { _ptDefense = nb; } /** Return defense points */ int getDefense() { return _ptDefense; } /** Set dist attack points */ void setDistAttack( int nb ) { _distAttack = nb; } /** Return dist attack points */ int getDistAttack() { return _distAttack; } /** Tell if dist attack is allowed */ bool isDistAttack() { return (_distAttack > 0 ); } /** Set max health points */ void setMaxHealth( int nb ) { _maxHealth = nb; } /** Return max health points */ int getMaxHealth() { return _maxHealth; } /** Set max move points */ void setMaxMove( int nb ) { _maxMove = nb; } /** Return max move points */ int getMaxMove() { return _maxMove; } /** Set morale */ void setMorale( int nb ) { _morale = nb; } /** Return morale */ int getMorale() { return _morale; } /** Set luck */ void setLuck( int nb ) { _luck = nb; } /** Return luck */ int getLuck() { return _luck; } /** Set min damages points */ void setMinDamages( int nb ) { _minDamages = nb; } /** Return min damages points */ int getMinDamages() { return _minDamages; } /** Set max damages points */ void setMaxDamages( int nb ) { _maxDamages = nb; } /** Return max damages points */ int getMaxDamages() { return _maxDamages; } uint getCost( uint res ); void setCost( uint res, uint cost ); uint getMantCost( uint res ); void setMantCost( uint res, uint cost ); int getSize() { return _size; } void setSize( int size ) { _size = size; } inline int getXOffset () { return _XOffset; } void setXOffset ( int XOffset ) { _XOffset = XOffset; } inline int getXOffsetMirror () { return _XOffsetMirror; } void setXOffsetMirror ( int XOffsetMirror ) { _XOffsetMirror = XOffsetMirror; } inline int getYOffset () { return _YOffset; } void setYOffset ( int YOffset ) { _YOffset = YOffset; } void setAnimation( CreatureAnimationType type, uint first, uint last ); int getFirstAnimationFrame( CreatureAnimationType type ); int getLastAnimationFrame( CreatureAnimationType type ); int getNumberAnimationFrame( CreatureAnimationType type ); void setNumFrames( int numFrames ) { _numFrames = numFrames; } int getNumFrames() { return _numFrames; } bool isAnimated() { return ( _numFrames > 0 ); } /** Return the number of animations */ uint numAnimation() { return _animations.count(); } void clearAnimations() { _animations.clear(); } void save( QTextStream & ts, int indent ); static QString getAnimationTypeName( CreatureAnimationType type ); class CreatureAnimation { public: CreatureAnimation( CreatureAnimationType type, uint first, uint last ); CreatureAnimationType getType() { return _type; } uint getFirst() { return _first; } uint getLast() { return _last; } protected: CreatureAnimationType _type; uint _first; uint _last; }; /* Return the 'num'-th creatureAnimation */ CreatureAnimation * getCreatureAnimation( int num ) { return _animations.at( num ); } protected: QString _name, _building; int _ptAttack, _ptDefense; int _maxHealth, _maxMove; int _distAttack; int _minDamages, _maxDamages; int _morale, _luck; uint _race, _level; uint _cost[MAX_RESS]; uint _mcost[MAX_RESS]; int _size; QList _animations; int _numFrames; // three fields for placing picture in right position int _XOffset; int _XOffsetMirror; int _YOffset; /// XXX: manage spells... }; /** Manage a stack of creature */ class CreatureStack { public: /** Constructor */ CreatureStack( Creature * creature, int nb ); /** \return Returns the creature of this stack */ Creature * getCreature() { return _creature; } /** \return Returns the nb of creatures */ int getNumber() { return _nb; } /** \set the nb of creatures */ void setNumber(int value) { _nb = value; } /** Increase nb of creatures of the stack */ void increase( int nb ); /** Decrease nb of creatures of the stack */ void decrease( int nb ); protected: Creature * _creature; int _nb; }; /** Counter of creatures */ class CreatureCounter { public: /** Constrcutor */ CreatureCounter(); /** Destructor */ ~CreatureCounter(); /** Clears counter */ void clear(); /** Adds some creatures to the counter */ void addCreature( Creature * creature, int nb ); /** Decreases creatures to the counter */ void decreaseCreature( Creature * creature, int number ); /** \return Returns the nb of different creatures */ int getCreatureNumber(); /** \return Returns the nb of creature 'num' */ int getCreatureCount( int num ); /** \set nb of creature 'num' */ void setCreatureCount( int num , int value ); /** \return Returns the nb of creature 'creature' */ int getCreatureCount( Creature * creature ); /** \set the nb of creature 'creature' */ void setCreatureCount( Creature * creature ,int value); /** \return Returns creature 'num' */ Creature * getCreature( int num ); protected: QList _list; }; /** List of creature (of the same race) */ class Race : public QList { public: /** Constructor */ Race(); /** Destructor */ virtual ~Race(); /** \return Returns the name of this race */ QString getName() { return _name; } /** Sets the name of this race */ void setName( const QString & name ) { _name = name; } private: QString _name; }; /** List of races */ class CreatureList : public QList { public: /** Constructor */ CreatureList(); /** Destructor */ virtual ~CreatureList(); /** Return num-th creature */ Creature * at( int race, int level ); /** Append new unit */ void append( const QString & race, Creature * creature ); /** Return race-id of creature named 'name' */ int findRace( const QString & name ); /** Return level-id of creature named 'name' */ int findLevel( const QString & name ); /** Init list */ bool init(); /** Saves the list in a data file */ bool save(); /** return the number of units */ int count(); void clear(); /** \return Returns the nb of races */ uint countRace() { return QList::count(); } /** \return Returns the race 'i' */ Race * getRace( int i ) { return QList::at( i ); } /** \return Gives the num of the race 'race' */ int giveNumRace( const QString & race ); /** compute the absolute number of the creature associated at 'unit' */ int computeSequence( GenericFightUnit * unit ); }; /* ------------------------------ * CreatureHandler * ------------------------------ */ class CreatureHandler : public QXmlDefaultHandler { public: /** Constructor */ CreatureHandler( CreatureList * list ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: int _resource; QString _errorProt; QString _race, _name; CreatureList * _list; Creature * _creature; enum State { StateInit, StateDocument, StateRace, StateCreature, StateAttack, StateDefense, StateHealth, StateMove, StateRange, StateMinDamages, StateMaxDamages, StateMorale, StateLuck, StateCost, StateMantCost, StateSize, StateAnimations, StateAnimation, StateXOffset, StateXOffsetMirror, StateYOffset }; State _state; }; #endif // CREATURE_H attal-src-1.0-rc2/libCommon/dataTheme.cpp0000644000175000017500000000621010617321421015767 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** dataTheme.cpp ** class for gathering all informations about theme (data part) ** ** Version : $Id: dataTheme.cpp,v 1.16 2007/05/06 09:42:41 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 03/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #define NO_EXTERN_DATATHEME #include "dataTheme.h" // generic include files // include files for QT #include // application specific include files DataTheme DataTheme; void indentation( QTextStream * ts, int num ) { for( int i = 0; i < num; i++ ) { (*ts) << "\t"; } } // // ----- DataTheme ----- // DataTheme::DataTheme() { _isLoaded = false; } bool DataTheme::init() { _isLoaded = general.init(); _isLoaded = _isLoaded && artefacts.init(); _isLoaded = _isLoaded && teams.init(); _isLoaded = _isLoaded && resources.init(); _isLoaded = _isLoaded && decorations.init(); _isLoaded = _isLoaded && creatures.init(); _isLoaded = _isLoaded && techList.init(); _isLoaded = _isLoaded && lordCategories.init(); _isLoaded = _isLoaded && lords.init(); _isLoaded = _isLoaded && bases.init(); _isLoaded = _isLoaded && buildings.init(); _isLoaded = _isLoaded && tiles.init(); _isLoaded = _isLoaded && machines.init(); _isLoaded = _isLoaded && lordExperience.init(); _isLoaded = _isLoaded && _category.init(); return isLoaded(); } void DataTheme::save() { general.save(); artefacts.save(); teams.save(); resources.save(); decorations.save(); creatures.save(); techList.save(); lordCategories.save(); lords.save(); bases.save(); buildings.save(); tiles.save(); machines.save(); lordExperience.save(); _category.save(); } void DataTheme::clear() { general.clear(); artefacts.clear(); teams.clear(); resources.clear(); decorations.clear(); creatures.clear(); techList.clearing(); lordCategories.clearList(); lords.clear(); bases.clear(); buildings.clear(); tiles.clear(); machines.clear(); lordExperience.clear(); _category.clear(); } QString DataTheme::getCategoryName( uint categ ) { return _category.getCategoryName( categ ); } uint DataTheme::computeCategory( int nb ) { return (uint)_category.computeCategory( nb ); } QString DataTheme::computeCategoryName( int nb ) { return _category.getCategoryName( nb ); } uint DataTheme::getRandomInCategory( uchar categ ) { return (uint)_category.getRandomInCategory(categ); } uint DataTheme::getLordCategory( LordCategoryModel * category ) { uint nbCat = lordCategories.count(); for( uint i = 0; i < nbCat; i++ ) { if( category == lordCategories.at( i ) ) { return i; } } return 0; } attal-src-1.0-rc2/libCommon/dataTheme.h0000644000175000017500000000535310713710377015454 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** dataTheme.h ** class for gathering all informations about theme (data part) ** ** Version : $Id: dataTheme.h,v 1.12 2007/11/05 21:54:07 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 03/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef DATATHEME_H #define DATATHEME_H // generic include files // include files for QT #include #include // application specific include files #include "libCommon/artefact.h" #include "libCommon/creature.h" #include "libCommon/categoryManager.h" #include "libCommon/generalOptions.h" #include "libCommon/genericCell.h" #include "libCommon/genericRessources.h" #include "libCommon/genericDecoration.h" #include "libCommon/genericLord.h" #include "libCommon/genericBase.h" #include "libCommon/genericBuilding.h" #include "libCommon/genericTeam.h" #include "libCommon/lordCategoryModel.h" #include "libCommon/lordExperience.h" #include "libCommon/technic.h" #include "libCommon/unit.h" #include "libCommon/warMachine.h" class QTextStream; void indentation( QTextStream * ts, int num ); /** ------------------------------ * DataTheme ** ------------------------------ */ class DataTheme { public: /** Constructor */ DataTheme(); bool init(); void save(); void clear(); bool isLoaded() { return _isLoaded; } uint countRace() { return creatures.countRace(); } QString getCategoryName( uint categ ); uint computeCategory( int nb ); QString computeCategoryName( int nb ); uint getRandomInCategory( uchar categ ); uint getLordCategory( LordCategoryModel * category ); ArtefactList artefacts; ResourceList resources; DecorationList decorations; TechnicList techList; CreatureList creatures; LordCategoryList lordCategories; LordList lords; BaseList bases; BuildingList buildings; TeamList teams; CellModelList tiles; WarMachineList machines; LordExperience lordExperience; GeneralOptions general; protected: CategoryManager _category; bool _isLoaded; }; #ifndef NO_EXTERN_DATATHEME extern DataTheme DataTheme; #else #undef NO_EXTERN_DATATHEME #endif #endif // DATATHEME_H attal-src-1.0-rc2/libCommon/define.h0000644000175000017500000000235411010170657015000 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** define.h ** file used for global '#define' ** ** Version : $Id: define.h,v 1.6 2008/05/07 00:02:55 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 30/12/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef DEFINE_H #define DEFINE_H // generic include files // include files for QT // application specific include files #define MAX_UNIT 7 #define MAX_SKILL 8 #define MAX_RESS 12 #define COST_ENTER 4 enum LordCharac { ATTACK = 1, DEFENSE, POWER, KNOWLEDGE, MOVE, MAXMOVE, TECHNICPOINT, MAXTECHNICPOINT, MORALE, LUCK, VISION, EXPERIENCE, CHARISMA, LEVEL, LAST }; #endif // DEFINE_H attal-src-1.0-rc2/libCommon/displayHelp.cpp0000644000175000017500000000353010762275404016365 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayHelp.cpp ** Dialog for displaying help (used by all exe) ** ** Version : $Id: displayHelp.cpp,v 1.6 2008/03/01 15:49:24 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/11/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "displayHelp.h" // generic include files // include files for QT #include #include #include #include #include // application specific include files DisplayHelp::DisplayHelp( QWidget * parent, const char * /* name */) : QDialog( parent, Qt::Dialog ) { _text = new QTextBrowser( this ); QStringList slist = QStringList("."); slist.append( ATT_DOCS_DIR ); _text->setSearchPaths( slist ); _text->setSource( QUrl ("./HOWTOPLAY.html") ); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( QObject::tr( "Ok" ) ); pbOk->setFixedSize( pbOk->sizeHint() ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( _text, 1 ); layout->addLayout( layH1 ); connect( pbOk, SIGNAL( clicked() ), SLOT( slot_accept() ) ); } void DisplayHelp::slot_accept() { accept(); } attal-src-1.0-rc2/libCommon/displayHelp.h0000644000175000017500000000266310411514640016025 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayHelp.h ** Dialog for displaying help (used by all exe) ** ** Version : $Id: displayHelp.h,v 1.3 2006/03/26 13:39:44 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/11/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef DISPLAYHELP_H #define DISPLAYHELP_H // generic include files // include files for QT #include #include // application specific include files class QTextBrowser; /* ------------------------------ * DisplayHelp * ------------------------------ */ class DisplayHelp : public QDialog { Q_OBJECT public: /** Constructor */ DisplayHelp( QWidget * parent = 0, const char * name = 0 ); public slots: void slot_accept(); protected: QTextBrowser * _text; }; #endif // DISPLAYHELP_H attal-src-1.0-rc2/libCommon/fightResultStatus.cpp0000644000175000017500000000417510344415054017612 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightResultStatus.cpp ** small class for managing result of fight ** ** Version : $Id: fightResultStatus.cpp,v 1.1 2005/12/03 22:20:28 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 03/12/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "fightResultStatus.h" // generic include files // include files for QT // application specific include files FightResultStatus::FightResultStatus() { clear(); } void FightResultStatus::clear() { _attackWin = false; _defenseWin = false; _fled = false; _surrendered = false; } void FightResultStatus::setAttackWin() { _attackWin = true; _defenseWin = false; } void FightResultStatus::setDefenseWin() { _attackWin = false; _defenseWin = true; } void FightResultStatus::setFled( bool state ) { _fled = state; } void FightResultStatus::setSurrendered( bool state ) { _surrendered = state; } bool FightResultStatus::isFightFinished() { if( _attackWin || _defenseWin ) { return true; } else { return false; } } void FightResultStatus::fromUChar( unsigned char result ) { if( ( result & 0x01 ) == 0x01 ) { _attackWin = true; } if( ( result & 0x02 ) == 0x02 ) { _defenseWin = true; } if( ( result & 0x04 ) == 0x04 ) { _fled = true; } if( ( result & 0x08 ) == 0x08 ) { _surrendered = true; } } unsigned char FightResultStatus::toUChar() { unsigned char ret = 0; if( _attackWin ) { ret |= 0x01; } if( _defenseWin ) { ret |= 0x02; } if( _fled ) { ret |= 0x04; } if( _surrendered ) { ret |= 0x08; } return ret; } attal-src-1.0-rc2/libCommon/fightResultStatus.h0000644000175000017500000000336410344415054017256 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightResultStatus.h ** small class for managing result of fight ** ** Version : $Id: fightResultStatus.h,v 1.1 2005/12/03 22:20:28 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 03/12/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef FIGHTRESULTSTATUS_H #define FIGHTRESULTSTATUS_H // generic include files // include files for QT // application specific include files /* ------------------------------ * FightResultStatus * ------------------------------ */ class FightResultStatus { public: /** Constructor */ FightResultStatus(); void setAttackWin(); void setDefenseWin(); void setFled( bool state = true ); void setSurrendered( bool state = true ); bool isFightFinished(); bool hasAttackWin() { return _attackWin; } bool hasDefenseWin() { return _defenseWin; } bool hasFled() { return _fled; } bool hasSurrendered() { return _surrendered; } void fromUChar( unsigned char result ); unsigned char toUChar(); void clear(); protected: bool _attackWin, _defenseWin, _fled, _surrendered; }; #endif // FIGHTRESULTSTATUS_H attal-src-1.0-rc2/libCommon/gameData.cpp0000644000175000017500000003227010761121041015577 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** gameData.cpp ** Manage data of a whole game ** ** Version : $Id: gameData.cpp,v 1.27 2008/02/26 23:34:57 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "gameData.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/artefact.h" #include "libCommon/artefactManager.h" #include "libCommon/calendar.h" #include "libCommon/dataTheme.h" #include "libCommon/genericBase.h" #include "libCommon/genericBonus.h" #include "libCommon/genericBuilding.h" #include "libCommon/genericCell.h" #include "libCommon/genericChest.h" #include "libCommon/genericEvent.h" #include "libCommon/genericLord.h" #include "libCommon/genericMap.h" #include "libCommon/genericMapCreature.h" #include "libCommon/genericPlayer.h" #include "libCommon/quest.h" #include "libCommon/questManager.h" extern QString VERSION; GameData::GameData() :_nbPlayer( 0 ), _map( 0 ) { _quests = new QuestManager(); _calendar = new Calendar(); _nbArtefact = 0; _nbBonus = 0; _nbChest = 0; reinit(); } GameData::~GameData() { TRACE("GameData::~GameData"); clearLists(); if( _quests ) { delete _quests; } if( _calendar ) { delete _calendar; } if( _map ) { delete _map; } TRACE("End of GameData::~GameData"); } void GameData::clearLists() { TRACE("GameData::clearLists"); while( ! _bases.isEmpty() ) { delete _bases.takeFirst(); } while( ! _buildings.isEmpty() ) { delete _buildings.takeFirst(); } while( ! _lords.isEmpty() ) { delete _lords.takeFirst(); } while( ! _events.isEmpty() ) { delete _events.takeFirst(); } while( ! _creatures.isEmpty() ) { delete _creatures.takeFirst(); } } void GameData::save( QTextStream * ts ) { *ts << "" << endl; *ts << "" << endl; *ts << "\t" << VERSION << "" << endl; *ts << "\t" << getScenarioName() << "" << endl; *ts << "\t" << getScenarioTheme() << "" << endl; *ts << "\t" << endl; *ts << "\t\t" << getScenarioDescription() << endl; *ts << "\t" << endl; _calendar->save( ts, 1 ); _map->save( ts ); for( int i = 0; i < _events.count(); i++ ) { _events.at( i )->save( ts, 1 ); } for( int i = 0; i < _bases.count(); i++ ) { _bases.at( i )->save( ts, 1 ); } for( int i = 0; i < _buildings.count(); i++ ) { _buildings.at( i )->save( ts, 1 ); } for( int i = 0; i < _lords.count(); i++ ) { _lords.at( i )->save( ts, 1 ); } for( int i = 0; i < _creatures.count(); i++ ) { _creatures.at( i )->save( ts, 1 ); } for( uint i = 0; i < getNbPlayer(); i++ ) { _players.at( i )->save( ts, 1 ); } _quests->save( ts, 1 ); *ts << "" << endl; } void GameData::reinit() { TRACE("GameData::reinit"); if( _map ) { _map->clear(); } if( _calendar ) { _calendar->reinit(); } clearLists(); _quests->clear(); _nbPlayer = 0; _nbArtefact = 0; _nbBonus = 0; _nbChest = 0; initLords(); } void GameData::initLords() { TRACE("GameData::initLords"); uint nbLords = DataTheme.lords.count(); for( uint i = 0; i < nbLords; i++ ) { GenericLord * lord = new GenericLord(); lord->setId( i ); _lords.append( lord ); } } void GameData::resetOwnership( GenericPlayer * player ) { for( int i = 0; i < _bases.count(); i++ ) { if(_bases.at( i )->getOwner() == player ) { _bases.at( i )->setOwner(0); } } for( int i = 0; i < _buildings.count(); i++ ) { if( _buildings.at( i )->getOwner() == player ) { _buildings.at( i )->setOwner(0); } } for( int i = 0; i < _lords.count(); i++ ) { if(_lords.at( i )->getOwner() == player ) { _lords.at( i )->setOwner(0); } } } GenericCell * GameData::getCell( uint row, uint col ) { if( ( row < _map->getHeight() ) && ( col < _map->getWidth() ) ) { return _map->at( row, col ); } else { return NULL; } } uint GameData::getBaseNumber() { return _bases.count(); } uint GameData::getBuildingNumber() { return _buildings.count(); } GenericBase * GameData::getBase( uint num ) { if( (int)num < _bases.count() ) { return _bases.at( num ); } return NULL; } void GameData::loadMap( QTextStream * stream, int width, int height ) { if( _map ) { delete _map; } _map = new GenericMap(); _map->load( stream, width, height ); } GenericBase * GameData::getNewBase( uchar race ) { GenericBase * base = new GenericBase( race ); _bases.append( base ); base->setOwner( NULL ); return base; } GenericBase * GameData::getNewBase( uchar race, int row, int col, int population, uchar id, int nb, const QList & forbidlist) { GenericBase * base = _map->at( row, col )->getBase(); if( base ) { removeBase( base ); } base = getNewBase( race ); base->setPosition( _map->at( row, col )); base->setPopulation( population ); _map->computeStoppable( base ); base->setId( id );/// XXX: to inv ?? base->isUnitBought( false ); for( int i = 0; i < nb; i++ ) { base->addForbiddenBuilding( forbidlist.at(i) ); } return base; } void GameData::removeBase( GenericBase * base ) { if( base ) { if(base->getOwner()){ base->getOwner()->removeBase(base); } _bases.removeAll( base ); delete base; } } void GameData::setBaseId( GenericBase * base ) { int id = 0; for( int i = 0; i < _bases.count(); i++ ) { if(_bases.at( i )->getId() == id && _bases.at( i ) != base ) { id++; i = 0; } } base->setId( id ); } void GameData::setBuildingId( GenericBuilding * build ) { int id = 0; for( int i = 0; i < _buildings.count(); i++ ) { if(_buildings.at( i )->getId() == id && _buildings.at( i ) != build ) { id++; i = 0; } } build->setId( id ); } void GameData::setBase2Player( int idBase, int player ) { TRACE("GameData::setBase2Player idBase %d, player %d", idBase, player ); if( _players.count() > player ) { GenericBase * base = getBaseById( idBase ); if( base->getOwner() ) { base->getOwner()->removeBase( base ); } if( ( _players.at( player ) ) && ( base ) ) { base->setOwner( _players.at( player ) ); _players.at( player )->addBase( base ); } } } void GameData::setBuilding2Player( int idBuild, int player ) { TRACE("GameData::setBuilding2Player idBuilding %d, player %d", idBuild, player ); if( ( _players.count() > player )) { GenericBuilding * build = getBuildingById( idBuild ); if( build->getOwner() ) { build->getOwner()->removeBuilding( build ); } if( _players.at( player ) ) { build->setOwner( _players.at( player ) ); _players.at( player )->addBuilding( build ); } } } void GameData::setDateByType( int type, int value ) { _calendar->setDateByType(type,value); } void GameData::setInitialDateByType( int type, int value ) { _calendar->setInitialDateByType(type,value); } void GameData::setTurn( uint turn ) { _calendar->setTurn( turn ); } uint GameData::getTurn() { return _calendar->getTurn(); } uint GameData::getDateByType( int type ) { return _calendar->getDateByType(type); } GenericLord * GameData::getLord( int idLord ) { return _lords.at( idLord ); } uint GameData::getLordNumber() { return _lords.count(); } GenericPlayer * GameData::getPlayer( int num ) { if( ( num >= 0 ) && (num < _players.count() ) ) { return _players.at( num ); } else { return NULL; } } uint GameData::getPlayerNumber() { return _players.count(); } GenericArtefact * GameData::getArtefactById( int id ) { GenericArtefact * ret = NULL; for( int i = 0; i < _events.count(); i++ ) { if( ( _events.at( i )->getType() == GenericEvent::EventArtefact ) && _events.at( i )->getArtefact()->getId() == id ) { ret = _events.at( i )->getArtefact(); } } return ret; } GenericBase * GameData::getBaseById( int id ) { GenericBase * ret = NULL; for( int i = 0; i < _bases.count(); i++ ) { if( _bases.at( i )->getId() == id ) { ret = _bases.at( i ); break; } } return ret; } GenericBuilding * GameData::getBuildingById( int id ) { GenericBuilding * ret = NULL; for( int i = 0; i < _buildings.count(); i++ ) { if( _buildings.at( i )->getId() == id ) { ret = _buildings.at( i ); break; } } return ret; } void GameData::setLord2Player( int idLord, int player ) { if( ( _players.count() > player ) && ( _lords.count() > idLord ) ) { if( ( _players.value( player ) ) && ( _lords.at( idLord ) ) ) { _lords.at( idLord )->setOwner( _players.at( player ) ); _players.at( player )->addLord( _lords.at( idLord ) ); } } } GenericEvent * GameData::getNewArtefact( int id ) { GenericEvent * ret = new GenericEvent(); GenericArtefact * artefact = new GenericArtefact(); artefact->setId( id ); ret->setArtefact( artefact ); _events.append( ret ); return ret; } GenericEvent * GameData::getNewBonus() { GenericEvent * ret = new GenericEvent(); GenericBonus * bonus = new GenericBonus(); ret->setBonus( bonus ); _events.append( ret ); return ret; } GenericEvent * GameData::getNewChest() { GenericEvent * ret = new GenericEvent(); GenericChest * chest = new GenericChest(); ret->setChest( chest ); _events.append( ret ); return ret; } GenericBuilding * GameData::getNewBuilding( uchar type ) { GenericBuilding * ret = new GenericBuilding( type ); _buildings.append( ret ); return ret; } GenericBuilding * GameData::getNewBuilding( uchar type, int id, int row, int col) { TRACE("GenericBuilding * GameData::getNewBuilding( uchar type %d, int id %d, int row %d, int col %d )",type, id, row, col ); GenericBuilding * building = _map->at( row, col )->getBuilding(); if( building ) { removeBuilding( building ); } building = getNewBuilding( type ); /* keep id, position in that order **/ building->setId( id ); building->setPosition( _map->at( row, col ) ); _map->computeStoppable( building ); return building; } void GameData::removeBuilding( GenericBuilding * build ) { if( build ) { if(build->getOwner()){ build->getOwner()->removeBuilding( build ); } _buildings.removeAll( build ); delete build; } } Quest * GameData::getNewQuest() { Quest * ret = new Quest(); _quests->appendSecondaryQuest( ret ); return ret; } Quest * GameData::getMainQuest() { Quest * ret = _quests->getMainQuest(); if( ! ret ) { ret = new Quest(); _quests->setMainQuest( ret ); } return ret; } GenericMapCreature * GameData::getNewMapCreature() { GenericMapCreature * ret = new GenericMapCreature(); _creatures.append( ret ); return ret; } GenericMapCreature * GameData::getNewMapCreature( int row, int col, uchar race, uchar level, int nb, bool /* looking */) { GenericMapCreature * creature = getNewMapCreature(); creature->setCreature( race, level ); creature->setCategoryNumber( nb ); creature->setCell( _map->at( row, col ) ); _map->at( row, col )->setCreature( creature ); return creature; } void GameData::removeMapCreature( GenericMapCreature * creature ) { if( creature ) { _creatures.removeAll( creature ); delete creature; } } void GameData::removeMapCreature( int row, int col ) { GenericMapCreature * crea = _map->at( row, col )->getCreature(); if( crea ) { removeMapCreature( crea ); _map->at( row, col )->setCreature( NULL ); } } void GameData::removeEvent( int row, int col ) { GenericEvent * event = _map->at( row, col )->getEvent(); if( event ) { removeEvent( event ); _map->at( row, col )->setEvent( NULL ); } } void GameData::removeEvent( GenericEvent * event ) { if( event ) { _events.removeAll( event ); delete event; } } void GameData::updateLordUnit(uchar id , uchar pos, uchar race, uchar level, int nb, uchar move, int health) { TRACE("GameData::updateLordUnit id %d, pos %d , race %d, level %d, nb %d, move %d, health %d", id,pos, race, level, nb, move, health ); if(_lords.at( id )) { _lords.at( id )->updateUnit( pos ,race, level,nb, move, health); } } void GameData::updateBaseBuilding( int row, int col, uchar level, bool create ) { TRACE("GameData::updateBaseBuilding row %d, col %d, level %d, create %d",row,col,level,create); GenericBase * base = _map->at( row, col )->getBase(); if( base ) { base->updateBuilding( level, create ); } else { logEE( "Base not found" ); } } void GameData::exchangeArtefactLord( uchar idLord1, uchar idLord2, int item) { GenericLord * lord1 = NULL; GenericLord * lord2 = NULL; if( idLord1 ) { lord1 = _lords.at( idLord1 ); } if( idLord2 ) { lord2 = _lords.at( idLord2 ); } if( lord1 && lord2 ) { ArtefactManager * manag1 = lord1->getArtefactManager(); ArtefactManager * manag2 = lord2->getArtefactManager(); GenericLordArtefact * artefact = manag1->getArtefact( item ); manag1->removeArtefact( item ); manag2->addArtefact( artefact ); } } attal-src-1.0-rc2/libCommon/gameData.h0000644000175000017500000001253410751372502015256 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** gameData.h ** Manage data of a whole game ** ** Version : $Id: gameData.h,v 1.22 2008/02/03 17:09:22 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GAMEDATA_H #define GAMEDATA_H // generic include files // include files for QT #include #include // application specific include files #include "libCommon/genericEvent.h" #include "libCommon/log.h" class QTextStream; class Calendar; class GenericBase; class GenericBuilding; class GenericCell; class GenericLord; class GenericMap; class GenericMapCreature; class GenericPlayer; class Quest; class QuestManager; class ScenarioParser; /** ------------------------------ * GameData ** ------------------------------ */ class GameData { public: /** Constructor */ GameData(); virtual ~GameData(); void save( QTextStream * ts ); /** Reinit data (new game) */ virtual void reinit(); /** clear lists of data */ void clearLists(); virtual void initLords(); /** Set the name of the scenario */ void setScenarioName( const QString & name ) { _scenarioName = name; } /** Return the name of the scenario */ QString getScenarioName() { return _scenarioName; } /** Set the description of the scenario */ void setScenarioDescription( const QString & desc ) { _scenarioDescription = desc; } /** Return the description of the scenario */ QString getScenarioDescription() { return _scenarioDescription; } /** Set the theme used by the scenario */ void setScenarioTheme( const QString & theme ) { _scenarioTheme = theme; } /** Return the theme used by the scenario */ QString getScenarioTheme() { return _scenarioTheme; } void setAttalVersion( const QString & version ) { _attalVersion = version; } QString getAttalVersion() { return _attalVersion; } void setDateByType( int type, int value ); uint getDateByType( int type ); void setTurn( uint turn ); uint getTurn(); void setInitialDateByType( int type, int value ); virtual void addPlayer() {} virtual void setNbPlayer( int nb ) { _nbPlayer = nb; } virtual uint getNbPlayer() { return _nbPlayer; } virtual GenericCell * getCell( uint row, uint col ); virtual void loadMap( QTextStream * stream, int width, int height ); uint getBaseNumber(); uint getBuildingNumber(); GenericBase * getBase( uint num ); virtual GenericBase * getNewBase( uchar race = 0 ); virtual GenericBase * getNewBase( uchar race, int row, int col, int population, uchar id, int nb, const QList & forbidlist); virtual void setBase2Player( int idBase, int player ); virtual void setBuilding2Player( int idBuild, int player ); virtual void resetOwnership( GenericPlayer * player ); GenericLord * getLord( int idLord ); uint getLordNumber(); GenericPlayer * getPlayer( int num ); uint getPlayerNumber(); GenericArtefact * getArtefactById( int id ); GenericBase * getBaseById( int id ); GenericBuilding * getBuildingById( int id ); virtual void setLord2Player( int idLord, int player ); virtual GenericEvent * getNewArtefact( int id = -1 ); virtual GenericEvent * getNewBonus(); virtual GenericEvent * getNewChest(); virtual GenericBuilding * getNewBuilding( uchar type = 0 ); virtual GenericBuilding * getNewBuilding( uchar type, int id, int row, int col ); virtual Quest * getNewQuest(); Quest * getMainQuest(); virtual GenericMapCreature * getNewMapCreature(); virtual GenericMapCreature * getNewMapCreature( int row, int col, uchar race, uchar level, int nb, bool looking); virtual void removeMapCreature( GenericMapCreature * creature ); virtual void removeMapCreature( int row, int col ); virtual void removeEvent( GenericEvent * event ); virtual void removeEvent( int row, int col ); virtual void removeBase( GenericBase * base ); virtual void removeBuilding( GenericBuilding * building ); void setBaseId( GenericBase * base ); void setBuildingId( GenericBuilding * build ); Calendar * getCalendar() { return _calendar; } void updateLordUnit( uchar id , uchar pos, uchar race, uchar level, int nb, uchar move, int health ); virtual void updateBaseBuilding( int row, int col, uchar level, bool create ); virtual void exchangeArtefactLord( uchar idLord1, uchar idLord2, int item); protected: int _nbPlayer; uint _nbArtefact, _nbBonus, _nbChest; GenericMap * _map; Calendar * _calendar; QList _players; QList _bases; QList _buildings; QList _lords; QList _events; QList _creatures; QuestManager * _quests; QString _scenarioName, _scenarioTheme, _scenarioDescription; QString _attalVersion; }; #endif // GAMEDATA_H attal-src-1.0-rc2/libCommon/generalOptions.cpp0000644000175000017500000001346110617176265017110 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** generalOptions.cpp ** general options of the theme ** ** Version : $Id: generalOptions.cpp,v 1.13 2007/05/05 21:52:53 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 06/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "generalOptions.h" // generic include files // include files for QT #include #include // application specific include files #include "libCommon/log.h" extern QString DATA_PATH; // // ----- GeneralOptions ----- // QString GeneralOptions::getVisionManagementName( VISION_MANAGEMENT type ) { QString ret; switch( type ) { case VISION_ONCE: ret = "Vision once"; break; case VISION_REAL: ret = "Vision real"; break; } return ret; } GeneralOptions::GeneralOptions() { _calendar = NULL; clear(); } GeneralOptions::~GeneralOptions() { if(_calendar) { delete _calendar; _calendar = NULL; } } void GeneralOptions::clear() { _visionManagement = VISION_ONCE; if(_calendar) { delete _calendar; _calendar = NULL; } } bool GeneralOptions::save() { QString filename = DATA_PATH + "general.dat"; QFile file( filename ); int j,i; if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writing\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; ts << "\t" << (uint)_visionManagement << "" << endl; ts << "\t" << endl; for( i = 0; i < 3; i++ ) { ts << "\t\tgetLevelValue( i ); ts << "\">" ; ts << endl; for( j = 0; j < (int) _calendar->getLevelValue(i); j++ ) { ts << "\t\t\t"; ts << _calendar->getLevelName( i, j ); ts << "" << endl; } ts << "\t\t" << endl; } ts << "\t" << endl; ts << "" << endl; file.close(); return true; } bool GeneralOptions::init() { clear(); GeneralOptionsHandler handler( this ); QFile file( DATA_PATH + "general.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "general.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } void GeneralOptions::setCalendar(CalendarModel * calendar) { if(_calendar) { delete _calendar; _calendar = 0; } _calendar = calendar; } // // ----- GeneralOptionsHandler ----- // GeneralOptionsHandler::GeneralOptionsHandler( GeneralOptions * general ) { _general = general; _num = -1; _levelC = 0; _value = 0; } bool GeneralOptionsHandler::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _general->clear(); _state = StateInit; return true; } bool GeneralOptionsHandler::startElement( const QString &, const QString &, const QString & qName, const QXmlAttributes & atts ) { if( qName == "general" && _state == StateInit ) { _state = StateDocument; } else if( qName == "vision" && _state == StateDocument ) { _state = StateVision; } else if ( qName == "calendar" && _state == StateDocument ) { _state = StateCalendar; _calendar = new CalendarModel(); } else if ( qName == "level" && _state == StateCalendar ) { if( atts.index( "num" ) != -1 ) { _levelC = atts.value( "num" ).toInt(); } else { _levelC = 0; } if( atts.index( "value") != -1 ){ _value = atts.value( "value" ).toInt(); } else { _value = 0; } _state = StateCalendarLevel; } else if ( qName == "name" && _state == StateCalendarLevel ) { if( atts.index( "num" ) != -1 ) { _num = atts.value( "num" ).toInt(); } else { _num = -1; } _state = StateCalendarName; } else { // error return false; } return true; } bool GeneralOptionsHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateVision: _state = StateDocument; break; case StateCalendar: _general->setCalendar(_calendar); _state = StateDocument; break; case StateCalendarLevel: _state = StateCalendar; break; case StateCalendarName: _state = StateCalendarLevel; break; default: // do nothing break; } return true; } bool GeneralOptionsHandler::characters( const QString & ch ) { QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) return true; switch( _state ) { case StateVision: _general->setVisionManagement( ( GeneralOptions::VISION_MANAGEMENT ) ch_simplified.toInt() ); break; case StateCalendarLevel: _calendar->setLevelValue(_levelC,_value); break; case StateCalendarName: { _calendar->setLevelName(_levelC,_num ,ch_simplified); } break; default: return false; } return true; } bool GeneralOptionsHandler::fatalError( const QXmlParseException & exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/generalOptions.h0000644000175000017500000000617310354076547016557 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** generalOptions.h ** general options of the theme ** ** Version : $Id: generalOptions.h,v 1.5 2005/12/26 23:31:51 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 06/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERALOPTIONS_H #define GENERALOPTIONS_H // generic include files // include files for QT #include #include // application specific include files #include "libCommon/calendar.h" /* ------------------------------ * GeneralOptions * ------------------------------ */ class GeneralOptions { public: enum VISION_MANAGEMENT { VISION_ONCE, VISION_REAL }; /** Constructor */ GeneralOptions(); ~GeneralOptions(); /** Clears data */ void clear(); /** save into data file */ bool save(); /** Init options from data file */ bool init(); VISION_MANAGEMENT getVisionManagement() { return _visionManagement; } void setVisionManagement( VISION_MANAGEMENT visionManagement ) { _visionManagement = visionManagement; } static QString getVisionManagementName( VISION_MANAGEMENT type ); CalendarModel * getCalendar() {return _calendar;} void setCalendar(CalendarModel * calendar); protected: VISION_MANAGEMENT _visionManagement; CalendarModel * _calendar; }; /* ------------------------------ * GeneralOptionsHandler * ------------------------------ */ class GeneralOptionsHandler : public QXmlDefaultHandler { public: /** Construtor */ GeneralOptionsHandler( GeneralOptions * general ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: QString _errorProt; GeneralOptions * _general; CalendarModel * _calendar; int _num; int _levelC,_value; enum State { StateInit, StateDocument, StateVision, StateCalendar, StateCalendarLevel, StateCalendarName }; State _state; }; #endif // GENERALOPTIONS_H attal-src-1.0-rc2/libCommon/genericBase.cpp0000644000175000017500000006362711006425226016322 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericBase.cpp ** in order to manage buildings... ** ** Version : $Id: genericBase.cpp,v 1.51 2008/05/01 20:39:50 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 10/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericBase.h" // generic include files // include files for QT #include #include // application specific include files #include "libCommon/creature.h" #include "libCommon/dataTheme.h" #include "libCommon/genericCell.h" #include "libCommon/genericInsideBuilding.h" #include "libCommon/genericPlayer.h" #include "libCommon/log.h" #include "libCommon/unit.h" #include "libCommon/priceMarket.h" extern QString DATA_PATH; // // ----- GenericBase ----- // GenericBase::GenericBase( int race ) : _id( 0 ), _name(""), _player( 0 ) { _race = race; _canBuild = true; _canSell = true; _currentCell = 0; _visitorLord = 0; _garrisonLord = 0; _population = 0; _ress = new GenericResourceList(); getInitPopulation(); getInitResources(); for( int i = 0; i < MAX_UNIT ; i++ ) { _units[i] = 0; } } GenericBase::~GenericBase() { while( ! _buildings.isEmpty() ) { delete _buildings.takeFirst(); } for( uint i = 0; i < MAX_UNIT; i++ ) { delete _units[ i ]; } delete _ress; } //XXX workaround for some problems in parser, too late to modify scenarios format, always keep type as first or second field void GenericBase::setRace( int race ) { _race = race; getInitPopulation(); getInitResources(); } void GenericBase::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent ); *ts << "\t" << _id << "" << endl; indentation( ts, indent ); *ts << "\t" << _race << "" << endl; indentation( ts, indent ); *ts << "\t" << _name << "" << endl; indentation( ts, indent ); *ts << "\t" << _currentCell->getCol() << "" << endl; indentation( ts, indent ); *ts << "\t" << _currentCell->getRow() << "" << endl; for( int j = 0; j < DataTheme.resources.count(); j++ ) { indentation( ts, indent ); (*ts) << "\t"; (*ts) << _ress->getValue( j ); (*ts) << "" << endl; } for( int i = 0; i < _buildings.count(); i++ ) { indentation( ts, indent ); *ts << "\t" << _buildings.at( i )->getLevel() << "" << endl; } for( int j = 0; j < _forbidden.count(); j++ ) { indentation( ts, indent ); *ts << "\t" << _forbidden.at( j ) << "" << endl; } for( int i = 0; i < MAX_UNIT; i++ ) { if( _units[i] ) { indentation( ts, indent ); *ts << "\t" << endl; indentation( ts, indent ); *ts << "\t\t" << _units[i]->getRace() << "" << endl; indentation( ts, indent ); *ts << "\t\t" << _units[i]->getLevel() << "" << endl; indentation( ts, indent ); *ts << "\t\t" << _units[i]->getNumber() << "" << endl; indentation( ts, indent ); *ts << "\t" << endl; } } int numprod = _counter.getCreatureNumber(); if( numprod > 0 ) { indentation( ts, indent ); *ts << "\t" << endl; for( int i = 0; i < numprod; i++ ) { Creature * crea =_counter.getCreature( i ); if( crea ) { indentation( ts, indent ); *ts << "\t\t" << endl; indentation( ts, indent ); *ts << "\t\t\t" << crea->getRace() << "" << endl; indentation( ts, indent ); *ts << "\t\t\t" << crea->getLevel() << "" << endl; indentation( ts, indent ); *ts << "\t\t\t" << _counter.getCreatureCount(i) << "" << endl; indentation( ts, indent ); *ts << "\t\t" << endl; } } indentation( ts, indent ); *ts << "\t" << endl; } indentation( ts, indent ); *ts << "" << endl; *ts << flush; } void GenericBase::setPosition( GenericCell * cell ) { if( _currentCell != 0 ) { _currentCell->setBase( 0 ); } _currentCell = cell; _currentCell->setBase( this ); } /*! compute the gold earned by the castle... */ /// XXX: resource earned now depend on total population int GenericBase::collectRessource( int /* num */ ) { int ret = 0; /*switch( num ) { case 0 : ret = getPopulation(); break; }*/ return ret; } bool GenericBase::load( QTextStream * ) { /// XXX: no args ? return true; } void GenericBase::exchangeLords() { GenericLord * temp = _visitorLord; _visitorLord = _garrisonLord; _garrisonLord = temp; } uint GenericBase::getDoorRow() { if( _race < DataTheme.bases.count() ) { return DataTheme.bases.at( _race )->getDoorRow(); } else { return 0; } } uint GenericBase::getDoorCol() { if( _race < DataTheme.bases.count() ) { return DataTheme.bases.at( _race )->getDoorCol(); } else { return 0; } } uint GenericBase::getDispoHeight() { if( _race < DataTheme.bases.count() ) { return DataTheme.bases.at( _race )->getHeight(); } else { return 0; } } uint GenericBase::getDispoWidth() { if( _race < DataTheme.bases.count() ) { return DataTheme.bases.at( _race )->getWidth(); } else { return 0; } } void GenericBase::getInitPopulation() { if( _race < DataTheme.bases.count() ) { _population = DataTheme.bases.at( _race )->getPopulation(); } else { _population = 0; } } void GenericBase::getInitResources() { if( _race < DataTheme.bases.count() ) { _ress->setListValues( DataTheme.bases.at( _race )->getResourceList() ); } else { } } void GenericBase::getPopulationGrowth() { if( _race < DataTheme.bases.count() ) { _population = (_population * (100 + (DataTheme.bases.at( _race )->getPopulationGrowth()))/100); } else { _population = 0; } } void GenericBase::getPopulationLoss() { if( _race < DataTheme.bases.count() ) { _population = (_population * (100 - (DataTheme.bases.at( _race )->getPopulationLoss()))/100); if(_population <= 0) _population = 100; } else { _population = 0; } } GenericMapDisposition::DispositionType GenericBase::getDisposition( uint row, uint col ) { if( _race < DataTheme.bases.count() ) { return DataTheme.bases.at( _race )->getDisposition( row, col ); } else { return GenericMapDisposition::OCCUPIED; } } QString GenericBase::getModelName() { if( _race < DataTheme.bases.count() ) { return DataTheme.bases.at( _race )->getModelName(); } else { return ""; } } void GenericBase::addBuilding( GenericInsideBuilding * build ) { if( ! _buildings.count( build ) ) { _buildings.append( build ); } } void GenericBase::addBuilding( int level ) { GenericInsideBuilding * building = new GenericInsideBuilding(); building->setRace( _race ); building->setLevel( level ); addBuilding( building ); } GenericInsideBuilding * GenericBase::getBuilding( uint num ) { GenericInsideBuilding * ret = 0; if( num < getBuildingCount() ) { return _buildings.at( num ); } return ret; } GenericInsideBuilding * GenericBase::getBuildingByType( uint type ) { GenericInsideBuilding * ret = 0; for( int i = 0; i < _buildings.count(); i++ ) { if( _buildings.at( i )->getLevel() == type ) { ret = _buildings.at( i ); } } return ret; } bool GenericBase::hasBuildingType( uint type ) { bool ret = false; for( int i = 0; i < _buildings.count(); i++ ) { if( _buildings.at( i )->getLevel() == type ) { ret = true; i = _buildings.count(); } } return ret; } void GenericBase::removeBuildingType( uint type ) { GenericInsideBuilding * building = getBuildingByType( type ); removeBuilding( building ); } void GenericBase::removeBuilding( GenericInsideBuilding * building ) { _buildings.removeAll( building ); delete building; } void GenericBase::removeBuilding( int level ) { GenericInsideBuilding * building = getBuildingByType(level); removeBuilding( building ); } void GenericBase::updateBuilding( uchar level, bool create ) { if( create ) { addBuilding( level ); } else { removeBuildingType( level ); } } uint GenericBase::getForbiddenBuildingsNumber() { return _forbidden.count(); } int GenericBase::getForbiddenBuilding( uint num ) { int ret = 0; if( (int)num < _forbidden.count() ) { ret = _forbidden.at( num ); } return ret; } void GenericBase::addForbiddenBuilding( int num ) { _forbidden.append( num ); } bool GenericBase::isForbidden( int num ) { bool ret = false; for( int i = 0; i < _forbidden.count(); i++ ) { if( _forbidden.at( i ) == num ) { ret = true; } } return ret; } bool GenericBase::canBuildBuilding( InsideBuildingModel * building ) { bool ret = true; int nbRequirements = building->getRequirementNumber(); for( int i = 0; i < nbRequirements; ++i ) { if( ! hasBuildingType( building->getRequirement( i ) ) ) { ret = false; break; } } return ret; } int GenericBase::getCreatureProduction( Creature * creature ) { return _counter.getCreatureCount( creature ); } int GenericBase::getCreatureProduction( int num ) { return _counter.getCreatureCount( num ); } void GenericBase::setCreatureProduction( Creature * creature, int value) { _counter.setCreatureCount( creature, value ); } bool GenericBase::canProduceCreature( Creature * creature ) { uint nbBuildings = _buildings.count(); int creatRace = creature->getRace(); int creatLevel = creature->getLevel(); GenericBaseModel * baseModel = DataTheme.bases.at( _race ); for( uint i = 0; i < nbBuildings; i++ ) { GenericInsideBuilding * building = _buildings.at( i ); InsideBuildingModel * model = baseModel->getBuildingModel( building->getLevel() ); InsideAction * action = model->getAction(); if( action ) { if( action->getType() == INSIDE_CREA ) { if( creatRace == action->getParam( 0 ) && creatLevel == action->getParam( 1 ) ) { return true; } } } } return false; } void GenericBase::initCreatureProduction() { uint nbBuildings = _buildings.count(); _counter.clear(); GenericBaseModel * baseModel = DataTheme.bases.at( _race ); for( uint i = 0; i < nbBuildings; i++ ) { GenericInsideBuilding * building = _buildings.at( i ); InsideBuildingModel * model = baseModel->getBuildingModel( building->getLevel() ); InsideAction * action = model->getAction(); if( action ) { if( action->getType() == INSIDE_CREA ) { int race = action->getParam( 0 ); int level = action->getParam( 1 ); int number = action->getParam( 2 ); addCreature( race, level, number ); } } } } void GenericBase::buyCreature( Creature * creature, int number ) { _counter.decreaseCreature( creature, number ); } void GenericBase::addCreature( int race, int level, int number ) { Creature * creature = DataTheme.creatures.at( race, level ); _counter.addCreature( creature, number ); } int GenericBase::getCreatureNumber() { return _counter.getCreatureNumber(); } Creature * GenericBase::getCreatureProduced(int num) { return _counter.getCreature(num); } bool GenericBase::canAddGarrison( Creature * creature ) { bool ret = false; for( int i = 0; i < MAX_UNIT; i++ ) { if( isGarrisonLord() ) { GenericFightUnit * tempUnit = getGarrisonLord()->getUnit( i ); if( ( tempUnit == 0 ) || ( tempUnit->getCreature() == creature ) ) { ret = true; } } else { if( ( getUnit( i ) == 0 ) || ( getUnit( i )->getCreature() == creature ) ) { ret = true; } } } return ret; } void GenericBase::addGarrison( Creature * creature, int number ) { if( isGarrisonLord() ) { getGarrisonLord()->addCreatures( creature, number ); } else { for( int i = 0; i < MAX_UNIT; i++ ) { if( getUnit( i ) == 0 ) { GenericFightUnit * unit = new GenericFightUnit(); unit->setCreature( creature ); unit->setNumber( number ); setUnit( i, unit ); break; } else if( getUnit( i )->getCreature() == creature ) { GenericFightUnit * unit = getUnit( i ); unit->addNumber( number ); break; } } } } void GenericBase::addUnit( int pos , int race , int level , int nb ) { GenericFightUnit * uni =getUnit( pos ); if( nb != 0 ){ if( !uni ){ uni = new GenericFightUnit(); } uni->setCreature( race, level ); uni->setNumber( nb ); } else { if( uni ) { uni->setNumber( nb ); delete uni; uni = NULL; } } setUnit( pos, uni ); } int GenericBase::getVision() { int ret = 3; if( _race < DataTheme.bases.count() ) { ret = DataTheme.bases.at( _race )->getVision(); } return ret; } QString GenericBase::getBaseDescription() { QString msg; msg = QObject::tr( "Base " ) + getName(); //+ QString(QObject::tr(" - population: %1 ") ).arg( getPopulation() ); msg += _ress->getAutoDescription(); return msg; } QList GenericBase::getActionList( Action::ActionType type ) { QList ret; GenericBaseModel * _model = DataTheme.bases.at( _race ); for( int i = 0; i < _model->getActionList()->count(); i++ ) { if( _model->getActionList()->at( i )->getType() == type ) { ret.append( _model->getActionList()->at( i ) ); } } return ret; } // // ----- GenericBaseModel ----- // GenericBaseModel::GenericBaseModel() : _race( 0 ), _vision( 3 ) { _actionList = new QList; _ress = new GenericResourceList(); _population = 0; _growth = 0; _loss = 0; GenericMapDisposition::init( 5, 5 ); setDisposition( 4, 0, DOOR ); _price = new PriceMarket(); } GenericBaseModel::~GenericBaseModel() { while( ! _buildings.isEmpty() ) { delete _buildings.takeFirst(); } if(_price) { delete _price; _price = 0; } delete _ress; while( ! _actionList->isEmpty() ) { delete _actionList->takeFirst(); } delete _actionList; } void GenericBaseModel::addBuilding( InsideBuildingModel * building ) { _buildings.append( building ); } InsideBuildingModel * GenericBaseModel::getBuildingModel( int num ) { return _buildings.at( num ); } void GenericBaseModel::removeBuilding( uint num ) { if( (int)num < _buildings.count() ) { delete _buildings.takeAt( num ); } } void GenericBaseModel::setPriceMarket( PriceMarket * price ) { if(_price) { delete _price; _price = 0; } _price = price; } void GenericBaseModel::save( QTextStream * ts, int indent ) { uint nbRes = DataTheme.resources.count(); indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent ); *ts << "\t" << _modelName << "" << endl; indentation( ts, indent ); *ts << "\t" << endl; GenericMapDisposition::save( ts, indent+1 ); indentation( ts, indent ); *ts << "\t" << endl; indentation( ts, indent+1 ); *ts << "\t" << _population << "" << endl; indentation( ts, indent+1 ); *ts << "\t" << _growth << "" << endl; indentation( ts, indent+1 ); *ts << "\t" << _loss << "" << endl; indentation( ts, indent+1 ); *ts << "" << endl; for( int j = 0; j < DataTheme.resources.count(); j++ ) { indentation( ts, indent ); *ts << "\t"; *ts << _ress->getValue( j ); *ts << "\t" << endl; } indentation( ts, indent+1 ); *ts << "" << endl; for( uint k = 0; k < nbRes; k++ ) { if( _price->getResourcePrice(k) > 0 ) { indentation( ts, indent+1 ); *ts << "\t"; *ts << _price->getResourcePrice( k ) << "" << endl; } } indentation( ts, indent+1 ); *ts << "" << endl; for( int i = 0; i < _actionList->count(); ++i ) { _actionList->at( i )->save( ts, indent ); } //indentation( ts, indent ); for( int i = 0; i < _buildings.count(); ++i ) { InsideBuildingModel * build = _buildings.at(i); build->save( ts, indent + 1 ); } indentation( ts, indent ); *ts << "" << endl; *ts << flush; } // // ----- BaseList ----- // BaseList::BaseList() { } BaseList::~BaseList() { clear(); /*while( ! _type.isEmpty() ) { delete _type.takeFirst(); }*/ } void BaseList::clear() { _type.clear(); while( ! isEmpty() ) { delete takeFirst(); } } bool BaseList::init() { clear(); BaseHandler handler( this ); QFile file( DATA_PATH + "bases.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "bases.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } bool BaseList::save() { QString filename = DATA_PATH + "bases.dat"; QFile file( filename ); if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writing\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; GenericBaseModel * base; for( int i = 0; i < count(); i++ ) { base = at( i ); if( base ) { base->save( &ts, 1 ); } } ts << "" << endl; file.close(); return true; } GenericBaseModel * BaseList::at( QString typeName ) { GenericBaseModel * ret = first(); GenericBaseModel * current; QListIterator ite( *this ); while( ite.hasNext() ) { current = ite.next(); if( current->getModelName() == typeName ) { ret = current; } } return ret; } // void BaseList::clear() // { // QPtrList::clear(); // _type.clear(); // } // int BaseList::addType( QString typeName ) // { // QPtrListIterator ite( _type ); // int cpt = 0, ret = -1; // for( ite.toFirst(); ite.current(); ++ite ) { // if( *(ite.current()) == typeName ) { // ret = cpt; // break; // } // cpt++; // } // if( ret == -1 ) { // ret = cpt; // _type.append( new QString( typeName ) ); // } // return ret; // } // // ----- BaseHandler ----- // BaseHandler::BaseHandler( BaseList * list ) { _list = list; } bool BaseHandler::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _list->clear(); _race = 0; _level = 0; _state = StateInit; return true; } bool BaseHandler::startElement( const QString &, const QString &, const QString & qName, const QXmlAttributes & atts ) { if( qName == "bases" && _state == StateInit ) { _state = StateDocument; } else if( qName == "base" && _state == StateDocument ) { _state = StateBase; _base = new GenericBaseModel(); _base->setRace( _race ); } else if( qName == "name" && _state == StateBase ) { _state = StateName; } else if( qName == "disposition" && _state == StateBase ) { _state = StateDisposition; _height = atts.value( "height" ).toUInt(); _width = atts.value( "width" ).toUInt(); _base->GenericMapDisposition::init( _height, _width ); } else if( qName == "population" && _state == StateBase ) { _state = StatePopulation; } else if( qName == "value" && _state == StatePopulation ) { _state = StatePopulationValue; } else if( qName == "growth" && _state == StatePopulation ) { _state = StatePopulationGrowth; } else if( qName == "loss" && _state == StatePopulation ) { _state = StatePopulationLoss; } else if( qName == "resource" && _state == StateBase ) { _state = StateResource; _res = atts.value( "type" ).toInt(); } else if( qName == "rescost" && _state == StateBase ) { _price = new PriceMarket(); _state = StateRessPrice; } else if( qName == "cost" && _state == StateRessPrice ) { if( atts.index( "ressource" ) != -1 ) { _csress = atts.value( "ressource" ).toInt(); } else { _csress = 0; } _state = StateRessCost; } else if( qName == "action" && _state == StateBase ) { _state = StateAction; _baseAction = new Action(); _baseAction->setType( (Action::ActionType)( atts.value( "type" ).toInt() ) ); _baseAction->setCoeff( ( atts.value( "coeff" ).toInt() ) ); } else if( qName == "elementary" && _state == StateAction ) { _state = StateElementary; _elementary = new ElementaryAction(); _elementary->setType( (ElementaryAction::ElementaryType)( atts.value( "type" ).toInt() ) ); _elementary->setArg( atts.value( "arg" ).toInt() ); _elementary->setArg1( atts.value( "arg1" ).toInt() ); } else if( qName == "building" && _state == StateBase ) { _building = new InsideBuildingModel(); _building->setRace( _race ); _building->setLevel( _level ); _level++; _state = StateBuilding; } else if( qName == "name" && _state == StateBuilding ) { _state = StateBuildingName; } else if( qName == "description" && _state == StateBuilding ) { _state = StateBuildingDescription; } else if( qName == "require" && _state == StateBuilding ) { _state = StateBuildingRequire; } else if( qName == "replace" && _state == StateBuilding ) { _state = StateBuildingReplace; } else if( qName == "cost" && _state == StateBuilding ) { if( atts.index( "ressource" ) != -1 ) { _ress = atts.value( "ressource" ).toInt(); } else { _ress = 0; } _state = StateBuildingCost; } else if( qName == "mcost" && _state == StateBuilding ) { if( atts.index( "ressource" ) != -1 ) { _mress = atts.value( "ressource" ).toInt(); } else { _mress = 0; } _state = StateBuildingMantCost; } else if( qName == "x" && _state == StateBuilding ) { _state = StateBuildingX; } else if( qName == "y" && _state == StateBuilding ) { _state = StateBuildingY; } else if( qName == "action" && _state == StateBuilding ) { _action = new InsideAction(); if( atts.index( "type" ) != -1 ) { _action->setType( atts.value( "type" ).toInt() ); } else { _action->setType( 0 ); } _state = StateBuildingAction; } else if( qName == "param" && _state == StateBuildingAction ) { _state = StateBuildingActionParam; } else { // error return false; } return true; } bool BaseHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateBase: _list->append( _base ); _race++; _level = 0; _state = StateDocument; break; case StateName: _state = StateBase; break; case StateDisposition: _state = StateBase; break; case StatePopulation: _state = StateBase; break; case StatePopulationValue: _state = StatePopulation; break; case StatePopulationGrowth: _state = StatePopulation; break; case StatePopulationLoss: _state = StatePopulation; break; case StateResource: _state = StateBase; break; case StateRessPrice: _base->setPriceMarket( _price ); _state = StateBase; break; case StateRessCost: _state = StateRessPrice; break; case StateAction: _state = StateBase; _base->addAction( _baseAction ); break; case StateElementary: _state = StateAction; _baseAction->addElementaryAction( _elementary ); break; case StateBuilding: _base->addBuilding( _building ); _state = StateBase; break; case StateBuildingName: _state = StateBuilding; break; case StateBuildingDescription: _state = StateBuilding; break; case StateBuildingRequire: _state = StateBuilding; break; case StateBuildingReplace: _state = StateBuilding; break; case StateBuildingCost: _state = StateBuilding; break; case StateBuildingMantCost: _state = StateBuilding; break; case StateBuildingX: _state = StateBuilding; break; case StateBuildingY: _state = StateBuilding; break; case StateBuildingAction: _state = StateBuilding; _building->setAction( _action ); break; case StateBuildingActionParam: _state = StateBuildingAction; break; default: // do nothing break; } return true; } bool BaseHandler::characters( const QString & ch ) { QString ch_simplified = ch.simplified(); if( ch_simplified.isEmpty() ) { return true; } switch( _state ) { case StateName: _base->setModelName( ch_simplified ); break; case StateDisposition: { QStringList li = ch_simplified.split( " " ); GenericMapDisposition::DispositionType type; for( uint i = 0; i < _height; i++ ) { for( uint j = 0; j < _width; j++ ) { type = GenericMapDisposition::DispositionType( li[ i * _width + j ].toInt() ); _base->setDisposition( i, j, type ); } } } break; case StatePopulationValue: _base->setPopulation( ch_simplified.toInt() ); break; case StatePopulationGrowth: _base->setPopulationGrowth( ch_simplified.toInt() ); break; case StatePopulationLoss: _base->setPopulationLoss( ch_simplified.toInt() ); break; case StateResource: _base->getResourceList()->setValue( _res, ch_simplified.toInt() ); break; case StateRessCost:{ int cost = ch_simplified.toInt(); cost = cost < 10000 ? cost : 100; cost = cost > 0 ? cost : 100; _price->setResourcePrice( _csress,cost ); } break; case StateElementary: _elementary->setCoeff( ch_simplified.toInt() ); break; case StateBuildingName: _building->setName( ch_simplified ); break; case StateBuildingDescription: _building->setDescription( ch_simplified ); break; case StateBuildingRequire: _building->addRequirement( ch_simplified.toInt() ); break; case StateBuildingReplace: _building->setReplacement( ch_simplified.toInt() ); break; case StateBuildingCost: _building->setCost( _ress, ch_simplified.toInt() ); break; case StateBuildingMantCost: _building->setMantCost( _mress, ch_simplified.toInt() ); break; case StateBuildingX: _building->setX( ch_simplified.toInt() ); break; case StateBuildingY: _building->setY( ch_simplified.toInt() ); break; case StateBuildingActionParam: _action->addParam( ch_simplified.toInt() ); break; default: return false; } return true; } bool BaseHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/genericBase.h0000644000175000017500000003065111006425230015751 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericBase.h ** in order to manage bases... ** ** Version : $Id: genericBase.h,v 1.32 2008/05/01 20:39:52 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 10/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICBASE_H #define GENERICBASE_H // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/action.h" #include "libCommon/creature.h" #include "libCommon/define.h" #include "libCommon/log.h" #include "libCommon/genericLord.h" #include "libCommon/genericInsideBuilding.h" #include "libCommon/genericMapDisposition.h" #include "libCommon/genericRessources.h" class QTextStream; class InsideAction; class GenericBuilding; class GenericFightUnit; class GenericPlayer; class PriceMarket; /** ------------------------------ * GenericBase ** ------------------------------ */ class GenericBase { public: /** Constructor */ GenericBase( int race = 0 ); virtual ~GenericBase(); /** When a lord enters in the base */ virtual void enter( GenericLord * lord ) { if( !setVisitorLord( lord ) ) { logEE( "Enter base failed" ); } } /** When the lord goes out of the base */ virtual void out( GenericLord * ) { if( isVisitorLord() ) { removeVisitorLord(); } else { logEE( "No visiting lord found" ); } } /** Load base */ virtual bool load( QTextStream * ); /** Save base */ void save( QTextStream * ts, int indent = 0 ); /** Collect ressource 'num' */ int collectRessource( int num ); /** Set id to the base */ void setId( int id ) { _id = id; } /** Get id */ int getId() { return _id; } /** Set 'race' */ virtual void setRace( int race ); /** Get 'race' */ int getRace() { return _race; } /** Set name */ void setName( const QString & name ) { _name = name; } /** Get name */ QString getName() { return _name; } GenericCell * getCell() { return _currentCell; } virtual void setPosition( GenericCell * cell ); /** Set owner of the building */ virtual void setOwner( GenericPlayer * player ) { _player = player; } /** Return owner of the building */ GenericPlayer * getOwner() { return _player; } /** Exchange lord (garrison and visitor) */ void exchangeLords(); /** Set visitor */ inline bool setVisitorLord( GenericLord * lord ); /** Set garrison */ inline bool setGarrisonLord( GenericLord * lord ); /** Get visitor */ inline GenericLord * getVisitorLord(); /** Get visitor unit 'num' */ inline GenericFightUnit * getVisitorUnit( int num ); /** Set visitor unit 'num' */ inline void setVisitorUnit( int num, GenericFightUnit * troop ); /** Get garrison */ inline GenericLord * getGarrisonLord(); /** Get garrison unit 'num' */ inline GenericFightUnit * getGarrisonUnit( int num ); /** Set garrison unit 'num' */ inline void setGarrisonUnit( int num, GenericFightUnit * troop ); /** Remove visitor */ inline GenericLord * removeVisitorLord(); /** Remove garrison */ inline GenericLord * removeGarrisonLord(); /** Tell if there is a visitor */ inline bool isVisitorLord(); /** Tell if there is a garrison */ inline bool isGarrisonLord(); /** Give unit 'num' of the base */ GenericFightUnit * getUnit( int num ) { return _units[num]; } /** Set unit 'num' of the base */ void setUnit( int num, GenericFightUnit * troop ) { _units[num] = troop; } bool canAddGarrison( Creature * creature ); void addGarrison( Creature * creature, int num ); void addUnit( int pos , int race , int level , int nb ); uint getDoorRow(); uint getDoorCol(); uint getDispoHeight(); uint getDispoWidth(); GenericMapDisposition::DispositionType getDisposition( uint row, uint col ); int getPopulation() { return _population; } void setPopulation( int population ) { _population = population; } void getInitPopulation(); void getPopulationGrowth(); void getPopulationLoss(); QString getModelName(); void addBuilding( GenericInsideBuilding * ); void addBuilding( int type ); uint getBuildingCount() { return _buildings.count(); } GenericInsideBuilding * getBuilding( uint num ); GenericInsideBuilding * getBuildingByType( uint type ); bool hasBuildingType( uint type ); void removeBuilding( GenericInsideBuilding * building ); void removeBuilding( int type ); void removeBuildingType( uint type ); void updateBuilding( uchar level, bool create ); uint getForbiddenBuildingsNumber(); int getForbiddenBuilding( uint num ); void addForbiddenBuilding( int num ); bool isForbidden( int num ); /** Check building requirements */ bool canBuildBuilding( InsideBuildingModel * building ); bool canBuild() { return _canBuild; } void canBuild( bool state ) { _canBuild = state; } bool canSell() { return _canSell; } void canSell( bool state ) { _canSell = state; } bool isUnitBought() { return _bought; } void isUnitBought( bool state ) { _bought = state; } int getCreatureProduction( Creature * creature ); int getCreatureProduction( int num ); void setCreatureProduction( Creature * creature, int value); void initCreatureProduction(); bool canProduceCreature( Creature * creature ); Creature * getCreatureProduced(int num); int getCreatureNumber(); void addCreature( int race, int level, int number ); void buyCreature( Creature * creature, int number ); int getVision(); PriceMarket * getPriceMarket() { return _price;} void setPriceMarket(PriceMarket * price) { _price = price;} QString getBaseDescription(); void getInitResources(); GenericResourceList * getResourceList() { return _ress; } QList getActionList( Action::ActionType type ); protected: int _id; int _race; QString _name; bool _canBuild; bool _canSell; bool _bought; GenericCell * _currentCell; uint _population; GenericPlayer * _player; QList _buildings; GenericLord * _visitorLord, * _garrisonLord; GenericFightUnit * _units[ MAX_UNIT ]; QList _forbidden; CreatureCounter _counter; PriceMarket * _price; GenericResourceList * _ress; }; /** Model for genericBase */ class GenericBaseModel : public GenericMapDisposition { public: /** Constructor */ GenericBaseModel(); /** Destructor */ virtual ~GenericBaseModel(); /** \return Returns the name of the model */ QString getModelName() { return _modelName; } /** Sets the name of the model */ void setModelName( const QString & name ) { _modelName = name; } int getPopulation() { return _population; } void setPopulation( int population ) { _population = population; } int getPopulationGrowth() { return _growth; } void setPopulationGrowth( int growth ) { _growth = growth; } int getPopulationLoss() { return _loss; } void setPopulationLoss( int loss ) { _loss = loss; } int getRace() { return _race; } void setRace( int race ) { _race = race; } int getVision() { return _vision; } void setVision( int vision ) { _vision = vision; } void addBuilding( InsideBuildingModel * ); void removeBuilding( uint num ); InsideBuildingModel * getBuildingModel( int ); uint getBuildingCount() { return _buildings.count(); } PriceMarket * getPriceMarket() { return _price;} void setPriceMarket( PriceMarket * price ); GenericResourceList * getResourceList() { return _ress; } /** Add an action associated to this model of base */ void addAction( Action * action ) { _actionList->append( action ); } /** \return Returns the list of actions associated to this model */ QList * getActionList() { return _actionList; } /** Clear the list of actions associated to this model of base */ void clearActions() { _actionList->clear(); } void save( QTextStream * ts, int indent = 0 ); protected: QString _modelName; int _race; int _population,_growth,_loss; int _vision; QList _buildings; QList * _actionList; PriceMarket * _price; GenericResourceList * _ress; }; /** List of GenericBaseModel */ class BaseList : public QList { public: /** Constructor */ BaseList(); /** Destructor */ virtual ~BaseList(); /** Return base corresponding to 'type' */ GenericBaseModel * at( int type ) { return QList::at( type ); } /** Return base corresponding to 'typeName' */ GenericBaseModel * at( QString typeName ); /** Clear list */ void clear(); bool save(); /** Init list */ bool init(); // /** Add a new type of base */ // int addType( QString typeName ); // /** Get type name corresponding to 'type' */ // QString getTypeName( int type ) { return *(_type.at( type )); } private: QList _type; }; /** Parser for BaseList */ class BaseHandler : public QXmlDefaultHandler { public: /** Construtor */ BaseHandler( BaseList * list ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: QString _errorProt; BaseList * _list; GenericBaseModel * _base; int _race, _level; int _unRace, _unLevel; InsideBuildingModel * _building; InsideAction * _action; QTextStream * _stream; QString _baseName; int _ress,_mress,_csress; int _res; uint _height, _width; PriceMarket * _price; Action * _baseAction; ElementaryAction * _elementary; enum State { StateInit, StateDocument, StateBase, StateName, StateDisposition, StatePopulation, StatePopulationValue, StatePopulationGrowth, StatePopulationLoss, StateResource, StateRessPrice, StateRessCost, StateAction, StateElementary, StateBuilding, StateBuildingName, StateBuildingDescription, StateBuildingCost, StateBuildingMantCost, StateBuildingRequire, StateBuildingReplace, StateBuildingX, StateBuildingY, StateBuildingAction, StateBuildingActionParam }; State _state; }; /*************************************************************/ inline bool GenericBase::setVisitorLord( GenericLord * lord ) { if( isVisitorLord() ) return false; _visitorLord = lord; return true; } inline bool GenericBase::setGarrisonLord( GenericLord * lord ) { if( isGarrisonLord() ) return false; _garrisonLord = lord; return true; } inline GenericLord * GenericBase::getVisitorLord() { return _visitorLord; } inline GenericFightUnit * GenericBase::getVisitorUnit( int num ) { if( isVisitorLord() ) { return getVisitorLord()->getUnit( num ); } return 0; } inline void GenericBase::setVisitorUnit( int num, GenericFightUnit * troop ) { if( isVisitorLord() ) { getVisitorLord()->setUnit( num, troop ); } } inline GenericLord * GenericBase::getGarrisonLord() { return _garrisonLord; } inline GenericFightUnit * GenericBase::getGarrisonUnit( int num ) { if( isGarrisonLord() ) { return getGarrisonLord()->getUnit( num ); } else { return _units[num]; } } inline void GenericBase::setGarrisonUnit( int num, GenericFightUnit * troop ) { if( isGarrisonLord() ) { getGarrisonLord()->setUnit( num, troop ); } else { _units[num] = troop; } } inline GenericLord * GenericBase::removeVisitorLord() { GenericLord * temp = _visitorLord; _visitorLord = 0; return temp; } inline GenericLord * GenericBase::removeGarrisonLord() { GenericLord * temp = _garrisonLord; _garrisonLord = 0; return temp; } inline bool GenericBase::isVisitorLord() { return( _visitorLord != 0 ); } inline bool GenericBase::isGarrisonLord() { return( _garrisonLord != 0 ); } #endif // GENERICBASE_H attal-src-1.0-rc2/libCommon/genericBonus.cpp0000644000175000017500000000467410704760204016535 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericBonus.cpp ** Class for managing bonus on map ** ** Version : $Id: genericBonus.cpp,v 1.7 2007/10/15 21:49:56 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericBonus.h" // generic include files // include files for QT #include #include // application specific include files #include "libCommon/dataTheme.h" // // ----- GenericBonus ----- // GenericBonus::GenericBonus() { _type = BonusResource; } GenericBonus::~GenericBonus() { } void GenericBonus::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; uint nbParam = _params.count(); for( uint i = 0; i < nbParam; i++ ) { indentation( ts, indent+1 ); *ts << "" << _params.at( i ) << "" << endl; } indentation( ts, indent ); *ts << "" << endl; *ts << flush; } void GenericBonus::addParam( uint value ) { _params.append( value ); } uint GenericBonus::getParamNumber() { return _params.count(); } uint GenericBonus::getParam( uint num ) { uint ret = 0; if( (int)num < _params.count() ) { ret = _params.at( num ); } return ret; } void GenericBonus::clearParams() { _params.clear(); } QString GenericBonus::getBonusDescription() { QString msg; switch( getType() ) { case GenericBonus::BonusResource: msg = QString( QObject::tr("Resource: ") ) + DataTheme.resources.getRessource( getParam( 0 ) ) + QString( QObject::tr(" Fixed Value: ") ) + QString::number( getParam( 2 ) ); break; case GenericBonus::BonusPrimSkill: msg = QObject::tr("Bonus "); break; case GenericBonus::BonusSkill: msg = QObject::tr("Bonus "); break; case GenericBonus::BonusSpell: msg = QObject::tr("Bonus "); break; default: break; } return msg; } attal-src-1.0-rc2/libCommon/genericBonus.h0000644000175000017500000000436110704760204016173 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericBonus.h ** Class for managing bonus on map ** ** Version : $Id: genericBonus.h,v 1.7 2007/10/15 21:49:56 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 26/08/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICBONUS_H #define GENERICBONUS_H // generic include files // include files for QT #include // application specific include files //class GenericCell; class QTextStream; // For BonusResource, first param is resource type, // then 2nd param is numberType: // 0 - Fixed -> next param is number of resource // 1 - Various -> next param describes how many various // values, then the couples (value-ponderation) // 2 - Alea ->next params are, minValue (included), // maxValue(included) and step value // For PrimSkill, first value is the primSkill // (0-Attack, 1-Defense, 2-Power, 3-Knowledge, 4-Morale, 5-Luck) // then the number 'added' /* ------------------------------ * GenericBonus * ------------------------------ */ class GenericBonus { public: enum BonusType { BonusResource = 0, BonusPrimSkill, BonusSkill, BonusSpell }; /** Constructor */ GenericBonus(); /** Destructor */ virtual ~GenericBonus(); BonusType getType() { return _type; } void setType( BonusType type ) { _type = type; } void addParam( uint value ); uint getParamNumber(); uint getParam( uint num ); void clearParams(); /** Save building */ void save( QTextStream * ts, int indent = 0 ); QString getBonusDescription(); virtual void setupBonus() {} protected: BonusType _type; QList _params; }; #endif // GENERICBONUS_H attal-src-1.0-rc2/libCommon/genericBuilding.cpp0000644000175000017500000003070310751372503017177 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericBuilding.cpp ** in order to manage buildings... ** ** Version : $Id: genericBuilding.cpp,v 1.33 2008/02/03 17:09:23 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 10/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericBuilding.h" // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/action.h" #include "libCommon/genericCell.h" #include "libCommon/genericLord.h" #include "libCommon/dataTheme.h" #include "libCommon/condition.h" extern QString DATA_PATH; // // ----- GenericBuilding ----- // GenericBuilding::GenericBuilding( int type ) : _id( 0 ), _player( 0 ) { _type = type; _currentCell = 0; _condition = 0; _ress = new GenericResourceList(); getInitResources(); } GenericBuilding::~GenericBuilding() { delete _ress; } void GenericBuilding::getInitResources() { GenericBuildingModel * model = DataTheme.buildings.at( _type ); _ress->setListValues( model->getResourceList() ); } bool GenericBuilding::load( QTextStream * ) { return true; } void GenericBuilding::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent ); *ts << "\t" << _id << "" << endl; indentation( ts, indent ); *ts << "\t" << _currentCell->getCol() << "" << endl; indentation( ts, indent ); *ts << "\t" << _currentCell->getRow() << "" << endl; for( int j = 0; j < DataTheme.resources.count(); j++ ) { indentation( ts, indent ); (*ts) << "\t"; (*ts) << _ress->getValue( j ); (*ts) << "" << endl; } indentation( ts, indent ); *ts << "" << endl; *ts << flush; } void GenericBuilding::enter( GenericLord * lord ) { if( _lords.indexOf( lord ) == -1 ) { _lords.append( lord ); } } QList GenericBuilding::getActionList( Action::ActionType type ) { QList ret; GenericBuildingModel * _model = DataTheme.buildings.at( _type ); for( int i = 0; i < _model->getActionList()->count(); i++ ) { if( _model->getActionList()->at( i )->getType() == type ) { ret.append( _model->getActionList()->at( i ) ); } } return ret; } QString GenericBuilding::getName() { GenericBuildingModel * _model = DataTheme.buildings.at( _type ); return _model->getName(); } QString GenericBuilding::getBuildDescription() { QString ret = ""; ret = getBuildAutoDescription(); ret += _ress->getAutoDescription(); return ret; } QString GenericBuilding::getBuildAutoDescription() { QString tmp = getName() + "\n"; for( int type = Action::DATE; type< Action::LAST; type++ ){ QList action = getActionList((Action::ActionType) type); for( int i = 0; i < action.count(); i++ ) { tmp += action.at( i )->getDescription( true ); } } return tmp; } uint GenericBuilding::getNbFrame() { GenericBuildingModel * _model = DataTheme.buildings.at( _type ); return _model->getNbFrame(); } int GenericBuilding::getAnimFreq() { GenericBuildingModel * _model = DataTheme.buildings.at( _type ); return _model->getAnimFreq(); } void GenericBuilding::setPosition( GenericCell * cell ) { TRACE("void GenericBuilding::setPosition( GenericCell * cell ) row %d, cell col %d",cell->getRow(), cell->getCol()); if( _currentCell != 0 ) { _currentCell->setBuilding( 0 ); } _currentCell = cell; cell->setBuilding( this ); } bool GenericBuilding::hasBeenVisited() { return( ! _lords.isEmpty() ); } bool GenericBuilding::hasBeenVisited( GenericLord * lord ) { return( _lords.indexOf( lord ) != -1 ); } uint GenericBuilding::getDoorRow() { GenericBuildingModel * model = DataTheme.buildings.at( _type ); if( model ) { return model->getDoorRow(); } else { return 0; } } uint GenericBuilding::getDoorCol() { GenericBuildingModel * model = DataTheme.buildings.at( _type ); if( model ) { return model->getDoorCol(); } else { return 0; } } uint GenericBuilding::getDispoHeight() { GenericBuildingModel * model = DataTheme.buildings.at( _type ); if( model ) { return model->getHeight(); } else { return 0; } } uint GenericBuilding::getDispoWidth() { GenericBuildingModel * model = DataTheme.buildings.at( _type ); if( model ) { return model->getWidth(); } else { return 0; } } GenericMapDisposition::DispositionType GenericBuilding::getDisposition( uint row, uint col ) { GenericBuildingModel * model = DataTheme.buildings.at( _type ); if( model ) { return model->getDisposition( row, col ); } else { return GenericMapDisposition::OCCUPIED; } } // // ----- GenericBuildingModel ----- // GenericBuildingModel::GenericBuildingModel() : _type( 0 ), _nbFrame( 1 ), _animFreq( 1 ) { _actionList = new QList; _ress = new GenericResourceList(); GenericMapDisposition::init( 5, 5 ); setDisposition( 4, 0, DOOR ); } GenericBuildingModel::~GenericBuildingModel() { while( ! _actionList->isEmpty() ) { delete _actionList->takeFirst(); } delete _actionList; delete _ress; } void GenericBuildingModel::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent ); *ts << "\t" << _name << "" << endl; indentation( ts, indent ); *ts << "\t" << _description << "" << endl; indentation( ts, indent ); *ts << "\t" << _nbFrame << "" << endl; indentation( ts, indent ); *ts << "\t" << _animFreq << "" << endl; for( int j = 0; j < DataTheme.resources.count(); j++ ) { indentation( ts, indent ); *ts << "\t"; *ts << _ress->getValue( j ); *ts << "\t" << endl; } for( int i = 0; i < _actionList->count(); ++i ) { _actionList->at( i )->save( ts, indent ); } GenericMapDisposition::save( ts, indent+1 ); indentation( ts, indent ); indentation( ts, indent ); *ts << "" << endl; *ts << flush; } // // ----- BuildingList ----- // BuildingList::BuildingList() { } BuildingList::~BuildingList() { clear(); } bool BuildingList::init() { clear(); BuildingHandler handler( this ); QFile file( DATA_PATH + "buildings.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "buildings.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } void BuildingList::clear() { while( ! isEmpty() ) { delete takeFirst(); } } bool BuildingList::save() { QString filename = DATA_PATH + "buildings.dat"; QFile file( filename ); if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writing\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; GenericBuildingModel * building; for( int i = 0; i < count(); i++ ) { building = at( i ); if( building ) { building->save( &ts, 1 ); } } ts << "" << endl; file.close(); return true; } // // ----- BuildingHandler ----- // BuildingHandler::BuildingHandler( BuildingList * list ) { _list = list; } bool BuildingHandler::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _list->clear(); _state = StateInit; return true; } bool BuildingHandler::startElement( const QString &, const QString &, const QString & qName, const QXmlAttributes& atts ) { if( qName == "buildings" && _state == StateInit ) { _state = StateDocument; } else if( qName == "building" && _state == StateDocument ) { _state = StateBuilding; _building = new GenericBuildingModel(); } else if( qName == "name" && _state == StateBuilding ) { _state = StateName; } else if( qName == "description" && _state == StateBuilding ) { _state = StateDescription; } else if( qName == "disposition" && _state == StateBuilding ) { _state = StateDisposition; _height = atts.value( "height" ).toUInt(); _width = atts.value( "width" ).toUInt(); _building->GenericMapDisposition::init( _height, _width ); } else if( qName == "animation" && _state == StateBuilding ) { _state = StateAnim; } else if( qName == "frame" && _state == StateBuilding ) { _state = StateFrame; } else if( qName == "action" && _state == StateBuilding ) { _state = StateAction; _action = new Action(); _action->setType( (Action::ActionType)( atts.value( "type" ).toInt() ) ); _action->setCoeff( ( atts.value( "coeff" ).toInt() ) ); } else if( qName == "resource" && _state == StateBuilding ) { _state = StateResource; _res = atts.value( "type" ).toInt(); } else if( qName == "elementary" && _state == StateAction ) { _state = StateElementary; _elementary = new ElementaryAction(); _elementary->setType( (ElementaryAction::ElementaryType)( atts.value( "type" ).toInt() ) ); _elementary->setArg( atts.value( "arg" ).toInt() ); _elementary->setArg1( atts.value( "arg1" ).toInt() ); /* } else if( qName == "arg" && _state == StateElementary ) { _state = StateElementaryArg; } else if( qName == "value" && _state == StateElementary ) { _state = StateElementaryValue;*/ } else { // error return false; } return true; } bool BuildingHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateBuilding: _list->append( _building ); _state = StateDocument; break; case StateName: _state = StateBuilding; break; case StateDescription: _state = StateBuilding; break; case StateDisposition: _state = StateBuilding; break; case StateAnim: _state = StateBuilding; break; case StateFrame: _state = StateBuilding; break; case StateAction: _state = StateBuilding; _building->addAction( _action ); break; case StateElementary: _state = StateAction; _action->addElementaryAction( _elementary ); break; case StateResource: _state = StateBuilding; break;/* case StateElementaryArg: _state = StateElementary; break; case StateElementaryValue: _state = StateElementary; break;*/ default: // do nothing break; } return true; } bool BuildingHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) { return true; } switch( _state ) { case StateName: _building->setName( ch_simplified ); break; case StateDescription: _building->setDescription( ch_simplified ); break; case StateDisposition:{ QStringList li = ch_simplified.split( " " ); GenericMapDisposition::DispositionType type; for( uint i = 0; i < _height; i++ ) { for( uint j = 0; j < _width; j++ ) { type = GenericMapDisposition::DispositionType( li[ i * _width + j ].toInt() ); _building->setDisposition( i, j, type ); } } } break; case StateFrame: _building->setNbFrame( ch_simplified.toInt() ); break; case StateAnim: _building->setAnimFreq( ch_simplified.toInt() ); break; case StateResource: _building->getResourceList()->setValue( _res, ch_simplified.toInt() ); break; case StateElementary: _elementary->setCoeff( ch_simplified.toInt() ); break; /* case StateElementaryValue: //_building->setType( ch_simplified.toInt() ); _elementary->setCoeff( ch_simplified.toInt() ); break; case StateElementaryArg: _elementary->setArg( ch_simplified.toInt() ); break;*/ default: return false; } return true; } bool BuildingHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/genericBuilding.h0000644000175000017500000001661210751372503016647 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericBuilding.h ** in order to manage buildings... ** ** Version : $Id: genericBuilding.h,v 1.17 2008/02/03 17:09:23 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 10/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICBUILDING_H #define GENERICBUILDING_H // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/action.h" #include "libCommon/genericMapDisposition.h" #include "libCommon/log.h" #include "libCommon/unit.h" #include "libCommon/genericRessources.h" //#include "common/genericLord.h" class QTextStream; class GenericPlayer; class GenericLord; class GenericCell; class Condition; /* ------------------------------ * GenericBuilding * ------------------------------ */ /** comment for the class */ class GenericBuilding { public: /** Constructor */ GenericBuilding( int type = 0 ); /** Destructor */ virtual ~GenericBuilding(); /** Returns return the id of the building */ int getId() { return _id; } /** Sets the id of this building */ void setId( int id ) { _id = id; } void getInitResources(); /** Load building */ virtual bool load( QTextStream * ); /** Save building */ void save( QTextStream * ts, int indent = 0 ); /** \returns Returns the type of the building */ int getType() { return _type; } /** Stes the type of the building */ virtual void setType( int type ) { _type = type; } /** Set owner of the building */ virtual void setOwner( GenericPlayer * player ) { _player = player; } /** Return owner of the building */ GenericPlayer * getOwner() { return _player; } /** Set type of the building */ int getBuildingType() { return _type; } /** Return type of the building */ void setBuildingType( int type ) { _type = type; } /** Enter in the building */ virtual void enter( GenericLord * lord ); /** Exit of the building */ virtual void out( GenericLord * ) {} /** \return Returns the action list associated to this building */ QList getActionList( Action::ActionType type ); /** \return Returns the building (model) name */ QString getName(); QString getBuildDescription(); QString getBuildAutoDescription(); /** Returns the nb of frame for the animation */ uint getNbFrame(); /** Returns the freq of the animation */ int getAnimFreq(); /** Set position of the building on the map */ virtual void setPosition( GenericCell * cell ); /** Return cell of the map where is the building */ GenericCell * getCell() { return _currentCell; } /** \return Returns true if this building has already be visited */ bool hasBeenVisited(); /** \return Returns true if the lord has already visited this building */ bool hasBeenVisited( GenericLord * lord ); /** \return Returns the condition for entering in this building */ Condition * getCondition() { return _condition; } uint getDoorRow(); uint getDoorCol(); uint getDispoHeight(); uint getDispoWidth(); GenericMapDisposition::DispositionType getDisposition( uint row, uint col ); GenericResourceList * getResourceList() { return _ress; } protected: int _id, _type; GenericPlayer * _player; GenericCell * _currentCell; QList _lords; Condition * _condition; GenericResourceList * _ress; }; /** Model of building */ class GenericBuildingModel : public GenericMapDisposition { public: /** Constructor */ GenericBuildingModel(); /** Destructor */ virtual ~GenericBuildingModel(); /** \return Returns the name of the model of building */ QString getName() { return _name; } /** Sets the name of the model of building */ void setName( const QString & name ) { _name = name; } /** \return Returns a description of the building */ QString getDescription() { return _description; } /** Sets a description of the building */ void setDescription( const QString & description ) { _description = description; } /** \return Returns the type of building */ int getType() { return _type; } /** Sets the type of building */ void setType( int type ) { _type = type; } /** \return Returns the nb of frames for the animation */ uint getNbFrame() { return _nbFrame; } /** Sets the nb of frames used for the animation */ void setNbFrame( int nb ) { _nbFrame = nb; } /** \return Returns the animation frequency */ int getAnimFreq() { return _animFreq; } /** Sets the animation frequency */ void setAnimFreq( int freq ) { _animFreq = freq; } /** Add an action associated to this model of building */ void addAction( Action * action ) { _actionList->append( action ); } /** \return Returns the list of actions associated to this model */ QList * getActionList() { return _actionList; } GenericResourceList * getResourceList() { return _ress; } /** Clear the list of actions associated to this model of building */ void clearActions() { _actionList->clear(); } void save( QTextStream * ts, int indent = 0 ); protected: QString _name, _description; QList * _actionList; int _type, _nbFrame, _animFreq; GenericResourceList * _ress; }; /** list of building model */ class BuildingList : public QList { public: /** Constructor */ BuildingList(); /** Destructor */ virtual ~BuildingList(); /** Return base corresponding to 'type' */ GenericBuildingModel * at( int type ) { return QList::at( type ); } /** Init list */ bool init(); /** clear list */ void clear(); /** Save the list (used by theme editor)*/ bool save(); }; /** parser for the building list */ class BuildingHandler : public QXmlDefaultHandler { public: /** Construtor */ BuildingHandler( BuildingList * list ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: QString _errorProt; BuildingList * _list; GenericBuildingModel * _building; Action * _action; uint _height, _width; int _res; ElementaryAction * _elementary; enum State { StateInit, StateDocument, StateBuilding, StateName, StateDescription, StateDisposition, StateFrame, StateAnim, StateResource, StateAction, StateElementary/*, StateElementaryArg, StateElementaryValue*/ }; State _state; }; #endif // GENERICBUILDING_H attal-src-1.0-rc2/libCommon/genericCell.cpp0000644000175000017500000004457311000761546016330 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericCell.cpp ** gereric class for managing (not graphical) cells ** ** Version : $Id: genericCell.cpp,v 1.28 2008/04/14 23:06:14 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier - Nick Semenov ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericCell.h" // generic include files #include // include files for QT #include // application specific include #include "libCommon/log.h" #include "libCommon/genericBase.h" #include "libCommon/genericBuilding.h" #include "libCommon/genericDecoration.h" #include "libCommon/genericEvent.h" #include "libCommon/genericMap.h" #include "libCommon/genericMapCreature.h" #include "libCommon/dataTheme.h" //#include "libCommon/artefact.h" extern QString DATA_PATH; /** gereric class for managing (not graphical) cells */ GenericCell::GenericCell( int row, int col ) : _coeff( -1 ), _row( row ), _col( col ), _transition( 0 ), _transitionCellType( 0 ), _decorationGroup( 0 ), _decorationItem( 0 ) { _stop = true; _lord = 0; _building = 0; _base = 0; _creature = 0; _event = 0; _divers = 0; _realCoeff = _coeff; } GenericCell::~GenericCell() { } int GenericCell::getCoeff() { return _realCoeff; } void GenericCell::setType( const int type ) { if( type < (int)DataTheme.tiles.count() ) { _type = type; setCoeff( DataTheme.tiles.getCoeffAt( type ) ); } else { setCoeff( DataTheme.tiles.getCoeffAt( 0 ) ); _type = 0; } } void GenericCell::setDiversification( uint divers ) { if( divers < DataTheme.tiles.at( _type )->getDiversificationNumber() ) { _divers = divers; } else { _divers = 0; } } void GenericCell::setBase( GenericBase * base ) { _base = base; _building = 0; _realCoeff = base == NULL ? _coeff : _coeff + COST_ENTER; } void GenericCell::setBuilding( GenericBuilding * build ) { _building = build; _base = 0; _realCoeff = build == NULL ? _coeff : _coeff + COST_ENTER; } void GenericCell::setRandomDiversification() { CellModel * cell; uint divers = 0; cell = DataTheme.tiles.at( _type ); divers = cell->getRandomDiversification(); setDiversification( divers ); } bool GenericCell::isFree() { //bool ret( false ); //ret = ( _lord == 0 ) && ( _event == 0 ) && ( _creature == 0 ); //return ret; return !_lord && !_event && !_creature; } void GenericCell::setDecoration( uint group, uint item ) { _decorationGroup = group; _decorationItem = item; setCoeff( DataTheme.tiles.getCoeffAt( _type ) ); DecorationGroup * decoGroup = DataTheme.decorations.at( _decorationGroup ); if( decoGroup ) { for( uint i = 0; i < decoGroup->getEffectNumber(); i++ ) { switch( decoGroup->getEffectType( i ) ) { case DecorationGroup::NONE: break; case DecorationGroup::NO_MOVE: _coeff = -1; break; case DecorationGroup::DECREASE_MOVECOST: if( _coeff != -1 ) { uint rate = decoGroup->getEffectParam( i ); rate += 100; _coeff = ( _coeff * 100 ) / rate; } break; case DecorationGroup::INCREASE_MOVECOST: if( _coeff != -1 ) { uint rate = decoGroup->getEffectParam( i ); rate += 100; _coeff = ( _coeff * rate ) / 100; } break; case DecorationGroup::NO_TECHNICAL: break; case DecorationGroup::MAX_TECHNICAL: break; case DecorationGroup::NO_BLOCK_DECO: break; default: logEE( "Should not happen" ); break; } } } _realCoeff = _coeff; } // // ----- CellModel ----- // CellModel::CellModel( const QString & name, int coeff ) : _name( name ), _coeff( coeff ) { _color = Qt::black; } CellModel::~CellModel() { while( ! _diversification.isEmpty() ) { delete _diversification.takeFirst(); } } void CellModel::addDiversification( uint weight ) { _diversification.append( new uint( weight ) ); } void CellModel::removeDiversification( uint num ) { if( _diversification.count() > (int)num ) { // Possibly dangerous, if paranoid use uint * div = _diversification.at( num ); _diversification.removeAll( div ); delete div; } } uint CellModel::getDiversificationNumber() { return _diversification.count(); } uint CellModel::getDiversification( uint num ) { uint ret = 0; if( (int)num < _diversification.count() ) { ret = * ( _diversification.at( num ) ); } return ret; } uint CellModel::getRandomDiversification() { uint ret = 0; uint i; uint nb = getDiversificationNumber(); uint total = 0, val = 0; for( i = 0; i < nb; i++ ) { total += getDiversification( i ); } val = rand() % total; total = 0; for( i = 0; i < nb; i++ ) { total += getDiversification( i ); if( val < total ) { ret = i; break; } } return ret; } void CellModel::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent + 1 ); *ts << "" << _name << "" << endl; indentation( ts, indent + 1 ); *ts << "" << _coeff << "" << endl; indentation( ts, indent + 1 ); *ts << "" << endl; indentation( ts, indent + 2 ); *ts << "" << _color.red() << "" << endl; indentation( ts, indent + 2 ); *ts << "" << _color.green() << "" << endl; indentation( ts, indent + 2 ); *ts << "" << _color.blue() << "" << endl; indentation( ts, indent + 1 ); *ts << "" << endl; uint nbDivers = _diversification.count(); for( uint i = 0; i < nbDivers; i++ ) { indentation( ts, indent + 1 ); *ts << "" << ( * ( _diversification.at( i ) ) ) << "" << endl; } indentation( ts, indent ); *ts << "" << endl; } // // ----- CellModelList ----- // CellModelList::CellModelList() { _width = 30; _height = 30; } CellModelList::~CellModelList() { while( ! isEmpty() ) { delete takeFirst(); } } bool CellModelList::save() { QString filename = DATA_PATH + "tiles.dat"; QFile file( filename ); if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writng\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; indentation( &ts, 1 ); ts << "" << _width << "" << endl; indentation( &ts, 1 ); ts << "" << _height << "" << endl; for( int i = 1; i < count(); i++ ) { at( i )->save( &ts, 1 ); } ts << "" << endl; file.close(); return true; } bool CellModelList::init() { clear(); CellModelHandler handler( this ); QFile file( DATA_PATH + "tiles.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "tiles.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } void CellModelList::print() { logDD( "not implemented yet" ); } void CellModelList::clear() { while( ! isEmpty() ) { delete takeFirst(); } } // // ----- CellModelHandler ----- // CellModelHandler::CellModelHandler( CellModelList * list ) { _list = list; } bool CellModelHandler::startDocument() { _errorProt = ""; _list->clear(); _model = new CellModel( "unknown", -1 ); _list->append( _model ); _state = StateInit; return true; } bool CellModelHandler::startElement( const QString &, const QString &, const QString& qName, const QXmlAttributes & ) { if( qName == "tiles" && _state == StateInit ) { _state = StateDocument; } else if ( qName == "height" && _state == StateDocument ) { _state = StateHeight; } else if ( qName == "width" && _state == StateDocument ) { _state = StateWidth; } else if ( qName == "tile" && _state == StateDocument ) { _state = StateTile; _model = new CellModel(); } else if ( qName == "name" && _state == StateTile ) { _state = StateName; } else if ( qName == "coef" && _state == StateTile ) { _state = StateCoeff; } else if ( qName == "color" && _state == StateTile ) { _state = StateColor; _red = 0; _green = 0; _blue = 0; } else if ( qName == "red" && _state == StateColor ) { _state = StateColorRed; } else if ( qName == "green" && _state == StateColor ) { _state = StateColorGreen; } else if ( qName == "blue" && _state == StateColor ) { _state = StateColorBlue; } else if ( qName == "diversification" && _state == StateTile ) { _state = StateDiversification; } else { // error return false; } return true; } bool CellModelHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateHeight: _state = StateDocument; break; case StateWidth: _state = StateDocument; break; case StateTile: _state = StateDocument; _list->append( _model ); break; case StateName: _state = StateTile; break; case StateCoeff: _state = StateTile; break; case StateColor: _model->setColor( QColor( _red, _green, _blue ) ); _state = StateTile; break; case StateColorRed: _state = StateColor; break; case StateColorGreen: _state = StateColor; break; case StateColorBlue: _state = StateColor; break; case StateDiversification: _state = StateTile; break; default: // do nothing break; } return true; } bool CellModelHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if( ch_simplified.isEmpty() ) { return true; } switch( _state ) { case StateHeight: _list->setHeight( ch_simplified.toInt() ); break; case StateWidth: _list->setWidth( ch_simplified.toInt() ); break; case StateName: _model->setName( ch_simplified ); break; case StateCoeff: _model->setCoeff( ch_simplified.toInt() ); break; case StateColorRed: _red = ch_simplified.toInt(); break; case StateColorGreen: _green = ch_simplified.toInt(); break; case StateColorBlue: _blue = ch_simplified.toInt(); break; case StateDiversification: _model->addDiversification( ch_simplified.toInt() ); break; default: return false; } return true; } bool CellModelHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } // // // int computeFlag( GenericCell * neighbour, GenericCell * center ) { int ret = 0; int deltaW = neighbour->getCol() - center->getCol(); int deltaH = neighbour->getRow() - center->getRow(); switch( deltaH ) { case -1: switch( deltaW ) { case -1: ret = 0x01; break; case 0: ret = 0x02; break; case 1: ret = 0x04; break; } break; case 0: switch( deltaW ) { case -1: ret = 0x08; break; case 1: ret = 0x10; break; } break; case 1: switch( deltaW ) { case -1: ret = 0x20; break; case 0: ret = 0x40; break; case 1: ret = 0x80; break; } break; } return ret; } char transitionTable[256] = { 0,8,7,7,6,0,7,7, // 0-7 5,5,13,13,0,0,13,13, // 8-15 4,14,14,0,4,0,14,14, // 16-23 0,0,0,0,0,0,0,0, // 24-31 3,0,0,0,0,0,0,0, // 32-39 5,5,13,13,0,0,13,13, // 40-47 0,0,0,0,0,0,0,0, // 48-55 0,0,0,0,0,0,0,0, // 56-63 2,0,0,0,0,0,0,0, // 64-71 15,15,0,0,0,0,0,0, // 72-79 16,0,0,0,16,0,0,0, // 80-87 0,0,0,0,0,0,0,0, // 88-95 2,0,0,0,0,0,0,0, // 96-103 15,15,0,0,0,0,0,0, // 104-111 16,0,0,0,16,0,0,0, // 112-119 0,0,0,0,0,0,0,0, // 120-127 1,0,0,0,0,0,0,0, // 128-135 0,0,0,0,0,0,0,0, // 136-143 4,0,14,14,4,0,14,14, // 144-151 0,0,0,0,0,0,0,0, // 152-159 0,0,0,0,0,0,0,0, // 160-167 0,0,0,0,0,0,0,0, // 168-175 0,0,0,0,0,0,0,0, // 176-183 0,0,0,0,0,0,0,0, // 184-191 2,0,0,0,0,0,0,0, // 192-199 15,15,0,0,0,0,0,0, // 200-207 16,0,0,0,16,0,0,0, // 208-215 0,0,0,0,0,0,0,0, // 216-223 2,0,0,0,0,0,0,0, // 224-231 15,15,0,0,0,0,0,0, // 232-239 16,0,0,0,16,0,0,0, // 240-247 0,0,0,0,0,0,0,0 // 248-255 }; int computeTransition( GenericMap * theMap, GenericCell * cell ) { int ret = 0; int row = cell->getRow(); int col = cell->getCol(); int height = theMap->getHeight(); int width = theMap->getWidth(); QList neighbours; if( row > 0 ) { if( col > 0 ) { neighbours.append( theMap->at( row - 1, col - 1 ) ); } neighbours.append( theMap->at( row - 1, col ) ); if( col < width - 1 ) { neighbours.append( theMap->at( row - 1, col + 1 ) ); } } if( col > 0 ) { neighbours.append( theMap->at( row, col - 1 ) ); } if( col < width - 1 ) { neighbours.append( theMap->at( row, col + 1 ) ); } if( row < height - 1 ) { if( col > 0 ) { neighbours.append( theMap->at( row + 1, col - 1 ) ); } neighbours.append( theMap->at( row + 1, col ) ); if( col < width - 1 ) { neighbours.append( theMap->at( row + 1, col + 1 ) ); } } int type = cell->getType(); int transType = 0; for( int i = 0; i < neighbours.count(); i++ ) { if( neighbours.at( i )->getType() != type ) { transType = neighbours.at( i )->getType(); } } int flag = 0; for( int i = 0; i < neighbours.count(); i++ ) { if( neighbours.at( i )->getType() == transType ) { flag = flag | computeFlag( neighbours.at( i ), cell ); } } ret = transitionTable[ flag ]; return ret; } int computeTransitionCellType( GenericMap * theMap, GenericCell * cell ) { int ret = 0; int row = cell->getRow(); int col = cell->getCol(); int height = theMap->getHeight(); int width = theMap->getWidth(); QList neighbours; if( row > 0 ) { if( col > 0 ) { neighbours.append( theMap->at( row - 1, col - 1 ) ); } neighbours.append( theMap->at( row - 1, col ) ); if( col < width - 1 ) { neighbours.append( theMap->at( row - 1, col + 1 ) ); } } if( col > 0 ) { neighbours.append( theMap->at( row, col - 1 ) ); } if( col < width - 1 ) { neighbours.append( theMap->at( row, col + 1 ) ); } if( row < height - 1 ) { if( col > 0 ) { neighbours.append( theMap->at( row + 1, col - 1 ) ); } neighbours.append( theMap->at( row + 1, col ) ); if( col < width - 1 ) { neighbours.append( theMap->at( row + 1, col + 1 ) ); } } int type = cell->getType(); for( int i = 0; i < neighbours.count(); i++ ) { if( neighbours.at( i )->getType() != type ) { ret = neighbours.at( i )->getType(); } } return ret; } /** Cells: 123 456 789 Types: 5 - lonely cell, 0 14 00100 25 1 12 00101 45 2 15 00110 56 3 13 01100 58 4 14 10100 245 5 9 00111 256 6 8 01101 258 7 1 10101 456 8 2 01110 458 9 10 10110 568 10 11 11100 2456 11 5 01111 2458 12 6 10111 2568 13 4 11101 4568 14 7 11110 24568 15 3 11111 */ const char roadTypeTable[ 16 ] = { 13, 11, 14, 12, 13, 8, 7, 0, 1, 9, 10, 4, 5, 3, 6, 2 }; const char binaryTable[ 16 ] = { 4, 5, 6, 12, 20, 7, 13, 21, 14, 22, 28, 15, 23, 29, 30, 31 }; int getRoadTypeByBinary( char binary ) { int index = -1; for( int i = 0; i < 16; i++ ) { if ( binary == binaryTable[ i ] ) { index = i; break; } } if( index == -1 ) { return -1; } return roadTypeTable[ index ]; } char smallCompute( GenericMap* theMap, GenericCell* cell, uint decorationGroup ) { int row = cell->getRow(); int col = cell->getCol(); int height = theMap->getHeight(); int width = theMap->getWidth(); GenericCell * neighbourUp = 0; GenericCell * neighbourLeft = 0; GenericCell * neighbourRight = 0; GenericCell * neighbourDown = 0; char result = 0; if( cell->getDecorationGroup() == decorationGroup ) { result |= 4; } if ( row > 0 ) { neighbourUp = theMap->at ( row - 1, col ); if( neighbourUp->getDecorationGroup() == decorationGroup ) { result |= 1; } } if ( col > 0 ) { neighbourLeft = theMap->at ( row, col - 1 ); if( neighbourLeft->getDecorationGroup() == decorationGroup ) { result |= 2; } } if ( row < height - 1 ) { neighbourDown = theMap->at ( row + 1, col ); if( neighbourDown->getDecorationGroup() == decorationGroup ) { result |= 16; } } if ( col < width - 1 ) { neighbourRight = theMap->at ( row, col + 1 ); if( neighbourRight->getDecorationGroup() == decorationGroup ) { result |= 8; } } return result; } void computeAndChangeRoadType( GenericMap* theMap, GenericCell* cell, uint decorationGroup ) { cell->setDecoration( decorationGroup, 0 ); int row = cell->getRow(); int col = cell->getCol(); int height = theMap->getHeight(); int width = theMap->getWidth(); char binary = smallCompute( theMap, cell, decorationGroup ); int roadType = getRoadTypeByBinary( binary ); if( roadType != -1 ) { cell->setDecoration( decorationGroup, roadType ); } GenericCell* neighbourUp = 0; GenericCell* neighbourLeft = 0; GenericCell* neighbourRight = 0; GenericCell* neighbourDown = 0; if ( row > 0 ) { neighbourUp = theMap->at( row - 1, col ); char newBinary = smallCompute( theMap, neighbourUp, decorationGroup ); int newRoadType = getRoadTypeByBinary ( newBinary ); if( newRoadType != -1 ) { neighbourUp->setDecoration( decorationGroup, newRoadType ); } } if( col > 0 ) { neighbourLeft = theMap->at( row, col - 1 ); char newBinary = smallCompute ( theMap, neighbourLeft, decorationGroup ); int newRoadType = getRoadTypeByBinary ( newBinary ); if( newRoadType != -1 ) { neighbourLeft->setDecoration( decorationGroup, newRoadType ); } } if( row < height - 1 ) { neighbourDown = theMap->at( row + 1, col ); char newBinary = smallCompute( theMap, neighbourDown, decorationGroup ); int newRoadType = getRoadTypeByBinary ( newBinary ); if( newRoadType != -1 ) { neighbourDown->setDecoration ( decorationGroup, newRoadType ); } } if ( col < width - 1 ) { neighbourRight = theMap->at( row, col + 1 ); char newBinary = smallCompute ( theMap, neighbourRight, decorationGroup ); int newRoadType = getRoadTypeByBinary ( newBinary ); if( newRoadType != -1 ) { neighbourRight->setDecoration ( decorationGroup, newRoadType ); } } } attal-src-1.0-rc2/libCommon/genericCell.h0000644000175000017500000002016711000761546015766 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericCell.h ** generic class for managing (not graphical) cells ** ** Version : $Id: genericCell.h,v 1.18 2008/04/14 23:06:14 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICCELL_H #define GENERICCELL_H // generic include files // include files for QT #include #include #include #include // application specific includes #include "libCommon/define.h" class QTextStream; class GenericBase; class GenericBuilding; class GenericEvent; class GenericLord; class GenericMapCreature; class GenericMap; /* ------------------------------ * GenericCell * ------------------------------ */ /** generic class for managing (not graphical) cells */ class GenericCell { public: /** Constructor */ GenericCell( int row = 0, int col = 0 ); /** Destructor */ virtual ~GenericCell(); /** Coeff is a movement modifier based on type of terrain if coeff is minor to zero no movement is allowed higher is the coeff, more difficult is the movement **/ /** Set the moving coeff */ void setCoeff( int c ) { _coeff = c; _realCoeff = _coeff; } /** \return Returns the moving coeff */ int getCoeff(); /** Set type of the cell */ virtual void setType( const int type ); /** Return type of the cell */ int getType() const { return _type; } virtual void setDiversification( uint divers ); void setRandomDiversification(); uint getDiversification() { return _divers; } /** \return Returns the transition of this cell */ int getTransition() { return _transition; } /** Set type of transition */ virtual void setTransition( int transi ) { _transition = transi; } /** \return Returns the type of transition cell */ int getTransitionCellType() { return _transitionCellType; } /** Set the type of transition for this cell */ virtual void setTransitionCellType( const int type ) { _transitionCellType = type; } /** \return Returns the type of decoration of this cell */ uint getDecorationGroup() { return _decorationGroup; } /** \return Returns the item of decoration of this cell */ uint getDecorationItem() { return _decorationItem; } /** Sets the type of decoration for this cell */ virtual void setDecoration( uint group, uint item ); /** Return row of the cell */ inline int getRow() const { return _row; } // voy a CAMBIAR (no he CAMBIADO) al 'uint's /** Return col of the cell */ inline int getCol() const { return _col; } // voy a CAMBIAR (no he CAMBIADO) al 'uint's /** Set lord on the cell */ void setLord( GenericLord * lord ) { _lord = lord; } /** Return lord on the cell (if any) */ GenericLord * getLord() const { return _lord; } /** Set building on the cell */ void setBuilding( GenericBuilding * build ); /** Return building on the cell (if any) */ GenericBuilding * getBuilding() const { return _building; } /** \return Returns the base on this cell (if any) */ GenericBase * getBase() { return _base; } /** Sets a base on this cell */ void setBase( GenericBase * base ); /** \return Returns the creature on this cell (if any) */ GenericMapCreature * getCreature() { return _creature; } /** Sets a creature on this cell */ void setCreature( GenericMapCreature * creature ) { _creature = creature; } /** Tell if the cell is free (for moving) */ bool isFree(); GenericEvent * getEvent() { return _event; } void setEvent( GenericEvent * event ) { _event = event; } /** \return Tells if we can stop (=go and stop) on this cell */ bool isStoppable() { return _stop; } /** Sets this cell 'stoppable' or not */ void setStoppable( bool state ) { _stop = state; } protected: bool _stop; int _type; uint _divers; int _coeff; int _realCoeff; //optimisation to avoid an if and to inline getCoeff int _row , _col; // voy a CAMBIAR (no he CAMBIADO) al 'uint's int _transition; int _transitionCellType; uint _decorationGroup, _decorationItem; GenericLord * _lord; GenericBuilding * _building; GenericBase * _base; GenericEvent * _event; GenericMapCreature * _creature; }; /** Manage model of cell */ class CellModel { public: /** Constructor */ CellModel( const QString & name = "", int coeff = 1 ); /** Destructor */ virtual ~CellModel(); /** \return Returns the name of this model */ QString getName() { return _name; } /** Sets the name of this model */ void setName( const QString & name ) { _name = name; } /** \return Returns the coefficient of this cell */ int getCoeff() { return _coeff; } /** Sets the coeff of this cell */ void setCoeff( int coeff ) { _coeff = coeff; } void addDiversification( uint weight ); void removeDiversification( uint num ); uint getDiversificationNumber(); uint getDiversification( uint num ); uint getRandomDiversification(); QColor getColor() { return _color; } void setColor( const QColor & color ) { _color = color; } void save( QTextStream * ts, int indent ); protected: QString _name; int _coeff; QColor _color; QList _diversification; }; /** Handle a list of models of cells */ class CellModelList : public QList { public: /** Constructor */ CellModelList(); /** Destructor */ virtual ~CellModelList(); /** Save list */ bool save(); /** Init list */ bool init(); void clear(); /** Print list (for debug) */ void print(); /** Return coeff of cell type 'num' */ int getCoeffAt( int num ) { return QList::at( num )->getCoeff(); } /** Return name of cell type 'num' */ QString getNameAt( int num ) { return QList::at( num )->getName(); } void save( QTextStream * ts, int indent ); /** these methods return the graphical dimensions of a cell **/ uint getHeight() { return _height; } void setHeight( uint height ) { _height = height; } uint getWidth() { return _width; } void setWidth( uint width ) { _width = width; } /** end dimensions **/ private: uint _height, _width; }; /* ------------------------------ * CellModelHandler * ------------------------------ */ /** Parser for CellModelList */ class CellModelHandler : public QXmlDefaultHandler { public: /** Constructor */ CellModelHandler( CellModelList * list ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: CellModelList * _list; CellModel * _model; QString _errorProt, _name; int _red, _green, _blue; int _coeff; enum State { StateInit, StateDocument, StateWidth, StateHeight, StateTile, StateName, StateCoeff, StateColor, StateColorRed, StateColorGreen, StateColorBlue, StateDiversification }; State _state; }; int computeTransition( GenericMap * theMap, GenericCell * cell ); int computeTransitionCellType( GenericMap * theMap, GenericCell * cell ); /** Compute and change road type for Cell and its neibours */ void computeAndChangeRoadType( GenericMap* theMap, GenericCell* cell, uint decorationGroup ); #endif // GENERICCELL_H attal-src-1.0-rc2/libCommon/genericChest.cpp0000644000175000017500000000333610347000231016475 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericChest.cpp ** Class for managing treasury chests on map ** ** Version : $Id: genericChest.cpp,v 1.5 2005/12/11 10:34:01 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 26/08/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericChest.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" GenericChest::GenericChest() { } GenericChest::~GenericChest() { } void GenericChest::addParam( uint value ) { _params.append( value ); } uint GenericChest::getParamNumber() { return _params.count(); } uint GenericChest::getParam( uint num ) { uint ret = 0; if( (int)num < _params.count() ) { ret = _params.at( num ); } return ret; } void GenericChest::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; uint nbParam = _params.count(); for( uint i = 0; i < nbParam; i++ ) { indentation( ts, indent+1 ); *ts << "" << _params.at( i ) << "" << endl; } indentation( ts, indent ); *ts << "" << endl; *ts << flush; } attal-src-1.0-rc2/libCommon/genericChest.h0000644000175000017500000000274010335201564016151 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericChest.h ** Class for managing treasury chests on map ** ** Version : $Id: genericChest.h,v 1.4 2005/11/11 20:47:48 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 26/08/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICCHEST_H #define GENERICCHEST_H // generic include files // include files for QT #include // application specific include files class QTextStream; /* ------------------------------ * GenericChest * ------------------------------ */ class GenericChest { public: /** Constructor */ GenericChest(); virtual ~GenericChest(); void addParam( uint value ); uint getParamNumber(); uint getParam( uint num ); /** Save building */ void save( QTextStream * ts, int indent = 0 ); protected: QList _params; }; #endif // GENERICCHEST_H attal-src-1.0-rc2/libCommon/genericDecoration.cpp0000644000175000017500000001752010522705152017527 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericDecoration.cpp ** manage decoration ** ** Version : $Id: genericDecoration.cpp,v 1.18 2006/11/03 18:28:58 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 10/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericDecoration.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" extern QString DATA_PATH; GenericDecoration::GenericDecoration() { _group = 0; } GenericDecoration::~GenericDecoration() { clear(); } void GenericDecoration::clear() { GenericMapDisposition::clear(); } void GenericDecoration::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; GenericMapDisposition::save( ts, indent + 1 ); indentation( ts, indent ); *ts << "" << endl; } // // ----- DecorationGroup ----- // DecorationGroup::DecorationGroup() { _name = ""; _info = ""; } DecorationGroup::~DecorationGroup() { clear(); } void DecorationGroup::clear() { _effectTypeList.clear(); _effectParamList.clear(); while( ! isEmpty() ) { delete takeFirst(); } } void DecorationGroup::save( QTextStream * ts, int indent ) { uint nb = count(); indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent+1 ); *ts << "\t" << _name << "" << endl; indentation( ts, indent+1 ); *ts << "\t" << _info << "" << endl; for( int i = 0; i < _effectTypeList.count(); ++i ) { indentation( ts, indent+1 ); *ts << "\t"; *ts << _effectParamList.at( i ) << "" << endl; } for( uint i = 0; i < nb; i++ ) { at( i )->save( ts, indent + 1 ); } indentation( ts, indent ); *ts << "" << endl; } uint DecorationGroup::getEffectNumber() { return _effectTypeList.count(); } DecorationGroup::EffectType DecorationGroup::getEffectType( uint num ) { EffectType ret = NONE; if( (int)num < _effectTypeList.count() ) { ret = _effectTypeList.at( num ); } return ret; } uint DecorationGroup::getEffectParam( uint num ) { uint ret = 0; if( (int)num < _effectParamList.count() ) { ret = _effectParamList.at( num ); } return ret; } void DecorationGroup::addEffect( DecorationGroup::EffectType type, uint param ) { _effectTypeList.append( type ); _effectParamList.append( param ); } void DecorationGroup::clearEffects() { _effectTypeList.clear(); _effectParamList.clear(); } QString DecorationGroup::getEffectTypeString( EffectType type ) { QString ret = "Unknown"; switch( type ) { case NONE: ret = "None"; break; case NO_MOVE: ret = "No move"; break; case DECREASE_MOVECOST: ret = "Decrease move cost"; break; case INCREASE_MOVECOST: ret = "Increase move cost"; break; case NO_TECHNICAL: ret = "No technical"; break; case MAX_TECHNICAL: ret = "Max technical"; break; case NO_BLOCK_DECO: ret = "No blocked decoration"; break; } return ret; } // // ----- DecorationList ----- // DecorationList::DecorationList() { } DecorationList::~DecorationList() { clear(); } void DecorationList::clear() { while( ! isEmpty() ) { delete takeFirst(); } } bool DecorationList::init() { clear(); DecorationHandler handler( this ); QFile file( DATA_PATH + "decorations.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "decorations.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } bool DecorationList::save() { QString filename = DATA_PATH + "decorations.dat"; QFile file( filename ); if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writng\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; for( int i = 1; i < count(); i++ ) { at( i )->save( &ts, 1 ); } ts << "" << endl; file.close(); return true; } // // ----- DecorationHandler ----- // DecorationHandler::DecorationHandler( DecorationList * list ) { _list = list; } bool DecorationHandler::startDocument() { _errorProt = ""; _list->clear(); _state = StateInit; _list->append( new DecorationGroup() ); return true; } bool DecorationHandler::startElement( const QString &, const QString &, const QString& qName, const QXmlAttributes& atts ) { if( qName == "decorations" && _state == StateInit ) { _state = StateDocument; } else if ( qName == "group" && _state == StateDocument ) { _state = StateGroup; _group = new DecorationGroup(); } else if ( qName == "name" && _state == StateGroup ) { _state = StateName; } else if ( qName == "info" && _state == StateGroup ) { _state = StateInfo; } else if ( qName == "effect" && _state == StateGroup ) { _state = StateEffect; _type = (DecorationGroup::EffectType) atts.value( "type" ).toInt(); _param = 0; } else if ( qName == "decoration" && _state == StateGroup ) { _state = StateDecoration; _decor = new GenericDecoration(); } else if ( qName == "disposition" && _state == StateDecoration ) { _state = StateDisposition; _height = atts.value( "height" ).toInt(); _width = atts.value( "width" ).toInt(); if( ( _height != 0 ) && ( _width != 0 ) ) { _decor->init( _height, _width ); } } else { return false; } return true; } bool DecorationHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateGroup: _list->append( _group ); _state = StateDocument; break; case StateName: _state = StateGroup; break; case StateInfo: _state = StateGroup; break; case StateEffect: _state = StateGroup; _group->addEffect( _type, _param ); break; case StateDecoration: _state = StateGroup; _group->append( _decor ); _decor->setGroup( _group ); break; case StateDisposition: _state = StateDecoration; break; default: // do nothing break; } return true; } bool DecorationHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) { return true; } switch( _state ) { case StateDisposition:{ if( ( _height > 0 ) && ( _width > 0 ) ) { QStringList li = ch_simplified.split( " " ); GenericMapDisposition::DispositionType type; for( int i = 0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { type = GenericMapDisposition::DispositionType( li[ i*_width + j ].toInt() ); _decor->setDisposition( i, j, type ); } } } } break; case StateName: _group->setName( ch_simplified ); break; case StateInfo: _group->setInfo( ch_simplified ); break; case StateEffect: _param = ch_simplified.toInt(); break; default: return false; } return true; } bool DecorationHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/genericDecoration.h0000644000175000017500000001045710335201564017176 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericDecoration.h ** manage decoration ** ** Version : $Id: genericDecoration.h,v 1.9 2005/11/11 20:47:48 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 10/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICDECORATION_H #define GENERICDECORATION_H // generic include files // include files for QT #include #include #include #include // application specific include files #include "libCommon/genericMapDisposition.h" class DecorationGroup; /* ------------------------------ * GenericDecoration * ------------------------------ */ class GenericDecoration : public GenericMapDisposition { public: /** Constructor */ GenericDecoration(); /** Destructor */ virtual ~GenericDecoration(); /** Saves the data of a decoration */ void save( QTextStream * ts, int indent ); void setGroup( DecorationGroup * group ) { _group = group; } DecorationGroup * getGroup() { return _group; } private: void clear(); DecorationGroup * _group; }; class DecorationGroup : public QList { public: enum EffectType { NONE = 0, NO_MOVE, DECREASE_MOVECOST, INCREASE_MOVECOST, NO_TECHNICAL, MAX_TECHNICAL, NO_BLOCK_DECO }; /** Constructor */ DecorationGroup(); /** Destructor */ virtual ~DecorationGroup(); void clear(); /** \return Returns the name of this type of decoration */ const QString & getName() { return _name; } /** Sets a name to the decoration */ void setName( const QString & name ) { _name = name; } /** \return Returns some information about this decoration */ const QString & getInfo() { return _info; } /** Sets some info about this decoration */ void setInfo( const QString & info ) { _info = info; } static QString getEffectTypeString( EffectType type ); uint getEffectNumber(); EffectType getEffectType( uint num ); uint getEffectParam( uint num ); void addEffect( EffectType, uint param ); void clearEffects(); /** Saves the data of a decoration */ void save( QTextStream * ts, int indent ); protected: QString _name, _info; QList _effectTypeList; QList _effectParamList; }; /** List for managing the different decoration group */ class DecorationList : public QList { public: /** Constructor */ DecorationList(); /** Destructor */ virtual ~DecorationList(); /** Init list */ bool init(); /** Save the list on data file */ bool save(); void clear(); }; /** Parser for the DecorationList */ class DecorationHandler : public QXmlDefaultHandler { public: /** Constructor */ DecorationHandler( DecorationList * list ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: DecorationList * _list; DecorationGroup * _group; GenericDecoration * _decor; int _height, _width; DecorationGroup::EffectType _type; uint _param; QString _errorProt; enum State { StateInit, StateDocument, StateGroup, StateDecoration, StateDisposition, StateName, StateInfo, StateEffect, StateEffectParam }; State _state; }; #endif // GENERICDECORATION_H attal-src-1.0-rc2/libCommon/genericEvent.cpp0000644000175000017500000000556610704431777016543 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericEvent.cpp ** this is a template for all .cpp files ** ** Version : $Id: genericEvent.cpp,v 1.5 2007/10/14 15:21:35 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 17/12/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericEvent.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/artefact.h" #include "libCommon/condition.h" #include "libCommon/dataTheme.h" #include "libCommon/genericBonus.h" #include "libCommon/genericChest.h" #include "libCommon/log.h" // // ----- GenericEvent ----- // GenericEvent::GenericEvent() { _type = EventNone; _cell = NULL; _condition = 0; _artefact = NULL; _bonus = NULL; _chest = NULL; } GenericEvent::~GenericEvent() { if( _artefact ) { delete _artefact; } if( _bonus ) { delete _bonus; } if( _chest ) { delete _chest; } } void GenericEvent::setCell( GenericCell * cell ) { TRACE("GenericEvent::setCell"); _cell = cell; } void GenericEvent::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent+1 ); *ts << "" << _cell->getCol() << "" << endl; indentation( ts, indent+1 ); *ts << "" << _cell->getRow() << "" << endl; if( _artefact ) { _artefact->save( ts, indent+1 ); } if( _bonus ) { _bonus->save( ts, indent+1 ); } if( _chest ) { _chest->save( ts, indent+1 ); } indentation( ts, indent ); *ts << "" << endl; *ts << flush; } void GenericEvent::setArtefact( GenericArtefact * artefact ) { TRACE("GenericEvent::setArtefact"); _type = EventArtefact; _artefact = artefact; if( _bonus ) { delete _bonus; _bonus = NULL; } if( _chest ) { delete _chest; _chest = NULL; } } void GenericEvent::setBonus( GenericBonus * bonus ) { TRACE("GenericEvent::setBonus"); _type = EventBonus; _bonus = bonus; if( _artefact ) { delete _artefact; _artefact = NULL; } if( _chest ) { delete _chest; _chest = NULL; } } void GenericEvent::setChest( GenericChest * chest ) { TRACE("GenericEvent::setChest"); _type = EventChest; _chest = chest; if( _artefact ) { delete _artefact; _artefact = NULL; } if( _bonus ) { delete _bonus; _bonus = NULL; } } attal-src-1.0-rc2/libCommon/genericEvent.h0000644000175000017500000000445710331243511016165 0ustar aaaa//Added by qt3to4: #include /**************************************************************** ** ** Attal : Lords of Doom ** ** genericEvent.h ** Handles events on map ** ** Version : $Id: genericEvent.h,v 1.6 2005/10/30 22:20:57 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 17/12/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICEVENT_H #define GENERICEVENT_H // generic include files // include files for QT // application specific include files class QTextStream; class Condition; class GenericArtefact; class GenericBonus; class GenericCell; class GenericChest; /** ------------------------------ * GenericEvent ** ------------------------------ */ class GenericEvent { public: enum EventType { EventNone = 0, EventArtefact, EventBonus, EventChest }; /** Constructor */ GenericEvent(); /** Destructor */ virtual ~GenericEvent(); EventType getType() { return _type; } GenericCell * getCell() { return _cell; } virtual void setCell( GenericCell * cell ); bool isVisible(); void setVisible( bool state ); Condition * getCondition() { return _condition; } void setCondition( Condition * condition ) { _condition = condition; } GenericArtefact * getArtefact() { return _artefact; } void setArtefact( GenericArtefact * artefact ); GenericBonus * getBonus() { return _bonus; } void setBonus( GenericBonus * bonus ); GenericChest * getChest() { return _chest; } void setChest( GenericChest * chest ); /** Save event */ void save( QTextStream * ts, int indent = 0 ); protected: EventType _type; bool _visible; GenericCell * _cell; Condition * _condition; GenericArtefact * _artefact; GenericBonus * _bonus; GenericChest * _chest; }; #endif // GENERICEVENT_H attal-src-1.0-rc2/libCommon/genericFightCell.cpp0000644000175000017500000000246310675026662017314 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericFightCell.cpp ** gereric class for managing (not graphical) fightCells ** ** Version : $Id: genericFightCell.cpp,v 1.3 2007/09/21 20:46:42 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericFightCell.h" // generic include files // include files for QT // application specific includes /** gereric class for managing (not graphical) fightCells */ GenericFightCell::GenericFightCell( int row, int col ) :_coeff( -1 ), _row( row ), _col( col ) { _access = AttalCommon::UNKNOWN_ACCESS; _unit = 0; _headUnit = 0; _dist = 0; } GenericFightCell::~GenericFightCell() { } attal-src-1.0-rc2/libCommon/genericFightCell.h0000644000175000017500000000515411000761546016747 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericFightCell.h ** generic class for managing (not graphical) fightCells ** ** Version : $Id: genericFightCell.h,v 1.4 2008/04/14 23:06:14 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICFIGHTCELL_H #define GENERICFIGHTCELL_H // generic include files // include files for QT // application specific includes #include "libCommon/attalCommon.h" class GenericFightUnit; /* ------------------------------ * GenericFightCell * ------------------------------ */ /** generic class for managing (not graphical) fightCells */ class GenericFightCell { public: /** Constructor */ GenericFightCell( int row, int col ); /** Destructor */ virtual ~GenericFightCell(); /** Set type of the fight cell */ void setType( int typ ) { _type = typ; _coeff = (typ == AttalCommon::OBSTACLE ? -1:1); } /** return type of the fight cell */ inline int getType() { return _type; } void setAccess( AttalCommon::FightCellAccess typ ) { _access = typ; } AttalCommon::FightCellAccess getAccess() { return _access; } int getDist() { return _dist; } void setDist( int dist ) { _dist = dist; } /** Return row */ int getRow() { return _row; } /** Return col */ int getCol() { return _col; } void setRow( int row ) { _row=row; } void setCol( int col ) { _col=col; } /** Tell which unit is on it */ void setUnit( GenericFightUnit * unit ) { _unit = unit; } /** Return the unit on the cell */ GenericFightUnit * getUnit() { return _unit; } /** Tell which unit is on it */ void setHeadUnit( GenericFightUnit * unit ) { _headUnit = unit; } /** Return the unit on the cell */ GenericFightUnit * getHeadUnit() { return _headUnit; } protected: int _coeff; int _type; int _dist; int _row, _col; GenericFightUnit * _unit; GenericFightUnit * _headUnit; AttalCommon::FightCellAccess _access; }; #endif // GENERICFIGHTCELL_H attal-src-1.0-rc2/libCommon/genericFightMap.cpp0000644000175000017500000003652211000761546017143 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightMap.cpp ** Manage the global view ** ** Version : $Id: genericFightMap.cpp,v 1.28 2008/04/14 23:06:14 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier - Sardi Carlo ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericFightMap.h" // generic include files #include // include files for QT #include #include #include // application specific include #include "libCommon/log.h" #include "libCommon/pathFinder.h" #include "libCommon/unit.h" #include "libCommon/creature.h" inline bool isEven( int number ) { return( ( number % 2 ) == 0 ); } // // ----- GenericFightMap ----- // GenericFightMap::GenericFightMap() { _height = 0; _width = 0; _genericFightCells = 0; } GenericFightMap::~GenericFightMap() { reinit(); if(_genericFightCells != 0){ for( int i=0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { delete _genericFightCells[i][j]; _genericFightCells[i][j] = 0; } delete [] _genericFightCells[i]; } delete [] _genericFightCells; } _genericFightCells = 0; } void GenericFightMap::newFightMap( int h, int w, bool horizontalDraw ) { _height = h; _width = w; _genericFightCells = new GenericFightCell **[_height]; for( int i = 0; i < _height; i++ ) { _genericFightCells[i] = new GenericFightCell * [_width]; for( int j = 0; j < _width; j++ ) { GenericFightCell * cell = new GenericFightCell( i, j ); _genericFightCells[i][j] = cell; } } _horizontalDraw = horizontalDraw; } void GenericFightMap::reinit() { TRACE("GenericFightMap::reinit"); for( int i = 0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { if(_genericFightCells[i][j]->getUnit()) { _genericFightCells[i][j]->getUnit()->setCell(0); _genericFightCells[i][j]->setUnit( NULL ); _genericFightCells[i][j]->setHeadUnit( NULL ); } } } } void GenericFightMap::clearPath() { TRACE("GenericFightMap::clearPath"); GenericFightCell * cell = NULL; for( int i = 0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { cell = _genericFightCells[i][j]; if (cell) { _genericFightCells[i][j]->setAccess( AttalCommon::UNKNOWN_ACCESS ); _genericFightCells[i][j]->setType( AttalCommon::NORMAL ); _genericFightCells[i][j]->setDist( 0 ); _genericFightCells[i][j]->setHeadUnit( NULL ); } else { logEE("error : cell null i ,%d j, %d",i,j); } } } } void GenericFightMap::initPath( GenericFightUnit * unit ) { TRACE("GenericFightMap::initPath"); TRACE("GenericFightUnit race %d, level %d", unit->getRace(), unit->getLevel()); //int checksum = 0; GenericFightCell * current = unit->getCell(); GenericFightCell * cell = NULL; FightPile pile( this, unit->getMove(), unit ); GenericFightMap::clearPath(); current->setAccess( AttalCommon::NONE ); current->setDist( 0 ); pile.appendNeighbours( current ); while( ! pile.isEmpty() ) { current = pile.takeSmallest(); pile.appendNeighbours( current ); } for( int i = 0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { cell = _genericFightCells[i][j]; if (cell) { if( _genericFightCells[i][j]->getAccess() == AttalCommon::UNKNOWN_ACCESS ) { if ( _genericFightCells[i][j]->getUnit() ) { _genericFightCells[i][j]->setAccess( AttalCommon::FAR_OCCUPIED ); } else { _genericFightCells[i][j]->setAccess( AttalCommon::FAR_FREE ); } //checksum += (int ) _genericFightCells[i][j]->getAccess(); } else { } } else { logEE("error : cell null i ,%d j, %d",i,j); } } } //logDD(" checksum %d", checksum); } void GenericFightMap::printPath() { for( int i = 0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { logDD("%d-%d = %d (%d)", i, j, _genericFightCells[i][j]->getDist(), _genericFightCells[i][j]->getAccess() ); } } } QStack GenericFightMap::computePath( GenericFightUnit *, GenericFightCell * cell ) { QStack path; int dist = cell->getDist(); GenericFightCell * current = cell; path.push( cell ); for( int i = dist - 1; i > 0; i-- ) { current = giveNeighbourOnPath( current, i ); path.push( current ); } //path.push( unit->getCell() ); return path; } GenericFightCell * GenericFightMap::giveNeighbourOnPath( GenericFightCell * cell, int dist ) { GenericFightCell * current; GenericFightCell * ret = 0; current = getNeighbour1( cell ); if( current && ( current->getDist() == dist ) && ( current->getAccess () != AttalCommon::NONE ) && ( current->getAccess () != AttalCommon::NEAR_OCCUPIED ) ) { ret = current; } current = getNeighbour2( cell ); if( current && ( current->getDist() == dist ) && ( current->getAccess () != AttalCommon::NONE ) && ( current->getAccess () != AttalCommon::NEAR_OCCUPIED ) ) { ret = current; } current = getNeighbour3( cell ); if( current && ( current->getDist() == dist ) && ( current->getAccess () != AttalCommon::NONE ) && ( current->getAccess () != AttalCommon::NEAR_OCCUPIED ) ) { ret = current; } current = getNeighbour4( cell ); if( current && ( current->getDist() == dist ) && ( current->getAccess () != AttalCommon::NONE ) && ( current->getAccess () != AttalCommon::NEAR_OCCUPIED ) ) { ret = current; } current = getNeighbour5( cell ); if( current && ( current->getDist() == dist ) && ( current->getAccess () != AttalCommon::NONE ) && ( current->getAccess () != AttalCommon::NEAR_OCCUPIED ) ) { ret = current; } current = getNeighbour6( cell ); if( current && ( current->getDist() == dist ) && ( current->getAccess () != AttalCommon::NONE ) && ( current->getAccess () != AttalCommon::NEAR_OCCUPIED ) ) { ret = current; } if( ! ret ) { logEE( "Should not happen : no cell found ??" ); } return ret; } GenericFightCell * GenericFightMap::getNeighbour1( GenericFightCell * cell ) { int row = cell->getRow(); int col = cell->getCol(); GenericFightCell * ret = 0; if ( _horizontalDraw ) { if( row > 0 ) { ret = at( row - 1, col ); } } else { if ( !isEven ( row ) ) { if (( row > 0 ) && ( col < _width - 1 )) { ret = at ( row - 1, col + 1 ); } } else if ( row > 0 ) { ret = at ( row - 1, col ); } } return ret; } GenericFightCell * GenericFightMap::getNeighbour2( GenericFightCell * cell ) { int row = cell->getRow(); int col = cell->getCol(); GenericFightCell * ret = 0; if ( _horizontalDraw ) { if( isEven( col ) ) { if( ( row > 0 ) && ( col < _width-1 ) ){ ret = at( row - 1, col + 1 ); } } else { if( col < _width-1 ) { ret = at( row, col + 1 ); } } } else { if ( col < _width - 1) { ret = at ( row , col + 1 ); } } return ret; } GenericFightCell * GenericFightMap::getNeighbour3( GenericFightCell * cell ) { int row = cell->getRow(); int col = cell->getCol(); GenericFightCell * ret = 0; if ( _horizontalDraw ) { if( isEven( col ) ) { if( col < _width - 1 ) { ret = at( row, col + 1 ); } } else { if( ( col < _width - 1 ) && ( row < _height - 1 ) ) { ret = at( row + 1, col + 1 ); } } } else { if ( !isEven ( row ) ) { if (( row < _height - 1 ) && ( col < _width - 1 )) { ret = at ( row + 1, col + 1 ); } } else if ( row < _height - 1 ) { ret = at ( row + 1, col ); } } return ret; } GenericFightCell * GenericFightMap::getNeighbour4( GenericFightCell * cell ) { int row = cell->getRow(); int col = cell->getCol(); GenericFightCell * ret = 0; if ( _horizontalDraw ) { if( row < _height - 1 ) { ret = at( row + 1, col ); } } else { if ( isEven ( row ) ) { if (( row < _height - 1 ) && ( col > 0 )) { ret = at ( row + 1, col - 1 ); } } else if ( row < _height - 1 ) { ret = at ( row + 1, col ); } } return ret; } GenericFightCell * GenericFightMap::getNeighbour5( GenericFightCell * cell ) { int row = cell->getRow(); int col = cell->getCol(); GenericFightCell * ret = 0; if ( _horizontalDraw ) { if( isEven( col ) ) { if( col > 0 ) { ret = at( row, col - 1 ); } } else { if( ( row < _height - 1 ) && ( col > 0 ) ) { ret = at( row + 1, col - 1 ); } } } else { if ( col > 0 ) { ret = at ( row , col - 1); } } return ret; } GenericFightCell * GenericFightMap::getNeighbour6( GenericFightCell * cell ) { int row = cell->getRow(); int col = cell->getCol(); GenericFightCell * ret = 0; if ( _horizontalDraw ) { if( isEven( col ) ) { if( ( row > 0 ) && ( col > 0 ) ) { ret = at( row - 1, col - 1 ); } } else { if( col > 0 ) { ret = at( row, col - 1 ); } } } else { if ( isEven ( row ) ) { if (( row > 0 ) && ( col > 0 )) { ret = at ( row - 1, col - 1 ); } } else if ( row > 0 ) { ret = at ( row - 1, col ); } } return ret; } bool GenericFightMap::isUpperLevel( GenericFightCell * cell1, GenericFightCell * cell2 ) { bool ret = false; if ( ( getNeighbour1( cell1 ) == cell2 ) || ( getNeighbour6( cell1 ) == cell2 ) ){ ret = true; } return ret; } bool GenericFightMap::isSameLevel( GenericFightCell * cell1, GenericFightCell * cell2 ) { bool ret = false; if ( ( getNeighbour2( cell1 ) == cell2 ) || ( getNeighbour5( cell1 ) == cell2 ) ){ ret = true; } return ret; } bool GenericFightMap::isLowerLevel( GenericFightCell * cell1, GenericFightCell * cell2 ) { bool ret = false; if ( ( getNeighbour3(cell1 ) == cell2 ) || ( getNeighbour4( cell1 ) == cell2 ) ){ ret = true; } return ret; } /* Neighbour map 6 / \ 1* 5 | | 2 4* \ / 3* */ bool GenericFightMap::areNeighbours( GenericFightCell * cell1, GenericFightCell * cell2 ) { bool ret = false; if( !cell1 || !cell2 ) { return ret; } if( ( getNeighbour1( cell1 ) == cell2 ) || ( getNeighbour2( cell1 ) == cell2 ) || ( getNeighbour3( cell1 ) == cell2 ) || ( getNeighbour4( cell1 ) == cell2 ) || ( getNeighbour5( cell1 ) == cell2 ) || ( getNeighbour6( cell1 ) == cell2 ) || ( cell1 == cell2 )){ ret = true; } return ret; } bool GenericFightMap::isPath( GenericFightUnit * unit , GenericFightCell * cell ) { QStack path; int dist = cell->getDist(); GenericFightCell * current = cell; path.push( cell ); for( int i = dist - 1; i > 0; i-- ) { current = giveNeighbourOnPath( current, i ); path.push( current ); } current = path.pop(); if( current != cell || path.count() == 0 ) { if( ! areNeighbours( unit->getCell(), current ) ) { return false; } } return true; } bool GenericFightMap::inMap( int row, int col ) { if( row < _height && row >= 0 && col >= 0 && col < _width ) { return true; } else { //logEE("Point not in fight map row %d , col %d , height %d, width %d", row, col , _height, _width); return false; } } GenericFightCell * GenericFightMap::getHeadCell( GenericFightCell * cell , bool isLookingToRight ) { GenericFightCell* headCell = NULL; if( isLookingToRight ) { headCell = getNeighbour2( cell ); } else { headCell = getNeighbour5( cell ); } return headCell; } /*********************************************/ FightPile::FightPile( GenericFightMap * map, int limit, GenericFightUnit* unit ) { _map = map; _limit = limit; _unit = unit; _unitsize = _unit->getCreature()->getSize(); } GenericFightCell * FightPile::takeSmallest() { FightPile::iterator i; GenericFightCell * smallest = first(); GenericFightCell * current; for (i = begin(); i != end(); ++i) { current = *i; if( smallest->getDist() > current->getDist() ) { smallest = current; } } removeAll(smallest); return smallest; } void FightPile::appendNeighbours( GenericFightCell * cell ) { int dist = cell->getDist() + 1; handleNeighbour( _map->getNeighbour1( cell ), dist ); handleNeighbour( _map->getNeighbour2( cell ), dist ); handleNeighbour( _map->getNeighbour3( cell ), dist ); handleNeighbour( _map->getNeighbour4( cell ), dist ); handleNeighbour( _map->getNeighbour5( cell ), dist ); handleNeighbour( _map->getNeighbour6( cell ), dist ); } void FightPile::handleNeighbour( GenericFightCell * neighbour, int dist ) { if( neighbour ) { bool isObstacle = testObstacle( neighbour ); GenericFightUnit * headUnit = testHeadFree( neighbour ); bool isOccupiedByAnotherUnit = false; if ( neighbour->getUnit () && ( neighbour->getUnit ()->isAlive () ) ) { isOccupiedByAnotherUnit = ( neighbour->getUnit () != _unit ); } switch( neighbour->getAccess() ) { case AttalCommon::UNKNOWN_ACCESS: if( isObstacle && !neighbour->getUnit() ) { neighbour->setAccess( AttalCommon::NONE ); break; } if( dist <= _limit ) { if( isOccupiedByAnotherUnit || headUnit ) { neighbour->setAccess( AttalCommon::NEAR_OCCUPIED ); neighbour->setDist( dist ); if( headUnit ) { neighbour->setHeadUnit( headUnit ); } } else { neighbour->setAccess( AttalCommon::NEAR_FREE ); neighbour->setDist( dist ); append( neighbour ); } } else if( isOccupiedByAnotherUnit || headUnit ) { neighbour->setAccess( AttalCommon::FAR_OCCUPIED ); neighbour->setDist( dist ); if( headUnit ) { neighbour->setHeadUnit( headUnit ); } } else { neighbour->setAccess( AttalCommon::FAR_FREE ); neighbour->setDist( dist ); } break; case AttalCommon::NONE: break; case AttalCommon::NEAR_FREE: if( dist < neighbour->getDist() ) { neighbour->setDist( dist ); append( neighbour ); } break; case AttalCommon::NEAR_OCCUPIED: if( dist < neighbour->getDist() ) { neighbour->setDist( dist ); } break; case AttalCommon::FAR_FREE: if( dist < neighbour->getDist() ) { neighbour->setDist( dist ); } if( neighbour->getDist() <= _limit ) { neighbour->setAccess( AttalCommon::NEAR_FREE ); append( neighbour ); } break; case AttalCommon::FAR_OCCUPIED: if( dist < neighbour->getDist() ) { neighbour->setDist( dist ); } if( neighbour->getDist() <= _limit ) { neighbour->setAccess( AttalCommon::NEAR_OCCUPIED ); } break; default: logEE( "Should not happen" ); break; } } } bool FightPile::testObstacle( GenericFightCell * cell ) { bool ret = false; if( cell->getType() == AttalCommon::OBSTACLE ) { ret = true; } if( _unitsize == 2 ) { GenericFightCell* headCell = _map->getHeadCell( cell, _unit->isLookingToRight() ); if( headCell ) { if ( headCell->getType () == AttalCommon::OBSTACLE ) { ret = true; } } else { ret = true; } } return ret; } GenericFightUnit * FightPile::testHeadFree( GenericFightCell * cell ) { GenericFightUnit * ret = 0; // If unit is 2-cells we can have problems with its head if( _unitsize == 2 ) { GenericFightCell* headCell = _map->getHeadCell( cell, _unit->isLookingToRight() ); if( headCell ) { if( ( headCell->getUnit () ) && ( headCell->getUnit () != _unit ) && ( headCell->getUnit ()->isAlive () ) ) { ret = headCell->getUnit(); } } } return ret; } attal-src-1.0-rc2/libCommon/genericFightMap.h0000644000175000017500000000727211000761546016610 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericFightMap.h ** generic class for managing (not graphical) fightMap ** ** Version : $Id: genericFightMap.h,v 1.18 2008/04/14 23:06:14 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICFIGHTMAP_H #define GENERICFIGHTMAP_H // generic include files // include files for QT #include #include // application specific include #include "libCommon/genericFightCell.h" class PathFightFinder; class GenericFightUnit; /* ------------------------------ * GenericFightMap * ------------------------------ */ /** generic class for managing (not graphical) cells */ class GenericFightMap { public: /** Constructor */ GenericFightMap(); /** Destructor */ virtual ~GenericFightMap(); /** Return cell of the fightMap */ inline GenericFightCell * at( int i, int j ) { return _genericFightCells[i][j]; } /** Create new fight map */ virtual void newFightMap( int h, int w, bool horizontalDraw = false ); virtual void reinit(); virtual void initPath( GenericFightUnit * unit ); void printPath(); virtual void clearPath(); QStack computePath( GenericFightUnit * unit, GenericFightCell * cell ); bool isPath( GenericFightUnit * unit , GenericFightCell * cell ); bool isLowerLevel( GenericFightCell * cell1, GenericFightCell * cell2 ); bool isUpperLevel( GenericFightCell * cell1, GenericFightCell * cell2 ); bool isSameLevel( GenericFightCell * cell1, GenericFightCell * cell2 ); GenericFightCell * getNeighbour1( GenericFightCell * cell ); GenericFightCell * getNeighbour2( GenericFightCell * cell ); GenericFightCell * getNeighbour3( GenericFightCell * cell ); GenericFightCell * getNeighbour4( GenericFightCell * cell ); GenericFightCell * getNeighbour5( GenericFightCell * cell ); GenericFightCell * getNeighbour6( GenericFightCell * cell ); bool areNeighbours( GenericFightCell * cell1, GenericFightCell * cell2 ); int getHeight () { return _height; } int getWidth () { return _width; } bool inMap( int row, int col ); GenericFightCell * getHeadCell( GenericFightCell * cell , bool isLookingToRight ); protected: GenericFightCell * giveNeighbourOnPath( GenericFightCell * cell, int dist ); int _height, _width; PathFightFinder * _path; bool _horizontalDraw; GenericFightCell *** _genericFightCells; }; /** pseudo-pile of GenericFightCell (in fact, a list..) */ class FightPile : public QList { public: /** Constrcutor */ FightPile( GenericFightMap * map, int limit, GenericFightUnit* unit ); /** \return Returns the 'smallest' cell */ GenericFightCell * takeSmallest(); /** Appends neighbours of a cell */ void appendNeighbours( GenericFightCell * cell ); private: void handleNeighbour( GenericFightCell * neighbour, int dist ); GenericFightUnit * testHeadFree( GenericFightCell * cell ); bool testObstacle( GenericFightCell * cell ); GenericFightMap * _map; int _limit; int _unitsize; GenericFightUnit * _unit; }; #endif // GENERICFIGHTMAP_H attal-src-1.0-rc2/libCommon/genericInsideBuilding.cpp0000644000175000017500000001416010713710377020335 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericInsideBuilding.cpp ** describes building inside bases ** ** Version : $Id: genericInsideBuilding.cpp,v 1.17 2007/11/05 21:54:07 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 04/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericInsideBuilding.h" // generic include files // include files for QT // application specific include files #include "libCommon/action.h" #include "libCommon/dataTheme.h" // // ----- GenericInsideBuilding ----- // GenericInsideBuilding::GenericInsideBuilding() { _race = 0; _level = 0; } GenericInsideBuilding::~GenericInsideBuilding() { } int GenericInsideBuilding::getX() { return DataTheme.bases.at( _race )->getBuildingModel( _level )->getX(); } int GenericInsideBuilding::getY() { return DataTheme.bases.at( _race )->getBuildingModel( _level )->getY(); } uint GenericInsideBuilding::getMantCost( uint ress ) { return DataTheme.bases.at( _race )->getBuildingModel( _level )->getMantCost( ress ); } // // ----- InsideBuildingModel ----- // InsideBuildingModel::InsideBuildingModel() { _race = 0; _level = 0; _name = ""; _description = ""; _x = 0; _y = 0; _replacement = -1; _action = NULL; for( int i = 0; i < MAX_RESS; i++ ) { _cost[i] = 0; _mcost[i] = 0; } } InsideBuildingModel::~InsideBuildingModel() { if( _action ) { delete _action; } } void InsideBuildingModel::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent ); *ts << "\t" << getName() << "" << endl; indentation( ts, indent ); *ts << "\t" << getDescription() << "" << endl; indentation( ts, indent ); *ts << "\t" << getX() << "" << endl; indentation( ts, indent ); *ts << "\t" << getY() << "" << endl; for( int i = 0; i < DataTheme.resources.count(); i++ ) { if( getCost( i ) > 0 ) { indentation( ts, indent ); *ts << "\t"; *ts << getCost( i ) << "" << endl; } } for( int i = 0; i < DataTheme.resources.count(); i++ ) { if( getMantCost( i ) > 0 ) { indentation( ts, indent ); *ts << "\t"; *ts << getMantCost( i ) << "" << endl; } } if( getAction() ) { indentation( ts, indent ); *ts << "\tgetType() ) << "\">" << endl; for( uint i = 0; i < getAction()->getParamNumber(); ++i ) { indentation( ts, indent+1 ); *ts << "\t" << getAction()->getParam( i ) << "" << endl; } indentation( ts, indent+1 ); *ts << "" << endl; } int nbReq = getRequirementNumber(); for( int i = 0; i < nbReq; ++i ) { indentation( ts, indent ); *ts << "\t" << getRequirement( i ) << "" << endl; } indentation( ts, indent ); *ts << "" << endl; } void InsideBuildingModel::setAction( InsideAction * action ) { if( _action ) { delete _action; } _action = action; } void InsideBuildingModel::addRequirement( int req ) { _require.append( req ); } int InsideBuildingModel::getRequirement( int num ) { int ret = 0; if( num < _require.count() ) { ret = _require.at( num ); } return ret; } uint InsideBuildingModel::getCost( uint ress ) { uint ret = 0; if( (int)ress < DataTheme.resources.count() ) { ret = _cost[ress]; } return ret; } void InsideBuildingModel::setCost( uint ress, uint cost ) { if( (int)ress < DataTheme.resources.count() ) { _cost[ress] = cost; } } uint InsideBuildingModel::getMantCost( uint ress ) { uint ret = 0; if( (int)ress < DataTheme.resources.count() ) { ret = _mcost[ress]; } return ret; } void InsideBuildingModel::setMantCost( uint ress, uint cost ) { if( (int)ress < DataTheme.resources.count() ) { _mcost[ress] = cost; } } QString InsideBuildingModel::getBuildDescActions() { ResourceList & themeResources = DataTheme.resources; uint nbRes = themeResources.count(); uint i; QString text = ""; QString cost = ""; QString req = ""; if( !_description.isEmpty() ) { text += tr("Description:") + "\n" + _description + "\n"; } if( _action ) { switch( _action->getType() ) { case INSIDE_NONE: text+=tr("Not implemented"); break; case INSIDE_VILLAGE: text+=tr("Main Building (not sellable)"); break; case INSIDE_CASTLE: text+=tr("Castle"); break; case INSIDE_CREA:{ /* specify what kind and number of units produced */ text+=tr("Produce "); if(_action->getParamNumber() == 3) { text+=QString("%1 ").arg(_action->getParam(2)); text+= DataTheme.creatures.at(_action->getParam(0),_action->getParam(1))->getName(); } break; } case INSIDE_MARKET: text+=tr("Market"); break; case INSIDE_TAVERN: text+=tr("Tavern"); break; default: break; } } else { text+=tr("Not implemented"); } text += "\n" ; for( i = 0; i < nbRes; ++i ) { if( getCost( i ) != 0 ) { if( cost != "" ) { cost += " + "; } cost += QString::number( getCost( i ) ) + " " + themeResources.getRessource( i ); } } if( cost == "" ) { cost = "0"; } text += tr("Cost: ") + cost; for( i = 0; (int)i < getRequirementNumber(); ++i ) { // Again, possibly dangerous range limiting and a check with may be necessary if( i > 0 ) { req += ", "; } req += DataTheme.bases.at( _race )->getBuildingModel( getRequirement( i ) )->getName(); } if( getRequirementNumber() > 0 ) { text += "\n" ; text += tr("Require: ") + req; } return text; } attal-src-1.0-rc2/libCommon/genericInsideBuilding.h0000644000175000017500000000645710707744746020026 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** insideBuilding.h ** describes building inside bases ** ** Version : $Id: genericInsideBuilding.h,v 1.10 2007/10/24 22:40:38 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 04/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICINSIDEBUILDING_H #define GENERICINSIDEBUILDING_H // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/define.h" class QTextStream; class InsideAction; /** ------------------------------ * InsideBuildingModel ** ------------------------------ */ class InsideBuildingModel { Q_DECLARE_TR_FUNCTIONS(InsideBuildingModel) public: /** Constructor */ InsideBuildingModel(); virtual ~InsideBuildingModel(); void save( QTextStream * ts, int indent ); uint getRace() { return _race; } void setRace( uint race ) { _race = race; } uint getLevel() { return _level; } void setLevel( uint level ) { _level = level; } QString getName() { return _name; } void setName( const QString & name ) { _name = name; } QString getDescription() { return _description; } void setDescription( const QString & description ) { _description = description; } QString getBuildDescActions(); int getX() { return _x; } void setX( int x ) { _x = x; } int getY() { return _y; } void setY( int y ) { _y = y; } int getReplacement() { return _replacement; } void setReplacement( int replace ) { _replacement = replace; } void clearRequirements() { _require.clear(); } void addRequirement( int ); int getRequirementNumber() { return _require.count(); } int getRequirement( int num ); InsideAction * getAction() { return _action; } void setAction( InsideAction * action ); uint getCost( uint ress ); void setCost( uint ress, uint cost ); uint getMantCost( uint ress ); void setMantCost( uint ress, uint cost ); private: QString _name, _description; uint _race, _level; int _x, _y; int _replacement; QList _require; InsideAction * _action; uint _cost[ MAX_RESS ]; uint _mcost[ MAX_RESS ]; }; /** ------------------------------ * GenericInsideBuilding ** ------------------------------ */ class GenericInsideBuilding { public: /** Constructor */ GenericInsideBuilding(); /** Destructor */ virtual ~GenericInsideBuilding(); uint getRace() { return _race; } void setRace( uint race ) { _race = race; } uint getLevel() { return _level; } void setLevel( uint level ) { _level = level; } int getX(); int getY(); uint getMantCost( uint ress ); protected: uint _race, _level; }; #endif // GENERICINSIDEBUILDING_H attal-src-1.0-rc2/libCommon/genericLord.cpp0000644000175000017500000006520611010171135016333 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericLord.cpp ** manages a lord and its units ** ** Version : $Id: genericLord.cpp,v 1.54 2008/05/07 00:05:49 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 09/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericLord.h" // generic include files #include // include files for QT #include // application specific include files #include "libCommon/artefact.h" #include "libCommon/artefactManager.h" #include "libCommon/categoryManager.h" #include "libCommon/dataTheme.h" #include "libCommon/genericPlayer.h" #include "libCommon/log.h" #include "libCommon/lordCategoryModel.h" #include "libCommon/pathFinder.h" #include "libCommon/unit.h" #include "libCommon/warMachine.h" extern QString DATA_PATH; LordCharac detectCharac( const QString & type ) { LordCharac ret = ATTACK; if( type == "attack" ) { ret = ATTACK; } else if( type == "defense" ) { ret = DEFENSE; } else if( type == "power" ) { ret = POWER; } else if( type == "knowledge" ) { ret = KNOWLEDGE; } else if( type == "move" ) { ret = MOVE; } else if( type == "movemax" ) { ret = MAXMOVE; } else if( type == "technicpoint" ) { ret = TECHNICPOINT; } else if( type == "maxtechnicpoint" ) { ret = MAXTECHNICPOINT; } else if( type == "morale" ) { ret = MORALE; } else if( type == "luck" ) { ret = LUCK; } else if( type == "vision" ) { ret = VISION; } else if( type == "experience" ) { ret = EXPERIENCE; } else if( type == "charisma" ) { ret = CHARISMA; } else if( type == "level" ) { ret = LEVEL; } else { logEE( "Unknown Lord's Characteristic: %s", type.toLatin1().constData() ); } return ret; } QString getCharacName( LordCharac charac ) { QString ret = ""; switch( charac ) { case ATTACK: ret = "attack"; break; case DEFENSE: ret = "defense"; break; case POWER: ret = "power"; break; case KNOWLEDGE: ret = "knowledge"; break; case MOVE: ret = "move"; break; case MAXMOVE: ret = "movemax"; break; case TECHNICPOINT: ret = "technicpoint"; break; case MAXTECHNICPOINT: ret = "maxtechnicpoint"; break; case MORALE: ret = "morale"; break; case LUCK: ret = "luck"; break; case VISION: ret = "vision"; break; case EXPERIENCE: ret = "experience"; break; case CHARISMA: ret = "charisma"; break; case LEVEL: ret = "level"; break; default: break; } return ret; } // // ----- GenericLord ----- // /** add comments here */ GenericLord::GenericLord() : _id( 0 ), _player( 0 ), _currentCell( NULL ), _dest( NULL ), _hasBook( false ), _move( 0 ), _maxMove( 0 ), _technicPoints( 0 ), _maxTechnicPoints( 0 ), _morale( 0 ), _luck( 0 ), _experience( 0 ), _power( 0 ), _knowledge( 0 ), _attack( 0 ), _defense( 0 ), _vision( 0 ), _charisma( 0 ), _level( 0 ), _isCreatureLord( false ), _visible( true ), _sleeping( false ) { for( int i = 0; i < MAX_UNIT; i++ ) { _units[i] = NULL; } _artefactManager = new ArtefactManager( this ); //_artefacts.setAutoDelete( true ); _model = 0; } GenericLord::~GenericLord() { clearUnits(); delete _artefactManager; } void GenericLord::reinit() { TRACE(" Reinit "); setId( _id ); _player = 0; _currentCell = 0; } QString GenericLord::getName() { QString ret = ""; if( _id != 0 ) { ret = _model->getName(); } return ret; } QString GenericLord::getCategoryName() { QString ret = ""; if( _id != 0 ) { ret = _model->getCategory()->getName(); } return ret; } int GenericLord::getRace() { int ret = 0; if( _id != 0 ) { ret = _model->getRace(); } return ret; } void GenericLord::setId( int id ) { _id = id; if( _id >= DataTheme.lords.count() ) { logEE( "Lord id %d doesn't exist", _id ); _id = 0; _model = 0; return; } _model = DataTheme.lords.at( _id ); _move = _model->getBaseCharac( MOVE ); _maxMove = _model->getBaseCharac( MAXMOVE ); _technicPoints = _model->getBaseCharac( TECHNICPOINT ); _maxTechnicPoints = _model->getBaseCharac( MAXTECHNICPOINT ); _morale = _model->getBaseCharac( MORALE ); _luck = _model->getBaseCharac( LUCK ); _experience = 0; _power = _model->getBaseCharac( POWER ); _knowledge = _model->getBaseCharac( KNOWLEDGE ); _attack = _model->getBaseCharac( ATTACK ); _defense = _model->getBaseCharac( DEFENSE ); _hasBook = _model->isBook(); _vision = _model->getBaseCharac( VISION ); _charisma = _model->getBaseCharac( CHARISMA ); _level = _model->getBaseCharac( LEVEL ); for( int i = 0; i < MAX_UNIT; i++ ) { if( _units[i] ) { delete _units[i]; } _units[i] = NULL; if( _model->getUnit( i ) ) { GenericFightUnit * unit = new GenericFightUnit( *_model->getUnit( i ) ); _units[i] = unit; } } _machines.clear(); for( uint j = 0; j < _model->getMachineNumber(); j++ ) { addMachine( getMachine( j ) ); } /// XXX: artefacts ??? } void GenericLord::setCell( GenericCell * cell ) { getOut(); if( _currentCell ) { _currentCell->setLord( NULL ); } _currentCell = cell ; if( _currentCell ) { _currentCell->setLord( (GenericLord *)this ); } } void GenericLord::getOut() { if( _currentCell ) { _currentCell->setLord( NULL ); GenericBase * base = _currentCell->getBase(); if( base != 0 ) { if( base->getGarrisonLord() == this ) { base->removeGarrisonLord(); } else if( base->getVisitorLord() == this ) { base->removeVisitorLord(); } } } } void GenericLord::setVisible( bool state ) { if( ! state ) { if( _currentCell ) { _currentCell->setLord( 0 ); } //_currentCell = 0; } _visible = state; } void GenericLord::endTurn() { _move = _maxMove; } QString GenericLord::getLordDescription() { QString ret = ""; ret += getName() + "\n"; ret += QString("Id %1 \n").arg( _id ); ret += QString("MaxMove %1 \n").arg(_maxMove); ret += QString("Vision %1 \n").arg(_vision); ret += QString("Experience %1 \n").arg(_experience); ret += QString("Attack %1 \n").arg(_attack); ret += QString("Defense %1 \n").arg(_defense); ret += QString("Move %1 \n").arg(_move); return ret; } void GenericLord::printLordData() { logDD(" id %d", _id ); logDD(" model %p", _model ); logDD(" move %d", _move ); logDD(" maxMove %d", _maxMove ); logDD(" techPoints %d", _technicPoints ); logDD(" maxTechnicPoints %d", _maxTechnicPoints ); logDD(" morale %d", _morale ); logDD(" luck %d", _luck); logDD(" experience %d", _experience ); logDD(" knowledge %d", _knowledge ); logDD(" attack %d", _attack ); logDD(" defense %d", _defense ); logDD(" hasBook %d", _hasBook ); logDD(" vision %d", _vision ); logDD(" charisma %d", _charisma ); logDD(" level %d", _level ); for( int i = 0; i < MAX_UNIT; i++ ) { if( _units[i] ) { logDD( " units %p", _units[i]); } } } /*! */ bool GenericLord::addCreatures( Creature * creature, int number ) { bool ret = false; for( int i = 0; i < MAX_UNIT; i++ ) { GenericFightUnit * unit = _units[i]; if( unit == 0 ) { unit = new GenericFightUnit(); unit->setCreature( creature ); unit->setNumber( number ); _units[i] = unit; ret = true; break; } else if( ( unit->getLevel() == creature->getLevel() ) && ( unit->getRace() == creature->getRace() ) ) { unit->addNumber( number ); ret = true; break; } } return ret; } void GenericLord::updateUnit( uchar pos ,uchar race, uchar level, int nb, uchar move, int health) { GenericFightUnit * uni = getUnit( pos ); if( nb != 0 ){ if( !uni ){ uni = new GenericFightUnit(); } uni->setCreature( race, level ); if(health > uni->getMaxHealth()) { logEE("bug, health %d, maxhealth %d", health, uni->getMaxHealth()); delete uni; return; } uni->setNumber( nb ); uni->setMove( move ); uni->setHealth( health ); } else { if( uni ) { delete uni; uni = NULL; } } setUnit( pos, uni ); } void GenericLord::clearUnits() { for( int i = 0; i < MAX_UNIT; i++ ) { if( _units[i] ) { delete _units[i]; _units[i] = NULL; } } } int GenericLord::countUnits() { int num=0; for( int i = 0; i < MAX_UNIT; i++ ) { if( _units[i] ) { num++; } } return num; } bool GenericLord::load( QTextStream * ) { /// XXX: no args ? return true; } void GenericLord::save( QTextStream * ts, int indent ) { uint i; indentation( ts, indent ); *ts << "" << endl; if( _currentCell ) { indentation( ts, indent ); *ts << "\t" << _currentCell->getCol() << "" << endl; indentation( ts, indent ); *ts << "\t" << _currentCell->getRow() << "" << endl; } for( i = 0; i < MAX_UNIT; i++ ) { if( _units[i] ) { indentation( ts, indent ); *ts << "\t" << endl; indentation( ts, indent ); *ts << "\t\t" << _units[i]->getRace() << "" << endl; indentation( ts, indent ); *ts << "\t\t" << _units[i]->getLevel() << "" << endl; indentation( ts, indent ); *ts << "\t\t" << _units[i]->getNumber() << "" << endl; indentation( ts, indent ); *ts << "\t" << endl; } } _artefactManager->save( ts, indent + 1 ); /** Here we will call "May day!! :) characteristics are upon us" */ LordCharac characIndex = ATTACK; for( int index = (int)ATTACK; index < (int)LAST; ++index ) { characIndex = (LordCharac)index; if( _model->getBaseCharac( characIndex ) != getBaseCharac( characIndex ) ) { indentation( ts, indent+1 ); *ts << ""; *ts << getBaseCharac( characIndex ); *ts << "" << endl; } } for( int j = 0; j < _machines.count(); j++ ) { indentation( ts, indent ); *ts << "\t" << _machines.at( j ) << "" << endl; } indentation( ts, indent ); *ts << "" << endl; *ts << flush; } int GenericLord::getCharac( LordCharac type ) { /// XXX: compute with artefacts, skills... int ret = 0; ret = getBaseCharac( type ); ret = _artefactManager->computeCharacModif( type, ret ); return ret; } int GenericLord::getBaseCharac( LordCharac type ) { int ret = 0; switch( type ) { case ATTACK: ret = _attack; break; case DEFENSE: ret = _defense; break; case POWER: ret = _power; break; case KNOWLEDGE: ret = _knowledge; break; case MOVE: ret = _move; break; case MAXMOVE: ret = _maxMove; break; case TECHNICPOINT: ret = _technicPoints; break; case MAXTECHNICPOINT: ret = _maxTechnicPoints; break; case MORALE: ret = _morale; break; case LUCK: ret = _luck; break; case VISION: ret = _vision; break; case EXPERIENCE: ret = _experience; break; case CHARISMA: ret = _charisma; break; case LEVEL: ret = _level; break; default: break; } return ret; } void GenericLord::setBaseCharac( LordCharac type, int value ) { switch( type ) { case ATTACK: _attack = value; break; case DEFENSE: _defense = value; break; case POWER: _power = value; break; case KNOWLEDGE: _knowledge = value; break; case MOVE: _move = value; break; case MAXMOVE: _maxMove = value; break; case TECHNICPOINT: _technicPoints = value; break; case MAXTECHNICPOINT: _maxTechnicPoints = value; break; case MORALE: _morale = value; break; case LUCK: _luck = value; break; case VISION: _vision = value; break; case EXPERIENCE: _experience = value; break; case CHARISMA: _charisma = value; break; case LEVEL: _level = value; break; default: break; } } void GenericLord::increaseBaseCharac( LordCharac type, int value ) { switch( type ) { case ATTACK: _attack += value; break; case DEFENSE: _defense += value; break; case POWER: _power += value; break; case KNOWLEDGE: _knowledge += value; break; case MOVE: _move += value; break; case MAXMOVE: _maxMove += value; break; case TECHNICPOINT: _technicPoints += value; break; case MAXTECHNICPOINT: _maxTechnicPoints += value; break; case MORALE: _morale += value; break; case LUCK: _luck += value; break; case VISION: _vision += value; break; case EXPERIENCE: _experience += value; break; case CHARISMA: _charisma += value; break; case LEVEL: _level += value; break; default: break; } } void GenericLord::decreaseBaseCharac( LordCharac type, int value ) { switch( type ) { case ATTACK: if( value < _attack ) { _attack -= value; } else { _attack = 0; } break; case DEFENSE: if( value < _defense ) { _defense -= value; } else { _defense = 0; } break; case POWER: if( value < _power ) { _power -= value; } else { _power = 0; } break; case KNOWLEDGE: if( value < _knowledge ) { _knowledge -= value; } else { _knowledge = 0; } break; case MOVE: if( value < _move ) { _move -= value; } else { _move = 0; } break; case MAXMOVE: if( value < _maxMove ) { _maxMove -= value; } else { _maxMove = 0; } break; case TECHNICPOINT: if( value < _technicPoints ) { _technicPoints -= value; } else { _technicPoints = 0; } break; case MAXTECHNICPOINT: if( value < _maxTechnicPoints ) { _maxTechnicPoints -= value; } else { _maxTechnicPoints = 0; } break; case MORALE: if( value < _morale ) { _morale = value; } else { _morale = 0; } break; case LUCK: if( value < _luck ) { _luck -= value; } else { _luck = 0; } break; case VISION: if( value < _vision ) { _vision -= value; } else { _vision = 0; } break; case EXPERIENCE: if( value < _experience ) { _experience -= value; } else { _experience = 0; } break; case CHARISMA: if( value < _charisma ) { _charisma -= value; } else { _charisma = 0; } break; case LEVEL: if( value < _level ) { _level -= value; } else { _level = 0; } break; default: break; } } void GenericLord::removeFromGame() { if( getOwner() ) { getOwner()->removeLord( this ); setOwner( NULL ); } if( getCell() ) { getCell()->setLord( NULL ); GenericBase * base = getCell()->getBase(); if( getCell()->getBase() ) { if( base->getGarrisonLord() == this ) { base->removeGarrisonLord(); } if( base->getVisitorLord() == this ) { base->removeVisitorLord(); } } _currentCell = NULL; } } void GenericLord::addMachine( int id ) { _machines.append( id ); } uint GenericLord::getMachineNumber() { uint ret = _machines.count(); return ret; } uint GenericLord::getMachine( uint num ) { uint ret = 0; if( (int)num < _machines.count() ) { ret = _machines.at( num ); } return ret; } void GenericLord::removeMachine( uint num ) { _machines.removeAt( num ); } bool GenericLord::hasMachine( int id ) { bool ret = false; for( int i = 0; i < _machines.count(); i++ ) { if( _machines.at( i ) == id ) { ret = true; } } return ret; } bool GenericLord::hasMachineType( int type ) { bool ret = false; for( int i = 0; i < _machines.count(); i++ ) { int id = _machines.at( i ); WarMachine * machine = DataTheme.machines.at( id ); if( machine ) { if( machine->getType() == type ) { ret = true; } } } return ret; } uint GenericLord::computeForceIndicator( bool real) { uint ret = 0; uint number = 0; GenericFightUnit * unit; for( int i = 0; i < MAX_UNIT; ++i ) { unit = _units[i]; if( unit ) { if( real ) { number = unit->getNumber(); } else { number = DataTheme.getRandomInCategory( (uchar)DataTheme.computeCategory( unit->getNumber() ) ); } ret += unit->getMaxHealth() * number; } } return ret; } uint GenericLord::getCost( uint res ) { uint ret = 0; if( (int)res < DataTheme.resources.count() ) { ret = _cost[res]; } return ret; } void GenericLord::setCost( uint res, uint cost ) { if( (int)res < DataTheme.resources.count() ) { _cost[res] = cost; } } uint GenericLord::computeCreatureMaxManaged() { //XXX TODO return MAX_UNIT; } // // ----- GenericLordModel ----- // GenericLordModel::GenericLordModel() : _name( "" ), _category( 0 ), _move( 0 ), _maxMove( 0 ), _technicPoints( 0 ), _maxTechnicPoints( 0 ), _morale( 0 ), _luck( 0 ), _power( 0 ), _knowledge( 0 ), _attack( 0 ), _defense( 0 ), _knowledgePoints( 0 ), _vision( 0 ), _charisma( 0 ), _level( 0 ) { for( int i = 0; i < MAX_UNIT; i++ ) { _units[i] = 0; } for( int i = 0; i < MAX_RESS; i++ ) { _cost[i] = 0; } } GenericLordModel::~GenericLordModel() { for( int i = 0; i < MAX_UNIT; i++ ) { if(_units[i]) { delete _units[i]; _units[i] = 0; } } } uint GenericLordModel::getRace() { uint ret = 0; if( _category ) { ret = _category->getRace(); } return ret; } void GenericLordModel::setBaseCharac( LordCharac type, int value ) { switch( type ) { case ATTACK: _attack = value; break; case DEFENSE: _defense = value; break; case POWER: _power = value; break; case KNOWLEDGE: _knowledge = value; break; case MOVE: _move = value; break; case MAXMOVE: _maxMove = value; break; case TECHNICPOINT: _technicPoints = value; break; case MAXTECHNICPOINT: _maxTechnicPoints = value; break; case MORALE: _morale = value; break; case LUCK: _luck = value; break; case VISION: _vision = value; break; case EXPERIENCE: _experience = value; break; case CHARISMA: _charisma = value; break; case LEVEL: _level = value; break; default: break; } } int GenericLordModel::getBaseCharac( LordCharac type ) { int ret = 0; switch( type ) { case ATTACK: ret = _attack; break; case DEFENSE: ret = _defense; break; case POWER: ret = _power; break; case KNOWLEDGE: ret = _knowledge; break; case MOVE: ret = _move; break; case MAXMOVE: ret = _maxMove; break; case TECHNICPOINT: ret = _technicPoints; break; case MAXTECHNICPOINT: ret = _maxTechnicPoints; break; case MORALE: ret = _morale; break; case LUCK: ret = _luck; break; case VISION: ret = _vision; break; case EXPERIENCE: ret = _experience; break; case CHARISMA: ret = _charisma; break; case LEVEL: ret = _level; break; default: break; } return ret; } void GenericLordModel::addMachine( int id ) { _machines.append( id ); } uint GenericLordModel::getMachineNumber() { uint ret = _machines.count(); return ret; } uint GenericLordModel::getMachine( uint num ) { uint ret = 0; if( (int)num < _machines.count() ) { ret = _machines.at( num ); } return ret; } int GenericLordModel::countUnits() { int num = 0; for( int i = 0; i < MAX_UNIT; i++ ) { if( _units[i] != 0 ) { num++; } } return num; } uint GenericLordModel::getCost( uint res ) { uint ret = 0; if( (int)res < DataTheme.resources.count() ) { ret = _cost[res]; } return ret; } void GenericLordModel::setCost( uint res, uint cost ) { if( (int)res < DataTheme.resources.count() ) { _cost[res] = cost; } } QString GenericLordModel::getLordDescription() { ResourceList & themeResources = DataTheme.resources; uint nbRes = themeResources.count(); QString text = ""; for( uint i = 0; i < nbRes; ++i ) { if( getCost( i ) != 0 ) { if( text != "" ) { text += " + "; } text += QString::number( getCost( i ) ) + " " + themeResources.getRessource( i ); } } if( text == "" ) { text = "0"; } text = "Cost: " + text; text += "\n" ; return text; } void GenericLordModel::removeMachine( uint num ) { _machines.removeAt( num ); } void GenericLordModel::save( QTextStream & ts, int indent ) { uint j; indentation( &ts, indent ); ts << "" << endl; indentation( &ts, indent + 1 ); ts << "" << getName() << "" << endl; indentation( &ts, indent + 1 ); ts << "" << getBaseCharac( ATTACK ) << "" << endl; indentation( &ts, indent + 1 ); ts << "" << getBaseCharac( DEFENSE ) << "" << endl; indentation( &ts, indent + 1 ); ts << "" << getBaseCharac( POWER ) << "" << endl; indentation( &ts, indent + 1 ); ts << "" << getBaseCharac( KNOWLEDGE ) << "" << endl; indentation( &ts, indent + 1 ); ts << "" << getBaseCharac( MAXMOVE ) << "" << endl; indentation( &ts, indent + 1 ); ts << "" << getBaseCharac( VISION ) << "" << endl; indentation( &ts, indent + 1 ); ts << "" << getBaseCharac( LEVEL ) << "" << endl; for( int k = 0; k < DataTheme.resources.count(); k++ ) { if( getCost( k ) > 0 ) { indentation( &ts, indent ); ts << "\t"; ts << getCost( k ) << "" << endl; } } for( j = 0; j < MAX_UNIT; j++ ) { GenericFightUnit * unit = getUnit( j ); if( unit ) { indentation( &ts, indent + 1 ); ts << "" << endl; indentation( &ts, indent + 2 ); ts << "" << unit->getRace() << "" << endl; indentation( &ts, indent + 2 ); ts << "" << unit->getLevel() << "" << endl; indentation( &ts, indent + 2 ); ts << "" << unit->getNumber() << "" << endl; indentation( &ts, indent + 1 ); ts << "" << endl; } else { indentation( &ts, indent + 1 ); ts << "" << endl; indentation( &ts, indent + 2 ); ts << "0" << endl; indentation( &ts, indent + 2 ); ts << "0" << endl; indentation( &ts, indent + 2 ); ts << "0" << endl; indentation( &ts, indent + 1 ); ts << "" << endl; } } for( j = 0; j < getMachineNumber(); j++ ) { indentation( &ts, indent + 1 ); ts << "" << getMachine( j ) << "" << endl; } indentation( &ts, indent ); ts << "" << endl; } // // ----- LordList ----- // LordList::LordList() { } LordList::~LordList() { clear(); } bool LordList::init() { clear(); LordHandler handler( this ); QFile file( DATA_PATH + "lords.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "lords.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } bool LordList::save() { QString filename = DATA_PATH + "lords.dat"; QFile file( filename ); if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writng\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; GenericLordModel * lord; for( int i = 1; i < count(); i++ ) { lord = at( i ); if( lord ) { lord->save( ts, 1 ); } } ts << "" << endl; file.close(); return true; } void LordList::clear() { while( ! isEmpty() ) { delete takeFirst(); } } // // ----- LordHandler ----- // LordHandler::LordHandler( LordList * list ) { _list = list; } bool LordHandler::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _list->clear(); GenericLordModel * lord = new GenericLordModel(); _list->append( lord ); _state = StateInit; return true; } bool LordHandler::startElement( const QString &, const QString &, const QString & qName, const QXmlAttributes & atts ) { if( qName == "lords" && _state == StateInit ) { _state = StateDocument; } else if ( qName == "lord" && _state == StateDocument ) { _state = StateLord; _lord = new GenericLordModel(); _lord->setCategory( DataTheme.lordCategories.at( atts.value( "category" ).toUInt() ) ); _numUnit = 0; } else if ( qName == "name" && _state == StateLord ) { _state = StateName; } else if( qName == "characteristic" && _state == StateLord ) { _state = StateCharac; _charac = detectCharac( atts.value( "type" ) ); } else if( qName == "cost" && _state == StateLord ) { _state = StateCost; _resource = atts.value( "resource" ).toInt(); } else if ( qName == "unit" && _state == StateLord ) { _state = StateUnit; _unit = new GenericFightUnit(); _race = 0; _level = 0; } else if ( qName == "race" && _state == StateUnit ) { _state = StateUnitRace; } else if ( qName == "level" && _state == StateUnit ) { _state = StateUnitLevel; } else if ( qName == "number" && _state == StateUnit ) { _state = StateNumber; } else if( qName == "machine" && _state == StateLord ) { _state = StateMachine; } else { // error return false; } return true; } bool LordHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateLord: _state = StateDocument; _list->append( _lord ); break; case StateName: _state = StateLord; break; case StateCharac: _state = StateLord; break; case StateCost: _state = StateLord; break; case StateUnit: _state = StateLord; _unit->setCreature( _race, _level ); if( _unit->getNumber() > 0 ) { _lord->setUnit( _numUnit, _unit ); } else { _lord->setUnit( _numUnit, 0 ); delete _unit; } _numUnit++; break; case StateUnitRace: _state = StateUnit; break; case StateUnitLevel: _state = StateUnit; break; case StateNumber: _state = StateUnit; break; case StateMachine: _state = StateLord; break; default: // do nothing break; } return true; } bool LordHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) return true; switch( _state ) { case StateName: _lord->setName( ch_simplified ); break; case StateCharac: _lord->setBaseCharac( _charac, ch_simplified.toInt() ); break; case StateCost: _lord->setCost( _resource, ch_simplified.toInt() ); break; case StateUnitRace: _race = ch_simplified.toInt(); break; case StateUnitLevel: _level = ch_simplified.toInt(); break; case StateNumber: _unit->setNumber( ch_simplified.toInt() ); break; case StateMachine: _lord->addMachine( ch_simplified.toInt() ); break; default: return false; } return true; } bool LordHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/genericLord.h0000644000175000017500000002147311010170657016006 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericLord.h ** manages a lord and its units ** ** Version : $Id: genericLord.h,v 1.34 2008/05/07 00:02:55 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 25/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICLORD_H #define GENERICLORD_H // generic include files // include files for QT #include // application specific include files #include "libCommon/artefact.h" #include "libCommon/define.h" #include "libCommon/skill.h" #include "libCommon/specialty.h" #include "libCommon/technic.h" class QTextStream; //class GenericArtefact; class ArtefactManager; class Creature; class GenericFightUnit; class GenericCell; class GenericPlayer; class GenericLordModel; class LordCategoryModel; enum LordPriority { PR_ENEMY = 1, PR_BASE, PR_BASEOWNER, PR_BUILD, PR_ART, PR_BONUS, PR_CHEST, PR_CREAT, PR_EXPLORE, PR_LAST }; /* ------------------------------ * GenericLord * ------------------------------ */ LordCharac detectCharac( const QString & type ); QString getCharacName( LordCharac charac ); class GenericLord { public: /** Constructor */ GenericLord(); /** Destructor */ virtual ~GenericLord(); /** Copy lord */ void copy( GenericLord * ); /** Load lord */ bool load( QTextStream * ); /** Save lord */ void save( QTextStream *, int indent = 0 ); /** Set Id of the lord */ void setId( int id ); /** Return Id of the lord */ int getId() { return _id; } void reinit(); /** Set owner of the lord */ virtual void setOwner( GenericPlayer * player ) { _player = player; } /** Get owner of the lord */ GenericPlayer * getOwner() { return _player; } /** Get name of the lord */ QString getName(); /** Get category name of the lord */ QString getCategoryName(); /** get type of lord */ int getRace(); /** Set the lord cell*/ virtual void setCell( GenericCell * cell ); /** Get cell where is the lord */ GenericCell * getCell() { return _currentCell; } /** Set lord sleeping (or not) */ void setSleeping( bool st ) { _sleeping = st; } /** Tell if lord is sleeping */ bool isSleeping() { return _sleeping; } /** Tell if lord is active */ bool isActive() { return true; } /** Set (or not) a technical book */ void setBook( bool st ) { _hasBook = st; } /** Tell if the lord has a technical book */ bool isBook() { return _hasBook; } /** Set unit 'num' */ void setUnit( int num, GenericFightUnit * troop ) { _units[num] = troop; } /** Return the unit 'num' */ GenericFightUnit * getUnit( int num ) { return _units[num]; } void clearUnits(); int countUnits(); bool addCreatures( Creature * creature, int number ); void updateUnit( uchar pos ,uchar race, uchar level, int nb, uchar move, int health); ArtefactManager * getArtefactManager() { return _artefactManager; } /** Compute end of turn */ void endTurn(); /** Collect ressource 'num' */ int collectRessource( int ) { return 0; } int getCharac( LordCharac type ); int getBaseCharac( LordCharac type ); void setBaseCharac( LordCharac type, int value ); void increaseBaseCharac( LordCharac type, int value ); void decreaseBaseCharac( LordCharac type, int value ); void removeFromGame(); uint getCost( uint res ); void setCost( uint res, uint cost ); bool isCreatureLord() { return _isCreatureLord; } void setCreatureLord( bool iscreat ) { _isCreatureLord = iscreat; } void getOut(); virtual void setVisible( bool state ); bool isVisible() { return _visible; } /** Set the destination of the lord */ void setDestination( GenericCell * cell ) { _dest = cell; } /** Get the destination of the lord */ GenericCell * getDestination() { return _dest; } /** Adds a new war machine */ void addMachine( int id ); /** \return Returns the number of machines owned */ uint getMachineNumber(); /** \return Return the id of the num-th machine */ uint getMachine( uint num ); /** Removes the num-th machine */ void removeMachine( uint num ); /** Tells if this machine is owned */ bool hasMachine( int id ); /** Tells if this machine type is owned */ bool hasMachineType( int type ); uint computeForceIndicator(bool real); uint computeCreatureMaxManaged(); void printLordData(); QString getLordDescription(); static const uchar MAX_LORDS=255; protected: int _id; GenericFightUnit * _units[ MAX_UNIT ]; ArtefactManager * _artefactManager; Specialty _special; TechnicalBook _book; Skill _skills[ MAX_SKILL ]; GenericPlayer * _player; GenericCell * _currentCell; GenericCell * _dest; bool _hasBook; int _move, _maxMove; int _technicPoints, _maxTechnicPoints; int _morale, _luck; int _experience; int _power, _knowledge; int _attack, _defense; int _vision, _charisma; int _level; bool _isCreatureLord; bool _visible; bool _sleeping; GenericLordModel * _model; uint _cost[MAX_RESS]; QList _machines; int _priorities[PR_LAST+1]; }; /** Model of genericLord */ class GenericLordModel { public: GenericLordModel(); ~GenericLordModel(); /** Set name of the lord */ void setName( const QString & name ) { _name = name; } /** Get name of the lord */ QString getName() { return _name; } void setCategory( LordCategoryModel * category ) { _category = category; } LordCategoryModel * getCategory() { return _category; } /** get race of lord */ uint getRace(); /** Set (or not) a technical book */ void setBook( bool st ) { _hasBook = st; } /** Tell if the lord has a technical book */ bool isBook() { return _hasBook; } /** Set unit 'num' */ void setUnit( int num, GenericFightUnit * troop ) { _units[num] = troop; } /** Return the unit 'num' */ GenericFightUnit * getUnit( int num ) { return _units[num]; } int countUnits(); /** Changes value of the charac 'type' */ void setBaseCharac( LordCharac type, int value ); int getBaseCharac( LordCharac type ); /** Adds a new war machine */ void addMachine( int id ); QString getLordDescription(); /** \return Returns the number of machines owned */ uint getMachineNumber(); /** \return Return the id of the num-th machine */ uint getMachine( uint num ); uint getCost( uint res ); void setCost( uint res, uint cost ); /** Removes the num-th machine */ void removeMachine( uint num ); void save( QTextStream & ts, int indent ); private: QString _name; LordCategoryModel * _category; Specialty _special; GenericFightUnit * _units[ MAX_UNIT ]; Skill _skills[ MAX_SKILL ]; bool _hasBook; int _move, _maxMove; int _technicPoints, _maxTechnicPoints; int _morale, _luck; int _experience; int _power, _knowledge; int _attack, _defense; int _knowledgePoints; int _vision, _charisma; int _level; uint _cost[ MAX_RESS ]; QList _machines; }; /** List of GenericLordModel */ class LordList : public QList { public: /** Constructor */ LordList(); /** Destructor */ virtual ~LordList(); /** Return lord in the list */ GenericLordModel * at( int num ) { return QList::at( num ); } /** Init list */ bool init(); /** Save on file */ bool save(); void clear(); }; /** Parser for LordList */ class LordHandler : public QXmlDefaultHandler { public: /** this is the construtor */ LordHandler( LordList * list ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: QString _errorProt, _name; LordList * _list; GenericLordModel * _lord; GenericFightUnit * _unit; LordCharac _charac; int _resource; int _level, _race; int _type; int _numUnit, _numLord; enum State { StateInit, StateDocument, StateLord, StateName, StateCharac, StateCost, StateUnit, StateUnitRace, StateUnitLevel, StateMachine, StateNumber }; State _state; }; #endif // GENERICLORD_H attal-src-1.0-rc2/libCommon/genericMap.cpp0000644000175000017500000003647110766751063016177 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericMap.cpp ** gereric class for managing (not graphical) map ** ** Version : $Id: genericMap.cpp,v 1.32 2008/03/15 13:42:11 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier - Sardi Carlo ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericMap.h" // generic include files #undef __USE_ISOC99 #include // include files for QT #include #include #include // application specific include files #include "libCommon/genericBase.h" #include "libCommon/genericBuilding.h" #include "libCommon/genericDecoration.h" #include "libCommon/log.h" #include "libCommon/pathFinder.h" #include "libCommon/dataTheme.h" /** gereric class for managing (not graphical) cells */ GenericMap::GenericMap() : _height( 0 ), _width( 0 ), _theCells( 0 ) { _path = new PathFinder(); } GenericMap::~GenericMap() { clear(); } void GenericMap::clear() { if( _theCells != 0 ) { for( uint i = 0; i < _height; i++ ) { for( uint j = 0; j < _width; j++ ) { delete _theCells[i][j]; } delete [] _theCells[i]; } delete [] _theCells; } _theCells = 0; _width = 0; _height = 0; if(_path) { delete _path; _path = 0; } } void GenericMap::newUnknownMap( int h, int w ) { newMapType( h, w, 0 ); } void GenericMap::newMapType( int h, int w, int typ ) { clear(); _height = h; _width = w; _theCells = new GenericCell **[_height]; uint i; for( i = 0; i < _height; i++ ) { _theCells[i] = new GenericCell *[_width]; } for( i = 0; i < _height; i++ ) { for( uint j = 0; j < _width; j++ ) { /// XXX: can be improved (smarter code) GenericCell * tempo; tempo = new GenericCell( i, j ); tempo->setType( typ ); _theCells[i][j] = tempo; } } if(!_path) { _path = new PathFinder(); } _path->newMap( _height, _width, this ); } void GenericMap::changeCell( int i, int j, int typ, int transition, int typtra, uint decorationGroup, uint decorationItem, uchar /* diversification */ ) { //logDD("chg cell %d %d %d %d %d %d", i, j, // typ, transition, typtra, decorationGroup ); if( _theCells[i][j]->getType() == 0 ) { _theCells[i][j]->setType( typ ); _theCells[i][j]->setTransition( transition ); _theCells[i][j]->setTransitionCellType( typtra ); _theCells[i][j]->setDecoration( decorationGroup, decorationItem ); if( decorationGroup && _theCells[i][j]->getCoeff()==-1) { GenericDecoration * deco = DataTheme.decorations.at( decorationGroup)->at(decorationItem) ; computeStoppable( deco, _theCells[i][j] ); } } else { logEE( "Cell type should be unknown" ); } } bool GenericMap::load( const QString filename ) { QFile f( filename ); if (! f.open(QIODevice::ReadOnly) ) { logEE("Could not open file %s for reading\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &f ); int w, h; ts >> w; ts >> h; bool ret = load( &ts, w, h ); f.close(); return ret; } bool GenericMap::load( QTextStream * ts, int width, int heigth ) { _width = width; _height = heigth; uint i, j; _theCells = new GenericCell **[_height]; for( i = 0; i < _height; i++ ) { _theCells[i] = new GenericCell *[_width]; } int val; uint item; // Loading base cell for( i = 0; i < _height; i++ ) { for( j = 0; j < _width; j++ ) { if( ! ts->atEnd() ) { _theCells[i][j] = new GenericCell( i, j ); *ts >> val; _theCells[i][j]->setType( val ); } else { logEE("Stream too short"); return false; } } } // Loading diversification cell for( i = 0; i < _height; i++ ) { for( j = 0; j < _width; j++ ) { if( ! ts->atEnd() ) { *ts >> val; _theCells[i][j]->setDiversification( val ); } else { logEE("Stream too short"); return false; } } } // Loading transition type for( i = 0; i < _height; i++ ) { for( j = 0; j < _width; j++ ) { if( ! ts->atEnd() ) { *ts >> val; _theCells[i][j]->setTransition( val ); } else { logEE("Stream too short"); return false; } } } // Loading transition cell for( i = 0; i < _height; i++ ) { for( j = 0; j < _width; j++ ) { if( ! ts->atEnd() ) { *ts >> val; _theCells[i][j]->setTransitionCellType( val ); } else { logEE("Stream too short"); return false; } } } // Loading decoration of the ground for( i = 0; i < _height; i++ ) { for( j = 0; j < _width; j++ ) { if( ! ts->atEnd() ) { *ts >> val; if( val ) { *ts >> item; _theCells[i][j]->setDecoration( val, item ); } } else { logEE("Stream too short"); return false; } } } if( _path ) { delete _path; } _path = new PathFinder( _width, _height, this ); return true; } void GenericMap::save( QTextStream * ts ) { uint i, j; *ts << "\t" << endl; *ts << "\t\t" << _width << "" << endl; *ts << "\t\t" << _height << "" << endl; for( i = 0; i < _height; i++ ) { *ts << "\t\t"; for( j = 0; j < _width; j++ ) { *ts << (int)_theCells[i][j]->getType() << " "; } *ts << endl; } *ts << flush; *ts << endl; for( i = 0; i < _height; i++ ) { *ts << "\t\t"; for( j = 0; j < _width; j++ ) { *ts << (int)_theCells[i][j]->getDiversification() << " "; } *ts << endl; } *ts << flush; *ts << endl; for( i = 0; i < _height; i++ ) { *ts << "\t\t"; for( j = 0; j < _width; j++ ) { *ts << (int)_theCells[i][j]->getTransition() << " "; } *ts << endl; } *ts << flush; *ts << endl; for( i = 0; i < _height; i++ ) { *ts << "\t\t"; for( j = 0; j < _width; j++ ) { *ts << (int)_theCells[i][j]->getTransitionCellType() << " "; } *ts << endl; } *ts << flush; *ts << endl; for( i = 0; i < _height; i++ ) { *ts << "\t\t"; for( j = 0; j < _width; j++ ) { *ts << (int)_theCells[i][j]->getDecorationGroup() << " "; if( (int)_theCells[i][j]->getDecorationGroup() ) { *ts << (int)_theCells[i][j]->getDecorationItem() << " "; } } *ts << endl; } *ts << flush; *ts << "\t" << endl; *ts << flush; } void GenericMap::computeStoppable() { for( uint i = 0; i < _height; i++ ) { for( uint j = 0; j < _width; j++ ) { _theCells[i][j]->setStoppable( true ); if( _theCells[i][j]->getDecorationGroup() && _theCells[i][j]->getCoeff()==-1) { GenericDecoration * deco = DataTheme.decorations.at( _theCells[i][j]->getDecorationGroup())->at(_theCells[i][j]->getDecorationItem()) ; computeStoppable( deco, _theCells[i][j] ); } if( _theCells[i][j]->getBase() ) { computeStoppable( _theCells[i][j]->getBase() ); } if( _theCells[i][j]->getBuilding() ) { computeStoppable( _theCells[i][j]->getBuilding() ); } } } } void GenericMap::computeStoppable( GenericBase * base ) { if( base->getCell() ) { GenericBaseModel * baseModel = DataTheme.bases.at( base->getRace() ); int col = base->getCell()->getCol() - base->getDoorCol(); int row = base->getCell()->getRow() - base->getDoorRow(); for( uint i = 0; i < baseModel->getHeight(); i++ ) { for( uint j = 0; j < baseModel->getWidth(); j++ ) { if( base->getDisposition( i, j ) == GenericMapDisposition::OCCUPIED ) { if( ( int( row + i ) >= 0 ) && ( int( col + j ) >= 0 ) && ( ( row + i ) < _height ) && ( ( col + j ) < _width ) ) { //logDD("stop %d %d", row+i, col+j ); _theCells[row+i][col+j]->setStoppable( false ); } } } } } } void GenericMap::computeStoppable( GenericDecoration * deco , GenericCell * cell ) { int col = cell->getCol() - deco->getDoorCol(); int row = cell->getRow() - deco->getDoorRow(); for( uint i = 0; i < deco->getHeight(); i++ ) { for( uint j = 0; j < deco->getWidth(); j++ ) { if(deco->getDisposition( i, j )){ if( deco->getDisposition( i, j ) == GenericMapDisposition::OCCUPIED || deco->getDisposition( i, j ) == GenericMapDisposition::DOOR) { if( ( int( row + i ) >= 0 ) && ( int( col + j ) >= 0 ) && ( ( row + i ) < _height ) && ( ( col + j ) < _width ) ) { //logDD("stop %d %d", row+i, col+j ); _theCells[row+i][col+j]->setStoppable( false ); } } } } } } void GenericMap::computeStoppable( GenericBuilding * building ) { if( building->getCell() ) { GenericBuildingModel * buildingModel = DataTheme.buildings.at( building->getType() ); int col = building->getCell()->getCol() - building->getDoorCol(); int row = building->getCell()->getRow() - building->getDoorRow(); for( uint i = 0; i < buildingModel->getHeight(); i++ ) { for( uint j = 0; j < buildingModel->getWidth(); j++ ) { if( building->getDisposition( i, j ) == GenericMapDisposition::OCCUPIED ) { if( ( int( row + i ) >= 0 ) && ( int( col + j ) >= 0 ) && ( ( row + i ) < _height ) && ( ( col + j ) < _width ) ) { //logDD("stop %d %d", row+i, col+j ); _theCells[row+i][col+j]->setStoppable( false ); } } } } } } bool GenericMap::isPlaceBaseFree( int race , GenericCell * cell) { if( cell ) { GenericBaseModel * baseModel = DataTheme.bases.at( race ); int col = cell->getCol() - baseModel->getDoorCol(); int row = cell->getRow() - baseModel->getDoorRow(); for( uint i = 0; i < baseModel->getHeight(); i++ ) { for( uint j = 0; j < baseModel->getWidth(); j++ ) { if( baseModel->getDisposition( i, j ) == GenericMapDisposition::OCCUPIED ) { if( ( int( row + i ) >= 0 ) && ( int( col + j ) >= 0 ) && ( ( row + i ) < _height ) && ( ( col + j ) < _width ) ) { //logDD("stop %d %d", row+i, col+j ); if(!_theCells[row+i][col+j]->isStoppable()) return false; } } } } } return true; } bool GenericMap::isPlaceDecoFree( GenericDecoration * deco , GenericCell * cell ) { int col = cell->getCol() - deco->getDoorCol(); int row = cell->getRow() - deco->getDoorRow(); for( uint i = 0; i < deco->getHeight(); i++ ) { for( uint j = 0; j < deco->getWidth(); j++ ) { if(deco->getDisposition( i, j )){ if( deco->getDisposition( i, j ) == GenericMapDisposition::OCCUPIED || deco->getDisposition( i, j ) == GenericMapDisposition::DOOR) { if( ( int( row + i ) >= 0 ) && ( int( col + j ) >= 0 ) && ( ( row + i ) < _height ) && ( ( col + j ) < _width ) ) { //logDD("stop %d %d", row+i, col+j ); if(!_theCells[row+i][col+j]->isStoppable()) return false; } } } } } return true; } bool GenericMap::isPlaceBuilFree( int type , GenericCell * cell) { if( cell ) { GenericBuildingModel * buildingModel = DataTheme.buildings.at( type ); int col = cell->getCol() - buildingModel->getDoorCol(); int row = cell->getRow() - buildingModel->getDoorRow(); for( uint i = 0; i < buildingModel->getHeight(); i++ ) { for( uint j = 0; j < buildingModel->getWidth(); j++ ) { if( buildingModel->getDisposition( i, j ) == GenericMapDisposition::OCCUPIED ) { if( ( int( row + i ) >= 0 ) && ( int( col + j ) >= 0 ) && ( ( row + i ) < _height ) && ( ( col + j ) < _width ) ) { if(!_theCells[row+i][col+j]->isStoppable()){ return false; } } } } } } return true; } bool GenericMap::inMap( uint row, uint col ) { if( row < _height && col < _width ) { return true; } else { //logEE("Point not in map row %d , col %d , height %d, width %d", row, col , _height, _width); return false; } } int GenericMap::computeMinimalNextCost( GenericLord * lord ) { int ret = 0; int cost = 0; GenericCell * cell = lord->getCell(); uint row = cell->getRow(); uint col = cell->getCol(); if( ( row > 0 ) && ( col > 0 ) ) { cost = PathFinder::computeCostMvt( cell, at( row - 1, col - 1 ) ); } if( ( ret == 0 ) || ( ( cost > 0 ) && cost < ret ) ) { ret = cost; } if( row > 0 ) { cost = PathFinder::computeCostMvt( cell, at( row - 1, col ) ); } if( ( ret == 0 ) || ( ( cost > 0 ) && cost < ret ) ) { ret = cost; } if( ( row > 0 ) && ( col < _width - 1 ) ) { cost = PathFinder::computeCostMvt( cell, at( row - 1, col + 1 ) ); } if( ( ret == 0 ) || ( ( cost > 0 ) && cost < ret ) ) { ret = cost; } if( col > 0 ) { cost = PathFinder::computeCostMvt( cell, at( row, col - 1 ) ); } if( ( ret == 0 ) || ( ( cost > 0 ) && cost < ret ) ) { ret = cost; } if( col < _width - 1 ) { cost = PathFinder::computeCostMvt( cell, at( row, col + 1 ) ); } if( ( ret == 0 ) || ( ( cost > 0 ) && cost < ret ) ) { ret = cost; } if( ( row < _height - 1 ) && ( col > 0 ) ) { cost = PathFinder::computeCostMvt( cell, at( row + 1, col - 1 ) ); } if( ( ret == 0 ) || ( ( cost > 0 ) && cost < ret ) ) { ret = cost; } if( row < _height - 1 ) { cost = PathFinder::computeCostMvt( cell, at( row + 1, col ) ); } if( ( ret == 0 ) || ( ( cost > 0 ) && cost < ret ) ) { ret = cost; } if( ( row < _height - 1 ) && ( col < _width - 1 ) ) { cost = PathFinder::computeCostMvt( cell, at( row + 1, col + 1 ) ); } if( ( ret == 0 ) || ( ( cost > 0 ) && cost < ret ) ) { ret = cost; } return ret; } void GenericMap::clearData() { uint i,j; for( i = 0; i < (uint) _height; i++ ) { for( j = 0; j < (uint) _width; j++ ) { if( _theCells[i][j]->getLord() ) { _theCells[i][j]->setLord( 0 ); } if( _theCells[i][j]->getBuilding() ) { _theCells[i][j]->setBuilding( 0 ); } if( _theCells[i][j]->getBase() ) { _theCells[i][j]->setBase( 0 ); } if( _theCells[i][j]->getCreature() ) { _theCells[i][j]->setCreature( 0 ); } if( _theCells[i][j]->getTransition() ) { _theCells[i][j]->setTransition( 0 ); _theCells[i][j]->setTransitionCellType( 0 ); } if( _theCells[i][j]->getType() ) { _theCells[i][j]->setType( 0 ); } if( _theCells[i][j]->getCoeff() ) { _theCells[i][j]->setCoeff( 0 ); } if( _theCells[i][j]->getDecorationGroup() ) { _theCells[i][j]->setDecoration( 0, 0 ); } if( _theCells[i][j]->getEvent() ) { _theCells[i][j]->setEvent( 0 ); } } } } QList GenericMap::giveRadiusCell( GenericCell * cell, int radius ) { QList list; int row= cell->getRow(); int col= cell->getCol(); uint i,j; uint initRow; uint initCol; uint endRow; uint endCol; initRow = std::max( row-radius , 0 ); initCol = std::max( col-radius , 0 ); endRow = std::min( row+radius, (int)( _height -1) ); endCol = std::min( col+radius, (int)( _width -1)); for( i = initRow; i <= endRow; i++){ for( j = initCol; j <= endCol; j++ ) { if( computeDist( row, col, i, j ) <= radius ) { list.append( at( i, j ) ); } } } return list; } int GenericMap::computeDist( GenericCell * cell1, GenericCell * cell2 ) { int ret = 0; int row1 = cell1->getRow(); int col1 = cell1->getCol(); int row2 = cell2->getRow(); int col2 = cell2->getCol(); ret = computeDist( row1, col1 , row2, col2 ); return ret; } int GenericMap::computeDist( int row1, int col1 , int row2, int col2 ) { return int( sqrt( ( (col1-col2)*(col1-col2) ) + ( (row1-row2)*(row1-row2) ) ) ); } attal-src-1.0-rc2/libCommon/genericMap.h0000644000175000017500000000662710760634227015640 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericMap.h ** generic class for managing (not graphical) map ** ** Version : $Id: genericMap.h,v 1.16 2008/02/25 21:52:23 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICMAP_H #define GENERICMAP_H // generic include files // include files for QT #include // application specific includes #include "libCommon/genericCell.h" #include "libCommon/log.h" class QString; class QTextStream; class PathFinder; class GenericBase; class GenericLord; class GenericDecoration; /* ------------------------------ * GenericMap * ------------------------------ */ /** generic class for managing (not graphical) cells */ class GenericMap { public: /** Constructor */ GenericMap(); /** Destructor */ virtual ~GenericMap(); /** Return heigth of the map */ uint getHeight() { return _height; } /** Return width of the map */ uint getWidth() { return _width; } /** Return cell of the map */ GenericCell * at( uint i, uint j ) { return _theCells[i][j]; } /** */ virtual void newUnknownMap( int h, int w ); virtual void newMapType( int h, int w, int typ ); /** Return the path finder */ PathFinder * getPath() { return _path; } /** Load a map file */ virtual bool load( QTextStream *, int width, int heigth ); /** Load a map */ virtual bool load( const QString filename ); virtual void changeCell( int i, int j, int typ, int transition, int typtra, uint decorationGroup, uint decorationItem, uchar diversification ); /** Save a map */ void save( QTextStream * ); /** Clear map */ virtual void clear(); virtual void clearData(); /** Compute the tiles where we can't stop because of this base */ void computeStoppable( GenericBase * base ); /** Compute the tiles where we can't stop because of this building */ void computeStoppable( GenericBuilding * building ); void computeStoppable( GenericDecoration * deco , GenericCell * cell); /** Compute the tiles where we can't stop because there is a base on it */ void computeStoppable(); static int computeDist( GenericCell * cell1, GenericCell * cell2 ); static inline int computeDist( int row1, int col1 , int row2, int col2 ); bool isPlaceBaseFree( int race , GenericCell * cell); bool isPlaceBuilFree( int type , GenericCell * cell); bool isPlaceDecoFree( GenericDecoration * deco , GenericCell * cell); bool inMap( uint row, uint col ); QList giveRadiusCell( GenericCell * cell, int radius ); /** Returns the minimal cost for the next movement of this lord */ int computeMinimalNextCost( GenericLord * lord ); protected: uint _height, _width; GenericCell *** _theCells; PathFinder * _path; }; #endif // GENERICMAP_H attal-src-1.0-rc2/libCommon/genericMapCreature.cpp0000644000175000017500000001612010740430047017643 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericMapCreature.cpp ** Manages creatures on map ** ** Version : $Id: genericMapCreature.cpp,v 1.23 2008/01/07 13:59:03 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 11/09/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericMapCreature.h" // generic include files #include // include files for QT #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/define.h" GenericMapCreature::GenericMapCreature() { _ress = new GenericResourceList(); _creature = NULL; _categoryNumber = 1; _stacks.resize( MAX_UNIT ); for( uint i = 0; i < MAX_UNIT; i++ ) { if(_stacks[i]) { delete _stacks[i]; } _stacks[i] = new uint( 0 ) ; } _estimated = true; _behaviour = Neutral; _growth = Stable; _growthParam0 = 0; _growthParam1 = 0; _flee = false; _lookingRight = false; } GenericMapCreature::~GenericMapCreature() { for (int i = 0; i < _stacks.size(); ++i) { uint * ptr = _stacks.at(i); _stacks[i] = 0; delete ptr; } delete _ress; } void GenericMapCreature::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; if( _cell ) { indentation( ts, indent+1 ); *ts << "" << _cell->getRow() << "" << endl; indentation( ts, indent+1 ); *ts << "" << _cell->getCol() << "" << endl; } if( _creature ) { indentation( ts, indent+1 ); *ts << "" << _creature->getRace() << "" << endl; indentation( ts, indent+1 ); *ts << "" << _creature->getLevel() << "" << endl; } for( uint i = 0; i < MAX_UNIT; i++ ) { if( getStack(i) > 0 ) { indentation( ts, indent+1 ); *ts << "" << getStack(i) << "" << endl; } } indentation( ts, indent+1 ); *ts << "" << (int)_behaviour << "" << endl; indentation( ts, indent+1 ); *ts << "" << (int)_flee << "" << endl; indentation( ts, indent+1 ); *ts << "" << (int)_lookingRight << "" << endl; indentation( ts, indent+1 ); *ts << "" << endl; if( _growth == FixedPercentage ) { indentation( ts, indent + 2 ); *ts << "" << _growthParam0 << "" << endl; } else if( _growth == VariablePercentage ) { indentation( ts, indent + 2 ); *ts << "" << _growthParam0 << "" << endl; indentation( ts, indent + 2 ); *ts << "" << _growthParam1 << "" << endl; } indentation( ts, indent+1 ); *ts << "" << endl; for( int j = 0; j < DataTheme.resources.count(); j++ ) { indentation( ts, indent ); (*ts) << "\t"; (*ts) << _ress->getValue( j ); (*ts) << "" << endl; } indentation( ts, indent ); *ts << "" << endl; } void GenericMapCreature::setCreature( int race, int level ) { _creature = DataTheme.creatures.at( race, level ); } int GenericMapCreature::getRace() { int ret = 0; if( _creature ) { ret = _creature->getRace(); } return ret; } int GenericMapCreature::getLevel() { int ret = 0; if( _creature ) { ret = _creature->getLevel(); } return ret; } /* unsigned int GenericMapCreature::getMinEstimatedNumber() { uint ret = 0; if( _estimated ) { ret = } else { ret = getCreatureNumber(); } return ret; } unsigned int GenericMapCreature::getMaxEstimatedNumber() { uint ret = 0; if( _estimated ) { ret = } else { ret = getCreatureNumber(); } return ret; } */ unsigned int GenericMapCreature::getCategoryNumber() { uint ret = 0; if( _estimated ) { ret = _categoryNumber; } else { ret = (uchar)DataTheme.computeCategory( getCreatureNumber() ); } return ret; } unsigned int GenericMapCreature::getCreatureNumber() { unsigned int ret = 0; if( ! _estimated ) { for( unsigned int i = 0; i < MAX_UNIT; i++ ) { ret += * ( _stacks.at( i ) ); } } return ret; } void GenericMapCreature::setStack( unsigned int numStack, unsigned int number ) { _estimated = false; //_stacks.append( new unsigned int( number ) ); if( (uint)numStack < MAX_UNIT ) { * _stacks[ numStack ] = number; } } unsigned int GenericMapCreature::getStack( unsigned int num ) { unsigned int ret = 0; if( (uint)num < MAX_UNIT ) { ret = * ( _stacks[ num ] ); } return ret; } QString GenericMapCreature::getBehaviourString() { return getBehaviourString( _behaviour ); } QString GenericMapCreature::getBehaviourString( CreatureBehaviour behaviour ) { QString ret = ""; switch( behaviour ) { case Obedient: ret = QObject::tr( "Obedient" ); break; case Friendly: ret = QObject::tr( "Friendly" ); break; case Neutral: ret = QObject::tr( "Neutral" ); break; case Aggressive: ret = QObject::tr( "Aggressive" ); break; case Hostile: ret = QObject::tr( "Hostile" ); break; } return ret; } QString GenericMapCreature::getGrowthString( GrowthMode growth ) { QString ret = ""; switch( growth ) { case Stable: ret = QObject::tr( "Stable" ); break; case FixedPercentage: ret = QObject::tr( "Percentage fixed" ); break; case VariablePercentage: ret = QObject::tr( "Percentage variable" ); break; } return ret; } uint GenericMapCreature::computeForceIndicator( bool real ) { uint ret = 0; if( _creature ) { TRACE("Force Indicator health %d, number %d", _creature->getAttack() , getCreatureNumber()); if( real ) { ret = _creature->getMaxHealth() * getCreatureNumber(); } else { uint estimatedNb = DataTheme.getRandomInCategory( getCategoryNumber() ); ret = _creature->getMaxHealth() * estimatedNb; } } return ret; } void GenericMapCreature::setGrowthParam( uint param, uint value ) { if( param == 0 ) { _growthParam0 = value; } else if( param == 1 ) { _growthParam1 = value; } } uint GenericMapCreature::getGrowthParam( uint param ) { uint ret = 0; if( param == 0 ) { ret = _growthParam0; } else if( param == 1 ) { ret = _growthParam1; } return ret; } void GenericMapCreature::grow() { uint value, percent; switch( _growth ) { case Stable: break; case FixedPercentage: for( uint i = 0; i < MAX_UNIT; i++ ) { value = getStack( i ); value = (int)( ( value * (100 + _growthParam0) ) / 100 ); setStack( i, value ); } break; case VariablePercentage: for( uint i = 0; i < MAX_UNIT; i++ ) { percent = _growthParam0 + ( rand() % (_growthParam1 + 1 - _growthParam0) ); value = getStack( i ); value = (int)( ( value * (100 + percent) ) / 100 ); setStack( i, value ); } break; } } attal-src-1.0-rc2/libCommon/genericMapCreature.h0000644000175000017500000001001210734030415017300 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericMapCreature.h ** Manages creatures on map ** ** Version : $Id: genericMapCreature.h,v 1.20 2007/12/24 22:22:05 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 11/09/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICMAPCREATURE_H #define GENERICMAPCREATURE_H // generic include files // include files for QT #include #include // application specific include files #include "libCommon/define.h" #include "libCommon/creature.h" #include "libCommon/log.h" #include "libCommon/genericRessources.h" class GenericCell; /** ------------------------------ * GenericMapCreature ** ------------------------------ */ class GenericMapCreature { public: /** Creature's behavior */ enum CreatureBehaviour { Obedient = 0, Friendly, Neutral, Aggressive, Hostile }; /** Creature growth mode */ enum GrowthMode { Stable, FixedPercentage, VariablePercentage }; /** Constructor */ GenericMapCreature(); virtual ~GenericMapCreature(); /** Save lord */ void save( QTextStream *, int indent = 0 ); /** \return Return the creature associated to this creature on map */ Creature * getCreature() { return _creature; } /** Sets the creature associated to this creature on map */ void setCreature( int race, int level ); /** \return Returns the race of the creature associated */ int getRace(); /** \return Returns the level of the creature associated */ int getLevel(); void setBehaviour ( CreatureBehaviour behaviour ) { _behaviour = behaviour; } CreatureBehaviour getBehaviour () { return _behaviour; } QString getBehaviourString(); static QString getBehaviourString( CreatureBehaviour behaviour ); static QString getGrowthString( GrowthMode growth ); bool isFleeing() { return _flee; } void setFleeing( bool state ) { _flee = state; } bool isEstimated() { return _estimated; } //unsigned int getMinEstimatedNumber(); //unsigned int getMaxEstimatedNumber(); /** \return Returns the category of size of this unit */ unsigned int getCategoryNumber(); unsigned int getCreatureNumber(); void setCategoryNumber( unsigned int nb ) { _categoryNumber = nb; } /** Set the value of the 'numStack' stack of creatures */ void setStack( uint numStack, uint value ); /** \return Returns the number of creature in the stack 'num' */ uint getStack( unsigned int num ); /** \return Returns the cell of the map where this creature is */ GenericCell * getCell() const { return _cell; } /** Sets the cell where this creature is */ virtual void setCell( GenericCell * cell ) { _cell = cell; } uint computeForceIndicator( bool real ); bool isLookingRight() { return _lookingRight; } virtual void setLookingRight( bool state ) { _lookingRight = state; } void setGrowthMode( GrowthMode growth ) { _growth = growth; } GrowthMode getGrowthMode() { return _growth; } void setGrowthParam( uint param, uint value ); uint getGrowthParam( uint param ); void grow(); GenericResourceList * getResourceList() { return _ress; } protected: QVector _stacks; Creature * _creature; GenericCell * _cell; unsigned int _categoryNumber; CreatureBehaviour _behaviour; GrowthMode _growth; uint _growthParam0, _growthParam1; bool _flee; bool _lookingRight; bool _estimated; GenericResourceList * _ress; }; #endif // GENERICMAPCREATURE_H attal-src-1.0-rc2/libCommon/genericMapDisposition.cpp0000644000175000017500000000700010331243511020364 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericMapDisposition.cpp ** Manage disposition on the map of the building, base... ** ** Version : $Id: genericMapDisposition.cpp,v 1.6 2005/10/30 22:20:57 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericMapDisposition.h" // generic include files #include // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" GenericMapDisposition::GenericMapDisposition() : _dispo( 0 ), _doorRow( 0 ), _doorCol( 0 ), _height( 1 ), _width( 1 ) { _dispo = new DispositionType * [1]; _dispo[0] = new DispositionType[1]; _dispo[0][0] = FREE; } GenericMapDisposition::~GenericMapDisposition() { clear(); } void GenericMapDisposition::clear() { if( _dispo ) { for( uint i = 0; i < _height; i++ ) { delete [] _dispo[i]; } delete [] _dispo; } _dispo = 0; } void GenericMapDisposition::init( uint height, uint width ) { uint i, j; clear(); _dispo = new DispositionType * [ height ]; for( i = 0; i < height; i++ ) { _dispo[i] = new DispositionType[ width ]; for( j = 0; j < width; j++ ){ _dispo[i][j] = FREE; } } _height = height; _width = width; } void GenericMapDisposition::resize( uint newHeight, uint newWidth ) { uint i, j; uint oldHeight = _height; uint oldWidth = _width; DispositionType ** dispo; dispo = new DispositionType * [ _height ]; for( i = 0; i < _height; i++ ) { dispo[i] = new DispositionType[ _width ]; for( j = 0; j < _width; j++ ){ dispo[i][j] = _dispo[i][j]; } } if( _dispo ) { for( i = 0; i < _height; i++ ) { delete [] _dispo[i]; } delete [] _dispo; } _height = newHeight; _width = newWidth; _dispo = new DispositionType * [ _height ]; for( i = 0; i < _height; i++ ) { _dispo[i] = new DispositionType[ _width ]; for( j = 0; j < _width; j++ ){ _dispo[i][j] = FREE; } } for( i = 0; i < std::min( newHeight, oldHeight ); i++ ) { for( j = 0; j < std::min( newWidth, oldWidth ); j++ ) { _dispo[ newHeight - i - 1 ][ j ] = dispo[ oldHeight - i - 1 ][ j ]; } } for( i = 0; i < oldHeight; i++ ) { delete [] dispo[ i ]; } delete [] dispo; } bool GenericMapDisposition::save( QTextStream * ts, uint indent ) { uint i, j; indentation( ts, indent ); *ts << "" << endl; for( i = 0; i < _height; i++ ) { indentation( ts, indent + 1 ); for( j = 0; j < _width; j++ ) { *ts << (int)_dispo[i][j]; if( j != ( _width - 1 ) ) { *ts << " "; } } *ts << endl; } indentation( ts, indent ); *ts << "" << endl; return true; } void GenericMapDisposition::setDisposition( uint row, uint col, DispositionType disposition ) { if( ( row >= _height ) || ( col >= _width ) ) { return; } _dispo[row][col] = disposition; if( disposition == DOOR ) { _doorCol = col; _doorRow = row; } } attal-src-1.0-rc2/libCommon/genericMapDisposition.h0000644000175000017500000000444110522705152020045 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericMapDisposition.h ** Manage disposition on the map of the building, base... ** ** Version : $Id: genericMapDisposition.h,v 1.5 2006/11/03 18:28:58 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICMAPDISPOSITION_H #define GENERICMAPDISPOSITION_H // generic include files // include files for QT #include #include // application specific include files class QTextStream; /* ------------------------------ * GenericMapDisposition * ------------------------------ */ class GenericMapDisposition { public: enum DispositionType { FREE = 0, OCCUPIED, DOOR }; /** Constructor */ GenericMapDisposition(); /** Destructor */ virtual ~GenericMapDisposition(); /** clear the disposition */ void clear(); /** Init the disposition area */ void init( uint height, uint width ); uint getHeight() { return _height; } uint getWidth() { return _width; } bool save( QTextStream * ts, uint indent ); /** \return Returns the disposition info of case (row, col) */ DispositionType getDisposition( uint row, uint col ) { return _dispo[row][col]; } /** Sets the disposition of the case (row, col) */ void setDisposition( uint row, uint col, DispositionType disposition ); /** \return Returns the row of the door */ uint getDoorRow() { return _doorRow; } /** \return Returns the col of the door */ uint getDoorCol() { return _doorCol; } void resize( uint newHeight, uint newWidth ); private: DispositionType ** _dispo; uint _doorRow, _doorCol; uint _height, _width; }; #endif // GENERICMAPDISPOSITION_H attal-src-1.0-rc2/libCommon/genericPlayer.cpp0000644000175000017500000003326010766751063016707 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericPlayer.cpp ** manage a player ** ** Version : $Id: genericPlayer.cpp,v 1.50 2008/03/15 13:42:11 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 08/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericPlayer.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/generalOptions.h" #include "libCommon/genericMap.h" #include "libCommon/log.h" #include "libCommon/pathFinder.h" #include "libCommon/priceMarket.h" // // ----- GenericPlayer ----- // GenericPlayer::GenericPlayer( GenericMap * theMap ) : _num( 0 ), _alive( true ), _isRuledByAi( false ), _selectedLord( NULL), _selectedBase( NULL) { _ress = new GenericResourceList(); _teamId = 0; _map = theMap; _vision = 0; _theight = 0; _totalPop = 0; _price = new PriceMarket(); _isTeamSet = false; setName( QString( "New player" ) ); setConnectionName( QString( "New player" ) ); } GenericPlayer& GenericPlayer::operator = (GenericPlayer& other) { for( int i = 0; i < DataTheme.resources.count(); i++ ) { _ress->setValue(i, other._ress->getValue(i)); } _num = other._num; _teamId = other._teamId; _name = other._name; _alive = other._alive; _isRuledByAi = other._isRuledByAi; _theLords = other._theLords; _theBase = other._theBase; _theBuild = other._theBuild; _totalPop = other._totalPop; _selectedLord = other._selectedLord; _selectedBase = other._selectedBase; _map = other._map; return *this; } GenericPlayer::~GenericPlayer() { clearVision(); if(_price){ delete _price; } delete _ress; } bool GenericPlayer::loadVision( QTextStream * ts , int width, int height) { int val; int i,j; clearVision(); _theight = height; _vision = new int * [ height ]; for( int i = 0; i < _theight; i++ ) { _vision[i] = new int [ width ]; for( int j = 0; j < width; j++ ) { _vision[i][j] = 0; } } for( i = 0; i < _theight; i++ ) { for( j = 0; j < width; j++ ) { if( ! ts->atEnd() ) { *ts >> val; _vision[i][j] = val; } else { logEE("Stream too short"); for( i = 0; i < _theight; ++i ) { delete [] _vision[i]; } delete [] _vision; _vision = 0; _theight = 0; return false; } } } return true; } void GenericPlayer::save( QTextStream * ts, int indent ) { indentation( ts, indent ); (*ts) << "" << endl; indentation( ts, indent ); (*ts) << "\t" << _isRuledByAi << "" << endl; indentation( ts, indent ); (*ts) << "\t" << getName().toLatin1() << "" << endl; indentation( ts, indent ); (*ts) << "\t" << getTeamId() << "" << endl; if( _vision ) { indentation( ts, indent ); (*ts) << "\t"; (*ts) << endl; uint height = _map->getHeight(); uint width = _map->getWidth(); for( uint i = 0; i < height; i++ ) { (*ts) << "\t\t"; for( uint j = 0; j < width; j++ ) { (*ts) << (int)_vision[i][j] << " "; } (*ts) << endl; } (*ts) << flush; indentation( ts, indent+1 ); (*ts) << "" << endl; } for( uint j = 0; j < numBase(); j++ ) { indentation( ts, indent ); (*ts) << "\t"; (*ts) << getBase( j )->getId(); (*ts) << "" << endl; } for( uint j = 0; j < numBuilding(); j++ ) { indentation( ts, indent ); (*ts) << "\t"; (*ts) << getBuilding( j )->getId(); (*ts) << "" << endl; } for( uint j = 0; j < numLord(); j++ ) { indentation( ts, indent ); (*ts) << "\t"; (*ts) << getLord( j )->getId(); (*ts) << "" << endl; } for( int j = 0; j < DataTheme.resources.count(); j++ ) { indentation( ts, indent ); (*ts) << "\t"; (*ts) << _ress->getValue( j ); (*ts) << "" << endl; } indentation( ts, indent ); (*ts) << "" << endl; *ts << flush; } void GenericPlayer::setNum( int num ) { _num = num; if( ! _isTeamSet ) { _teamId = num; } } void GenericPlayer::newTurn() { uint i; // XXX: do 'lord->newTurn()' ?? for( i = 0; i < numLord(); i++ ) { getLord( i )->setBaseCharac( MOVE, getLord( i )->getCharac( MAXMOVE ) ); } for( i = 0; i < numBase(); i++ ) { _theBase.at( i )->canBuild( true ); _theBase.at( i )->canSell( true ); } } void GenericPlayer::newWeek() { for( uint i = 0; i < numBase(); i++ ) { _theBase.at( i )->initCreatureProduction(); } } void GenericPlayer::addLord( GenericLord * lord ) { if( ! hasLord( lord ) ) { _theLords.append( lord ); } } void GenericPlayer::addBase( GenericBase * base ) { if( ! hasBase( base ) ) { _theBase.append( base ); } } void GenericPlayer::addBuilding( GenericBuilding * b ) { if( ! hasBuilding( b ) ) { _theBuild.append( b ); } } bool GenericPlayer::shouldEnd() { for( uint i = 0; i < numLord(); i++ ) { if( ( ! _theLords.at( i )->isSleeping() ) && canMove( _theLords.at( i ) ) ) return false; } return true; } void GenericPlayer::endTurn() { // Resources, thanks to lords for( uint i = 0; i < numLord(); i++ ) { for( int j = 0; j < DataTheme.resources.count(); j++ ) { _ress->increaseValue( j, _theLords.at( i )->collectRessource( j ) ); } _theLords.at(i)->endTurn(); } // Resources, thanks to base for( uint i = 0; i < numBase(); i++ ) { for( int j = 0; j < DataTheme.resources.count(); j++ ) { _ress->increaseValue( j, _theBase.at( i )->collectRessource( j )); } } // Resources, thanks to mines //for( uint i = 0; i < numBuilding(); i++ ) { //for( int j = 0; j < DataTheme.resources.count(); j++ ) { // _ress[j] += _theBuild.at( i )->collectRessource( j ); //} //} } bool GenericPlayer::selectFirstLord() { for( uint i = 0; i < numLord(); i++ ) { if( _theLords.at( i )->isActive() ) { //_selectedLord = _theLords.at( i ); setSelectedLord( _theLords.at( i ) ); return true; } } return false; } GenericLord * GenericPlayer::nextLord() { if ( _selectedLord == 0 ) { if ( numLord() > 0 ) { _selectedLord = _theLords.at( 0 ); return _theLords.at( 0 ); } else return 0; } else { int num = _theLords.indexOf( _selectedLord ); if ( num >= 0 ) { if ( (uint)num == numLord() - 1 ) { _selectedLord = _theLords.at( 0 ); return _theLords.at( 0 ); } else { _selectedLord = _theLords.at( num+1 ); return _theLords.at( num+1 ); } } else { if ( numLord() > 0 ) { _selectedLord = _theLords.at( 0 ); return _theLords.at( 0 ); } else { return 0; } } } } GenericLord * GenericPlayer::getLordById( int id ) { for( uint i = 0; i < numLord(); i++ ) { if( _theLords.at( i )->getId() == id ) { return _theLords.at( i ); } } return 0; } void GenericPlayer::removeLord( int num ) { if( _selectedLord == _theLords.at( num ) ) { _selectedLord = 0; } _theLords.removeAt( num ); } void GenericPlayer::removeLord( GenericLord * lord ) { _theLords.removeAll( lord ); if( _selectedLord == lord ) { _selectedLord = 0; } } GenericBase * GenericPlayer::nextBase() { if ( _selectedBase == 0 ) { if ( numBase() > 0 ) { _selectedBase = _theBase.at( 0 ); return _theBase.at( 0 ); } else return 0; } else { int num = _theBase.indexOf( _selectedBase ); if ( num >= 0 ) { if ( (uint)num == numBase() - 1 ) { _selectedBase = _theBase.at( 0 ); return _theBase.at( 0 ); } else { _selectedBase = _theBase.at( num+1 ); return _theBase.at( num+1 ); } } else { if ( numBase() > 0 ) { _selectedBase = _theBase.at( 0 ); return _theBase.at( 0 ); } else { return 0; } } } } void GenericPlayer::removeBase( GenericBase * base ) { _theBase.removeAll( base ); if( _selectedBase ) { _selectedBase = 0; } } GenericBase * GenericPlayer::getBaseById( int id ) { for( uint i = 0; i < numBase(); i++ ) { if( _theBase.at( i )->getId() == id ) { return _theBase.at( i ); } } return 0; } void GenericPlayer::cleanData() { uint tmp, i; tmp = numLord(); for( i = 0; i < tmp; i++ ) { removeLord( 0 ); } tmp = numBase(); for( i = 0; i < tmp; i++ ) { removeBase( 0 ); } tmp = numBuilding(); for( i = 0; i < tmp; i++ ) { removeBuilding( 0 ); } _alive = true; clearVision(); } bool GenericPlayer::hasLost() { bool ret = false; if( _theLords.count() == 0 ) { ret = true; _alive = false; } return ret; } bool GenericPlayer::canBuy( InsideBuildingModel * building ) { bool ret = true; for( int i = 0; i < DataTheme.resources.count(); i++ ) { if( _ress->getValue(i) < (int) building->getCost( i ) ) { ret = false; } } return ret; } bool GenericPlayer::canBuy( Creature * creature, int number ) { bool ret = true; for( int i = 0; i < DataTheme.resources.count(); i++ ) { if( _ress->getValue(i) < (int)(creature->getCost( i ) * number ) ) { ret = false; } } return ret; } bool GenericPlayer::canBuy( GenericLordModel * lord ) { bool ret = true; for( int i = 0; i < DataTheme.resources.count(); i++ ) { if( _ress->getValue( i ) < (int)(lord->getCost( i ) ) ) { ret = false; } } return ret; } void GenericPlayer::buy( Creature * creature, int number ) { for( int i = 0; i < DataTheme.resources.count(); i++ ) { ResourceModel * model = DataTheme.resources.get( i ); if( !model->isPreservable() ){ _ress->decreaseValue( i, creature->getCost( i ) * number ); } } } uint GenericPlayer::computeBuyCreatureMax( Creature * creature ) { int ret = -1; for( int i = 0; i < DataTheme.resources.count(); i++ ) { if( creature->getCost( i ) > 0 ) { int temp = _ress->getValue( i ) / creature->getCost( i ); if( ( ret == -1 ) || ( temp < ret ) ) { ret = temp; } } } if( ret == -1 ) { ret = 0; } return (uint)ret; } void GenericPlayer::clearVision() { if( _vision && _theight){ for( int i = 0; i < _theight; ++i ) { delete [] _vision[i]; } delete [] _vision; _vision = 0; _theight = 0; } } void GenericPlayer::initMapVision() { if(!_vision){ _theight = _map->getHeight(); int width = _map->getWidth(); _vision = new int * [ _theight ]; for( int i = 0; i < _theight; i++ ) { _vision[i] = new int [ width ]; for( int j = 0; j < width; j++ ) { _vision[i][j] = 0; } } } } QList GenericPlayer::removeCellVision( GenericCell * cell, int vision ) { QList ret; GenericCell * tmp = NULL; int i,j; GeneralOptions::VISION_MANAGEMENT visionType = DataTheme.general.getVisionManagement(); QList list = _map->giveRadiusCell( cell , vision ); if( visionType == GeneralOptions::VISION_REAL ) { for (int k = 0; k < list.size(); ++k) { tmp = list.at( k ); i = tmp->getRow(); j = tmp->getCol(); if( _vision[i][j] > 0 ) { _vision[i][j]--; if( _vision[i][j] == 0 ) { ret.append( tmp ); } } } } return ret; } QList GenericPlayer::addCellVision( GenericCell * cell, int vision ) { QList ret; GenericCell * tmp = NULL; int i, j; GeneralOptions::VISION_MANAGEMENT visionType = DataTheme.general.getVisionManagement(); QList list = _map->giveRadiusCell( cell , vision ); for (int k = 0; k < list.size(); ++k) { tmp = list.at( k ); i = tmp->getRow(); j = tmp->getCol(); _vision[i][j]++; if( _vision[i][j] == 1 ) { ret.append( tmp ); } else if( visionType == GeneralOptions::VISION_ONCE ) { _vision[i][j] = 2; } } return ret; } QList GenericPlayer::removeLordVision( GenericLord * lord ) { int vision = lord->getCharac( VISION ); GenericCell * cell = lord->getCell(); return removeCellVision( cell, vision ); } QList GenericPlayer::addLordVision( GenericLord * lord ) { int vision = lord->getCharac( VISION ); GenericCell * cell = lord->getCell(); return addCellVision( cell, vision ); } QList GenericPlayer::removeBaseVision( GenericBase * base ) { int vision = base->getVision(); GenericCell * cell = base->getCell(); return removeCellVision( cell, vision ); } QList GenericPlayer::addBaseVision( GenericBase * base ) { int vision = base->getVision(); GenericCell * cell = base->getCell(); return addCellVision( cell, vision ); } QList GenericPlayer::addBuildingVision( GenericBuilding * building ) { int vision = 3; // XXX: to change!!! GenericCell * cell = building->getCell(); return addCellVision( cell, vision ); } QList GenericPlayer::removeBuildingVision( GenericBuilding * building ) { int vision = 3; // XXX: to change!!! GenericCell * cell = building->getCell(); return removeCellVision( cell, vision ); } bool GenericPlayer::canSee( uint row, uint col ) { bool ret = false; if( _map->inMap( row, col ) ) { ret = ( _vision[row][col] > 0 ); } return ret; } bool GenericPlayer::canSee( GenericCell * cell ) { return canSee( cell->getRow(), cell->getCol() ); } bool GenericPlayer::canMove( GenericLord * lord ) { int movePt = lord->getCharac( MOVE ); GenericCell * start = lord->getCell(); QList list = _map->giveRadiusCell( lord->getCell() , 1 ); for (int i = 0; i < list.size(); ++i) { if( list.at(i) == start ) { continue; } int cost = PathFinder::computeCostMvt( start, list.at(i) ); if ( cost < movePt ) { return true; } } return false; } attal-src-1.0-rc2/libCommon/genericPlayer.h0000644000175000017500000001712510763100242016336 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericPlayer.h ** class that manage a player ** ** Version : $Id: genericPlayer.h,v 1.31 2008/03/03 22:50:10 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 08/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICPLAYER_H #define GENERICPLAYER_H // generic include files // include files for QT #include #include // application specific include #include "libCommon/define.h" #include "libCommon/genericLord.h" #include "libCommon/genericBuilding.h" #include "libCommon/genericBase.h" #include "libCommon/genericRessources.h" class QTextStream; class Creature; class GenericMap; class PriceMarket; class InsideBuildingModel; /* ------------------------------ * GenericPlayer * ------------------------------ */ class GenericPlayer { public: /** Constructor */ GenericPlayer( GenericMap * theMap = 0 ); GenericPlayer& operator = (GenericPlayer& other); /** Destructor */ virtual ~GenericPlayer(); /** load players data */ bool loadVision( QTextStream * ts , int width, int height); /** save players data */ void save( QTextStream * ts, int indent = 0 ); void newTurn(); void newWeek(); /** Set a name to the player */ void setName( QString name ) { _name = name; } /** Return the name of the player */ QString getName() { return _name; } /** Set a connection name to the player */ void setConnectionName( QString name ) { _connectionName = name; } /** Return the connection name of the player */ QString getConnectionName() { return _connectionName; } /** Give a number to the player */ void setNum( int num ); /** Return the number of the player */ int getNum() { return _num; } /* void setPopulation( uint popul ) { _totalPop = popul; } uint getPopulation() { return _totalPop; } void addPopulation( uint popul ) { _totalPop += popul; } void removePopulation( uint popul ) { _totalPop -= popul; } void resetPopulation() { _totalPop = 0; } */ void setTeam( uint teamId ) { _teamId = teamId; _isTeamSet = true; } uint getTeamId() { return _teamId; } /** Associate a map to the player */ void setMap( GenericMap * theMap ) { _map = theMap; } /** Return the map associated to the player */ GenericMap * getMap() { return _map; } GenericResourceList * getResourceList() { return _ress; } /** Return the 'num'-th lord */ GenericLord * getLord( int num ) { return _theLords.at( num ); } /** Return the lord with Id 'id' */ GenericLord * getLordById( int id ); /** Remove a lord from the player's list */ void removeLord( int num ); void removeLord( GenericLord * lord ); /** Add a new lord to the player */ void addLord( GenericLord * l ); /** Return the number of lords */ uint numLord() { return _theLords.count(); } void cleanData(); /** Tell if the player owns this lord */ bool hasLord( GenericLord * lord ) { return _theLords.contains( lord ) ; } /** Select a lord in the player list */ virtual void setSelectedLord( GenericLord * lord ) { _selectedLord = lord ; _selectedBase = 0; } /** Unselect lords (if any) */ virtual void unSelectLord() { _selectedLord = 0; } /** Select the first active lord */ bool selectFirstLord(); /** Return the lord selected in the player */ GenericLord * getSelectedLord( ) { return _selectedLord; } /** Cycle to the next lord of the player */ virtual GenericLord * nextLord(); /** Return the 'num'-th building */ GenericBuilding * getBuilding( int num ) { return _theBuild.at( num ); } /** Remove a building from the list */ void removeBuilding( int num ) { _theBuild.removeAt( num ); } /** Remove a building from the list */ void removeBuilding( GenericBuilding * building ) { _theBuild.removeAll( building );} /** Add a building to the list */ void addBuilding( GenericBuilding * b ); /** Return the number of building */ uint numBuilding() { return _theBuild.count(); } bool hasBuilding( GenericBuilding * building ) { return _theBuild.count( building ); } /** Tell if the player owns this base */ bool hasBase( GenericBase * base ) { return _theBase.count( base ) ; } /** Select a base in the player list */ virtual void setSelectedBase( GenericBase * base ) { _selectedBase = base; _selectedLord = 0; } /** Unselect bases (if any) */ void unSelectBase() { _selectedBase = 0; } /** Return the base selected in the player */ GenericBase * getSelectedBase( ) { return _selectedBase; } /** Cycle to the next lord of the player */ GenericBase * nextBase(); /** Return the 'num'-th base */ GenericBase * getBase( int num ) { return _theBase.at( num ); } GenericBase * getBaseById( int id ); /** Remove a base from the list */ void removeBase( int num ) { _theBase.removeAt( num ); } /** Remove a base from the list */ void removeBase( GenericBase * base ); /** Add a building to the list */ void addBase( GenericBase * base ); /** Return the number of bases */ uint numBase() { return _theBase.count(); } /** Select the first base */ bool selectFirstBase() { return true; } /** Give its advice about the end of the turn */ bool shouldEnd(); /** Compute the end of the turn */ void endTurn(); /** Is the player alive ? */ bool isAlive() { return _alive; } void setAlive(bool alive) { _alive = alive; } bool hasLost(); bool isRuledByAi () {return _isRuledByAi;} void setRuledByAi (bool ruledByAi) {_isRuledByAi = ruledByAi;} bool canBuy( InsideBuildingModel * building ); bool canBuy( Creature * creature, int number ); bool canBuy( GenericLordModel * lord ); void buy( Creature * creature, int number ); uint computeBuyCreatureMax( Creature * creature ); void initMapVision(); void clearVision(); QList addCellVision( GenericCell * cell, int vision ); QList removeCellVision( GenericCell * cell, int vision ); QList addLordVision( GenericLord * lord ); QList removeLordVision( GenericLord * lord ); QList addBaseVision( GenericBase * base ); QList removeBaseVision( GenericBase * base ); QList addBuildingVision( GenericBuilding * building ); QList removeBuildingVision( GenericBuilding * building ); bool canSee( uint row, uint col ); bool canSee( GenericCell * cell ); bool canMove( GenericLord * lord ); PriceMarket * getPriceMarket() { return _price;} void setPriceMarket( PriceMarket * price ) { _price = price;} void setGameId( int id ) { _gameId = id; } int getGameId() { return _gameId; } static const int NO_PLAYER=-1; protected: uint _totalPop; int _num; QString _name; QString _connectionName; bool _alive; bool _isRuledByAi; uint _teamId; bool _isTeamSet; int _gameId; GenericResourceList * _ress; QList _theLords; QList _theBase; QList _theBuild; GenericLord * _selectedLord; GenericBase * _selectedBase; GenericMap * _map; PriceMarket * _price; int ** _vision; int _theight; }; #endif // GENERICPLAYER_H attal-src-1.0-rc2/libCommon/genericRessources.cpp0000644000175000017500000002712210751372503017600 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericRessources.cpp ** Management of ressources infos ** ** Version : $Id: genericRessources.cpp,v 1.23 2008/02/03 17:09:23 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 03/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericRessources.h" // generic include files // include files for QT #include #include // application specific include files #include "libCommon/log.h" #include "libCommon/dataTheme.h" extern QString DATA_PATH; GenericResource::GenericResource() { _value = 0; _minValue = 0; } void GenericResource::decreaseValue( int val ) { if( val <= _value ) { _value -= val; } else { _value = 0; } } void GenericResource::increaseValue( int val ) { _value += val; } void GenericResource::modPercValue( int percentage ) { _value = (_value * (100 + percentage )/100); if(_value <= 0) _value = _minValue; } int GenericResource::getRandGrowth( int coeff ) { int tmp = 0; tmp = 2 * (int) (rand() % coeff); TRACE("GenericResource::getRandGrowth coeff %d , rand %d", coeff,tmp); return tmp; } void GenericResource::updateRandGrowth( int coeff ) { int ress = getRandGrowth( coeff ); increaseValue( ress ); } void GenericResource::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent ); *ts << "\t" << _id << "" << endl; indentation( ts, indent ); *ts << "\t" << _value << "" << endl; indentation( ts, indent ); *ts << "\t" << _minValue << "" << endl; indentation( ts, indent ); *ts << "" << endl; *ts << flush; } // // ----- GenericResourceList ----- // GenericResourceList::GenericResourceList() { uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { append( new GenericResource() ); at( i )->setId( i ); } } GenericResourceList::~GenericResourceList() { clear(); } void GenericResourceList::setListValues(GenericResourceList * other) { for( int i = 0; i < count(); i++ ) { setValue( i, other->getValue( i ) ); } } void GenericResourceList::clear() { while( ! isEmpty() ) { delete takeFirst(); } } GenericResource * GenericResourceList::get( uint num ) { for( int i = 0; i < count(); i++ ) { if( at( i )->getId() == num ) { return at( i ); } } return NULL; } void GenericResourceList::setValue( uint num, uint val ) { if( (int)num < DataTheme.resources.count() ) { GenericResource * rs = get( num ); if( rs ) rs->setValue(val); } } void GenericResourceList::decreaseValue( uint num, uint val ) { if( (int)num < DataTheme.resources.count() ) { GenericResource * rs = get( num ); if( rs ) rs->decreaseValue( val ); } } void GenericResourceList::increaseValue( uint num, uint val ) { if( (int)num < DataTheme.resources.count() ) { GenericResource * rs = get( num ); if( rs ) rs->increaseValue( val ); } } int GenericResourceList::getValue( uint num ) { if( (int)num < DataTheme.resources.count() ) { GenericResource * rs = get( num ); if( rs ) return rs->getValue(); } return 0; } void GenericResourceList::modPercValue( uint num, int percentage ) { if( (int)num < DataTheme.resources.count() ) { GenericResource * rs = get( num ); if( rs ) rs->modPercValue( percentage ); } } void GenericResourceList::updateRandGrowth( uint num, int coeff ) { if( (int)num < DataTheme.resources.count() ) { GenericResource * rs = get( num ); if( rs ) rs->updateRandGrowth( coeff ); } } void GenericResourceList::removeResources( GenericResourceList * list ) { for( int i = 0; i < count(); i++ ) { decreaseValue( i , list->getValue( i ) ); } } void GenericResourceList::addResources( GenericResourceList * list ) { for( int i = 0; i < count(); i++ ) { increaseValue( i , list->getValue( i ) ); } } QString GenericResourceList::getAutoDescription() { QString s = ""; for( int i = 0; i < count() ; i++ ) { if( getValue( i ) > 0 ) { s += qPrintable(DataTheme.resources.getRessource( i ) ); s += QString(" : %1").arg( getValue( i ) ); s += "\n"; } } if( !s.isEmpty() ) { s.prepend("\nResources\n"); } return s; } void GenericResourceList::print() { for( int i = 0; i < count(); i++ ) { logDD("Ress %d, value %d", i, getValue( i ) ); } } // // ResourceModel // ResourceModel::ResourceModel() { _type = RE_GLOB_NOPRESERVABLE; } bool ResourceModel::isPreservable() { if( _type == ResourceModel::RE_GLOB_NOPRESERVABLE || _type == ResourceModel::RE_LOC_NOPRESERVABLE ) return false; return true; } bool ResourceModel::isGlobal() { if( _type == ResourceModel::RE_GLOB_NOPRESERVABLE || _type == ResourceModel::RE_LOC_PRESERVABLE ) return true; return false; } void ResourceModel::setId( int id ) { TRACE("setId %d", id); _id = id; if( _filename.isEmpty() ) { _filename.sprintf( "ressources/ress_%02d.png", _id + 1 ); } if( _smallfilename.isEmpty() ) { _smallfilename.sprintf( "ressources/smallResource_%02d.png", _id + 1 ); } } void ResourceModel::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent ); *ts << "\t" << _id << "" << endl; indentation( ts, indent ); *ts << "\t" << _type << "" << endl; indentation( ts, indent ); *ts << "\t" << _name << "" << endl; indentation( ts, indent ); *ts << "\t" << _filename << "" << endl; indentation( ts, indent ); *ts << "\t" << _smallfilename << "" << endl; indentation( ts, indent ); *ts << "" << endl; *ts << flush; } // // ----- ResourceList ----- // ResourceList::ResourceList() { } ResourceList::~ResourceList() { clear(); } void ResourceList::clear() { _type.clear(); while( ! isEmpty() ) { delete takeFirst(); } } bool ResourceList::init() { TRACE("ResourceList::init"); clear(); ResourceHandler handler( this ); QFile file( DATA_PATH + "resources.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "resources.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } bool ResourceList::save() { QString filename = DATA_PATH + "resources.dat"; QFile file( filename ); if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writing\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; ResourceModel * ress; for( int i = 0; i < count(); i++ ) { ress = at( i ); if( ress ) { ress->save( &ts, 1 ); } } ts << "" << endl; file.close(); return true; } //compatibility QString ResourceList::getRessource( uint num ) { if( (int)num < count() ) { return at( num )->getResourceName(); } else { return QString(""); } } ResourceModel * ResourceList::get( int id ) { ResourceModel * ret = first(); ResourceModel * current; QListIterator ite( *this ); while( ite.hasNext() ) { current = ite.next(); if( current->getId() == id ) { ret = current; } } return ret; } ResourceHandler::ResourceHandler( ResourceList * list ) { _list = list; } bool ResourceHandler::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _list->clear(); _state = StateInit; return true; } bool ResourceHandler::startElement( const QString &, const QString &, const QString & qName, const QXmlAttributes & atts ) { if( qName == "resources" && _state == StateInit ) { _state = StateDocument; } else if( qName == "resource" && _state == StateDocument ) { _state = StateResource; _ress = new ResourceModel(); } else if( qName == "id" && _state == StateResource ) { _state = StateResourceId; } else if( qName == "type" && _state == StateResource ) { _state = StateResourceType; } else if( qName == "name" && _state == StateResource ) { _state = StateResourceName; } else if( qName == "filename" && _state == StateResource ) { _state = StateFilename; } else if( qName == "smallfilename" && _state == StateResource ) { _state = StateSmallFilename; } else { // error return false; } return true; } bool ResourceHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateResource: _list->append( _ress ); _state = StateDocument; break; case StateResourceId: _state = StateResource; break; case StateResourceType: _state = StateResource; break; case StateResourceName: _state = StateResource; break; case StateFilename: _state = StateResource; break; case StateSmallFilename: _state = StateResource; break; default: // do nothing break; } return true; } bool ResourceHandler::characters( const QString & ch ) { QString ch_simplified = ch.simplified(); if( ch_simplified.isEmpty() ) { return true; } switch( _state ) { case StateResourceName: _ress->setResourceName( ch_simplified ); break; case StateFilename: _ress->setFileName( ch_simplified ); break; case StateSmallFilename: _ress->setSmallFileName( ch_simplified ); break; case StateResourceId: _ress->setId( ch_simplified.toInt() ); break; case StateResourceType: _ress->setType( ( ResourceModel::ResourceType ) ch_simplified.toInt() ); break; default: return false; } return true; } bool ResourceHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } GenericRessources::GenericRessources() { } bool GenericRessources::init() { clear(); QString filename = DATA_PATH + "ressources.dat"; QFile f( filename ); if (! f.open( QIODevice::ReadOnly ) ) { logEE( "Could not open file %s for reading\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &f ); int temp; ts >> temp; for( int i = 0; i < temp; i++ ) { QString es; ts >> es; append( es ); //logDD( "%s", ress->toLatin1().constData() ); } f.close(); return true; } bool GenericRessources::save() { QString filename = DATA_PATH + "ressources.dat"; QFile f( filename ); if (! f.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writng\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &f ); ts << count() << endl; for( int i = 0; i < count(); i++ ) { ts << at( i ) << endl; } f.close(); return true; } void GenericRessources::update( int num, QString val ) { (*this)[ num ] = val; } GenericRessources::~GenericRessources() { clear(); } QString GenericRessources::getRessource( uint num ) { if( (int)num < count() ) { return at( num ); } else { return QString(""); } } attal-src-1.0-rc2/libCommon/genericRessources.h0000644000175000017500000001301310750155154017237 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericRessources.h ** Management of ressources infos ** ** Version : $Id: genericRessources.h,v 1.21 2008/01/30 20:13:32 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 03/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICRESSOURCES_H #define GENERICRESSOURCES_H // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/action.h" class QTextStream; class GenericResource { public: GenericResource(); int getValue() { return _value; } void setValue( int value ) { _value = value; } int getId() { return _id; } void setId( int id ) { _id = id; } void decreaseValue( int val ); void increaseValue( int val ); void modPercValue( int percentage ); int getMinValue() { return _minValue; } void setMinValue( int value ) { _minValue = value; } void updateRandGrowth( int coeff ); static int getRandGrowth( int coeff ); void save( QTextStream * ts, int indent ); private: int _value; int _minValue; int _id; }; class GenericResourceList : public QList { public: /** Constructor */ GenericResourceList(); /** Destructor */ virtual ~GenericResourceList(); void setListValues(GenericResourceList * other); /** Return resource corresponding to 'id' */ GenericResource * get( uint id ); /** Change ressource 'num' number */ void setValue( uint num, uint val ); void decreaseValue( uint num, uint val ); void increaseValue( uint num, uint val ); /** Return number of ressource 'num' */ int getValue( uint num ); void modPercValue( uint num, int percentage ); void updateRandGrowth( uint num, int coeff ); void removeResources( GenericResourceList * list ); void addResources( GenericResourceList * list ); QString getAutoDescription(); void print(); /** Clear list */ void clear(); }; class ResourceModel { public: enum ResourceType { RE_LOC_PRESERVABLE, RE_LOC_NOPRESERVABLE, RE_GLOB_PRESERVABLE, RE_GLOB_NOPRESERVABLE }; ResourceModel(); QString getResourceName() { return _name; } void setResourceName( QString name ) { _name = name; } int getId() { return _id; } void setId( int id ); bool isPreservable(); bool isGlobal(); QString getFileName() { return _filename; } void setFileName( QString name ) { if( !name.isEmpty() ) _filename = name; } QString getSmallFileName() { return _smallfilename; } void setSmallFileName( QString name ) { if( !name.isEmpty() ) _smallfilename = name; } void setType( ResourceType type ) { _type = type; } ResourceType getType() { return _type; } void save( QTextStream * ts, int indent = 0 ); private: ResourceType _type; int _id; QString _name; QString _filename; QString _smallfilename; }; class ResourceList : public QList { public: /** Constructor */ ResourceList(); /** Destructor */ virtual ~ResourceList(); /** Return resource corresponding to 'id' */ ResourceModel * get( int id ); /** Clear list */ void clear(); bool save(); /** Init list */ bool init(); QString getRessource( uint num ); private: QList _type; }; /** Parser for ResourceList */ class ResourceHandler : public QXmlDefaultHandler { public: /** Construtor */ ResourceHandler( ResourceList * list ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: QString _errorProt; ResourceList * _list; ResourceModel * _ress; QTextStream * _stream; QString _filename, _smallFilename; enum State { StateInit, StateDocument, StateResource, StateResourceId, StateResourceType, StateResourceName, StateFilename, StateSmallFilename }; State _state; }; /* ------------------------------ * GenericRessources * ------------------------------ */ /** comment for the class */ class GenericRessources : public QList { public: /** Construtor : load ressources info from 'filename' */ GenericRessources(); /** Destructor (for pointer) */ virtual ~GenericRessources(); /** Initializes ressources */ bool init(); bool save(); void update( int num, QString val ); /** Return the ressources 'num' if possible */ QString getRessource( uint num ); }; #endif // GENERICRESSOURCES_H attal-src-1.0-rc2/libCommon/genericTeam.cpp0000644000175000017500000001146210522705152016325 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericTeam.cpp ** manage team ** ** Version : $Id: genericTeam.cpp,v 1.11 2006/11/03 18:28:58 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 26/08/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "genericTeam.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" extern QString DATA_PATH; // // ----- GenericTeam ----- // GenericTeam::GenericTeam( uint num ) : _num( num ) { _name = ""; _red = 0; _green = 0; _blue = 0; } GenericTeam::~GenericTeam() { } QColor GenericTeam::getColor() { return QColor( _red, _green, _blue ); } // // ----- TeamList ----- // TeamList::TeamList() { } TeamList::~TeamList() { clear(); } bool TeamList::init() { clear(); TeamHandler handler( this ); QFile file( DATA_PATH + "teams.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "teams.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } bool TeamList::save() { QString filename = DATA_PATH + "teams.dat"; QFile file( filename ); if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writng\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; for( int i = 0; i < count(); i++ ) { GenericTeam * team = at( i ); ts << "\t" << endl; ts << "\t\t" << team->getName() << "" << endl; ts << "\t\t" << team->getRed() << "" << endl; ts << "\t\t" << team->getGreen() << "" << endl; ts << "\t\t" << team->getBlue() << "" << endl; ts << "\t" << endl; } ts << "" << endl; file.close(); return true; } void TeamList::clear() { while( ! isEmpty() ) { delete takeFirst(); } } // // ----- TeamHandler ----- // TeamHandler::TeamHandler( TeamList * list ) { _list = list; } bool TeamHandler::startDocument() { _errorProt = ""; _list->clear(); _state = StateInit; return true; } bool TeamHandler::startElement( const QString &, const QString &, const QString & qName, const QXmlAttributes & ) { if( qName == "teams" && _state == StateInit ) { _state = StateDocument; } else if ( qName == "team" && _state == StateDocument ) { _state = StateTeam; _team = new GenericTeam( _list->count() ); } else if ( qName == "name" && _state == StateTeam ) { _state = StateName; } else if ( qName == "red" && _state == StateTeam ) { _state = StateRed; } else if ( qName == "green" && _state == StateTeam ) { _state = StateGreen; } else if ( qName == "blue" && _state == StateTeam ) { _state = StateBlue; } else { return false; } return true; } bool TeamHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateTeam: _state = StateDocument; _list->append( _team ); break; case StateName: _state = StateTeam; break; case StateRed: _state = StateTeam; break; case StateGreen: _state = StateTeam; break; case StateBlue: _state = StateTeam; break; default: // do nothing break; } return true; } bool TeamHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) return true; switch( _state ) { case StateName: _team->setName( ch_simplified ); break; case StateRed: _team->setRed( ch_simplified.toInt() ); break; case StateGreen: _team->setGreen( ch_simplified.toInt() ); break; case StateBlue: _team->setBlue( ch_simplified.toInt() ); break; default: return false; } return true; } bool TeamHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/genericTeam.h0000644000175000017500000000663510335201564016000 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** genericTeam.h ** manage team ** ** Version : $Id: genericTeam.h,v 1.6 2005/11/11 20:47:48 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 26/08/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICTEAM_H #define GENERICTEAM_H // generic include files // include files for QT #include #include #include #include // application specific include files /* ------------------------------ * GenericTeam * ------------------------------ */ class GenericTeam { public: /** Constructor */ GenericTeam( uint num ); /** Destructor */ virtual ~GenericTeam(); uint getNumber() { return _num; } /** \return Returns the name of the team */ QString getName() { return _name; } /** Sets the name of the team */ void setName( const QString & name ) { _name = name; } /** \return Returns the 'red value' of the team's color */ uint getRed() { return _red; } /** Sets the 'red value' of the team's color */ void setRed( uint red ) { _red = red; } /** \return Returns the 'blue value' of the team's color */ uint getBlue() { return _blue; } /** Sets the 'blue value' of the team's color */ void setBlue( uint blue ) { _blue = blue; } /** \return Returns the 'green value' of the team's color */ uint getGreen() { return _green; } /** Sets the 'green value' of the team's color */ void setGreen( uint green ) { _green = green; } QColor getColor(); private: QString _name; uint _num; uint _red, _green, _blue; }; /** List of teams */ class TeamList : public QList { public: /** Constructor */ TeamList(); /** Destructor */ virtual ~TeamList(); /** Init list */ bool init(); /** Save info in data file */ bool save(); void clear(); }; /** Parser for the TeamList */ class TeamHandler : public QXmlDefaultHandler { public: /** Constructor */ TeamHandler( TeamList * list ); /** \return Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: TeamList * _list; GenericTeam * _team; QString _errorProt; enum State { StateInit, StateDocument, StateTeam, StateName, StateRed, StateGreen, StateBlue, }; State _state; }; #endif // GENERICTEAM_H attal-src-1.0-rc2/libCommon/groupName.cpp0000644000175000017500000000441010401056020016017 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** groupName.cpp ** Manage name for group of units ** ** Version : $Id: groupName.cpp,v 1.5 2006/02/28 14:20:00 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 15/12/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "groupName.h" // generic include files // include files for QT #include #include // application specific include files #include "libCommon/log.h" extern QString DATA_PATH; GroupName::GroupName() { } GroupName::~GroupName() { clear(); } void GroupName::init() { QString filename = DATA_PATH + "group.dat"; QFile f( filename ); if( ! f.open( QIODevice::ReadOnly ) ) { logEE( "Unable to open data file (read): %s", filename.toLatin1().constData() ); return; } QTextStream ts( &f ); ts >> _default; while( ! ts.atEnd() ) { Group * group = new Group(); ts >> group->name; ts >> group->value; _list.append( group ); } f.close(); } void GroupName::save() { QString filename = DATA_PATH + "group.dat"; QFile f( filename ); if( ! f.open( QIODevice::WriteOnly ) ) { logEE( "Unable to open data file (write): %s", filename.toLatin1().constData() ); return; } QTextStream ts( &f ); ts << _default << endl; for( int i = 0; i < _list.count(); i++ ) { ts << _list.at( i )->name << " "; ts << _list.at( i )->value; ts << endl; } f.close(); } void GroupName::clear() { _default = ""; while( ! _list.isEmpty() ) { delete _list.takeFirst(); } } QString GroupName::getGroupName( int nb ) { QString ret = _default; for( int i = 0; i < _list.count(); i++ ) { if( _list.at( i )->value > nb ) { ret = _list.at( i )->name; i = _list.count(); } } return ret; } attal-src-1.0-rc2/libCommon/groupName.h0000644000175000017500000000315410335201564015503 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** groupName.h ** Manage name for group of units ** ** Version : $Id: groupName.h,v 1.4 2005/11/11 20:47:48 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 15/12/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GROUPNAME_H #define GROUPNAME_H // generic include files // include files for QT #include #include // application specific include files /** ------------------------------ * GroupName ** ------------------------------ */ struct Group { QString name; int value; }; /** comment for the class */ class GroupName { public: /** Constructor */ GroupName(); /** Destructor */ virtual ~GroupName(); /** Inits group name list */ void init(); /** Saves group name list */ void save(); /** Clears group name list */ void clear(); /** \return Returns group name 'nb' */ QString getGroupName( int nb ); private: QList _list; QString _default; }; #endif // GROUPNAME_H attal-src-1.0-rc2/libCommon/libCommon.pro0000644000175000017500000000611311015367573016045 0ustar aaaa TEMPLATE = lib include( ../config.pro ) INCLUDEPATH += .. VERSION = 10.0.0 SOURCES += action.cpp SOURCES += artefact.cpp SOURCES += artefactManager.cpp SOURCES += attalCommon.cpp SOURCES += attalSettings.cpp SOURCES += attalSocket.cpp SOURCES += attalSocketData.cpp SOURCES += calendar.cpp SOURCES += campaign.cpp SOURCES += categoryManager.cpp SOURCES += condition.cpp SOURCES += creature.cpp SOURCES += dataTheme.cpp SOURCES += displayHelp.cpp SOURCES += fightResultStatus.cpp SOURCES += gameData.cpp SOURCES += generalOptions.cpp SOURCES += genericBuilding.cpp SOURCES += genericBase.cpp SOURCES += genericBonus.cpp SOURCES += genericCell.cpp SOURCES += genericChest.cpp SOURCES += genericDecoration.cpp SOURCES += genericEvent.cpp SOURCES += genericFightCell.cpp SOURCES += genericFightMap.cpp SOURCES += genericInsideBuilding.cpp SOURCES += genericLord.cpp SOURCES += genericMapCreature.cpp SOURCES += genericMapDisposition.cpp SOURCES += genericPlayer.cpp SOURCES += genericRessources.cpp SOURCES += genericMap.cpp SOURCES += genericTeam.cpp SOURCES += groupName.cpp SOURCES += log.cpp SOURCES += lordArtefactsConfiguration.cpp SOURCES += lordCategoryModel.cpp SOURCES += lordExperience.cpp SOURCES += parser.cpp SOURCES += pathFinder.cpp SOURCES += priceMarket.cpp SOURCES += quest.cpp SOURCES += questManager.cpp SOURCES += skill.cpp SOURCES += specialty.cpp SOURCES += technic.cpp SOURCES += unit.cpp SOURCES += warMachine.cpp HEADERS += ../conf.h HEADERS += action.h HEADERS += artefact.h HEADERS += artefactManager.h HEADERS += attalCommon.h HEADERS += attalSettings.h HEADERS += attalSocket.h HEADERS += attalSocketData.h HEADERS += attalTemplates.h HEADERS += calendar.h HEADERS += campaign.h HEADERS += categoryManager.h HEADERS += condition.h HEADERS += creature.h HEADERS += dataTheme.h HEADERS += displayHelp.h HEADERS += fightResultStatus.h HEADERS += gameData.h HEADERS += generalOptions.h HEADERS += genericBuilding.h HEADERS += genericBase.h HEADERS += genericBonus.h HEADERS += genericCell.h HEADERS += genericChest.h HEADERS += genericDecoration.h HEADERS += genericEvent.h HEADERS += genericFightCell.h HEADERS += genericFightMap.h HEADERS += genericInsideBuilding.h HEADERS += genericLord.h HEADERS += genericMap.h HEADERS += genericMapCreature.h HEADERS += genericMapDisposition.h HEADERS += genericPlayer.h HEADERS += genericRessources.h HEADERS += genericTeam.h HEADERS += groupName.h HEADERS += log.h HEADERS += lordArtefactsConfiguration.h HEADERS += lordCategoryModel.h HEADERS += lordExperience.h HEADERS += parser.h HEADERS += pathFinder.h HEADERS += priceMarket.h HEADERS += quest.h HEADERS += questManager.h HEADERS += skill.h HEADERS += specialty.h HEADERS += technic.h HEADERS += unit.h HEADERS += warMachine.h TRANSLATIONS += ../i18n/de/attal_libcommon_de.ts TRANSLATIONS += ../i18n/fr/attal_libcommon_fr.ts TRANSLATIONS += ../i18n/ru/attal_libcommon_ru.ts TRANSLATIONS += ../i18n/it/attal_libcommon_it.ts DESTDIR = .. OBJECTS_DIR=./obj MOC_DIR=./moc TARGET = AttalCommon unix { target.path = $${ATT_LIB_PREFIX} INSTALLS += target } #The following line was inserted by qt3to4 QT += xml network attal-src-1.0-rc2/libCommon/log.cpp0000644000175000017500000001645511006425230014664 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** log.cpp ** Print log and debugging messages ** ** Version : $Id: log.cpp,v 1.9 2008/05/01 20:39:52 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ******************************************************************/ #include // generic include files #include #include // application specific includes #include "log.h" LogLevel curLogLevel = LogDebug; // // ----- Log ----- // void Log::print( QString msg ) { qDebug( "%s", qPrintable( msg )); emit sig_print( msg ); } void Log::printAi( QString msg ) { emit sig_printAi( msg ); } // // ----- functions ----- // static const char *logLevelName[] = { "FATAL ", " ERROR", "INFO ", "WARNING ", "DEBUG ", "TRACE " }; static const char *AIlogLevelName[] = { "VERBOSE ", " NORMAL", "CRITICAL ", "QUIET " }; #define LOGMIN LogFatal #define LOGMAX LogTrace #define LOGAIMIN LOG_VERBOSE #define LOGAIMAX LOG_QUIET static FILE * logFile = stderr; static IALogLevel curAILogLevel = LOG_NORMAL; /** Set file to which all log will be made. If this function is not called * before logging, all output will go to stderr */ int setLogFile( char * file ) { if (logFile != 0 && logFile != stderr) { fclose(logFile); } logFile = fopen( file, "w+" ); if (! logFile) { fprintf( stderr, "Could not open log file %s\n", file ); return -1; } return 0; } int setLogFile( FILE * file ) { if (logFile != 0 && logFile != stderr) { fclose(logFile); } if (! file) { fprintf( stderr, "Setting to log output to NULL file."); } logFile = file; return 0; } /** Set the log level to 'level', so that every log below level will not * be displayed */ void setLogLevel( LogLevel level) { if (level > LOGMAX) level = LOGMAX; if (level < LOGMIN) level = LOGMIN; curLogLevel = level; logII( "Log level set to %s", logLevelName[level]); } #ifdef WIN32VC6 void aalogf( const char *fmt, ...) { LogLevel level = curLogLevel; va_list args; //if ( level > curLogLevel ) // return; fprintf(logFile, "\r\n%s: ", logLevelName[level] ); va_start(args, fmt); vfprintf(logFile, fmt, args); va_end(args); fflush(logFile); } #else /** Log with level */ void aalogf( LogLevel level, const char *fmt, ...) { va_list args; //if ( level > curLogLevel ) // return; fprintf(logFile, "%s: ", logLevelName[level] ); va_start(args, fmt); vfprintf(logFile, fmt, args); va_end(args); fputc('\n', logFile); fflush(logFile); } #endif #ifdef WIN32VC6 void Log::ialog( const char *cformat, ...) { #else /** Log with level */ void Log::ialog( IALogLevel level, const char *cformat, ...) { if ( level < curAILogLevel ) return; #endif QString result = ""; // This code has been taken from qt 2.3.2 sources (QString::sprintf) (which is under GPL) va_list ap; va_start( ap, cformat ); if ( !cformat || !*cformat ) { return; } QString format = QString::fromLatin1( cformat ); static QRegExp *escape = 0; if( !escape ) { escape = new QRegExp( "%#?0?-? ?\\+?'?[0-9*]*\\.?[0-9*]*h?l?L?q?Z?" ); } uint last = 0; int len = 0; int pos; for (;;) { /// was pos = escape->match( format, last, &len ); pos = escape->indexIn( format, last ); len = escape->matchedLength(); // Non-escaped text if ( pos > (int)last ) { result += format.mid(last,pos-last); } if ( pos < 0 ) { // The rest if ( (int)last < format.length() ) { result += format.mid(last); } break; } last = pos + len + 1; // Escape QString f = format.mid( pos, len ); uint width, decimals; int params = 0; int wpos = f.indexOf('*'); if ( wpos >= 0 ) { params++; width = va_arg( ap, int ); if ( f.indexOf('*', wpos + 1) >= 0 ) { decimals = va_arg( ap, int ); params++; } else { decimals = 0; } } else { decimals = width = 0; } QString replacement; if ( format[pos+len] == 's' || format[pos+len] == 'S' || format[pos+len] == 'c' ) { bool rightjust = ( f.indexOf('-') < 0 ); // Yes, %-5s really means left adjust in sprintf if ( wpos < 0 ) { QRegExp num( QString::fromLatin1("[0-9]+") ); QRegExp dot( QString::fromLatin1("\\.") ); /// was int nlen; /// was int p = num.match( f, 0, &nlen ); int p = num.indexIn( f, 0 ); int nlen = num.matchedLength(); /// was int q = dot.match( f, 0 ); int q = dot.indexIn( f, 0 ); if ( q < 0 || (p < q && p >= 0) ) { width = f.mid( p, num.matchedLength() ).toInt(); } if ( q >= 0 ) { /// was p = num.match( f, q ); p = num.indexIn( f, q ); // "decimals" is used to specify string truncation if ( p >= 0 ) { decimals = f.mid( p, nlen ).toInt(); } } } if ( format[pos+len] == 's' ) { QString s = QString::fromLatin1(va_arg(ap, char*)); if( decimals <= 0 ) { replacement = s; } else { replacement = s.left(decimals); } } else { int ch = va_arg(ap, int); replacement = QChar((ushort)ch); } if( replacement.length() < (int)width ) { replacement = rightjust ? replacement.rightJustified(width) : replacement.leftJustified(width); } } else if ( format[pos+len] == '%' ) { replacement = '%'; } else if ( format[pos+len] == 'n' ) { int* n = va_arg(ap, int*); *n = result.length(); } else { char in[64], out[330] = ""; strncpy(in,f.toLatin1(),63); char fch = format[pos+len].toLatin1(); in[f.length()] = fch; switch ( fch ) { case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': { int value = va_arg(ap, int); switch (params) { case 0: ::sprintf( out, in, value ); break; case 1: ::sprintf( out, in, width, value ); break; case 2: ::sprintf( out, in, width, decimals, value ); break; } } break; case 'e': case 'E': case 'f': case 'g': case 'G': { double value = va_arg(ap, double); switch (params) { case 0: ::sprintf( out, in, value ); break; case 1: ::sprintf( out, in, width, value ); break; case 2: ::sprintf( out, in, width, decimals, value ); break; } } break; case 'p': { void* value = va_arg(ap, void*); switch (params) { case 0: ::sprintf( out, in, value ); break; case 1: ::sprintf( out, in, width, value ); break; case 2: ::sprintf( out, in, width, decimals, value ); break; } } break; } replacement = QString::fromLatin1(out); } result += replacement; } va_end( ap ); printAi( result ); } /** Set the log level for AI to 'level', so that every log below level will not * be displayed */ void Log::setAiLogLevel( IALogLevel level) { if (level > LOGAIMAX) level = LOGAIMAX; if (level < LOGAIMIN) level = LOGAIMIN; curAILogLevel = level; logDD( "Log level set to %s", AIlogLevelName[level]); } attal-src-1.0-rc2/libCommon/log.h0000644000175000017500000000712011006425230014316 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** log.cpp ** Print log and debugging messages ** ** Version : $Id: log.h,v 1.10 2008/05/01 20:39:52 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** *******************************************************************/ #ifndef LOG_H #define LOG_H // generic include files #include // Qt include files #include #include // application specific includes enum LogLevel { LogFatal =0, /* preventing the program to continue */ LogError =1, /* bug or important problem */ LogInfo =2, /* information concerning the execution */ LogWarning =3, /* something strange is going on */ LogDebug =4, /* debug info */ LogTrace =5 /* debug info */ }; enum IALogLevel { LOG_VERBOSE, LOG_NORMAL, LOG_CRITICAL, LOG_QUIET }; extern LogLevel curLogLevel; /** Class for logging messages */ class Log : public QObject { Q_OBJECT public: /** Constructor */ Log() {} /** Print message in the log */ void print( QString msg ); void printAi( QString msg ); /** Set the ai log level to 'level', so that every log below level will not * be displayed. Default is LOG_NORMAL. */ void setAiLogLevel( IALogLevel level); /** Log function for the IA */ #ifdef WIN32VC6 void ialog( const char *cformat, ...); #else /** Log with level */ void ialog( IALogLevel level, const char *cformat, ...); #endif // VC6 signals: void sig_print( QString msg ); void sig_printAi( QString msg ); }; /** Set file to which all log will be made. If this function is not called * before logging, all output will go to stderr */ int setLogFile( char * file ); /** Set already opened file to which all log will be made. */ int setLogFile( FILE * file ); /** Set the log level to 'level', so that every log below level will not * be displayed. Default is LogDebug (everything log is written out). */ void setLogLevel( LogLevel level); #ifdef WIN32VC6 // under windows (not gcc or mingw ) //Useful macros, but not under non-gcc compiler... //Log with level void aalogf(const char *fmt, ...); #define TRACE #define logDD aalogf #define logEE aalogf #define logWW aalogf #define logCC aalogf #define logII aalogf #else // not windows /** Log with level */ void aalogf(LogLevel level, const char *fmt, ...); /** We could consider this one as an ugly macro, but it can be useful */ #define aalog2(loglevel, format, args... ) if ( __builtin_expect( loglevel <= curLogLevel, 0 ) ) aalogf(loglevel, " %25s (l.%5d): " format, __FUNCTION__, __LINE__ , ## args); #define TRACE( format, args... ) aalog2( LogTrace, format , ## args ) #define logDD( format, args... ) aalog2( LogDebug, format , ## args ) #define logEE( format, args... ) aalog2( LogError, format , ## args ) #define logWW( format, args... ) aalog2( LogWarning, format , ## args ) #define logCC( format, args... ) aalog2( LogCritical, format , ## args ) #define logII( format, args... ) aalog2( LogInfo, format , ## args ) #endif #endif // LOG_H attal-src-1.0-rc2/libCommon/lordArtefactsConfiguration.cpp0000644000175000017500000001467710522705152021442 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** lordArtefactsConfiguration.cpp ** Configuration of artefacts for lords ** ** Version : $Id: lordArtefactsConfiguration.cpp,v 1.8 2006/11/03 18:28:58 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "lordArtefactsConfiguration.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/log.h" extern QString DATA_PATH; // // ----- ArtefactPosition ----- // ArtefactPosition::ArtefactPosition() { _name = "Unknown"; _nb = 0; } ArtefactPosition::~ArtefactPosition() { while( ! _coordX.isEmpty() ) { delete _coordX.takeFirst(); } while( ! _coordY.isEmpty() ) { delete _coordY.takeFirst(); } } void ArtefactPosition::setNumber( uint nb ) { while( ! _coordX.isEmpty() ) { delete _coordX.takeFirst(); } while( ! _coordY.isEmpty() ) { delete _coordY.takeFirst(); } _nb = nb; for( uint i = 0; i < nb; i++ ) { _coordX.append( new uint(0) ); _coordY.append( new uint(0) ); } if( _nb == 0 ) { _coordX.append( new uint(0) ); _coordY.append( new uint(0) ); } } uint ArtefactPosition::getNumber() { return _nb; } void ArtefactPosition::setCoord( uint nb, uint x, uint y ) { if( nb < _nb ) { *( _coordX.at( nb ) ) = x; *( _coordY.at( nb ) ) = y; } else if( _nb == 0 ) { *( _coordX.at( 0 ) ) = x; *( _coordY.at( 0 ) ) = y; } } uint ArtefactPosition::getCoordX( uint nb ) { if( _nb < nb ) { return *( _coordX.at( nb ) ); } else { return *( _coordX.at( 0 ) ); } } uint ArtefactPosition::getCoordY( uint nb ) { if( _nb < nb ) { return *( _coordY.at( nb ) ); } else { return *( _coordY.at( 0 ) ); } } // // ----- LordartefactsConfiguration ----- // LordArtefactsConfiguration::LordArtefactsConfiguration() { } LordArtefactsConfiguration::~LordArtefactsConfiguration() { clear(); } void LordArtefactsConfiguration::appendPosition( ArtefactPosition * position ) { _artefacts.append( position ); } uint LordArtefactsConfiguration::getNbPosition() { return _artefacts.count(); } QString LordArtefactsConfiguration::getPositionName( uint pos ) { QString ret = ""; if( (int)pos < _artefacts.count() ) { ret = _artefacts.at( pos )->getName(); } return ret; } uint LordArtefactsConfiguration::getPositionNumber( uint pos ) { uint ret = 0; if( (int)pos < _artefacts.count() ) { ret = _artefacts.at( pos )->getNumber(); } return ret; } void LordArtefactsConfiguration::setPositionCoord( uint pos, uint nb, uint x, uint y ) { if( (int)pos < _artefacts.count() ) { _artefacts.at( pos )->setCoord( nb, x, y ); } } uint LordArtefactsConfiguration::getPositionCoordX( uint pos, uint nb ) { uint ret = 0; if( (int)pos < _artefacts.count() ) { ret = _artefacts.at( pos )->getCoordX( nb ); } return ret; } uint LordArtefactsConfiguration::getPositionCoordY( uint pos, uint nb ) { uint ret = 0; if( (int)pos < _artefacts.count() ) { ret = _artefacts.at( pos )->getCoordY( nb ); } return ret; } bool LordArtefactsConfiguration::init() { clear(); ArtefactsConfigurationHandler handler( this ); QFile file( DATA_PATH + "lordArtefacts.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "lordArtefacts.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } void LordArtefactsConfiguration::clear() { while( ! _artefacts.isEmpty() ) { delete _artefacts.takeFirst(); } } // // ----- ArtefactsConfigurationHandler ----- // ArtefactsConfigurationHandler::ArtefactsConfigurationHandler( LordArtefactsConfiguration * config ) { _config = config; } bool ArtefactsConfigurationHandler::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _config->clear(); _state = StateInit; return true; } bool ArtefactsConfigurationHandler::startElement( const QString&, const QString&, const QString& qName, const QXmlAttributes& atts) { if( qName == "lordArtefacts" && _state == StateInit ) { _state = StateDocument; } else if( qName == "artefact" && _state == StateDocument ) { _state = StateArtefact; _position = new ArtefactPosition(); _cpt = 0; } else if( qName == "name" && _state == StateArtefact ) { _state = StateName; } else if( qName == "number" && _state == StateArtefact ) { _state = StateNumber; _position->setNumber( atts.value( "value" ).toInt() ); } else if( qName == "position" && _state == StateNumber ) { _state = StatePosition; _position->setCoord( _cpt, atts.value( "x" ).toInt(), atts.value( "y" ).toInt() ); _cpt++; } else { // error return false; } return true; } bool ArtefactsConfigurationHandler::endElement( const QString&, const QString&, const QString& ) { switch ( _state ) { case StateArtefact: _config->appendPosition( _position ); _state = StateDocument; break; case StateName: _state = StateArtefact; break; case StateNumber: _state = StateArtefact; break; case StatePosition: _state = StateNumber; break; default: // do nothing break; } return true; } bool ArtefactsConfigurationHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) return true; switch( _state ) { case StateName: _position->setName( ch_simplified ); break; default: return false; } return true; } bool ArtefactsConfigurationHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/lordArtefactsConfiguration.h0000644000175000017500000000667410335201564021105 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** lordArtefactsConfiguration.h ** Configuration of artefacts for lords ** ** Version : $Id: lordArtefactsConfiguration.h,v 1.3 2005/11/11 20:47:48 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef LORDARTEFACTSCONFIGURATION_H #define LORDARTEFACTSCONFIGURATION_H // generic include files // include files for QT #include #include #include // application specific include files class ArtefactPosition { public: /** Constructor */ ArtefactPosition(); /** Destructor */ virtual ~ArtefactPosition(); void setName( const QString & name ) { _name = name; } QString getName() { return _name; } /** nb = 0 -> infinite */ void setNumber( uint nb ); uint getNumber(); void setCoord( uint nb, uint x, uint y ); uint getCoordX( uint nb ); uint getCoordY( uint nb ); protected: QString _name; QList _coordX; QList _coordY; uint _nb; }; /* ------------------------------ * LordArtefactsConfiguration * ------------------------------ */ /** comment for the class */ class LordArtefactsConfiguration { public: /** Constructor */ LordArtefactsConfiguration(); /** Destructor */ virtual ~LordArtefactsConfiguration(); /* nb = 0 -> infinite */ void appendPosition( ArtefactPosition * position ); uint getNbPosition(); QString getPositionName( uint pos ); uint getPositionNumber( uint pos ); void setPositionCoord( uint pos, uint nb, uint x, uint y ); uint getPositionCoordX( uint pos, uint nb ); uint getPositionCoordY( uint pos, uint nb ); bool init(); void clear(); protected: QList _artefacts; }; /** Parser of artefact's position list */ class ArtefactsConfigurationHandler : public QXmlDefaultHandler { public: /** Construtor */ ArtefactsConfigurationHandler( LordArtefactsConfiguration * config ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: QString _errorProt; LordArtefactsConfiguration * _config; ArtefactPosition * _position; uint _cpt; enum State { StateInit, StateDocument, StateArtefact, StateName, StateNumber, StatePosition, }; State _state; }; #endif // LORDARTEFACTSCONFIGURATION_H attal-src-1.0-rc2/libCommon/lordCategoryModel.cpp0000644000175000017500000001706110616724407017532 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** lordCategoryModel.cpp ** Manages category of lord models ** ** Version : $Id: lordCategoryModel.cpp,v 1.16 2007/05/04 21:43:35 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 08/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "lordCategoryModel.h" // generic include files #include // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" extern QString DATA_PATH; // // ----- LordCategoryModel ----- // LordCategoryModel::LordCategoryModel() : _name( "" ), _description( "" ), _race( 0 ) { _attack = 1; _defense = 1; _power = 1; _knowledge = 1; _charisma = 1; } void LordCategoryModel::save( QTextStream & ts, int indent ) { indentation( &ts, indent ); ts << "" << endl; indentation( &ts, indent + 1 ); ts << "" << getName() << "" << endl; indentation( &ts, indent + 1 ); ts << "" << getName() << "" << endl; indentation( &ts, indent + 1 ); ts << "" << endl; indentation( &ts, indent + 2 ); ts << ""; ts << _attack << "" << endl; indentation( &ts, indent + 2 ); ts << ""; ts << _defense << "" << endl; indentation( &ts, indent + 2 ); ts << ""; ts << _power << "" << endl; indentation( &ts, indent + 2 ); ts << ""; ts << _knowledge << "" << endl; indentation( &ts, indent + 2 ); ts << ""; ts << _charisma << "" << endl; indentation( &ts, indent + 1 ); ts << "" << endl; indentation( &ts, indent ); ts << "" << endl; } void LordCategoryModel::setEvolution( LordCharac charac, uint value ) { switch( charac ) { case ATTACK: _attack = value; break; case DEFENSE: _defense = value; break; case POWER: _power = value;; break; case KNOWLEDGE: _knowledge = value; break; case CHARISMA: _charisma = value; break; default: break; } } uint LordCategoryModel::getEvolution( LordCharac charac ) { uint ret; switch( charac ) { case ATTACK: ret = _attack; break; case DEFENSE: ret = _defense; break; case POWER: ret = _power; break; case KNOWLEDGE: ret = _knowledge; break; case CHARISMA: ret = _charisma; break; default: ret = 0; } return ret; } LordCharac LordCategoryModel::getRandomEvolution() { LordCharac ret = ATTACK; uint sum = _attack + _defense + _power + _knowledge + _charisma; if( sum > 0 ) { uint alea = rand() % sum; if( alea < _attack ) { ret = ATTACK; } else if( alea < ( _attack + _defense ) ) { ret = DEFENSE; } else if( alea < ( _attack + _defense + _power ) ) { ret = POWER; } else if( alea < ( _attack + _defense + _power + _knowledge) ) { ret = KNOWLEDGE; } else { ret = CHARISMA; } } return ret; } // // ----- LordCategoryList ----- // LordCategoryList::LordCategoryList() { } LordCategoryList::~LordCategoryList() { clearList(); } bool LordCategoryList::init() { clearList(); LordCategoryHandler handler( this ); QString filename = "lordCategories.dat"; QFile file( DATA_PATH + filename ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + filename ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } bool LordCategoryList::save() { QString filename = DATA_PATH + "lordCategories.dat"; QFile file( filename ); if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writng\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; LordCategoryModel * category; for( int i = 0; i < count(); i++ ) { category = at( i ); if( category ) { category->save( ts, 1 ); } } ts << "" << endl; file.close(); return true; } bool LordCategoryList::remove( uint index ) { delete takeAt(index); return true; } void LordCategoryList::clearList() { while (!isEmpty()) { delete takeFirst(); } } // // ----- LordCategoryHandler ----- // LordCategoryHandler::LordCategoryHandler( LordCategoryList * list ) { _list = list; _category = 0; } LordCategoryHandler::~LordCategoryHandler() { } bool LordCategoryHandler::startDocument() { _errorProt = ""; _list->clearList(); _state = StateInit; return true; } bool LordCategoryHandler::startElement( const QString &, const QString &, const QString & qName, const QXmlAttributes & atts ) { if( qName == "lordCategories" && _state == StateInit ) { _state = StateDocument; } else if ( qName == "category" && _state == StateDocument ) { _state = StateCategory; _category = new LordCategoryModel(); _category->setRace( atts.value( "race" ).toUInt() ); } else if ( qName == "name" && _state == StateCategory ) { _state = StateName; } else if( qName == "description" && _state == StateCategory ) { _state = StateDescription; } else if( qName == "evolution" && _state == StateCategory ) { _state = StateEvolution; } else if( qName == "characteristic" && _state == StateEvolution ) { _state = StateCharac; charac = detectCharac( atts.value( "type" ) ); } else { // error return false; } return true; } bool LordCategoryHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateCategory: _state = StateDocument; _list->append( _category ); break; case StateName: _state = StateCategory; break; case StateDescription: _state = StateCategory; break; case StateEvolution: _state = StateCategory; break; case StateCharac: _state = StateEvolution; break; default: // do nothing break; } return true; } bool LordCategoryHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if( ch_simplified.isEmpty() ) { return true; } switch( _state ) { case StateName: _category->setName( ch_simplified ); break; case StateDescription: _category->setDescription( ch_simplified ); break; case StateCharac: _category->setEvolution( charac, ch_simplified.toUInt() ); break; default: return false; } return true; } bool LordCategoryHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/lordCategoryModel.h0000644000175000017500000000637410616724407017204 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** lordCategoryModel.h ** Manages category of lord models ** ** Version : $Id: lordCategoryModel.h,v 1.7 2007/05/04 21:43:35 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef LORDCATEGORYMODEL_H #define LORDCATEGORYMODEL_H // generic include files // include files for QT #include #include #include #include // application specific include files #include "libCommon/define.h" class LordCategoryModel { public: /** Constructor */ LordCategoryModel(); void save( QTextStream & ts, int indent ); const QString & getName() { return _name; } void setName( const QString & name ) { _name = name; } const QString & getDescription() { return _description; } void setDescription( const QString & description ) { _description = description; } /** set race of lord category */ void setRace( uint race ) { _race = race; } /** get race of lord category */ uint getRace() { return _race; } void setEvolution( LordCharac charac, uint value ); uint getEvolution( LordCharac charac ); LordCharac getRandomEvolution(); protected: QString _name, _description; uint _race; uint _attack, _defense, _power, _knowledge, _charisma; }; class LordCategoryList : public QList { public: LordCategoryList(); ~LordCategoryList(); /** Init list */ bool init(); /** Save on file */ bool save(); bool remove( uint index ); void clearList(); }; /** Parser for LordCategoryList */ class LordCategoryHandler : public QXmlDefaultHandler { public: /** this is the construtor */ LordCategoryHandler( LordCategoryList * list ); /** Destructor */ ~LordCategoryHandler(); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: QString _errorProt; LordCategoryList * _list; LordCategoryModel * _category; LordCharac charac; enum State { StateInit, StateDocument, StateCategory, StateName, StateDescription, StateEvolution, StateCharac }; State _state; }; #endif // LORDCATEGORYMODEL_H attal-src-1.0-rc2/libCommon/lordExperience.cpp0000644000175000017500000001115010522705152017044 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** lordExperience.cpp ** Manage the levels of experience ** ** Version : $Id: lordExperience.cpp,v 1.9 2006/11/03 18:28:58 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "lordExperience.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" extern QString DATA_PATH; LordExperience::LordExperience() { } bool LordExperience::save() { QString filename = DATA_PATH + "experience.dat"; QFile file( filename ); uint lastLevel = 0; if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writng\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; uint nbLevels = _levels.count(); for( uint i = 0; i < nbLevels; i++ ) { ts << "\t"; ts << ( _levels.at( i ) ) - lastLevel; ts << "" << endl; lastLevel = _levels.at( i ) ; } ts << "" << endl; file.close(); return true; } bool LordExperience::init() { clear(); LordExperienceHandler handler( this ); QString filename = DATA_PATH + "experience.dat"; QFile file( filename ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", filename.toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } void LordExperience::clear() { _levels.clear(); } uint LordExperience::getLevelNumber() { return _levels.count() + 1; } uint LordExperience::getLevel( uint num ) { uint ret = 0; if( ( num > 0 ) && ( num < (uint)_levels.count() + 1 ) ) { ret = _levels.at( num-1 ); } return ret; } void LordExperience::appendLevel( uint value ) { _levels.append( value ); } void LordExperience::appendLevelByDiff( uint diff ) { uint value = 0; if( _levels.count() > 0 ) { value = _levels.at( _levels.count() - 1 ); } _levels.append( diff + value ); } uint LordExperience::computeLevelForExperience( uint experience ) { uint ret; uint i; uint nbLevels = _levels.count(); ret = nbLevels; if( experience < ( _levels.at( 0 ) ) ) { ret = 0; } else { for( i = 1; i < nbLevels; i++ ) { if( ( experience < ( _levels.at( i ) ) ) && ( experience >= ( _levels.at( i-1 ) ) ) ) { ret = i; break; } } } return ret; } // // ----- LordExperienceHandler ----- // LordExperienceHandler::LordExperienceHandler( LordExperience * list ) { _list = list; } bool LordExperienceHandler::startDocument() { _errorProt = ""; _list->clear(); _state = StateInit; return true; } bool LordExperienceHandler::startElement( const QString &, const QString &, const QString& qName, const QXmlAttributes & ) { if( qName == "experience" && _state == StateInit ) { _state = StateDocument; } else if ( qName == "level" && _state == StateDocument ) { _state = StateLevel; } else { // error return false; } return true; } bool LordExperienceHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateLevel: _state = StateDocument; break; default: // do nothing break; } return true; } bool LordExperienceHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if( ch_simplified.isEmpty() ) { return true; } switch( _state ) { case StateLevel: _list->appendLevelByDiff( ch_simplified.toUInt() ); break; default: return false; } return true; } bool LordExperienceHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/lordExperience.h0000644000175000017500000000522710401044117016512 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** lordExperience.h ** Manage the levels of experience ** ** Version : $Id: lordExperience.h,v 1.4 2006/02/28 12:55:43 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef LORDEXPERIENCE_H #define LORDEXPERIENCE_H // generic include files // include files for QT #include #include // application specific include files /* ------------------------------ * LordExperience * ------------------------------ */ class LordExperience { public: /** Constructor */ LordExperience(); /** Save level of experience list */ bool save(); /** Init level of experience list */ bool init(); void clear(); uint getLevelNumber(); uint getLevel( uint num ); void appendLevel( uint value ); void appendLevelByDiff( uint diff ); uint computeLevelForExperience( uint experience ); protected: QList _levels; }; /* ------------------------------ * LordExperienceHandler * ------------------------------ */ class LordExperienceHandler : public QXmlDefaultHandler { public: /** Constructor */ LordExperienceHandler( LordExperience * list ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: LordExperience * _list; QString _errorProt, _name; enum State { StateInit, StateDocument, StateLevel, }; State _state; }; #endif // LORDEXPERIENCE_H attal-src-1.0-rc2/libCommon/parser.cpp0000644000175000017500000010417410751426402015403 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** parser.cpp ** Parser for scenarii and saved games. ** ** Version : $Id: parser.cpp,v 1.14 2008/02/03 21:07:14 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 04/02/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "parser.h" // generic include files // include files for QT #include #include // application specific include files #include "libCommon/artefact.h" #include "libCommon/artefactManager.h" #include "libCommon/dataTheme.h" #include "libCommon/gameData.h" #include "libCommon/genericInsideBuilding.h" #include "libCommon/genericBonus.h" #include "libCommon/genericBuilding.h" #include "libCommon/genericChest.h" #include "libCommon/genericEvent.h" #include "libCommon/genericPlayer.h" #include "libCommon/genericMap.h" #include "libCommon/genericMapCreature.h" #include "libCommon/log.h" #include "libCommon/unit.h" ScenarioParser::ScenarioParser( GameData * data ) { _data = data; _tempStream = 0; } ScenarioParser::~ScenarioParser() { if( _tempStream ) { delete _tempStream; } } bool ScenarioParser::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _player = 0; _state = StateInit; //_conditionStack.setAutoDelete( false ); _currentCondition = 0; return true; } bool ScenarioParser::startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ) { bool ret = true; if( qName == "scenario" && _state == StateInit ) { _state = StateDocument; _data->reinit(); _data->setNbPlayer( atts.value( "nbPlayer" ).toInt() ); } else if( qName == "attalversion" && _state == StateDocument ) { _state = StateAttalVersion; } else if( qName == "name" && _state == StateDocument ) { _state = StateName; } else if( qName == "theme" && _state == StateDocument ) { _state = StateTheme; } else if( qName == "description" && _state == StateDocument ) { _state = StateDescription; } else if( qName == "calendar" && _state == StateDocument ) { _state = StateCalendar; } else if( qName == "value" && _state == StateCalendar ) { _state = StateCalendarDate; _number = atts.value( "type" ).toInt(); } else if( qName == "startcalendar" && _state == StateCalendar ) { _state = StateCalendarStart; } else if( qName == "value" && _state == StateCalendarStart ) { _state = StateCalendarStartDate; _number = atts.value( "type" ).toInt(); } else if( qName == "turn" && _state == StateCalendar ) { _state = StateCalendarTurn; } else if( qName == "map" && _state == StateDocument ) { _state = StateMap; } else if( qName == "width" && _state == StateMap ) { _state = StateWidth; } else if ( qName == "height" && _state == StateMap ) { _state = StateHeight; } else if( qName == "base" && _state == StateDocument ) { _state = StateBase; _baseState = BaseStateInit; _row = 0; _col = 0; _baseId = -1; _baseType = 0; _baseName = ""; _base = _data->getNewBase(); } else if( _state == StateBase ) { ret = startElementBase( namespaceURI, localName, qName, atts ); } else if( qName == "building" && _state == StateDocument ) { _state = StateBuilding; _building = _data->getNewBuilding( atts.value( "type" ).toInt() ); _buildId = -1; _row = 0; _col = 0; } else if( qName == "id" && _state == StateBuilding ) { _state = StateBuildingId; } else if( qName == "col" && _state == StateBuilding ) { _state = StateBuildingCol; } else if( qName == "row" && _state == StateBuilding ) { _state = StateBuildingRow; } else if( qName == "resource" && _state == StateBuilding ) { _state = StateBuildingResource; _res = atts.value( "type" ).toInt(); } else if( qName == "creature" && _state == StateDocument ) { _state = StateCreature; _creature = _data->getNewMapCreature(); _row = 0; _col = 0; _race = 0; _level = 0; _number = 0; _behaviour = 2; _flee = false; _looking = false; } else if( qName == "col" && _state == StateCreature ) { _state = StateCreatureCol; } else if( qName == "row" && _state == StateCreature ) { _state = StateCreatureRow; } else if( qName == "race" && _state == StateCreature ) { _state = StateCreatureRace; } else if( qName == "level" && _state == StateCreature ) { _state = StateCreatureLevel; } else if( qName == "stack" && _state == StateCreature ) { _state = StateCreatureStack; _number = atts.value( "num" ).toInt(); } else if( qName == "behaviour" && _state == StateCreature ) { _state = StateCreatureBehaviour; } else if( qName == "growth" && _state == StateCreature ) { _state = StateCreatureGrowth; _creature->setGrowthMode( (GenericMapCreature::GrowthMode)atts.value( "type" ).toInt() ); _nbParam = 0; } else if( qName == "param" && _state == StateCreatureGrowth ) { _state = StateCreatureGrowthParam; } else if( qName == "flee" && _state == StateCreature ) { _state = StateCreatureFlee; } else if( qName == "lookingRight" && _state == StateCreature ) { _state = StateCreatureLooking; } else if( qName == "resource" && _state == StateCreature ) { _state = StateCreatureResource; _res = atts.value( "type" ).toInt(); } else if( qName == "lord" && _state == StateDocument ) { _state = StateLord; _lordState = LordStateInit; _row = 0; _col = 0; _posOk = false; _id = atts.value( "id" ).toInt(); _lord = _data->getLord( _id ); _lord->clearUnits(); } else if( _state == StateLord ) { ret = startElementLord( namespaceURI, localName, qName, atts ); } else if( qName == "player" && _state == StateDocument ) { _state = StatePlayer; _data->addPlayer(); if(_data->getPlayer( _player )){ _data->getPlayer( _player )->setNum( _player ); } } else if( qName == "name" && _state == StatePlayer ) { _state = StatePlayerName; } else if( qName == "ruledbyai" && _state == StatePlayer ) { _state = StatePlayerRuled; } else if( qName == "team" && _state == StatePlayer ) { _state = StatePlayerTeam; } else if( qName == "vision" && _state == StatePlayer ) { _state = StatePlayerVision; } else if( qName == "base" && _state == StatePlayer ) { _state = StatePlayerBase; } else if( qName == "building" && _state == StatePlayer ) { _state = StatePlayerBuilding; } else if( qName == "lord" && _state == StatePlayer ) { _state = StatePlayerLord; } else if( qName == "resource" && _state == StatePlayer ) { _state = StatePlayerResource; _res = atts.value( "type" ).toInt(); } else if( qName == "quests" && _state == StateDocument ) { _state = StateQuest; _questState = QuestInit; } else if( qName == "event" && _state == StateDocument ) { _state = StateEvent; _eventState = EventInit; _row = 0; _col = 0; GenericEvent::EventType type = (GenericEvent::EventType)atts.value( "type" ).toInt(); switch( type ) { case GenericEvent::EventArtefact: _event = _data->getNewArtefact(); break; case GenericEvent::EventBonus: _event = _data->getNewBonus(); break; case GenericEvent::EventChest: _event = _data->getNewChest(); break; default: ret = false; } } else if( _state == StateEvent ) { ret = startElementEvent( namespaceURI, localName, qName, atts ); } else if( _state == StateQuest ) { ret = startElementQuest( namespaceURI, localName, qName, atts ); } else { logEE( "Not found %s", qName.toLatin1().constData() ); return false; } return ret; } bool ScenarioParser::endElement( const QString& namespaceURI, const QString& localName, const QString& qName ) { bool ret = true; switch ( _state ) { case StateAttalVersion: _state = StateDocument; break; case StateName: _state = StateDocument; break; case StateTheme: _state = StateDocument; break; case StateDescription: _state = StateDocument; break; case StateCalendar: _state = StateDocument; break; case StateCalendarDate: _state = StateCalendar; break; case StateCalendarStart: _state = StateCalendar; break; case StateCalendarStartDate: _state = StateCalendarStart; break; case StateCalendarTurn: _state = StateCalendar; break; case StateMap: _data->loadMap( _tempStream, _width, _height ); _state = StateDocument; break; case StateWidth: _state = StateMap; break; case StateHeight: _state = StateMap; break; case StateBase: ret = endElementBase( namespaceURI, localName, qName ); break; case StateBuilding: _building->setPosition( _data->getCell( _row, _col ) ); if( _buildId < 0 ) { _building->setId( _data->getBuildingNumber()-1 ); } _state = StateDocument; break; case StateBuildingId: _building->setId( _buildId ); _state = StateBuilding; break; case StateBuildingCol: _state = StateBuilding; break; case StateBuildingRow: _state = StateBuilding; break; case StateBuildingResource: _state = StateBuilding; break; case StateCreature: _creature->setCreature( _race, _level ); _creature->setCell( _data->getCell( _row, _col ) ); _creature->setBehaviour( (GenericMapCreature::CreatureBehaviour)_behaviour ); _creature->setFleeing( _flee ); _creature->setLookingRight( _looking ); _data->getCell( _row, _col )->setCreature( _creature ); _state = StateDocument; break; case StateCreatureCol: _state = StateCreature; break; case StateCreatureRow: _state = StateCreature; break; case StateCreatureRace: _state = StateCreature; break; case StateCreatureLevel: _state = StateCreature; break; case StateCreatureStack: _state = StateCreature; break; case StateCreatureBehaviour: _state = StateCreature; break; case StateCreatureGrowth: _state = StateCreature; break; case StateCreatureGrowthParam: _state = StateCreatureGrowth; break; case StateCreatureFlee: _state = StateCreature; break; case StateCreatureLooking: _state = StateCreature; break; case StateCreatureResource: _state = StateCreature; break; case StateLord: ret = endElementLord( namespaceURI, localName, qName ); break; case StatePlayer: _player++; _state = StateDocument; break; case StatePlayerName: _state = StatePlayer; break; case StatePlayerRuled: _state = StatePlayer; break; case StatePlayerTeam: _state = StatePlayer; break; case StatePlayerVision: if( _data->getPlayer( _player ) ) { _data->getPlayer( _player )->loadVision( _tempStream , _width, _height ); } _state = StatePlayer; break; case StatePlayerBase: _state = StatePlayer; break; case StatePlayerBuilding: _state = StatePlayer; break; case StatePlayerLord: _state = StatePlayer; break; case StatePlayerResource: _state = StatePlayer; break; case StateQuest: ret = endElementQuest( namespaceURI, localName, qName ); break; case StateEvent: ret = endElementEvent( namespaceURI, localName, qName ); break; default: break; } return ret; } bool ScenarioParser::characters( const QString& ch ) { bool ret = true; QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) return true; switch( _state ) { case StateAttalVersion: _data->setAttalVersion( ch_simplified ); break; case StateName: _data->setScenarioName( ch_simplified ); break; case StateTheme: _data->setScenarioTheme( ch_simplified ); break; case StateDescription: _data->setScenarioDescription( ch_simplified ); break; case StateCalendar: break; case StateCalendarDate: _data->setDateByType( _number, ch_simplified.toInt() ); break; case StateCalendarStart: break; case StateCalendarStartDate: _data->setInitialDateByType( _number, ch_simplified.toInt() ); break; case StateCalendarTurn: _data->setTurn( ch_simplified.toInt() ); break; case StateMap: delete _tempStream; _tempStream = new QTextStream( ch_simplified.toLatin1() ); break; case StateWidth: _width = ch_simplified.toInt(); break; case StateHeight: _height = ch_simplified.toInt(); break; case StateBase: ret = charactersBase( ch_simplified ); break; case StateBuilding: break; case StateBuildingId: _buildId = ch_simplified.toInt(); break; case StateBuildingCol: _col = ch_simplified.toInt(); break; case StateBuildingRow: _row = ch_simplified.toInt(); break; case StateBuildingResource: _building->getResourceList()->setValue( _res, ch_simplified.toInt() ); break; case StateCreatureCol: _col = ch_simplified.toInt(); break; case StateCreatureRow: _row = ch_simplified.toInt(); break; case StateCreatureRace: _race = ch_simplified.toInt(); break; case StateCreatureLevel: _level = ch_simplified.toInt(); break; case StateCreatureStack: _creature->setStack( _number, ch_simplified.toInt() ); break; case StateCreatureBehaviour: _behaviour = ch_simplified.toInt(); break; case StateCreatureGrowth: _creature->setGrowthMode( (GenericMapCreature::GrowthMode)ch_simplified.toInt() ); break; case StateCreatureGrowthParam: _creature->setGrowthParam( _nbParam, ch_simplified.toInt() ); _nbParam++; break; case StateCreatureFlee: _flee = (bool) ch_simplified.toInt(); break; case StateCreatureLooking: _looking = (bool) ch_simplified.toInt(); break; case StateCreatureResource: _creature->getResourceList()->setValue( _res, ch_simplified.toInt() ); break; case StatePlayerName: if( _data->getPlayer( _player ) ) { _data->getPlayer( _player )->setName( ch_simplified ); } break; case StatePlayerRuled: if( _data->getPlayer( _player ) ) { _data->getPlayer( _player )->setRuledByAi( ch_simplified.toInt() ); } break; case StatePlayerTeam: if( _data->getPlayer( _player ) ) { _data->getPlayer( _player )->setTeam( ch_simplified.toInt() ); } break; case StatePlayerBase: _data->setBase2Player( ch_simplified.toInt(), _player ); break; case StatePlayerVision: delete _tempStream; _tempStream = new QTextStream( ch_simplified.toLatin1() ); break; case StatePlayerBuilding: _data->setBuilding2Player( ch_simplified.toInt(), _player ); break; case StatePlayerLord: _data->setLord2Player( ch_simplified.toInt(), _player ); break; case StatePlayerResource: if( _data->getPlayer( _player ) ) { _data->getPlayer( _player )->getResourceList()->setValue( _res, ch_simplified.toInt() ); } break; case StateLord: ret = charactersLord( ch_simplified ); break; case StateQuest: ret = charactersQuest( ch_simplified ); break; case StateEvent: ret = charactersEvent( ch_simplified ); break; default: ret = false; } return ret; } // Parsing of Lords bool ScenarioParser::startElementLord( const QString &, const QString &, const QString & qName, const QXmlAttributes & atts ) { if( qName == "col" && _lordState == LordStateInit ) { _lordState = LordStateCol; } else if( qName == "row" && _lordState == LordStateInit ) { _lordState = LordStateRow; } else if( qName == "characteristic" && _lordState == LordStateInit ) { _lordState = LordStateCharac; _charac = detectCharac( atts.value( "type" ) ); } else if( qName == "unit" && _lordState == LordStateInit ) { _lordState = LordStateUnit; _pos = atts.value( "pos" ).toInt(); _unit = new GenericFightUnit(); _race = 0; _level = 0; } else if( qName == "race" && _lordState == LordStateUnit ) { _lordState = LordStateUnitRace; } else if( qName == "level" && _lordState == LordStateUnit ) { _lordState = LordStateUnitLevel; } else if( qName == "number" && _lordState == LordStateUnit ) { _lordState = LordStateUnitNumber; } else if( qName == "move" && _lordState == LordStateUnit ) { _lordState = LordStateUnitMove; } else if( qName == "health" && _lordState == LordStateUnit ) { _lordState = LordStateUnitHealth; } else if( qName == "artefact" && _lordState == LordStateInit ) { _lordState = LordStateArtefact; _pos = 0; _lordArtefact = new GenericLordArtefact(); _lordArtefact->setType( atts.value( "type" ).toInt() ); } else if( qName == "position" && _lordState == LordStateArtefact ) { _lordState = LordStateArtefactPosition; } else if( qName == "machine" && _lordState == LordStateInit ) { _lordState = LordStateMachine; } else { logEE( "Not found %s", qName.toLatin1().constData() ); return false; } return true; } bool ScenarioParser::endElementLord( const QString &, const QString &, const QString & ) { switch ( _lordState ) { case LordStateInit: _state = StateDocument; if( _posOk ) { _lord->setCell( _data->getCell( _row, _col ) ); } break; case LordStateCol: _lordState = LordStateInit; _posOk = true; break; case LordStateRow: _lordState = LordStateInit; _posOk = true; break; case LordStateCharac: _lordState = LordStateInit; break; case LordStateUnit: _unit->setCreature( _race, _level ); _lord->setUnit( _pos, _unit ); _lordState = LordStateInit; break; case LordStateUnitRace: //_unit->setCreature( _type ); _lordState = LordStateUnit; break; case LordStateUnitLevel: _lordState = LordStateUnit; break; case LordStateUnitNumber: _unit->setNumber( _number ); _lordState = LordStateUnit; break; case LordStateUnitMove: _unit->setMove( _move ); _lordState = LordStateUnit; break; case LordStateUnitHealth: _unit->setHealth( _health ); _lordState = LordStateUnit; break; case LordStateArtefact: _lord->getArtefactManager()->addArtefact( _lordArtefact ); _lordArtefact->setLord( _lord ); _lordState = LordStateInit; break; case LordStateArtefactPosition: _lordState = LordStateArtefact; break; case LordStateMachine: _lordState = LordStateInit; _lord->addMachine( _machine ); break; default: break; } return true; } bool ScenarioParser::charactersLord( const QString& ch ) { bool ret = true; switch( _lordState ) { case LordStateCol: _col = ch.toInt(); break; case LordStateRow: _row = ch.toInt(); break; case LordStateCharac: _lord->setBaseCharac( _charac, ch.toInt() ); break; case LordStateUnitRace: _race = ch.toInt(); break; case LordStateUnitLevel: _level = ch.toInt(); break; case LordStateUnitNumber: _number = ch.toInt(); break; case LordStateUnitMove: _move = ch.toInt(); break; case LordStateUnitHealth: _health = ch.toInt(); break; case LordStateArtefactPosition: _lordArtefact->setPosition( ch.toInt() ); break; case LordStateMachine: _machine = ch.toInt(); break; default: ret = false; } return ret; } // Parsing of Bases bool ScenarioParser::startElementBase( const QString &, const QString &, const QString & qName, const QXmlAttributes & atts ) { if( qName == "type" && _baseState == BaseStateInit ) { _baseState = BaseStateType; } else if( qName == "name" && _baseState == BaseStateInit ) { _baseState = BaseStateName; } else if( qName == "id" && _baseState == BaseStateInit ) { _baseState = BaseStateId; } else if( qName == "col" && _baseState == BaseStateInit ) { _baseState = BaseStateCol; } else if( qName == "row" && _baseState == BaseStateInit ) { _baseState = BaseStateRow; } else if( qName == "resource" && _baseState == BaseStateInit ) { _baseState = BaseStateResource; _res = atts.value( "type" ).toInt(); } else if( qName == "building" && _baseState == BaseStateInit ) { _baseState = BaseStateBuilding; } else if( qName == "forbidden" && _baseState == BaseStateInit ) { _baseState = BaseStateForbidden; } else if( qName == "unit" && _baseState == BaseStateInit ) { _baseState = BaseStateUnit; _pos = atts.value( "pos" ).toInt(); _unit = new GenericFightUnit(); _race = 0; _level = 0; } else if( qName == "race" && _baseState == BaseStateUnit ) { _baseState = BaseStateUnitRace; } else if( qName == "level" && _baseState == BaseStateUnit ) { _baseState = BaseStateUnitLevel; } else if( qName == "number" && _baseState == BaseStateUnit ) { _baseState = BaseStateUnitNumber; } else if( qName == "move" && _baseState == BaseStateUnit ) { _baseState = BaseStateUnitMove; } else if( qName == "health" && _baseState == BaseStateUnit ) { _baseState = BaseStateUnitHealth; } else if( qName == "available" && _baseState == BaseStateInit ) { _baseState = BaseStateProduction; } else if( qName == "unit" && _baseState == BaseStateProduction ) { _baseState = BaseStateProductionUnit; _race = 0; _level = 0; _number = 0; } else if( qName == "race" && _baseState == BaseStateProductionUnit ) { _baseState = BaseStateProductionUnitRace; } else if( qName == "level" && _baseState == BaseStateProductionUnit ) { _baseState = BaseStateProductionUnitLevel; } else if( qName == "number" && _baseState == BaseStateProductionUnit ) { _baseState = BaseStateProductionUnitNumber; } else { logEE( "Not found %s", qName.toLatin1().constData() ); return false; } return true; } bool ScenarioParser::endElementBase( const QString &, const QString &, const QString & ) { switch ( _baseState ) { case BaseStateInit: _state = StateDocument; _base->setName( _baseName ); _base->setPosition( _data->getCell( _row, _col ) ); //used for compatibility with old scenarios if( _baseId < 0 ) { _base->setId( _data->getBaseNumber()-1 ); } break; case BaseStateId: _base->setId( _baseId ); _baseState = BaseStateInit; break; case BaseStateType: _baseState = BaseStateInit; break; case BaseStateName: _baseState = BaseStateInit; break; case BaseStateCol: _baseState = BaseStateInit; break; case BaseStateRow: _baseState = BaseStateInit; break; case BaseStateBuilding: { GenericInsideBuilding * building = new GenericInsideBuilding(); building->setRace( _baseType ); building->setLevel( _id ); _base->addBuilding( building ); _baseState = BaseStateInit; } break; case BaseStateForbidden: _baseState = BaseStateInit; break; case BaseStateUnit: _unit->setCreature( _race, _level ); _base->setUnit( _pos, _unit ); _baseState = BaseStateInit; break; case BaseStateUnitRace: //_unit->setCreature( _type ); _baseState = BaseStateUnit; break; case BaseStateUnitLevel: _baseState = BaseStateUnit; break; case BaseStateUnitNumber: _unit->setNumber( _number ); _baseState = BaseStateUnit; break; case BaseStateUnitMove: _unit->setMove( _move ); _baseState = BaseStateUnit; break; case BaseStateUnitHealth: _unit->setHealth( _health ); _baseState = BaseStateUnit; break; case BaseStateProductionUnitRace: _baseState = BaseStateProductionUnit; break; case BaseStateProductionUnitLevel: _baseState = BaseStateProductionUnit; break; case BaseStateProductionUnitNumber: _baseState = BaseStateProductionUnit; break; case BaseStateProductionUnit: _base->addCreature( _race, _level, _number ); _baseState = BaseStateProduction; break; case BaseStateProduction: _baseState = BaseStateInit; break; case BaseStateResource: _baseState = BaseStateInit; break; default: break; } return true; } bool ScenarioParser::charactersBase( const QString& ch ) { bool ret = true; switch( _baseState ) { case BaseStateType: _baseType = ch.toInt(); //XXX: workaround to race set in costructor _base->setRace( _baseType ); break; case BaseStateId: _baseId = ch.toInt(); break; case BaseStateName: _baseName = ch; break; case BaseStateCol: _col = ch.toInt(); break; case BaseStateRow: _row = ch.toInt(); break; case BaseStateBuilding: _id = ch.toInt(); break; case BaseStateForbidden: _base->addForbiddenBuilding( ch.toInt() ); break; case BaseStateUnitRace: _race = ch.toInt(); break; case BaseStateUnitLevel: _level = ch.toInt(); break; case BaseStateUnitNumber: _number = ch.toInt(); break; case BaseStateUnitMove: _move = ch.toInt(); break; case BaseStateUnitHealth: _health = ch.toInt(); break; case BaseStateProductionUnitRace: _race = ch.toInt(); break; case BaseStateProductionUnitLevel: _level = ch.toInt(); break; case BaseStateProductionUnitNumber: _number = ch.toInt(); break; case BaseStateResource: _base->getResourceList()->setValue( _res, ch.toInt() ); break; default: ret = false; } return ret; } // Parsing of Events bool ScenarioParser::startElementEvent( const QString &, const QString &, const QString& qName, const QXmlAttributes& atts ) { if( qName == "row" && _eventState == EventInit ) { _eventState = EventRow; } else if( qName == "col" && _eventState == EventInit ) { _eventState = EventCol; } else if( qName == "artefact" && _eventState == EventInit ) { _eventState = EventArtefact; _event->getArtefact()->setType( atts.value( "type" ).toInt() ); } else if( qName == "bonus" && _eventState == EventInit ) { _eventState = EventBonus; _event->getBonus()->setType( (GenericBonus::BonusType) atts.value( "type" ).toInt() ); } else if( qName == "param" && _eventState == EventBonus ) { _eventState = EventBonusParam; } else if( qName == "chest" && _eventState == EventInit ) { _eventState = EventChest; } else if( qName == "param" && _eventState == EventChest ) { _eventState = EventChestParam; } else { logEE( "Not found %s", qName.toLatin1().constData() ); return false; } return true; } bool ScenarioParser::endElementEvent( const QString &, const QString &, const QString & ) { switch ( _eventState ) { case EventInit: _event->setCell( _data->getCell( _row, _col ) ); _data->getCell( _row, _col )->setEvent( _event ); _state = StateDocument; break; case EventRow: _eventState = EventInit; break; case EventCol: _eventState = EventInit; break; case EventArtefact: _eventState = EventInit; break; case EventBonus: _event->getBonus()->setupBonus(); _eventState = EventInit; break; case EventBonusParam: _eventState = EventBonus; break; case EventChest: _eventState = EventInit; break; case EventChestParam: _eventState = EventChest; break; default: break; } return true; } bool ScenarioParser::charactersEvent( const QString& ch ) { bool ret = true; switch( _eventState ) { case EventRow: _row = ch.toInt(); break; case EventCol: _col = ch.toInt(); break; case EventBonusParam: _event->getBonus()->addParam( ch.toInt() ); break; case EventChestParam: _event->getChest()->addParam( ch.toInt() ); break; default: ret = false; } return ret; } // Parsing of Quests bool ScenarioParser::startElementQuest( const QString &, const QString &, const QString & qName, const QXmlAttributes & atts ) { if( qName == "quest" && _questState == QuestInit ) { _questState = QuestQuest; if( atts.value( "type" ) == "main" ) { _quest = _data->getMainQuest(); } else { _quest = _data->getNewQuest(); } } else if( qName == "name" && _questState == QuestQuest ) { _questState = QuestName; } else if( qName == "description" && _questState == QuestQuest ) { _questState = QuestDescription; } else if( qName == "confirmation" && _questState == QuestQuest ) { _questState = QuestConfirmation; } else if( qName == "start" && _questState == QuestQuest ) { _questState = QuestStart; } else if( qName == "message" && ( _questState == QuestStart || _questState == QuestFail || _questState == QuestSuccess ) ) { _oldQuestState = _questState; _questState = QuestStartEndMessage; } else if( qName == "agree" && _questState == QuestStart ) { _questState = QuestStartAgree; } else if( qName == "disagree" && _questState == QuestStart ) { _questState = QuestStartDisagree; } else if( qName == "arg" && ( _questState == QuestStart || _questState == QuestFail || _questState == QuestSuccess ) ) { _oldQuestState = _questState; _questState = QuestStartEndArg; } else if( qName == "condition" && ( _questState == QuestStart || _questState == QuestFail || _questState == QuestSuccess ) ) { _oldQuestState = _questState; _questState = QuestDefCondition; _conditionStack.clear(); _currentCondition = 0; manageCondition( atts.value( "type" ) ); } else if( qName == "condition" && _questState == QuestDefCondition ) { manageCondition( atts.value( "type" ) ); } else if( qName == "param" && _questState == QuestDefCondition ) { _questState = QuestConditionParam; } else if( qName == "fail" && _questState == QuestQuest ) { _questState = QuestFail; } else if( qName == "success" && _questState == QuestQuest ) { _questState = QuestSuccess; } else if( qName == "message" && _questState == QuestQuest ) { _questState = QuestMessage; } else { logEE( "Not found %s", qName.toLatin1().constData() ); return false; } return true; } void ScenarioParser::manageCondition( const QString & type ) { _params.clear(); if( _currentCondition ) { _conditionStack.push( (QuestConditionComposite *)_currentCondition ); } if( type == "composite" ) { _currentCondition = new QuestConditionComposite(); } else if( type == "lord" ) { _currentCondition = new QuestConditionLord(); } else if( type == "date" ) { _currentCondition = new QuestConditionDate(); } else if( type == "player" ) { _currentCondition = new QuestConditionPlayer(); } if( _conditionStack.isEmpty() ) { switch( _oldQuestState ) { case QuestStart: _quest->setStartCondition( _currentCondition ); break; case QuestFail: _quest->setFailCondition( _currentCondition ); break; case QuestSuccess: _quest->setSuccessCondition( _currentCondition ); break; default: logEE( "Should not happen" ); } } else { _conditionStack.top()->addCondition( _currentCondition ); } } bool ScenarioParser::endElementQuest( const QString &, const QString &, const QString & ) { switch ( _questState ) { case QuestInit: _state = StateDocument; break; case QuestQuest: _questState = QuestInit; break; case QuestName: _questState = QuestQuest; break; case QuestDescription: _questState = QuestQuest; break; case QuestConfirmation: _questState = QuestQuest; break; case QuestStart: _questState = QuestQuest; break; case QuestStartEndMessage: _questState = _oldQuestState; break; case QuestStartAgree: _questState = QuestStart; break; case QuestStartDisagree: _questState = QuestStart; break; case QuestStartEndArg: _questState = _oldQuestState; break; case QuestDefCondition: if( _conditionStack.isEmpty() ) { _questState = _oldQuestState; } else { _currentCondition = _conditionStack.pop(); } break; case QuestConditionParam: _questState = QuestDefCondition; break; case QuestFail: _questState = QuestQuest; break; case QuestSuccess: _questState = QuestQuest; break; case QuestMessage: _questState = QuestQuest; break; default: break; } return true; } bool ScenarioParser::charactersQuest( const QString& ch ) { bool ret = true; switch( _questState ) { case QuestName: _quest->setName( ch ); break; case QuestDescription: _quest->setDescription( ch ); break; case QuestConfirmation: _quest->setConfirmationNeeded( true ); _quest->setConfirmationQuestion( ch ); break; case QuestStartEndMessage: break; case QuestStartAgree: break; case QuestStartDisagree: break; case QuestStartEndArg: break; case QuestDefCondition: break; case QuestConditionParam: manageConditionParam( ch ); break; case QuestQuest: break; case QuestFail: break; case QuestSuccess: break; case QuestMessage: break; default: ret = false; } return ret; } void ScenarioParser::manageConditionParam( const QString & param ) { switch( _currentCondition->getType() ) { case QuestCondition::COMPOSITE: if( param == "OR" ) { ( ( QuestConditionComposite * ) _currentCondition )->setCompositeType( QuestConditionComposite::OR ); } else { ( ( QuestConditionComposite * ) _currentCondition )->setCompositeType( QuestConditionComposite::AND ); } break; case QuestCondition::DATE: _params.append( param.toUInt() ); switch( (QuestConditionDate::ConditionCategory) _params[ 0 ] ) { case QuestConditionDate::DATE: if( _params.count() == 5 ) { ( ( QuestConditionDate * ) _currentCondition )->setConditionDate( _params[1], _params[2], _params[3], _params[4] ); } break; case QuestConditionDate::DELAY: if( _params.count() == 2 ) { ( ( QuestConditionDate * ) _currentCondition )->setConditionDelay( _params[ 1 ] ); } break; default: break; } break; case QuestCondition::LORD: _params.append( param.toUInt() ); switch( (QuestConditionLord::ConditionCategory) _params[ 0 ] ) { case QuestConditionLord::ARTEFACT: if( _params.count() == 3 ) { ( ( QuestConditionLord * ) _currentCondition )->setArtefactCondition( _params[ 1 ], (bool)_params[ 2 ] ); } break; case QuestConditionLord::PRIMARY_SKILL: if( _params.count() == 4 ) { ( ( QuestConditionLord * ) _currentCondition )->setPrimarySkillCondition( (LordCharac)_params[1], (QuestCondition::CheckType)_params[2], _params[3] ); } break; case QuestConditionLord::NB_CREATURES: if( _params.count() == 3 ) { ( ( QuestConditionLord * ) _currentCondition )->setNumberCondition( (QuestCondition::CheckType)_params[1], _params[2] ); } break; default: break; } break; case QuestCondition::PLAYER: if( _params.count() == 0 ) { _params.append( param.toUInt() ); } else { switch( (QuestConditionPlayer::ConditionCategory) _params[ 0 ] ) { case QuestConditionPlayer::NB_LORD: if( _params.count() == 1 ) { _params.append( param.toUInt() ); } else { ( ( QuestConditionPlayer * ) _currentCondition )->setNbBaseCondition( (QuestCondition::CheckType)_params[ 1 ], param.toUInt() ); } break; case QuestConditionPlayer::NB_BASE: if( _params.count() == 1 ) { _params.append( param.toUInt() ); } else { ( ( QuestConditionPlayer * ) _currentCondition )->setNbBaseCondition( (QuestCondition::CheckType)_params[ 1 ], param.toUInt() ); } break; case QuestConditionPlayer::BASENAME: ( ( QuestConditionPlayer * ) _currentCondition )->setBasenameCondition( param ); break; } } break; } } bool ScenarioParser::fatalError( const QXmlParseException& exception ) { logEE( "state %d, lordState %d, baseState %d, questState %d, eventState %d", _state, _lordState, _baseState, _questState, _eventState ); _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/parser.h0000644000175000017500000001457710740430047015055 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** parser.h ** Parser for scenarii and saved games. ** ** Version : $Id: parser.h,v 1.7 2008/01/07 13:59:03 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 04/02/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PARSER_H #define PARSER_H // generic include files // include files for QT #include #include #include #include // application specific include files #include "libCommon/genericLord.h" #include "libCommon/quest.h" enum ScenarioState { StateInit, StateDocument, StateAttalVersion, StateName, StateTheme, StateDescription, StateCalendar, StateCalendarDate, StateCalendarStart, StateCalendarStartDate, StateCalendarTurn, StateMap, StateWidth, StateHeight, StateBase, StateCreature, StateCreatureCol, StateCreatureRow, StateCreatureRace, StateCreatureLevel, StateCreatureStack, StateCreatureBehaviour, StateCreatureGrowth, StateCreatureGrowthParam, StateCreatureFlee, StateCreatureLooking, StateCreatureResource, StateBuilding, StateBuildingId, StateBuildingCol, StateBuildingRow, StateBuildingResource, StateLord, StateEvent, StateQuest, StatePlayer, StatePlayerName, StatePlayerVision, StatePlayerRuled, StatePlayerTeam, StatePlayerBase, StatePlayerBuilding, StatePlayerLord, StatePlayerResource }; /* ------------------------------ * ScenarioParser * ------------------------------ */ class GameData; class Calendar; class GenericArtefact; class GenericBase; class GenericBonus; class GenericBuilding; class GenericChest; class GenericEvent; class GenericFightUnit; class GenericLord; class GenericMapCreature; /** comment for the class */ class ScenarioParser : public QXmlDefaultHandler { public: /** Constructor */ ScenarioParser( GameData * data ); /** Destructor */ virtual ~ScenarioParser(); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); bool startElementLord( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); bool startElementBase( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); bool startElementQuest( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); bool startElementEvent( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); bool endElementLord( const QString& namespaceURI, const QString& localName, const QString& qName ); bool endElementBase( const QString& namespaceURI, const QString& localName, const QString& qName ); bool endElementQuest( const QString& namespaceURI, const QString& localName, const QString& qName ); bool endElementEvent( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); bool charactersLord( const QString& ch ); bool charactersBase( const QString& ch ); bool charactersQuest( const QString& ch ); bool charactersEvent( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); protected: void manageCondition( const QString & type ); void manageConditionParam( const QString & param ); private: GameData * _data; QTextStream * _tempStream; QString _errorProt; Calendar * _calendar; GenericBase * _base; GenericBuilding * _building; GenericLord * _lord; GenericMapCreature * _creature; Quest * _quest; GenericFightUnit * _unit; GenericEvent * _event; GenericArtefact * _artefact; GenericLordArtefact * _lordArtefact; QuestCondition * _currentCondition; QStack _conditionStack; QList _params; LordCharac _charac; int _height, _width; int _id, _row, _col, _pos, _baseType, _baseId, _buildId; int _number, _move, _health; int _behaviour; bool _flee, _looking; int _race, _level, _res; int _machine; QString _type, _baseName; int _player; bool _posOk; uint _nbParam; enum LordState { LordStateInit, LordStateCol, LordStateRow, LordStateCharac, LordStateUnit, LordStateUnitRace, LordStateUnitLevel, LordStateUnitNumber, LordStateUnitMove, LordStateUnitHealth, LordStateArtefact, LordStateArtefactPosition, LordStateMachine }; enum BaseState { BaseStateInit, BaseStateId, BaseStateType, BaseStateName, BaseStateResource, BaseStateBuilding, BaseStateForbidden, BaseStateCol, BaseStateRow, BaseStateUnit, BaseStateUnitRace, BaseStateUnitLevel, BaseStateUnitNumber, BaseStateUnitMove, BaseStateUnitHealth, BaseStateProduction, BaseStateProductionUnit, BaseStateProductionUnitRace, BaseStateProductionUnitLevel, BaseStateProductionUnitNumber }; enum QuestState { QuestInit, QuestQuest, QuestName, QuestConfirmation, QuestDescription, QuestStart, QuestFail, QuestSuccess, QuestStartEndMessage, QuestStartAgree, QuestStartDisagree, QuestStartEndArg, QuestDefCondition, QuestConditionParam, QuestAction, QuestMessage }; enum EventState { EventInit, EventRow, EventCol, EventArtefact, EventBonus, EventBonusParam, EventChest, EventChestParam }; ScenarioState _state; LordState _lordState; BaseState _baseState; QuestState _questState, _oldQuestState; EventState _eventState; }; #endif // PARSER_H attal-src-1.0-rc2/libCommon/pathFinder.cpp0000644000175000017500000002626510644672214016204 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** pathFinder.cpp ** Compute pathes in the map ** ** Version : $Id: pathFinder.cpp,v 1.10 2007/07/10 11:59:08 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "pathFinder.h" // generic include files #include #include // include files for QT // application specific includes /** */ PathFinder::PathFinder() { _width = 0; _height = 0; } PathFinder::PathFinder( int w, int h, GenericMap * m ) { newMap( h, w, m ); } /** free the table */ PathFinder::~PathFinder() { clear(); } GenericCell * PathFinder::getStartCell() { GenericCell * ret = 0; if( _start ) { ret = _start->cell; } return ret; } void PathFinder::newMap( int h, int w, GenericMap * m ) { _width = w; _height = h; _start = 0; int i; _table = new PathCell *[h]; for( i = 0; i < h; i++ ) { _table[i] = new PathCell[w]; } for( i = 0; i < h; i++ ) { for( int j = 0; j < w; j++ ) { _table[i][j].cell = m->at( i, j ); _table[i][j].prev = 0; _table[i][j].dist = 0; } } } void PathFinder::reinit( GenericMap * ) { /// XXX: remove map or used in overload ? _start = 0; for( int i = 0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { _table[i][j].prev = 0; _table[i][j].dist = 0; } } } void PathFinder::clear() { // XXX: delete [][] for( int i = 0; i < _height; i++ ) { delete [] _table[i] ; } if( _height > 0 ) delete [] _table; _height = 0; _width = 0; } void PathFinder::compute( Pile * p, GenericCell * c, PathCell * work, int cost ) { //if( c && ( c->getCoeff() >= 0 ) && ( c->isFree() ) ) { //if( c && ( c->getCoeff() >= 0 ) && c->isStoppable() ) { if( c && ( c->getCoeff() > 0 ) && c->isStoppable() && c->isFree() ) { if( (_table[c->getRow()][c->getCol()].dist == 0) || ( ( std::max(work->dist,0) + c->getCoeff() + cost ) < _table[c->getRow()][c->getCol()].dist ) ) { _table[c->getRow()][c->getCol()].dist = ( std::max(work->dist,0) + c->getCoeff() + cost ); _table[c->getRow()][c->getCol()].prev = work; if( p->indexOf( &_table[c->getRow()][c->getCol()] ) == -1 ) { p->append( &_table[c->getRow()][c->getCol()] ); } } } } void PathFinder::computePath( GenericCell * start ) { if( ! start ) { logEE( "computePath on a NULL genericCell..." ); return; } _start = &_table[start->getRow()][start->getCol()]; _start->dist = 0;//-1; Pile pile; PathCell * work; GenericCell * neighbour; int row, col; pile.append( _start ); while( pile.count() > 0 ) { work = pile.takeSmallest(); row = work->cell->getRow(); col = work->cell->getCol(); if( col > 0 ) { neighbour = _table[row][col-1].cell; compute( &pile, neighbour, work, COST_DIRECT ); if( row > 0 ) { neighbour = _table[row-1][col-1].cell; compute( &pile, neighbour, work, COST_DIAG ); } if( row < _height-1 ) { neighbour = _table[row+1][col-1].cell; compute( &pile, neighbour, work, COST_DIAG ); } } if( col < _width - 1 ) { neighbour = _table[row][col+1].cell; compute( &pile, neighbour, work, COST_DIRECT ); if( row > 0 ) { neighbour = _table[row-1][col+1].cell; compute( &pile, neighbour, work, COST_DIAG ); } if( row < _height-1 ) { neighbour = _table[row+1][col+1].cell; compute( &pile, neighbour, work, COST_DIAG ); } } if( row > 0 ) { neighbour = _table[row-1][col].cell; compute( &pile, neighbour, work, COST_DIRECT ); } if( row < _height - 1 ) { neighbour = _table[row+1][col].cell; compute( &pile, neighbour, work, COST_DIRECT ); } } } bool PathFinder::isPath( GenericCell * dest ) { if( _start && ( _start->cell == dest ) ) { return true; } if( _table[dest->getRow()][dest->getCol()].dist <= 0 ) { return false; } return true; } int PathFinder::getDist( GenericCell * dest ) { return _table[dest->getRow()][dest->getCol()].dist; } bool PathFinder::isNearPath( GenericCell * dest ) { bool ret = false; if( dest->getCoeff() > 0 ) { int row = dest->getRow(); int col = dest->getCol(); if( row > 0 ) { ret = ret || isPath( _table[row-1][col].cell ); if( col > 0 ) ret = ret || isPath( _table[row-1][col-1].cell ); if( col < _width - 1 ) ret = ret || isPath( _table[row-1][col+1].cell ); } if( col > 0 ) ret = ret || isPath( _table[row][col-1].cell ); if( col < _width - 1 ) ret = ret || isPath( _table[row][col+1].cell ); if( row < _height - 1 ) { ret = ret || isPath( _table[row+1][col].cell ); if( col > 0 ) ret = ret || isPath( _table[row+1][col-1].cell ); if( col < _width - 1 ) ret = ret || isPath( _table[row+1][col+1].cell ); } } return ret; } QStack * PathFinder::giveCells( GenericCell * dest ) { if( !isPath( dest ) ) return 0; QStack * ret = new QStack; PathCell * cur; int i=0; cur = & _table[dest->getRow()][dest->getCol()]; ret->push( cur->cell ); while( cur != _start ) { i++; cur = cur->prev; ret->push( cur->cell ); } return ret; } QStack * PathFinder::giveNearCells( GenericCell * dest ) { if( !isNearPath( dest ) ) { return 0; } return( giveCells( getNearCell( dest ) ) ); } GenericCell * PathFinder::getNearCell( GenericCell * dest ) { PathCell temp; temp.dist = -1; int row = dest->getRow(); int col = dest->getCol(); if( row > 0 ) { if( isPath( _table[row-1][col].cell ) ) { if( temp.dist != -1 ) { if( _table[row-1][col].dist < temp.dist ) temp = _table[row-1][col]; } else { temp = _table[row-1][col]; } } if( col > 0 ) { if( isPath( _table[row-1][col-1].cell ) ) { if( temp.dist != -1 ) { if( _table[row-1][col-1].dist < temp.dist ) temp = _table[row-1][col-1]; } else temp = _table[row-1][col-1]; } } if( col < _width - 1 ) if( isPath( _table[row-1][col+1].cell ) ) { if( temp.dist != -1 ) { if( _table[row-1][col+1].dist < temp.dist ) temp = _table[row-1][col+1]; } else temp = _table[row-1][col+1]; } } if( col > 0 ) if( isPath( _table[row][col-1].cell ) ) { if( temp.dist != -1 ) { if( _table[row][col-1].dist < temp.dist ) temp = _table[row][col-1]; } else temp = _table[row][col-1]; } if( col < _width - 1 ) if( isPath( _table[row][col+1].cell ) ) { if( temp.dist != -1 ) { if( _table[row][col+1].dist < temp.dist ) temp = _table[row][col+1]; } else temp = _table[row][col+1]; } if( row < _height - 1 ) { if( isPath( _table[row+1][col].cell ) ) { if( temp.dist != -1 ) { if( _table[row+1][col].dist < temp.dist ) temp = _table[row+1][col]; } else temp = _table[row+1][col]; } if( col > 0 ) if( isPath( _table[row+1][col-1].cell ) ) { if( temp.dist != -1 ) { if( _table[row+1][col-1].dist < temp.dist ) temp = _table[row+1][col-1]; } else temp = _table[row+1][col-1]; } if( col < _width - 1 ) if( isPath( _table[row+1][col+1].cell ) ) { if( temp.dist != -1 ) { if( _table[row+1][col+1].dist < temp.dist ) temp = _table[row+1][col+1]; } else temp = _table[row+1][col+1]; } } return temp.cell; } int PathFinder::computeCostMvt( GenericCell * start, GenericCell * end ) { int ret = 0; if( ( start->getCoeff() != -1 ) && ( end->getCoeff() != -1 ) ) { int r1 = start->getRow(); int r2 = end->getRow(); int c1 = start->getCol(); int c2 = end->getCol(); if( ( abs( c1 - c2 ) < 2 ) && ( abs( r1 - r2 ) < 2 ) ) { if( c1 != c2 ) { if( r1 != r2 ) { ret = COST_DIAG; } else { ret = COST_DIRECT; } } else { if( r1 != r2 ) { ret = COST_DIRECT; } } ret = ret * ( start->getCoeff() + end->getCoeff() ); ret = ret / 2; } else { ret = -1; } } return ret; } /** Constructs an empty Pile */ Pile::Pile() { } /** take the smallest element of the list */ PathCell * Pile::takeSmallest() { int nbItems = count(); int mini = 0; PathCell * smallest = value( 0 ); PathCell * cur; for( int i = 1; i < nbItems; i++ ) { cur = value( i ); if( sup( smallest, cur ) ) { smallest = cur; mini = i; } } return takeAt( mini ); /* int mini; PathCell * sm = first(); mini = at(); PathCell * cur = next(); while( cur ) { if ( sup(sm, cur) ) { sm = cur; mini = at(); } cur = next(); } return take( mini );*/ } /** */ PathFightFinder::PathFightFinder( int w, int h, GenericFightMap * m ) { _width = w; _height = h; _start = 0; int i; _table = new PathFightCell * [h]; for( i = 0; i < h; i++ ) { _table[i] = new PathFightCell[w]; } for( i = 0; i < h; i++ ) { for( int j = 0; j < w; j++ ) { _table[i][j].cell = m->at( i, j ); _table[i][j].prev = 0; _table[i][j].dist = 0; } } } /** free the _table */ PathFightFinder::~PathFightFinder() { for( int i = 0; i < _height; i++ ) { delete [] _table[i] ; } delete [] _table; } void PathFightFinder::reinit( GenericFightMap * ) { /// XXX: unused genericFightMap or for overloading _start = 0; for( int i = 0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { _table[i][j].prev = 0; _table[i][j].dist = 0; } } } void PathFightFinder::computePath( GenericFightCell * ) { // _start = &_table[start->getRow()][start->getCol()]; // _start->dist = -1; // FightPile pile; // PathFightCell * work; // // GenericFightCell * voisin; // pile.append( _start ); // while( pile.count() > 0 ) { // work = pile.takeSmallest(); // // voisin = work->cell->getN(); // // COMPUTE_CELL; // // voisin = work->cell->getNE(); // // COMPUTE_CELL; // // voisin = work->cell->getSE(); // // COMPUTE_CELL; // // voisin = work->cell->getS(); // // COMPUTE_CELL; // // voisin = work->cell->getSW(); // // COMPUTE_CELL; // // voisin = work->cell->getNW(); // // COMPUTE_CELL; // } } QStack * PathFightFinder::giveCells( GenericFightCell * dest ) { QStack * ret = new QStack; PathFightCell * cur; int i=0; cur = & _table[dest->getRow()][dest->getCol()]; ret->push( cur->cell ); do { i++; cur = cur->prev; ret->push( cur->cell ); } while( cur != _start ); return ret; } // /** Constructs an empty FightPile */ // FightPile::FightPile() // { // setAutoDelete( false ); // } // /** take the smallest element of the list */ // PathFightCell * FightPile::takeSmallest() // { // int mini; // PathFightCell * sm = first(); // mini = at(); // PathFightCell * cur = next(); // while( cur ) { // if ( sup(sm, cur) ) { // sm = cur; // mini = at(); // } // cur = next(); // } // return take( mini ); // } attal-src-1.0-rc2/libCommon/pathFinder.h0000644000175000017500000001024510760633222015633 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** pathFinder.h ** Compute pathes in the map ** ** Version : $Id: pathFinder.h,v 1.8 2008/02/25 21:43:46 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 04/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PATHFINDER_H #define PATHFINDER_H // generic include files // include files for QT #include #include // application specific includes #include "libCommon/log.h" #include "libCommon/genericCell.h" #include "libCommon/genericMap.h" #include "libCommon/genericFightMap.h" #include "libCommon/genericFightCell.h" #define COST_DIRECT 2 #define COST_DIAG 3 /** Structure for representing a path on the adventure map */ struct PathCell { GenericCell * cell; PathCell * prev; int dist; friend bool sup( PathCell * a, PathCell * b ) { return (a->dist > b->dist); } }; /** structure of pathCell allowing to get the smallest */ class Pile : public QList { public: /** Constructor */ Pile(); /** Return the pathcell with smallest dist */ PathCell * takeSmallest(); }; /** Structure for representing a path on the fight map */ struct PathFightCell { GenericFightCell * cell; PathFightCell * prev; int dist; friend bool sup( PathFightCell * a, PathFightCell * b ) { return (a->dist>b->dist); } }; /* class FightPile : public QPtrList { public: ** Constructor * FightPile(); ** Return the pathcell with smallest dist * PathFightCell * takeSmallest(); }; */ /* ------------------------------ * PathFinder * ------------------------------ */ /** Find the shortest path from A to B on the map */ class PathFinder { public: /** Constructor */ PathFinder(); /** Constructor */ PathFinder( int h, int w, GenericMap * m ); /** Destructor */ ~PathFinder(); /** Reinit the pathfinder with current map */ void reinit( GenericMap * m ); /** Precompute paths */ void computePath( GenericCell * start ); /** Return true if there is a path between 'start' and 'dest' */ bool isPath( GenericCell * dest ); int getDist( GenericCell * dest ); /** Return true if there is a 'near path' between 'start' and 'dest' */ bool isNearPath( GenericCell * dest ); /** Return the 'near cell' */ GenericCell * getNearCell( GenericCell * dest ); /** Give next cell to go for dest */ QStack * giveCells( GenericCell * dest ); /** Give next near cell to go for dest */ QStack * giveNearCells( GenericCell * dest ); /** Clear path */ void clear(); /** Change map */ void newMap( int h, int w, GenericMap * m ); GenericCell * getStartCell(); static int computeCostMvt( GenericCell * start, GenericCell * end ); private: int _width, _height; PathCell ** _table; PathCell * _start; void compute( Pile *, GenericCell *, PathCell *, int cost = 0 ); }; /* ------------------------------ * PathFightFinder * ------------------------------ */ /** Find the shortest path from A to B on the map */ class PathFightFinder { public: /** Constructor */ PathFightFinder( int w, int h, GenericFightMap * m ); /** Destructor */ ~PathFightFinder(); /** Reinit the pathfinder with current map */ void reinit( GenericFightMap * m ); /** Precompute paths */ void computePath( GenericFightCell * start ); /** Give next cell to go for X, Y */ QStack * giveCells( GenericFightCell * dest ); private: int _width, _height; PathFightCell ** _table; PathFightCell * _start; }; #endif // PATHFINDER_H attal-src-1.0-rc2/libCommon/priceMarket.cpp0000644000175000017500000000276510522705152016356 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** priceMarket.cpp ** compute prices on markets (for trading resources) ** ** Version : $Id: priceMarket.cpp,v 1.7 2006/11/03 18:28:58 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 17/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "priceMarket.h" // generic include files #include // include files for QT // application specific include files #include "libCommon/dataTheme.h" PriceMarket::PriceMarket() { uint nbRes = DataTheme.resources.count(); _resources = new int[ nbRes ]; for( uint i = 0; i < nbRes; i++ ) { if( i != 0){ _resources[i] = 100; } else { _resources[i] = 1; } } } PriceMarket::~PriceMarket() { delete [] _resources; } void PriceMarket::reinit( GenericPlayer * ) { } int PriceMarket::getResourceInResource( char dest, char prov ) { return( std::max( (_resources[dest] / _resources[prov] ), 1 ) ); } attal-src-1.0-rc2/libCommon/priceMarket.h0000644000175000017500000000334410164763015016021 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** priceMarket.h ** compute prices on markets (for trading resources) ** ** Version : $Id: priceMarket.h,v 1.4 2004/12/30 11:27:09 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 17/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PRICEMARKET_H #define PRICEMARKET_H // generic include files // include files for QT // application specific include files #include "libCommon/genericPlayer.h" /* ------------------------------ * PriceMarket * ------------------------------ */ /** comment for the class */ class PriceMarket { public: /** Constructor */ PriceMarket(); ~PriceMarket(); /** Reinit market */ void reinit( GenericPlayer * player ); /** Set price of ressource ress */ void setResourcePrice( char res, uint num ) { _resources[res] = num; } /** Get price of ressource ress */ int getResourcePrice( char res ) { return _resources[res]; } /** Get 'price' of resource dest in resource prov */ int getResourceInResource( char dest, char prov ); private: int * _resources; }; #endif // PRICEMARKET_H attal-src-1.0-rc2/libCommon/quest.cpp0000644000175000017500000003217710617176265015265 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** quest.cpp ** Manages quests in Attal ** ** Version : $Id: quest.cpp,v 1.27 2007/05/05 21:52:53 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 02/04/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "quest.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/artefactManager.h" #include "libCommon/calendar.h" #include "libCommon/dataTheme.h" #include "libCommon/genericPlayer.h" // // ----- Quest ----- // Quest::Quest() { _type = ONLY_ONE; _needConfirmation = true; _confirmationQuestion = tr( "Do you accept this quest ?" ); _startCondition = NULL; _failCondition = NULL; _successCondition = NULL; } Quest::~Quest() { if( _startCondition ) { delete _startCondition; } if( _failCondition ) { delete _failCondition; } if( _successCondition ) { delete _successCondition; } } QString Quest::getTypeName( QuestType type ) { QString ret; switch( type ) { case ONLY_ONE: ret = tr( "Only once" ); break; case ONE_PERPLAYER: ret = tr( "Once for each player" ); break; case ONE_PERLORD: ret = tr( "Once for each lord" ); break; case ANYONE: ret = tr( "Anytime requested" ); break; } return ret; } void Quest::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << _name << "" << endl; indentation( ts, indent ); *ts << "" << _description << "" << endl; indentation( ts, indent ); *ts << "" << endl; if( _startCondition ) { _startCondition->save( ts, indent + 1 ); } indentation( ts, indent ); *ts << "" << endl; if( _needConfirmation ) { indentation( ts, indent ); *ts << "" << _confirmationQuestion << "" << endl; } indentation( ts, indent ); *ts << "" << endl; if( _failCondition ) { _failCondition->save( ts, indent + 1 ); } indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent ); *ts << "" << endl; if( _successCondition ) { _successCondition->save( ts, indent + 1 ); } indentation( ts, indent ); *ts << "" << endl; } // // ----- QuestData ----- // QuestData::QuestData() { _lord = 0; _player = 0; _currentDate = 0; _currentTurn = 0; } // // ----- QuestCondition ----- // QuestCondition::~QuestCondition() { } void QuestCondition::clear() { } // // ----- QuestConditionComposite ----- // QuestConditionComposite::QuestConditionComposite( CompositeType type ) { _type = COMPOSITE; _compositeType = type; } QuestConditionComposite::~QuestConditionComposite() { clear(); } void QuestConditionComposite::clear() { while( ! _list.isEmpty() ) { delete _list.takeFirst(); } } void QuestConditionComposite::addCondition( QuestCondition * condition ) { _list.append( condition ); } void QuestConditionComposite::save( QTextStream * ts, int indent ) { uint nb; indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent+1 ); if( _compositeType == AND ) { *ts << "AND" << endl; } else { *ts << "OR" << endl; } nb = _list.count(); for( uint i = 0; i < nb; ++i ) { _list.at( i )->save( ts, indent+1 ); } indentation( ts, indent ); *ts << "" << endl; } uint QuestConditionComposite::getConditionNumber() { return _list.count(); } QuestCondition * QuestConditionComposite::getCondition( uint nb ) { QuestCondition * ret = 0; if( (int)nb < _list.count() ) { ret = _list.at( nb ); } return ret; } void QuestConditionComposite::delCondition( uint nb ) { delete _list.takeAt( nb ); } void QuestConditionComposite::delCondition( QuestCondition * condition ) { _list.removeAll( condition ); delete condition; } bool QuestConditionComposite::check( QuestData * data ) { bool ret = false; uint i, nb; nb = _list.count(); if( nb ) { if( _compositeType == AND ) { ret = true; for( i = 0; i < nb; i++ ) { ret = ret && _list.at( i )->check( data ); } } else { ret = false; for( i = 0; i < nb; i++ ) { ret = ret || _list.at( i )->check( data ); } } } return ret; } QString QuestConditionComposite::getLabel() { QString ret; if( _compositeType == AND ) { ret = "AND"; } else { ret = "OR"; } return ret; } // // ----- QuestConditionDate ----- // QuestConditionDate::QuestConditionDate() { _type = QuestCondition::DATE; _category = DELAY; _day = 0; _month = 0; _week = 0; _year = 0; _nbDay = 0; } void QuestConditionDate::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent+1 ); *ts << "" << _category << "" << endl; if( _category == DATE ) { indentation( ts, indent+1 ); *ts << "" << _day << "" << endl; indentation( ts, indent+1 ); *ts << "" << _week << "" << endl; indentation( ts, indent+1 ); *ts << "" << _month << "" << endl; indentation( ts, indent+1 ); *ts << "" << _year << "" << endl; } else { indentation( ts, indent+1 ); *ts << "" << _nbDay << "" << endl; } indentation( ts, indent ); *ts << "" << endl; } bool QuestConditionDate::check( QuestData * data ) { bool ret = false; long absoluteCurrentDay, absoluteQuestDay; uint turn; if( _category == DATE ) { absoluteQuestDay = Calendar::getAbsoluteDate( _day , _week , _month , _year ); absoluteCurrentDay = data->getCurrentAbsoluteDate(); if( absoluteCurrentDay > absoluteQuestDay ) { ret = true; } } else if( _category == DELAY ) { turn = data->getCurrentTurn(); TRACE(" check turn %d , _nbDay %d", turn, _nbDay); if( turn > _nbDay) { ret = true; } } return ret; } QString QuestConditionDate::getLabel() { QString ret; if( _category == DATE ) { ret = tr( "Must be accomplished before day %1, week %2, month %3" ).arg( _day).arg(_week).arg( _month ); } else { ret = tr( "Must be accomplished before %1 days" ).arg( _nbDay ); } return ret; } void QuestConditionDate::setConditionDate( uint day, uint week, uint month, uint year ) { _category = DATE; _day = day; _week = week; _month = month; _year = year; } void QuestConditionDate::setConditionDelay( uint nbDay ) { _category = DELAY; _nbDay = nbDay; } // // ----- QuestConditionLord ----- // QuestConditionLord::QuestConditionLord() { _type = LORD; _category = PRIMARY_SKILL; _charac = ATTACK; _check = EQUAL; _present = true; _value = 0; _secondary = 0; _artefact = 0; _spell = 0; } void QuestConditionLord::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent+1 ); *ts << "" << _category << "" << endl; switch( _category ) { case PRIMARY_SKILL: savePrimary( ts, indent + 1 ); break; case SECONDARY_SKILL: //saveSecondary( ts, indent + 1 ); break; case ARTEFACT: saveArtefact( ts, indent + 1 ); break; case NB_CREATURES: saveNumber( ts, indent + 1 ); break; case SPELL: //saveSpell( ts, indent + 1 ); break; } indentation( ts, indent ); *ts << "" << endl; } void QuestConditionLord::saveNumber( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << (uint)_check << "" << endl; indentation( ts, indent ); *ts << "" << _value << "" << endl; } void QuestConditionLord::savePrimary( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << (uint)_charac << "" << endl; indentation( ts, indent ); *ts << "" << (uint)_check << "" << endl; indentation( ts, indent ); *ts << "" << _value << "" << endl; } void QuestConditionLord::saveArtefact( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << _artefact << "" << endl; indentation( ts, indent ); *ts << "" << (uint)_present << "" << endl; } bool QuestConditionLord::check( QuestData * data ) { bool ret = false; switch( _category ) { case PRIMARY_SKILL: ret = checkPrimary( data ); break; case SECONDARY_SKILL: //saveSecondary( ts, indent + 1 ); break; case ARTEFACT: if( data->getLord()->getArtefactManager()->hasArtefactType( _artefact ) ) { ret = true; } break; case NB_CREATURES: ret = checkPrimary( data ); break; case SPELL: //saveSpell( ts, indent + 1 ); break; } return ret; } bool QuestConditionLord::checkPrimary( QuestData * data ) { bool ret = false; GenericLord * lord = data->getLord(); uint valLord = 0; if( lord ) { switch( _category ) { case PRIMARY_SKILL: valLord = lord->getCharac( _charac ); break; case SECONDARY_SKILL: break; case NB_CREATURES: valLord = lord->countUnits(); break; default: break; } switch( _check ) { case INFERIOR: ret = ( valLord < _value ); break; case INFERIOR_EQUAL: ret = ( valLord <= _value ); break; case EQUAL: ret = ( valLord == _value ); break; case SUPERIOR_EQUAL: ret = ( valLord >= _value ); break; case SUPERIOR: ret = ( valLord > _value ); break; } } return ret; } QString QuestConditionLord::getLabel() { QString ret; ret.sprintf( "Lord condition" ); return ret; } void QuestConditionLord::setPrimarySkillCondition( LordCharac charac, CheckType check, uint value ) { _category = PRIMARY_SKILL; _charac = charac; _check = check; _value = value; } void QuestConditionLord::setNumberCondition( CheckType check, uint value ) { _category = NB_CREATURES; _check = check; _value = value; } void QuestConditionLord::setSecondarySkillCondition( uint secondarySkill, bool present ) { _category = SECONDARY_SKILL; _secondary = secondarySkill; _present = present; } void QuestConditionLord::setArtefactCondition( uint artefact, bool present ) { _category = ARTEFACT; _artefact = artefact; _present = present; } void QuestConditionLord::setSpellCondition( uint spell, bool present ) { _category = SPELL; _spell = spell; _present = present; } // // ----- QuestConditionPlayer ----- // QuestConditionPlayer::QuestConditionPlayer() { _type = PLAYER; _category = NB_LORD; _check = EQUAL; _value = 0; _name = "";; } void QuestConditionPlayer::save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "" << endl; indentation( ts, indent+1 ); *ts << "" << (uint)_category << "" << endl; if( _category == NB_LORD ) { indentation( ts, indent+1 ); *ts << "" << (uint)_check << "" << endl; indentation( ts, indent+1 ); *ts << "" << _value << "" << endl; } else if( _category == NB_BASE ) { indentation( ts, indent+1 ); *ts << "" << (uint)_check << "" << endl; indentation( ts, indent+1 ); *ts << "" << _value << "" << endl; } else { indentation( ts, indent+1 ); *ts << "" << _name << "" << endl; } indentation( ts, indent ); *ts << "" << endl; } bool QuestConditionPlayer::check( QuestData * data ) { bool ret = false; GenericPlayer * player = data->getPlayer(); uint valPlayer; switch( _category ) { case NB_LORD: valPlayer = player->numLord(); switch( _check ) { case INFERIOR: ret = ( valPlayer < _value ); break; case INFERIOR_EQUAL: ret = ( valPlayer <= _value ); break; case EQUAL: ret = ( valPlayer == _value ); break; case SUPERIOR_EQUAL: ret = ( valPlayer >= _value ); break; case SUPERIOR: ret = ( valPlayer > _value ); break; } break; case NB_BASE: valPlayer = player->numBase(); switch( _check ) { case INFERIOR: ret = ( valPlayer < _value ); break; case INFERIOR_EQUAL: ret = ( valPlayer <= _value ); break; case EQUAL: ret = ( valPlayer == _value ); break; case SUPERIOR_EQUAL: ret = ( valPlayer >= _value ); break; case SUPERIOR: ret = ( valPlayer > _value ); break; } break; case BASENAME: { uint nbBases = player->numBase(); GenericBase * base; for( uint i = 0; i < nbBases; i++ ) { base = player->getBase( i ); if( base->getName() == _name ) { ret = true; break; } } } break; } return ret; } QString QuestConditionPlayer::getLabel() { return "Player condition"; } void QuestConditionPlayer::setNbLordCondition( CheckType check, uint value ) { _category = NB_LORD; _value = value; _check = check; } void QuestConditionPlayer::setNbBaseCondition( CheckType check, uint value ) { _category = NB_BASE; _value = value; _check = check; } void QuestConditionPlayer::setBasenameCondition( const QString & name ) { _category = BASENAME; _name = name; } attal-src-1.0-rc2/libCommon/quest.h0000644000175000017500000002030010605441452014701 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** quest.h ** Manages quests in Attal ** ** Version : $Id: quest.h,v 1.16 2007/04/06 12:55:06 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 02/04/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef QUEST_H #define QUEST_H // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/define.h" class QTextStream; class GenericLord; class GenericPlayer; class QuestCondition; /* ------------------------------ * Quest * ------------------------------ */ class Quest : public QObject { Q_OBJECT public: /** Constructor */ Quest(); ~Quest(); enum QuestType { ONLY_ONE, ONE_PERPLAYER, ONE_PERLORD, ANYONE }; QuestType getType() { return _type; } static QString getTypeName( QuestType type ); void setType( QuestType type ) { _type = type; } const QString & getName() { return _name; } void setName( const QString & name ) { _name = name; } const QString & getDescription() { return _description; } void setDescription( const QString & description ) { _description = description; } /** for saving quest in scenario file */ void save( QTextStream * ts, int indent ); QuestCondition * getStartCondition() { return _startCondition; } void setStartCondition( QuestCondition * condition ) { _startCondition = condition; } QuestCondition * getFailCondition() { return _failCondition; } void setFailCondition( QuestCondition * condition ) { _failCondition = condition; } QuestCondition * getSuccessCondition() { return _successCondition; } void setSuccessCondition( QuestCondition * condition ) { _successCondition = condition; } void setConfirmationQuestion( const QString & confirmation ) { _confirmationQuestion = confirmation; } const QString & getConfirmationQuestion() { return _confirmationQuestion; } void setAcceptMessage( const QString & msg ) { _acceptMsg = msg; } const QString & getAcceptMessage() { return _acceptMsg; } void setRejectMessage( const QString & msg ) { _rejectMsg = msg; } const QString & getRejectMessage() { return _rejectMsg; } bool isConfirmationNeeded() { return _needConfirmation; } void setConfirmationNeeded( bool state ) { _needConfirmation = state; } protected: QuestType _type; QString _name; QString _description; bool _needConfirmation; QString _confirmationQuestion; QString _acceptMsg, _rejectMsg; QuestCondition * _startCondition; QuestCondition * _failCondition; QuestCondition * _successCondition; }; class QuestData { public: /** Constructor */ QuestData(); GenericLord * getLord() { return _lord; } void setLord( GenericLord * lord ) { _lord = lord; } GenericPlayer * getPlayer() { return _player; } void setPlayer( GenericPlayer * player ) { _player = player; } void setCurrentAbsoluteDate( uint date ) { _currentDate = date; } void setCurrentTurn( uint turn ) { _currentTurn = turn; } uint getCurrentAbsoluteDate() { return _currentDate; } uint getCurrentTurn() { return _currentTurn; } protected: GenericLord * _lord; GenericPlayer * _player; uint _currentDate, _currentTurn; }; class QuestCondition : public QObject { public: enum ConditionType { COMPOSITE, DATE, LORD, PLAYER }; enum CheckType { INFERIOR, INFERIOR_EQUAL, EQUAL, SUPERIOR_EQUAL, SUPERIOR }; /** Constructor */ QuestCondition() {} /** Destructor */ virtual ~QuestCondition() = 0; /** for saving quest condition in scenario file */ virtual void save( QTextStream * ts, int indent ) = 0; virtual void clear(); virtual bool check( QuestData * data ) = 0; virtual QString getLabel() = 0; ConditionType getType() { return _type; } protected: ConditionType _type; }; class QuestConditionComposite : public QuestCondition { Q_OBJECT public: enum CompositeType { AND, OR }; /** Constructor */ QuestConditionComposite( CompositeType type = AND ); virtual ~QuestConditionComposite(); virtual void clear(); CompositeType getCompositeType() { return _compositeType; } void setCompositeType( CompositeType type ) { _compositeType = type; } void addCondition( QuestCondition * condition ); uint getConditionNumber(); QuestCondition * getCondition( uint nb ); void delCondition( uint nb ); void delCondition( QuestCondition * condition ); /** for saving quest condition in scenario file */ void save( QTextStream * ts, int indent ); bool check( QuestData * data ); QString getLabel(); protected: CompositeType _compositeType; QList _list; }; class QuestConditionDate : public QuestCondition { Q_OBJECT public: enum ConditionCategory { DATE, DELAY }; /** Constructor */ QuestConditionDate(); /** for saving quest condition in scenario file */ void save( QTextStream * ts, int indent ); bool check( QuestData * data ); QString getLabel(); void setConditionDate( uint day, uint week, uint month, uint year ); void setConditionDelay( uint nbDay ); ConditionCategory getCategory() { return _category; } uint getDay() { return _day; } uint getWeek() { return _week; } uint getMonth() { return _month; } uint getYear() { return _year; } uint getDelay() { return _nbDay; } protected: ConditionCategory _category; uint _day, _week, _month, _year; uint _nbDay; }; class QuestConditionLord : public QuestCondition { Q_OBJECT public: enum ConditionCategory { PRIMARY_SKILL, SECONDARY_SKILL, ARTEFACT, SPELL, NB_CREATURES }; /** Constructor */ QuestConditionLord(); /** for saving quest condition in scenario file */ void save( QTextStream * ts, int indent ); bool check( QuestData * data ); QString getLabel(); void setPrimarySkillCondition( LordCharac charac, CheckType check, uint value ); LordCharac getLordCharac() { return _charac; } CheckType getCheckType() { return _check; } uint getValue() { return _value; } void setNumberCondition( CheckType check, uint value ); void setSecondarySkillCondition( uint secondarySkill, bool present ); uint getSecondarySkill() { return _secondary; } bool isSecondarySkillPresent() { return _present; } void setArtefactCondition( uint artefact, bool present ); uint getArtefact() { return _artefact; } bool isArtefactPresent() { return _present; } void setSpellCondition( uint spell, bool present ); uint getSpell() { return _spell; } bool isSpellPresent() { return _present; } ConditionCategory getConditionType() { return _category; } protected: void savePrimary( QTextStream * ts, int indent ); void saveArtefact( QTextStream * ts, int indent ); void saveNumber( QTextStream * ts, int indent ); bool checkPrimary( QuestData * data ); ConditionCategory _category; LordCharac _charac; CheckType _check; bool _present; uint _value, _secondary, _artefact, _spell; }; class QuestConditionPlayer : public QuestCondition { Q_OBJECT public: enum ConditionCategory { NB_LORD, NB_BASE, BASENAME }; /** Constructor */ QuestConditionPlayer(); /** for saving quest condition in scenario file */ void save( QTextStream * ts, int indent ); bool check( QuestData * data ); QString getLabel(); void setNbLordCondition( CheckType check, uint value ); void setNbBaseCondition( CheckType check, uint value ); void setBasenameCondition( const QString & name ); uint getValue() { return _value; } CheckType getCheckType() { return _check; } const QString & getName() { return _name; } ConditionCategory getConditionType() { return _category; } protected: ConditionCategory _category; CheckType _check; uint _value; QString _name; }; #endif // QUEST_H attal-src-1.0-rc2/libCommon/questManager.cpp0000644000175000017500000000447310603766267016560 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** questManager.cpp ** Manages the quests of a scenario ** ** Version : $Id: questManager.cpp,v 1.2 2007/04/01 17:32:39 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "questManager.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" QuestManager::QuestManager() { _mainQuest = 0; //_quests.setAutoDelete( true ); clear(); } QuestManager::~QuestManager() { clear(); } void QuestManager::clear() { if( _mainQuest ) { delete _mainQuest; _mainQuest = 0; } while( ! _quests.isEmpty() ) { delete _quests.takeFirst(); } } void QuestManager::save( QTextStream * ts, uint indent ) { indentation( ts, indent ); (*ts) << "" << endl; if( _mainQuest ) { indentation( ts, indent + 1 ); (*ts) << "" << endl; _mainQuest->save( ts, indent + 2 ); indentation( ts, indent + 1 ); (*ts) << "" << endl; } uint nbQuests = _quests.count(); for( uint i = 0; i < nbQuests; i++ ) { indentation( ts, indent + 1 ); (*ts) << "" << endl; ( _quests.at( i ) )->save( ts, indent + 2 ); indentation( ts, indent + 1 ); (*ts) << "" << endl; } indentation( ts, indent ); (*ts) << "" << endl; } Quest * QuestManager::getMainQuest() { return _mainQuest; } uint QuestManager::getSecondaryQuestNumber() { return _quests.count(); } Quest * QuestManager::getSecondaryQuest( uint num ) { Quest * ret = 0; if( (int)num < _quests.count() ) { ret = _quests.at( num ); } return ret; } void QuestManager::appendSecondaryQuest( Quest * quest ) { _quests.append( quest ); } attal-src-1.0-rc2/libCommon/questManager.h0000644000175000017500000000322010531067472016202 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** questManager.h ** Manages the quests of a scenario ** ** Version : $Id: questManager.h,v 1.1 2006/11/22 15:39:38 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 06/04/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef QUESTMANAGER_H #define QUESTMANAGER_H // generic include files // include files for QT #include // application specific include files #include "libCommon/quest.h" class QTextStream; /* ------------------------------ * QuestManager * ------------------------------ */ class QuestManager { public: /** Constructor */ QuestManager(); /** Destructor */ virtual ~QuestManager(); void clear(); void save( QTextStream * ts, uint indent ); Quest * getMainQuest(); void setMainQuest( Quest * quest ) { _mainQuest = quest; } uint getSecondaryQuestNumber(); Quest * getSecondaryQuest( uint num ); void appendSecondaryQuest( Quest * quest ); protected: Quest * _mainQuest; QList _quests; }; #endif // QUESTMANAGER_H attal-src-1.0-rc2/libCommon/skill.cpp0000644000175000017500000000320310347000231015201 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** skill.cpp ** manages skills of the lords ** ** Version : $Id: skill.cpp,v 1.3 2005/12/11 10:34:01 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 23/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "skill.h" // generic include files // include files for QT // application specific includes // // ----- Skill ----- // Skill::Skill() { _id = 0; _level = 0; } // // ----- SkillLevel ----- // SkillLevel::SkillLevel() { } SkillLevel::~SkillLevel() { while( ! _params.isEmpty() ) { delete _params.takeFirst(); } } void SkillLevel::addParam( int param ) { _params.append( new int( param ) ); } uint SkillLevel::getParamNumber() { return _params.count(); } int SkillLevel::getParam( uint num ) { int ret = 0; if( (int)num < _params.count() ) { ret = * ( _params.at( num ) ); } return ret; } void SkillLevel::setParam( uint num, int val ) { if( (int)num < _params.count() ) { *( _params.at( num ) ) = val; } } // // ----- SkillModel ----- // SkillModel::SkillModel() { } attal-src-1.0-rc2/libCommon/skill.h0000644000175000017500000000465010335201564014666 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** skill.h ** manages skills of the lords ** ** Version : $Id: skill.h,v 1.4 2005/11/11 20:47:48 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 23/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SKILL_H #define SKILL_H // generic include files // include files for QT #include #include // application specific includes enum PrimarySkill { SKI_ATTACK, SKI_DEFENSE }; /** ------------------------------ * Skill ** ------------------------------ */ class Skill { public: /** Constructor */ Skill(); int getId() { return _id; } void setId( int id ) { _id = id; } /** Return level of skill */ int getLevel() { return _level; } /** Set level of skill */ void setLevel( int level ) { _level = level; } protected: int _id, _level; }; class SkillLevel { public: /** Constructor */ SkillLevel(); /** Destructor */ virtual ~SkillLevel(); void addParam( int param ); uint getParamNumber(); int getParam( uint num ); void setParam( uint num, int val ); protected: QList _params; }; class SkillModel { public: enum SkillType { SKI_ATTACK, SKI_DEFENSE, SKI_POWER, SKI_KNOWLEDGE }; /** Constructor */ SkillModel(); QString getName() { return _name; } void setName( const QString & name ) { _name = name; } QString getDescription() { return _description; } void setDescription( QString description ) { _description = description; } /** Return type of skill */ SkillType getType() { return _type; } /** Set type of skill */ void setType( SkillType type ) { _type = type; } void addLevel( SkillLevel * level ); uint getLevelNumber(); SkillLevel * getLevel( uint num ); private: QString _name, _description; SkillType _type; QList _levels; }; #endif // SKILL_H attal-src-1.0-rc2/libCommon/specialty.cpp0000644000175000017500000000203307673141260016100 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** specialty.cpp ** specialty of the lord ** ** Version : $Id: specialty.cpp,v 1.1.1.1 2003/06/15 19:02:08 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 23/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "specialty.h" // generic include files // include files for QT // application specific includes /** add comments here */ Specialty::Specialty() { // internal comments } attal-src-1.0-rc2/libCommon/specialty.h0000644000175000017500000000234307673141260015551 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** specialty.h ** specialty of the lord ** ** Version : $Id: specialty.h,v 1.1.1.1 2003/06/15 19:02:08 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 23/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SPECIALTY_H #define SPECIALTY_H // generic include files // include files for QT // application specific includes /* ------------------------------ * Specialty * ------------------------------ */ /** comment for the class */ class Specialty { public: /** Constructor */ Specialty(); }; #endif // SPECIALTY_H attal-src-1.0-rc2/libCommon/technic.cpp0000644000175000017500000001125310401056020015502 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** technic.cpp ** deals with Technics and around ** ** Version : $Id: technic.cpp,v 1.9 2006/02/28 14:20:00 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 19/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "technic.h" // generic include files // include files for QT #include #include #include // application specific includes #include "libCommon/log.h" extern QString DATA_PATH; TechnicList techList; // // -----GenericTechnic ----- // GenericTechnic::GenericTechnic() { _cost = 1; _type = 0; _class = 0; _level = 1; } // // ----- TechnicList ----- // TechnicList::TechnicList() { } TechnicList::~TechnicList() { clearing(); } void TechnicList::clearing() { while( ! isEmpty() ) { delete takeFirst(); } while( ! _domain.isEmpty() ) { delete _domain.takeFirst(); } } void TechnicList::clear() { while( ! isEmpty() ) { delete takeFirst(); } } bool TechnicList::init() { clearing(); TechnicHandler handler( this ); QFile file( DATA_PATH + "technics.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s): %s", QString( DATA_PATH + "technics.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } void TechnicList::print() { for( int i = 0; i < _domain.count(); i++ ) { logDD( "%s", _domain.at(i)->toLatin1().constData() ); } } int TechnicList::addDomain( QString domainName ) { QListIterator ite( _domain ); int cpt = 0, ret = -1; while( ite.hasNext() ) { if( *( ite.next() ) == domainName ) { ret = cpt; break; } cpt++; } if( ret == -1 ) { ret = cpt; _domain.append( new QString( domainName ) ); } return ret; } // // ----- TechnicalBook ----- // TechnicalBook::TechnicalBook() { } // // ----- TechnicHandler ----- // TechnicHandler::TechnicHandler( TechnicList * list ) { _list = list; } bool TechnicHandler::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _list->clearing(); _state = StateInit; _cla = 0; return true; } bool TechnicHandler::startElement( const QString &, const QString &, const QString& qName, const QXmlAttributes& atts ) { if( qName == "technical" && _state == StateInit ) { _state = StateDocument; } else if ( qName == "domain" && _state == StateDocument ) { _state = StateDomain; _cla = _list->addDomain( atts.value( "name" ) ); } else if ( qName == "technic" && _state == StateDomain ) { _state = StateTechnic; _tech = new GenericTechnic(); _tech->setClass( _cla ); _tech->setName( atts.value( "name" ) ); } else if ( qName == "level" && _state == StateTechnic ) { _state = StateLevel; } else if ( qName == "cost" && _state == StateTechnic ) { _state = StateCost; } else { // error return false; } return true; } bool TechnicHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateDomain: _state = StateDocument; break; case StateTechnic: _state = StateDomain; _list->append( _tech ); break; case StateLevel: _state = StateTechnic; break; case StateCost: _state = StateTechnic; break; default: // do nothing break; } return true; } bool TechnicHandler::characters( const QString& ch ) { _val = 0; QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) return true; switch( _state ) { case StateLevel: _tech->setLevel( ch_simplified.toInt() ); break; case StateCost: _tech->setCost( ch_simplified.toInt() ); break; default: return false; } return true; } bool TechnicHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/technic.h0000644000175000017500000001060110335201564015156 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** technic.h ** deals with Technics and around ** ** Version : $Id: technic.h,v 1.4 2005/11/11 20:47:48 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 19/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GENERICTECHNIC_H #define GENERICTECHNIC_H // generic include files // include files for QT #include #include #include #include // application specific includes /* ------------------------------ * GenericTechnic * ------------------------------ */ class GenericTechnic { public: /** Constructor */ GenericTechnic(); /** Set cost of the technic */ void setCost( int val ) { _cost = val; } /** Return cost of the technic */ int getCost() { return _cost; } /** Set class of the technic */ void setClass( int clas ) { _class = clas; } /** Return class of the technic */ int getClass() { return _class; } /** Set level of the technic */ void setLevel( int level ) { _level = level; } /** Return level of the technic */ int getLevel() { return _level; } /** Set type of the technic */ void setType( int typ ) { _type = typ; } /** Return type of the technic */ int getType() { return _type; } /** Set name of the technic */ void setName( QString name ) { _name = name; } /** Return name of the technic */ QString getName() { return _name; } /** Tell if it is a fighting technic */ bool isFight() { return true; } protected: int _cost; int _type; int _class; int _level; QString _name; }; /* ------------------------------ * TechnicList * ------------------------------ */ /** comment for the class */ class TechnicList : public QList { public: /** Constructor */ TechnicList(); /** Destructor */ virtual ~TechnicList(); /** Save list */ void save() {} /** Clear list */ void clearing(); /** Init list */ bool init(); /** Print list (for debug) */ void print(); /** Return technic 'type' */ GenericTechnic * at( int type ) { return QList::at( type ); } /** Add a domain name */ int addDomain( QString domainName ); private: void clear(); QList _domain; }; /* ------------------------------ * TechnicalBook * ------------------------------ */ /** comment for the class */ class TechnicalBook { public: /** Constructor */ TechnicalBook(); /** Add a technic */ void add( GenericTechnic * ); private: QList _theBook; }; /* ------------------------------ * TechnicHandler * ------------------------------ */ /** comment for the class */ class TechnicHandler : public QXmlDefaultHandler { public: /** Constructor */ TechnicHandler( TechnicList * list ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: TechnicList * _list; GenericTechnic * _tech; QString _errorProt, _name; int _val; int _cla; enum State { StateInit, StateDocument, StateDomain, StateTechnic, StateLevel, StateCost }; State _state; }; #endif // GENERICTECHNIC_H attal-src-1.0-rc2/libCommon/unit.cpp0000644000175000017500000001630410702155342015061 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** unit.cpp ** manages unit (army) ** ** Version : $Id: unit.cpp,v 1.22 2007/10/07 13:10:58 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 09/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "unit.h" // generic include files #include // include files for QT #include #include // application specific include files #include "libCommon/creature.h" #include "libCommon/dataTheme.h" #include "libCommon/genericFightCell.h" #include "libCommon/genericFightMap.h" #include "libCommon/log.h" extern QString DATA_PATH; // // ----- GenericFightUnit ----- // GenericFightUnit::GenericFightUnit() : _number( 0 ), _move ( 0 ), _health( 0 ), _experience( 0 ), _race ( 0 ), _level ( 0 ), _currentFightCell( 0 ), _currentNeibCell( 0 ), _creature( 0 ), _map ( 0 ), _hasAttack ( true ) { } GenericFightUnit::~GenericFightUnit() { _map = 0; } void GenericFightUnit::setCreature( QString name ) { _race = DataTheme.creatures.findRace( name ); _level = DataTheme.creatures.findLevel( name ); _creature = DataTheme.creatures.at( _race, _level ); _move = _creature->getMaxMove(); _health = _creature->getMaxHealth(); } void GenericFightUnit::setCreature( uint race, uint level ) { _race = race; _level = level; _creature = DataTheme.creatures.at( _race, _level ); _move = _creature->getMaxMove(); _health = _creature->getMaxHealth(); } void GenericFightUnit::setCreature( Creature * creature ) { _creature = creature; _race = _creature->getRace(); _level = _creature->getLevel(); _move = _creature->getMaxMove(); _health = _creature->getMaxHealth(); } /*! display on the log infos about unit */ void GenericFightUnit::display() { if( _creature ) { logDD("Unit race : %d - level : %d - number : %d", _race, _level, _number ); logDD("Attack : %d - Defense : %d", _creature->getAttack(), _creature->getDefense() ); logDD("Health : %d / %d", _health, _creature->getMaxHealth() ); logDD("Move : %d / %d", _move, _creature->getMaxMove() ); logDD("Far Attack : %s", _creature->getDistAttack()?"true":"false" ); logDD("Damages [%d - %d]", _creature->getMinDamages(), _creature->getMaxDamages() ); logDD("Morale : %d, Luck : %d", _creature->getMorale(), _creature->getLuck() ); } else { logEE("Creature not exist" ); } } QString GenericFightUnit::getUnitDescription() { QString text; if( _creature ) { text = ""; text = _creature->getName(); text += "\n\n"; text += "Number: " + QString::number( getNumber() ); text += "\n"; text += "HitPoints: " + QString::number ( getHealth ()) + "/" + QString::number ( getMaxHealth () ); text += "\n"; text += "Attack: " + QString::number ( getAttack () ); text += "\n"; if (isDistAttack ()) { text += "Distance attack: " + QString::number ( getDistAttack ()); text += "\n"; } text += "Defense: " + QString::number (getDefense ()); text += "\n"; text += "Morale: " + QString::number (getMorale ()); text += "\n"; text += "Luck: " + QString::number (getLuck ()); text += "\n"; text += "Damage: Min/Max " + QString::number (getMinDamages ()) + "/" + QString::number (getMaxDamages ()); text += "\n"; text += "Experience: " + QString::number ( getExperience () ); text += "\n"; text += "MovePoints: " + QString::number ( getMove() ); text += "\n"; } else { logEE("Creature not exist" ); } return text; } void GenericFightUnit::setMaxMove() { _move = _creature->getMaxMove(); } int GenericFightUnit::hit( long int nb ) { if( _number == 0 ) { logEE( "Unit has already been destroyed" ); return 0; } if( _health < 0 ) { logEE( "Unit has already been destroyed" ); logEE( "Now : %d creatures, h = %d", _number, _health ); return 0; } long int number = _number; long int oldNum = _number; long int oldH = _health; long int maxH = _creature->getMaxHealth(); long int point = ( (_number-1) * maxH ) + _health - nb; number = point / maxH; _health = point % maxH; if( _health == 0 ) { _health = maxH; } else { number++; } if( number < 0 ) { _number = 0; } else { _number = number; } if( _health <= 0 ) { _number = 0; } logDD( "Before hit : %d creatures, h = %d", oldNum, oldH ); logDD( "Hit : %d", nb ); logDD( "Now : %d creatures, h = %d", _number, _health ); return ( int ) ( oldNum - _number ); } void GenericFightUnit::goTo( GenericFightCell * cell ) { if( _currentFightCell ) { _currentFightCell->setUnit( 0 ); if ( _currentNeibCell ) { _currentNeibCell->setUnit ( 0 ); } } _currentFightCell = cell; _currentFightCell->setUnit( this ); _currentNeibCell = getNeighbour( cell ); if ( _currentNeibCell ) { _currentNeibCell->setUnit ( this ); } } GenericFightCell * GenericFightUnit::getNeighbour( GenericFightCell * cell ) { GenericFightCell * neib = 0; if ( _creature->getSize () != 2 ) { return neib; } if( cell ) { if ( _lookingToRight ) { neib = _map->getNeighbour2 ( cell ); } else { neib = _map->getNeighbour5 ( cell ); } } return neib; } int GenericFightUnit::getAttack() { if( _creature ) { return _creature->getAttack(); } else { return 0; } } int GenericFightUnit::getDefense() { if( _creature ) { return _creature->getDefense(); } else { return 0; } } int GenericFightUnit::getDistAttack() { if( _creature ) { return _creature->getDistAttack(); } else { return 0; } } bool GenericFightUnit::isDistAttack() { if( _creature ) { return _creature->isDistAttack(); } else { return 0; } } int GenericFightUnit::getMaxHealth() { if( _creature ) { return _creature->getMaxHealth(); } else { return 0; } } int GenericFightUnit::getMaxMove() { if( _creature ) { return _creature->getMaxMove(); } else { return 0; } } int GenericFightUnit::getMorale() { if( _creature ) { return _creature->getMorale(); } else { return 0; } } int GenericFightUnit::getLuck() { if( _creature ) { return _creature->getLuck(); } else { return 0; } } int GenericFightUnit::getMinDamages() { if( _creature ) { return _creature->getMinDamages(); } else { return 0; } } int GenericFightUnit::getMaxDamages() { if( _creature ) { return _creature->getMaxDamages(); } else { return 0; } } int GenericFightUnit::getMantCost(int ress) { if( _creature ) { return _creature->getMantCost(ress); } else { return 0; } } bool GenericFightUnit::isLookingToRight () { return _lookingToRight; } void GenericFightUnit::setLookingToRight ( bool mirror ) { _lookingToRight = mirror; } void GenericFightUnit::setFightMap ( GenericFightMap* map ) { _map = map; } attal-src-1.0-rc2/libCommon/unit.h0000644000175000017500000001041310702155344014523 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** unit.h ** manages unit (army) ** ** Version : $Id: unit.h,v 1.20 2007/10/07 13:11:00 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 09/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef UNIT_H #define UNIT_H // generic include files // include files for QT #include // application specific includes class Creature; class GenericFightCell; class GenericFightMap; /* ------------------------------ * Unit * ------------------------------ */ class GenericFightUnit { public: /** Constructor */ GenericFightUnit(); /** Destructor */ virtual ~GenericFightUnit(); /** Set the fight map for unit */ void setFightMap ( GenericFightMap* map ); GenericFightMap* getFightMap () { return _map; } /** Set race of unit */ void setCreature( QString name ); void setCreature( uint race, uint level ); void setCreature( Creature * creature ); Creature * getCreature() { return _creature; } /** Return race of unit */ uint getRace() { return _race; } /** Return race of unit */ uint getLevel() { return _level; } /** Set nb of creatures */ void setNumber( long int nb ) { _number = nb; } /** return nb of creatures */ long int getNumber() { return _number; } /** Add nb of creatures */ void addNumber( long int nb ) { _number += nb; } /** Set move points */ void setMove( long int nb ) { _move = nb; } /** Return move points */ long int getMove() { return _move; } void setMaxMove(); /** Set health */ void setHealth( long int nb ) { _health = nb; } /** Return health */ long int getHealth() { return _health; } /** Set experience */ void setExperience( long int nb ) { _experience = nb; } /** Return health */ long int getExperience() { return _experience; } /** Display unit */ void display(); QString getUnitDescription(); /** Calculate the damages made by the attack */ int hit( long int nb ); bool isAlive () { return (_number > 0); } /** Go to fight cell */ void goTo( GenericFightCell * cell ); /** Get the second cell of a 2 size unit */ GenericFightCell * getNeighbour( GenericFightCell * cell ); /** Return cell of the unit */ GenericFightCell * getCell() { return _currentFightCell; } /** Return second cell of the unit (if exist)*/ GenericFightCell * getNeibCell() { return _currentNeibCell; } /** buggy, don't use */ void setCell(GenericFightCell * cell) { _currentFightCell = cell; } /** Return attack points of creature */ int getAttack(); /** Return defense points of creature */ int getDefense(); /** Return dist attack points of creature */ int getDistAttack(); /** Tell if dist attack is allowed for creature */ bool isDistAttack(); /** Return max health points of creature */ int getMaxHealth(); /** Return max move points of creature */ int getMaxMove(); /** Return morale of creature */ int getMorale(); /** Return luck of creature */ int getLuck(); /** Return min damages points of creature */ int getMinDamages(); /** Return max damages points of creature */ int getMaxDamages(); /** Return maintenance cost of creature */ int getMantCost(int ress); /** Is this unit looking to right (important for 2-cells units)*/ bool isLookingToRight (); void setLookingToRight ( bool mirror ); bool canAttack () {return _hasAttack;} void finishAttack () { _hasAttack = false;} void activateAttack () { _hasAttack = true;} protected: long int _number, _move, _health, _experience; uint _race, _level; GenericFightCell * _currentFightCell, * _currentNeibCell; Creature * _creature; GenericFightMap* _map; bool _lookingToRight; bool _hasAttack; }; #endif // UNIT_H attal-src-1.0-rc2/libCommon/warMachine.cpp0000644000175000017500000001223510401056020016144 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** warMachine.cpp ** Manages war machines (first aid, balist...) ** ** Version : $Id: warMachine.cpp,v 1.11 2006/02/28 14:20:00 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 27/11/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "warMachine.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/log.h" extern QString DATA_PATH; // // ----- WarMachine ----- // WarMachine::WarMachine() { } WarMachine::~WarMachine() { while( ! _params.isEmpty() ) { delete _params.takeFirst(); } } int WarMachine::getParam( uint num ) { int ret = 0; if( (int)num < _params.count() ) { ret = * ( _params.at( num ) ); } return ret; } void WarMachine::addParam( int val ) { _params.append( new int( val ) ); } void WarMachine::addParam0( int val ) { delete _params[ 0 ]; _params[ 0 ] = new int( val ); } void WarMachine::save( QTextStream & ts, int indent ) { indentation( &ts, indent ); ts << "" << endl; indentation( &ts, indent + 1 ); ts << "" << (int)getType() << "" << endl; for( int i = 0; i < _params.count(); i++ ) { indentation( &ts, indent + 1 ); ts << "" << *(_params.at( i )) << "" << endl; } indentation( &ts, indent ); ts << "" << endl; } // // ----- WarMachineList ----- // WarMachineList::WarMachineList() { } WarMachineList::~WarMachineList() { clear(); } void WarMachineList::clear() { while( ! isEmpty() ) { delete takeFirst(); } } bool WarMachineList::init() { clear(); WarMachineHandler handler( this ); QFile file( DATA_PATH + "machines.dat" ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", QString( DATA_PATH + "machines.dat" ).toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } bool WarMachineList::save() { QString filename = DATA_PATH + "machines.dat"; QFile file( filename ); if (! file.open( QIODevice::WriteOnly ) ) { logEE( "Could not open file %s for writing\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &file ); ts << "" << endl; ts << "" << endl; WarMachine * machine; for( int i = 0; i < count(); i++ ) { machine = at( i ); if( machine ) { machine->save( ts, 1 ); } } ts << "" << endl; file.close(); return true; } // // ----- WarMachineHandler ----- // WarMachineHandler::WarMachineHandler( WarMachineList * list ) { _list = list; } bool WarMachineHandler::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _list->clear(); _state = StateInit; return true; } bool WarMachineHandler::startElement( const QString &, const QString &, const QString& qName, const QXmlAttributes& atts ) { if( qName == "machines" && _state == StateInit ) { _state = StateDocument; } else if ( qName == "machine" && _state == StateDocument ) { _state = StateMachine; _machine = new WarMachine(); _machine->setName( atts.value( "name" ) ); } else if ( qName == "type" && _state == StateMachine ) { _state = StateType; } else if ( qName == "param" && _state == StateMachine ) { _state = StateParam; } else { // error return false; } return true; } bool WarMachineHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateMachine: _state = StateDocument; _list->append( _machine ); break; case StateType: _state = StateMachine; break; case StateParam: _state = StateMachine; break; default: // do nothing break; } return true; } bool WarMachineHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if( ch_simplified.isEmpty() ) { return true; } switch( _state ) { case StateType: _machine->setType( (WarMachine::MachineType)ch_simplified.toInt() ); break; case StateParam: _machine->addParam( ch_simplified.toInt() ); break; default: return false; } return true; } bool WarMachineHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libCommon/warMachine.h0000644000175000017500000000621110335201564015621 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** warMachine.h ** Manages war machines (first aid, balist...) ** ** Version : $Id: warMachine.h,v 1.6 2005/11/11 20:47:48 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 27/11/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef WARMACHINE_H #define WARMACHINE_H // generic include files // include files for QT #include #include #include #include // application specific include files /** ------------------------------ * WarMachine ** ------------------------------ */ class WarMachine { public: enum MachineType { WM_HEAL = 0, WM_AMMO, WM_BALIST, // XXX: we should find another name for 'stg that can kill enemy units' WM_CATAPULT // XXX: another name for 'stg that can destroy walls and defenses' ? }; /** Constructor */ WarMachine(); /** Destructor */ virtual ~WarMachine(); int getId() { return _id; } void setId( int id ) { _id = id; } MachineType getType() { return _type; } void setType( MachineType type ) { _type = type; } QString getName() { return _name; } void setName( const QString & name ) { _name = name; } int getParam( uint num ); void addParam( int val ); void addParam0( int val ); void save( QTextStream & ts, int indent ); protected: int _id; MachineType _type; QString _name; QList _params; }; class WarMachineList : public QList { public: /** Constructor */ WarMachineList(); /** Destructor */ virtual ~WarMachineList(); bool init(); bool save(); void clear(); }; class WarMachineHandler : public QXmlDefaultHandler { public: WarMachineHandler( WarMachineList * list ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); protected: QString _errorProt; WarMachineList * _list; WarMachine * _machine; enum State { StateInit, StateDocument, StateMachine, StateType, StateParam }; State _state; }; #endif // WARMACHINE_H attal-src-1.0-rc2/libFight/0000755000175000017500000000000011016113672013202 5ustar aaaaattal-src-1.0-rc2/libFight/.cvsignore0000644000175000017500000000025110331243514015176 0ustar aaaamoc obj moc_* *.moc.cpp *.o *.opt *.plg *.dsp .deps Makefile Makefile.Release Makefile.Debug Makefile.in attal-server duel-server server.plg libserver.plg Debug Release attal-src-1.0-rc2/libFight/casualtiesReport.cpp0000644000175000017500000001021710777472612017257 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** casualtiesReport.cpp ** Report widget about casualties of a lord ** ** Version : $Id: casualtiesReport.cpp,v 1.13 2008/04/10 20:16:10 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 03/12/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "casualtiesReport.h" // generic include files // include files for QT #include #include #include #include #include // application specific include files #include "libCommon/creature.h" #include "libCommon/dataTheme.h" #include "libCommon/genericLord.h" #include "libCommon/log.h" #include "libCommon/unit.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/widget.h" #include "libFight/fight.h" CasualtiesReport::CasualtiesReport( CLASS_FIGHTER fighter, Fight * fight, QWidget * parent, const char * /*name*/ ) : QFrame( parent ) { GenericLord * lord = fight->getFighterLord( fighter ); _fight = fight; _fighter = fighter; _list = new QListWidget( this ); _list->setSelectionMode( QAbstractItemView::NoSelection ); _photo = new Icon( this ); if( lord ) { displayCasualtiesLord( lord ); } else { uint race = fight->getCreatureRace(); uint level = fight->getCreatureLevel(); Creature * creature = DataTheme.creatures.at( race, level ); displayCasualtiesCreature( creature ); } QLabel * reportLabel = new QLabel( this ); reportLabel->setText( _reportTitle ); FIXEDSIZE( reportLabel ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setSpacing( 5 ); layH1->setMargin( 5 ); layH1->addWidget( _photo, 0, Qt::AlignTop ); layH1->addWidget( _list, 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( reportLabel ); layout->addLayout( layH1, 1 ); layout->activate(); } void CasualtiesReport::displayCasualtiesLord( GenericLord * lord ) { GenericFightUnit * unit = 0; _list->setIconSize( QSize ( 30, 60 ) ); for( uint i = 0; i < _fight->getCasualtiesNumber( _fighter ); i++ ) { unit = _fight->getCasualtiesUnit( _fighter, i ); if( unit ) { QString itemText; itemText.sprintf( "%ld %s killed", unit->getNumber(), unit->getCreature()->getName().toLatin1().constData() ); QListWidgetItem * item = new QListWidgetItem( itemText, _list ); item->setIcon( ImageTheme.getMapCreature( unit->getRace() , unit->getLevel() ) ); } } QPixmap * photoPixmap = ImageTheme.getLordPixmap( lord->getId() ); if( photoPixmap ) { _photo->setPixmap( * photoPixmap ); } if( ( _fight->isAttack() && ( _fighter == FIGHTER_ATTACK ) ) || ( ( ! _fight->isAttack() ) && ( _fighter == FIGHTER_DEFENSE ) ) ) { _reportTitle.sprintf( QString(tr( "Report - Your lord %1" ).arg(lord->getName())).toLatin1().constData() ); } else { _reportTitle.sprintf( QString(tr( "Report - Opponent lord %1" ).arg(lord->getName())).toLatin1().constData() ); } } void CasualtiesReport::displayCasualtiesCreature( Creature * creature ) { GenericFightUnit * unit = 0; QString imagePath; _photo->setPixmap( ImageTheme.getPhotoCreature( creature->getRace(), creature->getLevel() ) ); _reportTitle.sprintf( QString(tr( "Report - Opponent creatures %1").arg(creature->getName() ) ).toLatin1().constData() ); unit = _fight->getCasualtiesUnit( _fighter, 0 ); if( unit ) { QString itemText; itemText.sprintf( QString(tr( "%1 %2 killed" ).arg(unit->getNumber()).arg( unit->getCreature()->getName())).toLatin1().constData() ); new QListWidgetItem( itemText, _list ); } else { new QListWidgetItem( tr( "No creatures killed" ), _list ); } } attal-src-1.0-rc2/libFight/casualtiesReport.h0000644000175000017500000000335410347251261016714 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** casualtiesReport.h ** Report widget about casualties of a lord ** ** Version : $Id: casualtiesReport.h,v 1.3 2005/12/12 10:36:33 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 03/12/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CASUALTIESREPORT_H #define CASUALTIESREPORT_H // generic include files // include files for QT #include #include // application specific include files #include "libCommon/attalSocket.h" class QListWidget; class Creature; class Fight; class GenericLord; class Icon; /* ------------------------------ * CasualtiesReport * ------------------------------ */ class CasualtiesReport : public QFrame { Q_OBJECT public: /** Constructor */ CasualtiesReport( CLASS_FIGHTER fighter, Fight * fight, QWidget * parent = 0, const char * name = 0 ); protected: void displayCasualtiesLord( GenericLord * lord ); void displayCasualtiesCreature( Creature * creature ); Fight * _fight; CLASS_FIGHTER _fighter; QListWidget * _list; Icon * _photo; QString _reportTitle; }; #endif // CASUALTIESREPORT_H attal-src-1.0-rc2/libFight/fight.cpp0000644000175000017500000006214111000754011015002 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fight.cpp ** Manages the whole fight ** ** Version : $Id: fight.cpp,v 1.120 2008/04/14 22:17:45 lusum Exp $ ** ** Author(s) : Cyrille Verrier, Pascal Audoux - Sardi Carlo ** ** Date : 07/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "fight.h" #include #include // include files for QT #include #include #include #include #include #include #include #include #include // application specific include #include "conf.h" #include "libCommon/attalCommon.h" #include "libCommon/attalSocket.h" #include "libCommon/attalSettings.h" #include "libCommon/genericFightCell.h" #include "libCommon/log.h" #include "libCommon/pathFinder.h" #include "libCommon/unit.h" #include "libFight/fightMapView.h" #include "libFight/fightResult.h" #include "libFight/fightSettingsDialog.h" #include "libClient/attalSound.h" #include "libClient/game.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/lord.h" extern QString DATA_PATH; extern QString IMAGE_PATH; attalFightData::attalFightData() { unit = NULL; damages = 0; dataType = FIGHT_DATA_NONE; } Fight::Fight( QWidget * parent , const char * name ) : QWidget( parent ) { setWindowTitle( QString ( name )); _socket = NULL; _game = NULL; _popup = NULL; _currentCell = NULL; _isAttack = true; _isActive = false; _isCreature = false; _period = 40; _idTimeFight = -1; _idTimeAnim = startTimer(_period); _activeUnit = NULL; _animatedUnit = NULL; _lostAttack = new QList; _lostDefense = new QList; _attData = new QList; for( int i = 0; i < MAX_UNIT; i ++ ) { _unitsAtt[i] = NULL; _unitsDef[i] = NULL; } _map = new FightMap( this ); _pixmap = new QPixmap( IMAGE_PATH + "fight/background_0.png" ); _map->setBackgroundBrush(QBrush ( * _pixmap)); _view = new FightMapView( _map, this ); _control = new FightControl( this ); _layH = new QHBoxLayout(); _map->setSceneRect( 0,0, _pixmap->width(), _pixmap->height() ); _view->setMaximumSize( _pixmap->width(), _pixmap->height() ); _layH->addWidget( _view, 1, Qt::AlignVCenter ); _layout = new QVBoxLayout( this ); _layout->addLayout( _layH, 1 ); _layout->addWidget( _control ); _layout->activate(); //_view->fitInView( _view->frameRect(), Qt::KeepAspectRatioByExpanding); _view->fitInView( QRect(0,0,0,0), Qt::KeepAspectRatioByExpanding); updateDispositionMode(); AttalSettings::FightSettings fsettings = AttalSettings::getInstance()->getFightSettings(); if( fsettings.areCellsVisible ) { _map->showCells(); } else { _map->hideCells(); } connect( _control, SIGNAL( sig_wait( ) ), SLOT( slot_wait( ) ) ); connect( _control, SIGNAL( sig_retreat( ) ), SLOT( slot_flee( ) ) ); connect( _control, SIGNAL( sig_defend() ), SLOT( slot_defend() ) ); connect( _control, SIGNAL( sig_control() ), SLOT( slot_control() ) ); connect( _control, SIGNAL( sig_message( QString ) ), SLOT( slot_message( QString ) ) ); connect( _view, SIGNAL( sig_mouseMoved( FightCell * , bool) ), SLOT( slot_mouseMoved( FightCell * , bool) ) ); connect( _view, SIGNAL( sig_mouseRightPressed( FightCell * ) ), SLOT( slot_mouseRightPressed( FightCell * ) ) ); connect( _view, SIGNAL( sig_mouseLeftPressed( FightCell * , bool) ), SLOT( slot_mouseLeftPressed( FightCell *, bool ) ) ); connect( _view, SIGNAL( sig_mouseReleased() ), SLOT( slot_mouseReleased() ) ); connect( this , SIGNAL( sig_showResults() ) , SLOT ( showFightResults() ) ); } Fight::~Fight() { stopDataTimer(); stopAnimTimer(); clear(); delete _lostAttack; delete _lostDefense; delete _attData; if( _pixmap ) { delete _pixmap; } } void Fight::reinit() { clear(); _lordAtt = NULL; _lordDef = NULL; _isAttack = true; _isActive = false; _isCreature = false; _currentCell = NULL; _activeUnit = NULL; _animatedUnit = NULL; _map->clearPath(); _map->reinit(); _control->clear(); _result.clear(); _idTimeFight = -1; _idTimeAnim = startTimer( _period ); updateDispositionMode(); } void Fight::clear() { for( int i = 0; i < MAX_UNIT; i++ ) { if( _unitsAtt[i] ) { delete _unitsAtt[i]; _unitsAtt[i] = NULL; } if( _unitsDef[i] ) { delete _unitsDef[i]; _unitsDef[i] = NULL; } } while( ! _lostAttack->isEmpty() ) { delete _lostAttack->takeFirst(); } while( ! _lostDefense->isEmpty() ) { delete _lostDefense->takeFirst(); } _animations.clear(); } void Fight::updateDispositionMode() { _control->updateResolutionMode(); update(); } void Fight::setLord( GenericLord * lord, CLASS_FIGHTER fighter ) { if( fighter == FIGHTER_ATTACK ) { _isAttack = true; _lordAtt = lord; } else { _isAttack = false; _lordDef = lord; } for( int i = 0; i < MAX_UNIT; i++ ) { setUnit( lord->getUnit( i ), fighter, i ); } } void Fight::setOpponent( GenericLord * lord ) { if( _isAttack ) { _lordDef = lord; } else { _lordAtt = lord; } } FightUnit * Fight::getUnit( int num, CLASS_FIGHTER fighter ) { if( fighter == FIGHTER_ATTACK ) { return _unitsAtt[num]; } else { return _unitsDef[num]; } } void Fight::setUnit( GenericFightUnit * unit, CLASS_FIGHTER fighter, int num ) { if( unit ) { if( _isCreature ) { _creatureRace = unit->getRace(); _creatureLevel = unit->getLevel(); } FightUnit * currentUnit; bool noMirror =( fighter == FIGHTER_ATTACK ) ? true : false; currentUnit = new FightUnit( _map, unit, noMirror ); currentUnit->setFightMap ( _map ); appendAnimation( currentUnit ); if( fighter == FIGHTER_ATTACK ) { if( _unitsAtt[num] ) { delete _unitsAtt[num]; } _unitsAtt[num] = currentUnit; currentUnit->setPosition( _map->at( num, 0 ) ); } else if( fighter == FIGHTER_DEFENSE ) { if( _unitsDef[num] ) { delete _unitsDef[num]; } _unitsDef[num] = currentUnit; currentUnit->setPosition( _map->at( num, 14 ) ); } } else { //!unit if( ( fighter == FIGHTER_ATTACK ) && ( _unitsAtt[num] ) ) { delete _unitsAtt[num]; _unitsAtt[num] = NULL; } else if( ( fighter == FIGHTER_DEFENSE ) && _unitsDef[num] ) { delete _unitsDef[num]; _unitsDef[num] = NULL; } } } void Fight::slot_mouseMoved( FightCell * cell, bool isUnit ) { if( !cell) { setCursor( Qt::ArrowCursor ); return; } if( cell) { _currentCell = cell; _isUnit = isUnit; } if( _currentCell ) { #ifdef QT_DEBUG QString msg; msg = QString(tr("Cell: row %1, col %2, coordinates x %3, y %4 ")).arg(_currentCell->getRow()).arg(_currentCell->getCol()).arg(_currentCell->x()).arg( _currentCell->y()); emit sig_statusMsg( msg ); #endif GenericFightUnit * unit = _currentCell->getUnit(); AttalCommon::FightCellAccess access = _currentCell->getAccess(); if( unit ) { if( unit == _activeUnit ) { setCursor( Qt::WaitCursor ); } else if ( !isOpponent(unit) ){ setCursor( Qt::ForbiddenCursor ); } else { if( access == AttalCommon::FAR_OCCUPIED ) { if ( _activeUnit->isDistAttack() && _isUnit ) { setCursor( Qt::PointingHandCursor ); } else { setCursor( Qt::ForbiddenCursor ); } } else if ( access == AttalCommon::NEAR_OCCUPIED && _isUnit ) { setCursor( Qt::PointingHandCursor ); } else { setCursor( Qt::ArrowCursor ); } } } else if ( access == AttalCommon::NEAR_FREE ) { setCursor( Qt::ArrowCursor ); } else { setCursor( Qt::ForbiddenCursor ); } } else { setCursor( Qt::ForbiddenCursor ); } } void Fight::slot_mouseLeftPressed( FightCell * cell, bool isUnit ) { if( _popup && _popup->isVisible() ) { _popup->hide(); _popup->setType(); return; } AttalCommon::FightCellAccess access = cell->getAccess(); TRACE("left pressed cell access %d, active unit %p , isActive %d", access, _activeUnit, _isActive); TRACE("cell->getUnit %p, isUnit %d dist %d", cell->getUnit(), isUnit, cell->getDist() ); TRACE("cell row %d, col %d", cell->getRow(), cell->getCol() ); GenericFightCell * neib = NULL; GenericFightUnit * oppunit = cell->getUnit(); if( oppunit && !isOpponent( oppunit ) ) { return; } if( _activeUnit && _isActive ) { switch( access ) { case AttalCommon::NEAR_FREE : TRACE("NEAR_FREE"); moveUnit( cell ); break; case AttalCommon::NEAR_OCCUPIED: TRACE("NEAR_OCCUPIED"); if( _activeUnit->getDistAttack() > 0 && oppunit ) { _socket->sendFightDistAttack( giveClass( oppunit ), giveNum( oppunit ) ); _socket->sendFightUnitEndMove(); } else if ( oppunit ) { moveUnit( cell ); } else { neib = _map->getHeadCell( cell ,_activeUnit->isLookingToRight() ); if( neib ) { oppunit = neib->getUnit(); if ( ( oppunit ) && ( isOpponent ( oppunit ) ) ) { moveUnit( neib ); } } } break; case AttalCommon::FAR_OCCUPIED: TRACE("FAR_OCCUPIED"); if( ( oppunit ) && ( _activeUnit->getDistAttack() > 0 ) ) { _socket->sendFightDistAttack( giveClass( oppunit ), giveNum( oppunit ) ); _socket->sendFightUnitEndMove(); } else { neib = _map->getHeadCell( cell , !_activeUnit->isLookingToRight() ); if( neib ) { oppunit = neib->getHeadUnit(); if( oppunit && neib->getAccess()== AttalCommon::NEAR_OCCUPIED && ( isOpponent ( oppunit ) ) ) { moveUnit( neib ); } } } break; default: break; } } } void Fight::slot_mouseRightPressed( FightCell * cell ) { if( !_popup ) { _popup = new AttalPopup( this ); } QPoint point = (QPoint)(_view->mapFromScene( cell->x() + 140, cell->y() + 40)); GenericFightUnit * unit = cell->getUnit(); if( unit && ( unit->getNumber() > 0 ) ) { _popup->setUnit( unit ); } _popup->move( point ); _popup->show(); } void Fight::slot_mouseReleased() { } void Fight::slot_wait( void ) { _socket->sendFightWait(); _activeUnit->setActive( false ); } void Fight::slot_flee( void ) { _socket->sendFightFlee(); } void Fight::slot_defend() { _socket->sendFightDefend(); } void Fight::slot_animateFighting() { attalFightData dataFight; if( !_attData->isEmpty() ) { if( !_animatedUnit || !_animatedUnit->isMoving() ) { dataFight = _attData->first(); processData( dataFight ); _attData->removeFirst(); } if( _animatedUnit && _animatedUnit->isMoving() ) { dataFight = _attData->first(); while(( _animatedUnit == dataFight.unit && dataFight.dataType == FIGHT_DATA_MOVE ) ) { processData( dataFight ); _attData->removeFirst(); dataFight = _attData->first(); } } } else { _animatedUnit = NULL; } checkTimer(); } void Fight::timerEvent(QTimerEvent *event) { int id = event->timerId(); if( id == -1 ) { return; } if( id == _idTimeFight) { slot_animateFighting(); } if( id == _idTimeAnim) { //stopAnimTimer(); int animCount = _animations.count(); if( animCount ) { for( int i = 0 ; i < animCount; i++ ) { _animations.at( i )->advance(1); } } //startAnimTimer(); } //qDebug() << "Timer ID:" << event->timerId(); } void Fight::processData( attalFightData dataFight ) { TRACE("process data %d", _idTimeFight); AttalSettings::FightSettings fsettings = AttalSettings::getInstance()->getFightSettings(); int speedMove = 300 / fsettings.animationSpeed; int speed = 400 / fsettings.animationSpeed; switch( dataFight.dataType ) { case FIGHT_DATA_FIGHT: //logDD("fight"); setAdvancePeriod(speed); handleDamages( dataFight ); break; case FIGHT_DATA_MOVE: //logDD("move"); setAdvancePeriod(speedMove); dataFight.unit->goTo( _map->at( dataFight.row, dataFight.col ) ); _animatedUnit = dataFight.unit; break; case FIGHT_DATA_ACTIVE: //logDD("active"); setAdvancePeriod( 200 ); setActive( (CLASS_FIGHTER)dataFight.cla, dataFight.num ); break; case FIGHT_DATA_END: fightEnd( dataFight.result ); break; default: case FIGHT_DATA_NONE: break; } } void Fight::handleSocket() { Q_ASSERT( _socket ); _game->handleSocket(); _socket->reReadData(); switch( _socket->getCla1() ) { case SO_MSG: socketMsg(); break; case SO_GAME: break; case SO_TURN: break; case SO_MODIF: break; case SO_QR: break; case SO_MVT: break; case SO_TECHNIC: break; case SO_EXCH: break; case SO_CONNECT: break; case SO_FIGHT: socketFight(); break; default: logEE( "Unknown socket_class" ); } } void Fight::socketMsg() { TRACE("Fight::socketMsg"); int cla2 = _socket->getCla2(); TRACE(" cla2 %d", cla2 ); QString msg; uchar len = _socket->readChar(); for( uint i = 0; i < len; i++ ) { msg[ i ] = _socket->readChar(); } if( cla2 == C_MSG_FIGHT ) { _listmsg.enqueue( msg ); return; } _control->newMessage( msg ); } void Fight::socketFight() { switch( _socket->getCla2() ) { case C_FIGHT_INIT: logEE( "Should not happen (C_FIGHT_INIT in Fight)" ); break; case C_FIGHT_CREATURE: socketFightCreatue(); break; case C_FIGHT_LORD: socketFightLord(); break; case C_FIGHT_CELL: socketFightCell(); break; case C_FIGHT_UNIT: socketFightUnit(); break; case C_FIGHT_MODUNIT: socketFightModify(); break; case C_FIGHT_MOVE: socketFightMove(); break; case C_FIGHT_ENDMOVE: socketFightEndMove(); break; case C_FIGHT_ACTIVE: socketFightActive(); break; case C_FIGHT_DAMAGE: socketFightDamage(); break; case C_FIGHT_END: socketFightEnd(); break; } } void Fight::updateUnits( void ) { updateLordUnits( getAttack() , FIGHTER_ATTACK ); updateLordUnits( getDefense() , FIGHTER_DEFENSE ); } void Fight::updateLordUnits( GenericLord * lord , CLASS_FIGHTER type ) { GenericLord *oldLord; GenericFightUnit * oldUnit, * newUnit; uint i; if ( lord ) { oldLord = _game->getLord( lord->getId() ); for( i = 0; i < MAX_UNIT; i++) { newUnit = getUnit( i, type ); oldUnit = oldLord->getUnit( i ); if( newUnit ) { if( newUnit->getNumber() == 0 ) { newUnit = NULL; } } if( newUnit && oldUnit ) { oldUnit->setNumber( newUnit->getNumber() ); oldUnit->setMove( newUnit->getMove() ); oldUnit->setHealth( newUnit->getHealth() > 0 ? newUnit->getHealth() : 0); } else if (oldUnit) { oldLord->setUnit(i,NULL); } } } } void Fight::showFightResults() { FightResultWizard resultDialog( this ); resultDialog.exec(); } void Fight::socketFightCell() { int row = _socket->readInt(); int col = _socket->readInt(); uchar type = _socket->readChar(); _map->changeFightCell( row, col, (AttalCommon::TypeFightCell)type ); } void Fight::socketFightUnit() { GenericFightUnit * unit = new GenericFightUnit(); uchar cla = _socket->readChar(); uchar num = _socket->readChar(); uchar race = _socket->readChar(); uchar level = _socket->readChar(); int number = _socket->readInt(); uchar move =_socket->readChar(); int health =_socket->readInt(); /*if(health > unit->getMaxHealth()) { logEE("bug, health %d, maxhealth %d", health, unit->getMaxHealth()); }*/ unit->setCreature( race, level ); unit->setNumber( number ); unit->setMove( move ); unit->setHealth( health ); setUnit( unit, (CLASS_FIGHTER)cla, num ); } void Fight::socketFightCreatue() { _isCreature = true; setOpponent( _game->getLord( 0 ) ); } void Fight::socketFightEndMove() { _isActive = false; _map->clearPath(); } void Fight::socketFightEnd() { attalFightData dataFight; uchar result = _socket->readChar(); // process all pending fight data before end of fight while( !_attData->isEmpty() ) { dataFight = _attData->first(); processData( dataFight ); _attData->removeFirst(); } fightEnd( result ); /* dataFight.result = _socket->readChar(); dataFight.dataType = FIGHT_DATA_END; AttalSettings::FightSettings fsettings = AttalSettings::getInstance()->getFightSettings(); if( fsettings.isAnimationEnabled ) { _attData->append(dataFight); checkTimer(); } else { fightEnd( dataFight.result ); } */ } void Fight::fightEnd( uchar result ) { updateUnits(); _result.fromUChar( result ); //showFightResults(); emit sig_showResults(); stopDataTimer(); stopAnimTimer(); emit sig_quit(); } void Fight::socketFightLord() { uchar id = _socket->readChar(); uchar valueAtt = _socket->readChar(); uchar valueDef = _socket->readChar(); GenericLord * lord = _game->getLord( id ); if( lord ) { lord->setBaseCharac( ATTACK, valueAtt ); lord->setBaseCharac( DEFENSE, valueDef ); setOpponent( lord ); } else { logEE(" lord not exist id %d, valueAtt %d, valueDef %d", id, valueAtt, valueDef); } } void Fight::socketFightActive() { attalFightData dataFight; dataFight.cla = _socket->readChar(); dataFight.num = _socket->readChar(); dataFight.dataType = FIGHT_DATA_ACTIVE; manageData( dataFight ); } void Fight::socketFightModify() { TRACE("socket modify"); GenericFightUnit * unit; uchar cla = _socket->readChar(); uchar num = _socket->readChar(); uchar race = _socket->readChar(); uchar level = _socket->readChar(); int number = _socket->readInt(); uchar move =_socket->readChar(); int health =_socket->readInt(); unit = getUnit ( num, (CLASS_FIGHTER)cla); unit->setCreature( race, level ); unit->setNumber( number ); unit->setMove( move ); unit->setHealth( health ); } void Fight::socketFightMove() { attalFightData dataFight; dataFight.cla = _socket->readChar(); dataFight.num = _socket->readChar(); dataFight.row = _socket->readInt(); dataFight.col = _socket->readInt(); dataFight.dataType = FIGHT_DATA_MOVE; dataFight.unit = getUnit( dataFight.num, (CLASS_FIGHTER)dataFight.cla) ; manageData( dataFight ); } void Fight::handleDamages( attalFightData dataFight ) { int numKilled = 0; FightUnit * attUnit = NULL; FightUnit * defUnit = NULL; CLASS_ATTACK_TYPE type = dataFight.type; QString msg; attUnit = getUnit( dataFight.numAtt, (CLASS_FIGHTER)dataFight.claAtt) ; defUnit = getUnit( dataFight.numDef, (CLASS_FIGHTER)dataFight.claDef) ; if(type == ATTACK_SHOOT) { ImageTheme.playSound( AttalSound::SND_ARROW ); if( attUnit->getCell()->getRow() > defUnit->getCell()->getRow() && attUnit->canAnimate(ShootHigh) ) { attUnit->animate(ShootHigh); } else if( attUnit->getCell()->getRow() < defUnit->getCell()->getRow() && attUnit->canAnimate(ShootLow) ) { attUnit->animate(ShootLow); } else { attUnit->animate(Shooting); } } else { ImageTheme.playSound( AttalSound::SND_HIT ); if( _map->isUpperLevel( attUnit->getCell() , defUnit->getCell() ) && attUnit->canAnimate(AttackHigh) ) { attUnit->animate(AttackHigh); } else if( _map->isLowerLevel( attUnit->getCell() , defUnit->getCell() ) && attUnit->canAnimate(AttackLow) ) { attUnit->animate(AttackLow); } else { attUnit->animate(Fighting); } } defUnit->animate(Defending); numKilled = defUnit->hit( dataFight.damages ); TRACE( "DAMAGES %d", numKilled ); addCasualties( (CLASS_FIGHTER)dataFight.claDef, defUnit->getRace(), defUnit->getLevel(), numKilled ); if( _popup ) { _popup->update(); } if( !_listmsg.isEmpty() ) { msg = _listmsg.dequeue(); _control->newMessage( msg ); } } void Fight::socketFightDamage() { attalFightData dataFight; dataFight.claAtt = _socket->readChar (); dataFight.numAtt = _socket->readChar(); dataFight.type = (CLASS_ATTACK_TYPE) _socket->readChar (); dataFight.claDef = _socket->readChar(); dataFight.numDef = _socket->readChar(); dataFight.damages = _socket->readInt(); dataFight.attUnit = getUnit( dataFight.numAtt, (CLASS_FIGHTER)dataFight.claAtt) ; dataFight.defUnit = getUnit( dataFight.numDef, (CLASS_FIGHTER)dataFight.claDef) ; dataFight.dataType = FIGHT_DATA_FIGHT; manageData( dataFight ); } void Fight::goTo( FightUnit * /* unit */, int /* row */, int /* col */ ) { } void Fight::setActive( CLASS_FIGHTER cla, int num ) { TRACE("set active cla %d, num %d", cla, num); if( _activeUnit ) { _activeUnit->setActive( false ); } if( cla == FIGHTER_ATTACK ) { _activeUnit = _unitsAtt[num]; if( _isAttack ) { _isActive = true; } else { _isActive = false; _map->clearPath(); } } else { _activeUnit = _unitsDef[num]; if( _isAttack ) { _isActive = false; _map->clearPath(); } else { _isActive = true; } } _activeUnit->setActive( true ); if( !isOpponent( _activeUnit ) ) { setUnitsAlpha( true ); _activeUnit->setAlpha( false ); } else { setUnitsAlpha( false ); } if( _isActive ) { _map->initPath( _activeUnit ); slot_mouseMoved( NULL, true ); ///_map->printPath(); } } void Fight::setUnitsAlpha( bool state ) { for( int i = 0; i < MAX_UNIT; i++ ) { if( _isAttack ) { if( _unitsAtt[i] ) { _unitsAtt[ i ]->setAlpha( state ); } } else if( _unitsDef[i] ){ _unitsDef[ i ]->setAlpha( state ); } } } void Fight::moveUnit( GenericFightCell * cell ) { GenericFightCell * current; QStack path = _map->computePath( _activeUnit, cell ); while( ! path.isEmpty() ) { current = path.pop(); _socket->sendFightUnitMove( giveClass( _activeUnit ), giveNum( _activeUnit ), current ); } _socket->sendFightUnitEndMove(); _activeUnit->setActive( false ); _map->clearPath(); } int Fight::giveNum( GenericFightUnit * unit ) { for( int i = 0; i < MAX_UNIT; i++ ) { if( ( _unitsAtt[ i ] == unit ) || ( _unitsDef[ i ] == unit ) ) { return i; } } logEE( "Should not happen" ); return -1; } CLASS_FIGHTER Fight::giveClass( GenericFightUnit * unit ) { for( int i = 0; i < MAX_UNIT; i++ ) { if( _unitsAtt[ i ] == unit ) { return FIGHTER_ATTACK; } if( _unitsDef[ i ] == unit ) { return FIGHTER_DEFENSE; } } logEE( "Fight::giveClass Should not happen %p", unit ); return FIGHTER_ATTACK; } bool Fight::isOpponent( GenericFightUnit * unit ) { if( isAttack() ) { return ( giveClass( unit ) == FIGHTER_DEFENSE ); } else { return ( giveClass( unit ) == FIGHTER_ATTACK ); } } GenericLord * Fight::getFighterLord( CLASS_FIGHTER fighter ) { if( fighter == FIGHTER_ATTACK ) { return _lordAtt; } else { return _lordDef; } } uint Fight::getCasualtiesNumber( CLASS_FIGHTER fighter ) { if( fighter == FIGHTER_ATTACK ) { return _lostAttack->count(); } else { return _lostDefense->count(); } } GenericFightUnit * Fight::getCasualtiesUnit( CLASS_FIGHTER fighter, int numUnit ) { if( fighter == FIGHTER_ATTACK && numUnit < (int)_lostAttack->count() ) { return _lostAttack->at( numUnit ); } else if( fighter == FIGHTER_DEFENSE && numUnit < (int)_lostDefense->count() ) { return _lostDefense->at( numUnit ); } else { return NULL; } } void Fight::addCasualties( CLASS_FIGHTER fighter, uint race, uint level, uint nb ) { if( nb ) { bool found = false; QList * list; if( fighter == FIGHTER_ATTACK ) { list = _lostAttack; } else { list = _lostDefense; } for( int i = 0; i < list->count(); i++ ) { GenericFightUnit * unit = list->at( i ); if( ( unit->getRace() == race ) && ( unit->getLevel() == level ) ) { unit->addNumber( nb ); found = true; } } if( !found ) { GenericFightUnit * unit = new GenericFightUnit(); unit->setCreature( race, level ); unit->setNumber( nb ); list->append( unit ); } } } void Fight::slot_control ( void ) { FightSettingsDialog* dlg = new FightSettingsDialog ( this ); dlg->exec(); if( dlg->result() == QDialog::Accepted ) { AttalSettings::FightSettings fsettings = AttalSettings::getInstance()->getFightSettings(); if( fsettings.areCellsVisible ) { _map->showCells(); } else { _map->hideCells(); } } } void Fight::slot_message( QString msg ) { GenericLord * lord; if( _socket ) { if( _isAttack ) { lord = _lordAtt; } else { lord = _lordDef; } _socket->sendMessage( lord->getOwner()->getConnectionName() + " : " + msg ); } else { _control->newMessage( "(Not connected) : " + msg ); } } void Fight::appendAnimation( AttalSprite * item) { _animations.append( item ); } void Fight::setAdvancePeriod( int period ) { if( _period != period) { _period = period; if( _idTimeAnim != -1 ) { killTimer( _idTimeAnim ); _idTimeAnim = startTimer( _period ); } } } void Fight::checkTimer() { if( _attData->isEmpty() ) { stopDataTimer(); } else { startDataTimer(); } } void Fight::manageData( attalFightData dataFight ) { AttalSettings::FightSettings fsettings = AttalSettings::getInstance()->getFightSettings(); if( fsettings.isAnimationEnabled ) { _attData->append(dataFight); startDataTimer(); } else { processData( dataFight ); } } void Fight::startDataTimer() { if( _idTimeFight == -1 ) { _idTimeFight = startTimer( 40 ); } } void Fight::stopDataTimer() { TRACE("Fight::stopDataTimer"); if( _idTimeFight != -1 ) { killTimer( _idTimeFight ); _idTimeFight = -1; } } void Fight::startAnimTimer() { if( _idTimeAnim == -1 ) { _idTimeAnim = startTimer(_period); } } void Fight::stopAnimTimer() { if( _idTimeAnim != -1 ) { killTimer( _idTimeAnim ); _idTimeAnim = -1; } } attal-src-1.0-rc2/libFight/fight.h0000644000175000017500000001344211000754011014447 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fight.h ** Manages the whole game ** ** Version : $Id: fight.h,v 1.36 2008/04/14 22:17:45 lusum Exp $ ** ** Author(s) : Cyrille Verrier - Sardi Carlo ** ** Date : 17/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef FIGHT_H #define FIGHT_H // include files for QT #include #include #include #include #include // application specific includes #include "libCommon/attalSocket.h" #include "libCommon/fightResultStatus.h" #include "libFight/fightCell.h" #include "libFight/fightControl.h" #include "libFight/fightMap.h" #include "libFight/fightUnit.h" //#include "libClient/attalSprite.h" #include "libClient/lord.h" #include "libClient/widget.h" class QHBoxLayout; class QPixmap; class QVBoxLayout; class FightMapView; class Game; enum fightDataType { FIGHT_DATA_NONE, FIGHT_DATA_MOVE, FIGHT_DATA_FIGHT, FIGHT_DATA_ACTIVE, FIGHT_DATA_END }; class attalFightData { public: attalFightData(); uchar result; uchar claDef, claAtt, numAtt , numDef; int damages; CLASS_ATTACK_TYPE type; int row, col; FightUnit * attUnit, * defUnit; FightUnit * unit; uchar cla, num; fightDataType dataType; }; /* ------------------------------ * Fight * ------------------------------ */ class Fight : public QWidget { Q_OBJECT public: /** Constructor */ Fight( QWidget * parent = 0, const char * name = 0 ); /** delete player and lord */ ~Fight(); /** Reinit widget */ void reinit(); void clear(); /** Set socket for sending infos to the server */ void setSocket( AttalSocket * sock ) { _socket = sock; } void setGame( Game * game ) { _game = game; } void handleSocket(); void handleDamages( attalFightData data ); void setOpponent( GenericLord * lord ); void setLord( GenericLord * lord, CLASS_FIGHTER fighter ); void setUnit( GenericFightUnit * unit, CLASS_FIGHTER fighter, int num ); FightUnit * getUnit( int num, CLASS_FIGHTER fighter ); bool isAttack() { return _isAttack; } GenericLord * getAttack() { return _lordAtt; } GenericLord * getDefense() { return _lordDef; } GenericLord * getFighterLord( CLASS_FIGHTER fighter ); uint getCasualtiesNumber( CLASS_FIGHTER fighter ); GenericFightUnit * getCasualtiesUnit( CLASS_FIGHTER fighter, int numUnit ); FightResultStatus getFightResultStatus() { return _result; } uint getCreatureRace() { return _creatureRace; } uint getCreatureLevel() { return _creatureLevel; } void updateDispositionMode(); void goTo(FightUnit * unit, int row, int col); void processData( attalFightData dataFight ); void manageData( attalFightData dataFight ); signals: void sig_quit(); void sig_showResults(); void sig_statusMsg( const QString & ); private slots: /** slot for managing mouse movements */ void slot_mouseMoved( FightCell * cell, bool isUnit ); /** slot for managing right click */ void slot_mouseRightPressed( FightCell * cell ); /** slot for managing left click */ void slot_mouseLeftPressed( FightCell * cell , bool isUnit); /** slot for managing button release */ void slot_mouseReleased(); void slot_animateFighting(); void slot_wait( void ); void slot_flee( void ); void slot_defend( void ); void slot_control ( void ); void slot_message( QString msg ); void showFightResults(); protected: void timerEvent(QTimerEvent *event); private: void socketMsg(); void socketFight(); void socketFightCell(); void socketFightUnit(); void socketFightModify(); void socketFightMove(); void socketFightDamage(); void socketFightActive(); void socketFightLord(); void socketFightEnd(); void socketFightEndMove(); void socketFightCreatue(); void setActive( CLASS_FIGHTER, int ); void moveUnit( GenericFightCell * cell ); int giveNum( GenericFightUnit * unit ); CLASS_FIGHTER giveClass( GenericFightUnit * unit ); bool isOpponent( GenericFightUnit * unit ); void addCasualties( CLASS_FIGHTER fighter, uint race, uint level, uint nb ); void updateUnits( void ); void setUnitsAlpha( bool state ); void updateLordUnits( GenericLord * lord , CLASS_FIGHTER type ); void fightEnd( uchar result ); void appendAnimation( AttalSprite * item); void setAdvancePeriod( int period ); void inline checkTimer(); void inline startDataTimer(); void stopDataTimer(); void inline startAnimTimer(); void stopAnimTimer(); bool _isAttack; bool _isActive; bool _isCreature; uint _creatureRace, _creatureLevel; GenericLord * _lordAtt, * _lordDef; //int _lostAtt[ MAX_UNIT ], _lostDef[ MAX_UNIT ]; QList * _lostAttack, * _lostDefense; QList * _attData; QList _animations; QQueue _listmsg; FightUnit * _activeUnit; FightUnit * _animatedUnit; AttalSocket * _socket; QTimer *_timer; int _idTimeFight, _idTimeAnim, _period; FightMap * _map; FightMapView * _view; FightUnit * _unitsAtt[MAX_UNIT], * _unitsDef[MAX_UNIT]; FightControl * _control; FightCell * _currentCell; FightResultStatus _result; AttalPopup * _popup; Game * _game; QVBoxLayout * _layout; QHBoxLayout * _layH; QPixmap * _pixmap; uchar _claDef, _claAtt, _numAtt , _numDef; int _damages; bool _isUnit; }; #endif // FIGHT_H attal-src-1.0-rc2/libFight/fightCell.cpp0000644000175000017500000000236210506030626015612 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightCell.cpp ** ** Version : $Id: fightCell.cpp,v 1.2 2006/09/25 19:44:22 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "fightCell.h" // generic include files #include // include files for QT // application specific includes #include "libCommon/log.h" const int FightCell::RTTI = Type; /** Print FightCell info */ void FightCell::displayCell() { printf( "FightCell [%d][%d]\n", getRow(), getCol() ); } int FightCell::type() const { // Enable the use of qgraphicsitem_cast with this item. return Type; } attal-src-1.0-rc2/libFight/fightCell.h0000644000175000017500000000327410506030626015262 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightCell.h ** ** Version : $Id: fightCell.h,v 1.4 2006/09/25 19:44:22 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef FIGHTCELL_H #define FIGHTCELL_H // generic include files // include files for QT #include // application specific includes #include "libCommon/genericFightCell.h" #include "libFight/graphicalFightCell.h" /* ------------------------------ * FightCell * ------------------------------ */ /** comment for the class */ class FightCell : public GraphicalFightCell , public GenericFightCell { public: /** Constructor */ FightCell( int row, int col, QGraphicsScene * canvas, bool horizontalDraw = false ) : GraphicalFightCell( row, col, canvas, horizontalDraw ), GenericFightCell( row, col ) {}; /** Display cell info in the log */ void displayCell(); enum { Type = QGraphicsItem::UserType + 44 }; static const int RTTI; int type() const; }; #endif // FIGHTCELL_H attal-src-1.0-rc2/libFight/fightControl.cpp0000644000175000017500000001111311007640016016342 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightControl.cpp ** Widget for the control board in fight mode ** ** Version : $Id: fightControl.cpp,v 1.10 2008/05/05 17:12:46 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "fightControl.h" // generic include files // include files for QT #include #include // application specific include files #include "libCommon/attalSettings.h" #include "libCommon/log.h" #include "libClient/attalButton.h" #include "libClient/chatWidget.h" #include "libClient/imageTheme.h" // // ----- FightControl ----- // FightControl::FightControl( QWidget * parent, const char * /* name*/ ) : QWidget( parent ) { AttalButton * butControl = new AttalButton( this ); butControl->setPixmap( QPixmap ( *ImageTheme.getWidgetPixmap( BTN_CONTROL ) ) ); butControl->setFixedSize( 52, 52 ); butControl->setToolTip( tr( "Options" ) ); AttalButton * butSurrender = new AttalButton( this ); butSurrender->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( BTN_SURRENDER ) ) ); butSurrender->setFixedSize( 52, 52 ); butSurrender->setToolTip( tr( "Surrender" ) ); butSurrender->setEnabled( false ); AttalButton * butFlee = new AttalButton( this ); butFlee->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( BTN_FLEE ) ) ); butFlee->setFixedSize( 52, 52 ); butFlee->setToolTip( tr( "Flee" ) ); AttalButton * butAuto = new AttalButton( this ); butAuto->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( BTN_AUTO )) ); butAuto->setFixedSize( 52, 52 ); butAuto->setToolTip( tr( "Auto-fight" ) ); butAuto->setEnabled( false ); AttalButton * butSpell = new AttalButton( this ); butSpell->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( BTN_SPELL )) ); butSpell->setFixedSize( 52, 52 ); butSpell->setToolTip( tr( "Spells" ) ); butSpell->setEnabled( false ); AttalButton * butWait = new AttalButton( this ); butWait->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( BTN_WAIT )) ); butWait->setFixedSize( 52, 52 ); butWait->setToolTip( tr( "Wait" ) ); AttalButton * butDefend = new AttalButton( this ); butDefend->setPixmap( QPixmap( *ImageTheme.getWidgetPixmap( BTN_DEFEND )) ); butDefend->setFixedSize( 52, 52 ); butDefend->setToolTip( tr( "Defend" ) ); butDefend->setEnabled( false ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( butWait ); layH1->addStretch( 1 ); layH1->addWidget( butDefend ); layH1->addStretch( 1 ); layH1->addWidget( butSpell ); layH1->addStretch( 1 ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addStretch( 1 ); layH2->addWidget( butFlee ); layH2->addStretch( 1 ); layH2->addWidget( butSurrender ); layH2->addStretch( 1 ); layH2->addWidget( butAuto ); layH2->addStretch( 1 ); layH2->addWidget( butControl ); layH2->addStretch( 1 ); _layV1 = new QVBoxLayout(); _layV1->setSpacing( 5 ); _layV1->setMargin( 5 ); _layV1->addStretch( 1 ); _layV1->addLayout( layH1 ); _layV1->addStretch( 1 ); _layV1->addLayout( layH2 ); _layV1->addStretch( 1 ); _chat = new ChatWidget( this ); _layout = new QHBoxLayout( this ); _layout->addLayout( _layV1 ); _layout->addWidget( _chat, 1 ); _layout->activate(); connect( butWait, SIGNAL( pressed( ) ), SLOT( slot_waitPressed( ) ) ); connect( butFlee, SIGNAL( pressed( ) ), SLOT( slot_fleePressed( ) ) ); connect( butControl, SIGNAL( clicked( ) ), SLOT( slot_controlPressed( ) ) ); connect( butDefend, SIGNAL( pressed() ), SIGNAL( sig_defend() ) ); connect( _chat, SIGNAL( sig_message( QString ) ),this, SIGNAL( sig_message( QString ) ) ); } void FightControl::updateResolutionMode() { if( AttalSettings::getInstance()->getDispositionMode() == AttalSettings::DM_FULL ) { setMinimumHeight( 150 ); setMaximumHeight( 500 ); setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); } else { setFixedHeight( 150 ); } update(); } void FightControl::clear() { _chat->clear(); } void FightControl::newMessage( const QString & msg ) { emit sig_newMessage( msg ); } attal-src-1.0-rc2/libFight/fightControl.h0000644000175000017500000000473110642003523016017 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightControl.h ** Widget for the control board in fight mode ** ** Version : $Id: fightControl.h,v 1.3 2007/07/01 19:58:11 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef FIGHTCONTROL_H #define FIGHTCONTROL_H // generic include files // include files for QT #include #include // application specific include files class QHBoxLayout; class QVBoxLayout; class ChatWidget; /* ------------------------------ * FightControl * ------------------------------ */ /** Controlboard in fight mode */ class FightControl : public QWidget { Q_OBJECT public: /** Constructor */ FightControl( QWidget * parent = 0, const char * name = 0 ); /** Displays new message */ void newMessage( const QString & msg ); /** Clear the message box */ void clear(); void updateResolutionMode(); public slots: /** Slot if 'Wait' button pressed */ void slot_waitPressed( void ) { emit sig_wait(); } /** Slot if 'Flee' button pressed */ void slot_fleePressed( void ) { emit sig_retreat(); } void slot_controlPressed ( void ) { emit sig_control (); } signals: /** Signal Control button clicked */ void sig_control(); /** Signal 'Spell' button clicked */ void sig_useSpell(); /** Signal 'Quit' button clicked */ void sig_quit(); /** Signal 'Autofight' button clicked */ void sig_autoFight(); /** Signal 'Wait' button clicked */ void sig_wait(); /** Signal 'Defend' button clicked */ void sig_defend(); /** Signal 'Retreat' button clicked */ void sig_retreat(); /** Signal 'Surrender' button clicked */ void sig_surrender(); void sig_message( QString ); void sig_newMessage( const QString & ); private: ChatWidget * _chat; QHBoxLayout * _layout; QVBoxLayout * _layV1; }; #endif // CLASSNAME_H attal-src-1.0-rc2/libFight/fightMap.cpp0000644000175000017500000001027410510307651015451 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightMap.cpp ** Manage the global view ** ** Version : $Id: fightMap.cpp,v 1.15 2006/10/02 22:16:09 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 07/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "fightMap.h" // generic include files #include // include files for QT // application specific includes #include "libCommon/log.h" #include "libCommon/pathFinder.h" #include "libCommon/genericFightCell.h" #include "libFight/fightCell.h" #include "libFight/fightUnit.h" FightMap::FightMap( QObject * parent , const char * /* name */) : GraphicalFightMap( parent ), GenericFightMap() { newFightMap( 9, 15 ); } FightMap::~FightMap() { // XXX: delete [][] // XXX to complete } void FightMap::clearFightMap() { if( _genericFightCells != NULL ) { for( int i = 0 ; i < _height ; i++ ) { for( int j = 0; j < _width; j++ ){ if( _genericFightCells[i][j] ) delete (FightCell*)_genericFightCells[i][j]; } if( _genericFightCells[i] ) delete [] _genericFightCells[i]; } if( _genericFightCells ) delete [] _genericFightCells; } _genericFightCells = NULL; _height = 0; _width = 0; } void FightMap::newFightMap( int h, int w, bool horizontalDraw ) { _height = h; _width = w; _genericFightCells = new GenericFightCell **[_height]; int i; for( i = 0; i < _height; i++ ) { _genericFightCells[i] = new GenericFightCell *[_width]; } for( i = 0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { FightCell * tempo; tempo = new FightCell( i, j, this, true /*false*/ ); tempo->setType( AttalCommon::NORMAL ); _genericFightCells[i][j] = tempo; tempo->show (); } } _horizontalDraw = horizontalDraw; } void FightMap::changeFightCell( int i, int j, AttalCommon::TypeFightCell typ ) { if( _genericFightCells[i][j]->getType() == AttalCommon::UNKNOWN_TYPE ) { ( (FightCell*)_genericFightCells[i][j] )->setType( typ ); ( (FightCell*)_genericFightCells[i][j] )->show(); } else { logEE( "FightCell type should be unknown" ); } } void FightMap::initPath( GenericFightUnit * unit ) { GenericFightMap::initPath( unit ); for( int i = 0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { switch( ( (FightCell*)_genericFightCells[i][j] )->getAccess() ) { case AttalCommon::UNKNOWN_ACCESS: ( (FightCell*)_genericFightCells[i][j] )->setColor( Qt::gray ); break; case AttalCommon::NONE: ( (FightCell*)_genericFightCells[i][j] )->setColor( Qt::red ); break; case AttalCommon::NEAR_FREE: ( (FightCell*)_genericFightCells[i][j] )->setColor( Qt::blue ); break; case AttalCommon::NEAR_OCCUPIED: ( (FightCell*)_genericFightCells[i][j] )->setColor( Qt::yellow ); break; case AttalCommon::FAR_FREE: case AttalCommon::FAR_OCCUPIED: ( (FightCell*)_genericFightCells[i][j] )->setColor( Qt::green ); break; default: logEE( "Should not happen %d", ( (FightCell*)_genericFightCells[i][j] )->getAccess() ); break; } } } update(); } void FightMap::clearPath() { GenericFightMap::clearPath(); for( int i = 0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { ( (FightCell*)_genericFightCells[i][j] )->setColor( Qt::gray ); } } update(); } void FightMap::showCells () { for( int i = 0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { ( (FightCell*)_genericFightCells[i][j] )->setEnabled( true ); } } update (); } void FightMap::hideCells () { for( int i = 0; i < _height; i++ ) { for( int j = 0; j < _width; j++ ) { ( (FightCell*)_genericFightCells[i][j] )->setEnabled( false ); } } update (); } attal-src-1.0-rc2/libFight/fightMap.h0000644000175000017500000000440710331243514015115 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightMap.h ** Manage the map of the fight ** ** Version : $Id: fightMap.h,v 1.4 2005/10/30 22:21:00 audoux Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 07/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef FIGHTMAP_H #define FIGHTMAP_H // generic include files // include files for QT // application specific includes #include "libCommon/attalCommon.h" #include "libCommon/genericFightMap.h" #include "libFight/graphicalFightMap.h" #include "libFight/fightCell.h" /* ------------------------------ * FightMap * ------------------------------ */ /** A Map that contains FightCells */ class FightMap : public GraphicalFightMap, public GenericFightMap { public: /** Constructor */ FightMap( QObject * parent =0 , const char * name =0); /// XXX: Does we need a destructor for the FightCells ?? /** Destructor */ ~FightMap(); /** Clear the map */ void clearFightMap(); /** Change the cell type */ void changeFightCell( int i, int j, AttalCommon::TypeFightCell typ ); /** Reinit a new fight map */ void newFightMap( int h, int w, bool horizontalDraw = false ); /** Reinit a new unknown fight map */ void newUnknownFightMap( int h, int w ); /** Return the FightCell at (i,j) */ FightCell * at( int i, int j ) { return (FightCell*)GenericFightMap::at( i, j ); } /** Clears the path on the figth map */ void clearPath(); /** Compute the state of the cells (and the color) before unit mvt */ void initPath( GenericFightUnit * unit ); /** Show all cells*/ void showCells (); /** Hide all cells*/ void hideCells (); }; #endif // FIGHTMAP_H attal-src-1.0-rc2/libFight/fightMapView.cpp0000644000175000017500000000607111007640016016301 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightMapView.cpp ** subclass of QCanvasSprite that handles mouse event ... ** ** Version : $Id: fightMapView.cpp,v 1.14 2008/05/05 17:12:46 lusum Exp $ ** ** Author(s) : Cyrille Verrier - Sardi Carlo ** ** Date : 07/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "fightMapView.h" // generic include files // include files for QT #include // application specific includes #include "libCommon/log.h" #include "libClient/lord.h" #include "libFight/fightUnit.h" /** subclass of QCanvasView that handles mouse event ... */ FightMapView::FightMapView( FightMap *map, QWidget * parent, const char * /* name */, Qt::WFlags /* f */ ) : QGraphicsView( map, parent ) { viewport()->setMouseTracking( true ) ; } /** handles mouse move event */ void FightMapView::mouseMoveEvent( QMouseEvent *e) { QPointF pos = mapToScene(e->pos()); QList list = scene()->items( pos ); uint nbItems = (uint)list.count(); for( unsigned int i = 0; i < nbItems; i++ ) { if( list[i]->type() == FightUnit::RTTI ) { if(((FightUnit*)list[ i ] )->hit( pos ) ){ emit sig_mouseMoved( (FightCell *) ((FightUnit*)list[i])->getCell(), true); return; } } else if( list[i]->type() == FightCell::RTTI ) { emit sig_mouseMoved( (FightCell *) list[i] , false); return; } } emit sig_mouseMoved( NULL, true ); } /* * handles mouse press event * emit a signal to say which cell is selected */ void FightMapView::mousePressEvent( QMouseEvent * e ) { QPointF pos = mapToScene(e->pos()); QList list = scene()->items( pos ); uint nbItems = (uint)list.count(); for( unsigned int i=0; i< nbItems; i++ ) { if( list[i]->type() == FightUnit::RTTI ) { if(((FightUnit*)list[ i ] )->hit( pos ) ){ if( e->button() == Qt::LeftButton ) { emit sig_mouseLeftPressed( (FightCell *) ((FightUnit*)list[i])->getCell() , true); return; } else { emit sig_mouseRightPressed( (FightCell *) ((FightUnit*)list[i])->getCell() ); return; } } } else if( list[i]->type() == FightCell::RTTI ) { if( e->button() != Qt::RightButton ) { emit sig_mouseLeftPressed( (FightCell *) list[i], false); return; } } } } /** handles mouse release event */ void FightMapView::mouseReleaseEvent( QMouseEvent *e ) { if( e->button() == Qt::RightButton ) emit sig_mouseReleased(); } void FightMapView::updateView() { QList rectlist; rectlist.append( sceneRect() ); updateScene( rectlist ); } attal-src-1.0-rc2/libFight/fightMapView.h0000644000175000017500000000430311007640016015742 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightMapView.cpp ** subclass of QCanvasSprite that handles mouse event ... ** ** Version : $Id: fightMapView.h,v 1.9 2008/05/05 17:12:46 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 17/10/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef FIGHTMAPVIEW_H #define FIGHTMAPVIEW_H // generic include files // include files for QT #include #include // application specific includes #include "libFight/fightMap.h" #include "libFight/fightCell.h" /* ------------------------------ * FightMapView * ------------------------------ */ /** subclass of QCanvasView that handles mouse event ... */ class FightMapView : public QGraphicsView { Q_OBJECT public: /** Constructor */ FightMapView( FightMap * map, QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0 ); signals: /** Indicates where the mouse has been moved */ void sig_mouseMoved( FightCell * cell, bool isUnit ); /** Indicates where the mouse has been presses with right button */ void sig_mouseRightPressed( FightCell * cell ); /** Indicates where the mouse has been presses with left button */ void sig_mouseLeftPressed( FightCell * cell , bool isUnit); /** Indicated that the mouse has been released */ void sig_mouseReleased(); public slots: void updateView(); protected: /** reimplemented : handles mouse event */ void mouseMoveEvent ( QMouseEvent *e ); void mouseReleaseEvent( QMouseEvent *e ); void mousePressEvent( QMouseEvent *e ); }; #endif // FIGHTMAPVIEW_H attal-src-1.0-rc2/libFight/fightResult.cpp0000644000175000017500000002012710777503654016230 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightResult.cpp ** Displaying the result of a fight ** ** Version : $Id: fightResult.cpp,v 1.12 2008/04/10 21:33:32 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 19/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "fightResult.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include #include // application specific include file #include "libClient/attalButton.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/widget.h" #include "libFight/casualtiesReport.h" #include "libFight/fight.h" #include "libFight/lordReport.h" // // ----- FightResult ----- // FightResult::FightResult( Fight * fight, char /*result*/, QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { /// XXX: use result ? QVBoxLayout * layout = new QVBoxLayout( this ); layout->addSpacing( 5 ); _mainResult = new MainResult( fight->getAttack(), fight->getDefense(), this ); layout->addWidget( _mainResult ); layout->addStretch( 1 ); QLabel * labCasu = new QLabel( this ); labCasu->setFont( QFont( "Helvetica", 20, QFont::Bold ) ); labCasu->setAlignment( Qt::AlignCenter ); labCasu->setText( "Battlefield Casualties" ); layout->addWidget( labCasu ); layout->addStretch( 1 ); QLabel * labAttack = new QLabel( this ); labAttack->setFont( QFont( "Helvetica", 16, QFont::Bold ) ); labAttack->setAlignment( Qt::AlignCenter ); labAttack->setText( "Attack" ); layout->addWidget( labAttack ); _attackList = new CasualtiesList( this ); for( uint i = 0; i < fight->getCasualtiesNumber( FIGHTER_ATTACK ); i++ ) { GenericFightUnit * unit = fight->getCasualtiesUnit( FIGHTER_ATTACK, i ); if( unit ) { _attackList->addCasualty( unit ); } } layout->addWidget( _attackList ); layout->addStretch( 1 ); QLabel * labDefense = new QLabel( this ); labDefense->setFont( QFont( "Helvetica", 16, QFont::Bold ) ); labDefense->setAlignment( Qt::AlignCenter ); labDefense->setText( "Defense" ); layout->addWidget( labDefense ); _defenseList = new CasualtiesList( this ); for( uint j = 0; j < fight->getCasualtiesNumber( FIGHTER_DEFENSE ); j++ ) { GenericFightUnit * unit = fight->getCasualtiesUnit( FIGHTER_DEFENSE, j ); if( unit ) { _defenseList->addCasualty( unit ); } } layout->addWidget( _defenseList ); layout->addStretch( 1 ); QHBoxLayout * lay1 = new QHBoxLayout(); AttalButton * pbOk = new AttalButton( this, AttalButton::BT_OK ); lay1->addStretch( 6 ); lay1->addWidget( pbOk ); lay1->addStretch( 1 ); layout->addLayout( lay1 ); layout->addSpacing( 15 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); hide(); } // // ----- MainResult ----- // MainResult::MainResult( GenericLord * attack, GenericLord * defense, QWidget * parent, const char * /* name */ ) : QWidget( parent ) { QHBoxLayout * layout = new QHBoxLayout( this ); _photo1 = new Icon( this ); _photo1->setPixmap( * ImageTheme.getLordPixmap( attack->getId() ) ); layout->addWidget( _photo1 ); layout->addStretch( 1 ); if( defense ) { _photo2 = new Icon( this ); _photo2->setPixmap(* ImageTheme.getLordPixmap( attack->getId() ) ); layout->addWidget( _photo2 ); } layout->activate(); } // // ----- CasualtiesList ----- // CasualtiesList::CasualtiesList( QWidget * parent, const char * /* name */) : QWidget( parent ) { _present = new QFrame( this ); _present->setFrameStyle( QFrame::Box | QFrame::Raised ); _present->setLineWidth( 1 ); _present->setMidLineWidth( 1 ); _present->setFixedHeight( 44 ); _none = new QLabel( _present ); _none->setText( "None" ); _none->setFixedSize( _none->sizeHint() ); _layPresent = new QHBoxLayout( _present ); _layPresent->addStretch( 1 ); _layPresent->addWidget( _none ); _layPresent->addStretch( 1 ); _layPresent->activate(); _numbers = new QFrame( this ); _numbers->setFixedHeight( 10 ); _layNumbers = new QHBoxLayout( _numbers ); _layNumbers->addStretch( 1 ); _layNumbers->activate(); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( _present, 1 ); layout->addWidget( _numbers, 1 ); layout->activate(); setFixedHeight( 54 ); } void CasualtiesList::addCasualty( GenericFightUnit * unit ) { if( unit ) { _none->hide(); Icon * photo = new Icon( _present, "photo" ); photo->setPixmap( ImageTheme.getPhotoCreature( unit ) ); _layPresent->addWidget( photo ); _layPresent->addStretch( 2 ); } } // // ----- FightResultWizard ----- // FightResultWizard::FightResultWizard( Fight * fight ) : QDialog( fight, Qt::Dialog ) { setWindowTitle(tr("FightResultWizard")); FightResultStatus result = fight->getFightResultStatus(); QLabel * labResult = new QLabel( this ); labResult->setFont( QFont( "Helvetica", 20, QFont::Bold ) ); labResult->setAlignment( Qt::AlignCenter ); if( ( fight->isAttack() && result.hasAttackWin() ) || ( ( ! fight->isAttack() ) && result.hasDefenseWin() ) ) { _lordReport = 0; /// XXX TODO when other gain will be managed more clearly _lordReport = new LordReport; labResult->setText( tr( "Congratulations, you win!" ) ); } else { _lordReport = 0; if( result.hasFled() ) { labResult->setText( tr( "Humm, you have fled!" ) ); } else if( result.hasSurrendered() ) { labResult->setText( tr( "Pff, you have surrendered!" ) ); } else { labResult->setText( tr( "Sorry, you lose!" ) ); } } if( fight->isAttack() ) { _playerCasualties = new CasualtiesReport( FIGHTER_ATTACK, fight ); _opponentCasualties = new CasualtiesReport( FIGHTER_DEFENSE, fight ); } else { _playerCasualties = new CasualtiesReport( FIGHTER_DEFENSE, fight ); _opponentCasualties = new CasualtiesReport( FIGHTER_ATTACK, fight ); } _stack = new QStackedWidget( this ); if( _lordReport ) { _stack->addWidget( _lordReport ); } _stack->addWidget( _playerCasualties ); _stack->addWidget( _opponentCasualties ); _pbPrev = new AttalButton( this, AttalButton::BT_PREV ); _pbNext = new AttalButton( this, AttalButton::BT_NEXT ); _pbOk = new AttalButton( this, AttalButton::BT_OK ); FIXEDSIZE( labResult ); QHBoxLayout * layHButtons = new QHBoxLayout(); layHButtons->setMargin( 5 ); layHButtons->setSpacing( 5 ); layHButtons->addStretch( 1 ); layHButtons->addWidget( _pbPrev ); layHButtons->addStretch( 1 ); layHButtons->addWidget( _pbNext ); layHButtons->addStretch( 1 ); layHButtons->addWidget( _pbOk ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->addSpacing( 5 ); layout->addWidget( labResult ); layout->addWidget( _stack, 1 ); layout->addLayout( layHButtons ); layout->activate(); connect( _pbPrev, SIGNAL( clicked() ), SLOT( slot_previous() ) ); connect( _pbNext, SIGNAL( clicked() ), SLOT( slot_next() ) ); connect( _pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); _stack->setCurrentIndex( 0 ); checkArrows(); } void FightResultWizard::slot_previous() { int index = _stack->currentIndex(); if( index > 0 ) { _stack->setCurrentIndex( index - 1 ); } checkArrows(); } void FightResultWizard::slot_next() { if( _stack->currentIndex() < ( _stack->count() - 1 ) ) { _stack->setCurrentIndex( _stack->currentIndex() + 1 ); } checkArrows(); } void FightResultWizard::checkArrows() { int index = _stack->currentIndex(); if( index == 0 ) { _pbPrev->setEnabled( false ); } else { _pbPrev->setEnabled( true ); } if( index == ( _stack->count() - 1 ) ) { _pbNext->setEnabled( false ); } else { _pbNext->setEnabled( true ); } } attal-src-1.0-rc2/libFight/fightResult.h0000644000175000017500000000541010344415426015660 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightResult.h ** Displaying the result of a fight ** ** Version : $Id: fightResult.h,v 1.3 2005/12/03 22:24:22 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 19/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef FIGHTRESULT_H #define FIGHTRESULT_H // generic include files // include files for QT #include #include // application specific includes class QFrame; class QHBoxLayout; class QLabel; class QStackedWidget; class AttalButton; class CasualtiesList; class CasualtiesReport; class Creature; class Fight; class GenericFightUnit; class GenericLord; class Icon; class LordReport; class MainResult; /* ------------------------------ * FightResult * ------------------------------ */ /** Dialog displaying the result of the fight */ class FightResult : public QDialog { public: /** Constructor */ FightResult( Fight * fight, char result, QWidget * parent = 0, const char * name = 0 ); private: MainResult * _mainResult; CasualtiesList * _attackList, * _defenseList; }; /** Main widget of the result of the fight */ class MainResult : public QWidget { public: /** Constructor */ MainResult( GenericLord * attack, GenericLord * defense, QWidget * parent = 0, const char * name = 0 ); private: Icon * _photo1, * _photo2; }; /** Display list of casualties */ class CasualtiesList : public QWidget { public: /** Constructor */ CasualtiesList( QWidget * parent = 0, const char * name = 0 ); /** Add a new casualty to the list */ void addCasualty( GenericFightUnit * unit ); /** Clear the list */ void clear(); private: QFrame * _present, * _numbers; QHBoxLayout * _layPresent, * _layNumbers; QLabel * _none; }; /** Dialog displaying the result of the fight */ class FightResultWizard : public QDialog { Q_OBJECT public: /** Constructor */ FightResultWizard( Fight * fight ); public slots: void slot_previous(); void slot_next(); private: void checkArrows(); AttalButton * _pbOk, * _pbNext, * _pbPrev; QStackedWidget * _stack; CasualtiesReport * _playerCasualties, * _opponentCasualties; LordReport * _lordReport; }; #endif // FIGHTRESULT_H attal-src-1.0-rc2/libFight/fightSettingsDialog.cpp0000644000175000017500000000631010600220100017627 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** template.cpp ** this is a template for all .cpp files ** ** Version : $Id: fightSettingsDialog.cpp,v 1.6 2007/03/21 12:08:32 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "fightSettingsDialog.h" // generic include files // include files for QT #include #include #include #include // application specific include files #include "libCommon/attalSettings.h" #include "libClient/attalButton.h" #include "libClient/gui.h" #include "libClient/askWidget.h" /** add comments here */ FightSettingsDialog::FightSettingsDialog( QWidget* parent ) :QDialog ( parent ) { setWindowTitle(tr("Settings")); _animationCheckBox = new QCheckBox( tr ( "Animation" ), this ); connect( _animationCheckBox, SIGNAL ( clicked () ), this, SLOT ( slot_animationCheckBoxClicked () ) ); _animationSpeed = new AskInt( tr( "Animation Speed" ), this ); _animationSpeed->setMinValue( 1 ); _animationSpeed->setValue( 6 ); _animationSpeed->setMaxValue( 10 ); _cellsCheckBox = new QCheckBox ( tr ( "Show cells" ), this ); AttalButton * okButton = new AttalButton( this, AttalButton::BT_OK ); connect( okButton, SIGNAL ( pressed ( ) ), this, SLOT ( slot_okButtonClicked ()) ); QVBoxLayout* layout = new QVBoxLayout ( this ); layout->setMargin ( 15 ); layout->addWidget ( _animationCheckBox, 1 , Qt::AlignHCenter ); layout->addWidget ( _animationSpeed, 1, Qt::AlignHCenter ); layout->addWidget ( _cellsCheckBox, 1, Qt::AlignHCenter ); layout->setSpacing ( 10 ); layout->addWidget( okButton, 1 , Qt::AlignHCenter ); layout->activate(); AttalSettings::FightSettings fsettings = AttalSettings::getInstance()->getFightSettings(); _animationSpeed->setEnabled( fsettings.isAnimationEnabled ); _animationSpeed->setValue( fsettings.animationSpeed ); _animationCheckBox->setChecked( fsettings.isAnimationEnabled ); _cellsCheckBox->setChecked( fsettings.areCellsVisible ); FIXEDSIZE( this ); } void FightSettingsDialog::slot_okButtonClicked() { accept(); } void FightSettingsDialog::slot_cancelButtonClicked() { QDialog::reject(); } void FightSettingsDialog::accept () { AttalSettings::FightSettings fsettings; fsettings.isAnimationEnabled = _animationCheckBox->isChecked(); fsettings.animationSpeed = _animationSpeed->getValue(); fsettings.areCellsVisible = _cellsCheckBox->isChecked(); AttalSettings::getInstance()->setFightSettings( fsettings ); QDialog::accept(); } void FightSettingsDialog::slot_animationCheckBoxClicked() { _animationSpeed->setEnabled( _animationCheckBox->isChecked() ); } attal-src-1.0-rc2/libFight/fightSettingsDialog.h0000644000175000017500000000266410362453404017330 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** Author(s) : Nick Semenov ** ** Date : 06/12/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef FIGHTSETTINGSDIALOG_H #define FIGHTSETTINGSDIALOG_H // generic include files // include files for QT #include // application specific include files class QCheckBox; class AskInt; /* ------------------------------ * FightSettingsDialog * ------------------------------ */ class FightSettingsDialog: public QDialog { Q_OBJECT public: FightSettingsDialog(QWidget* parent); void accept (); private slots: void slot_okButtonClicked(); void slot_cancelButtonClicked(); void slot_animationCheckBoxClicked(); private: QCheckBox * _animationCheckBox; AskInt * _animationSpeed; QCheckBox * _cellsCheckBox; }; #endif // FIGHTSETTINGSDIALOG_H attal-src-1.0-rc2/libFight/fightUnit.cpp0000644000175000017500000002760311000754011015646 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightUnit.cpp ** Manage Units ** ** Version : $Id: fightUnit.cpp,v 1.59 2008/04/14 22:17:45 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 28/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "fightUnit.h" // generic include files #include // include files for QT #include #include #include // application specific include files #include "conf.h" #include "libCommon/attalSettings.h" #include "libCommon/dataTheme.h" #include "libCommon/log.h" #include "libFight/fightCell.h" #include "libClient/imageTheme.h" /** rtti number for GraphicalFightUnit class */ const int FightUnit::RTTI = Type; FightUnit::FightUnit( QGraphicsScene * canvas ) : AttalSprite( (*ImageTheme.getCreature(0))[0], canvas ), GenericFightUnit() { _cpt = 0; _isMoving = false; _alpha = false; _isActive = false; setFrame( 0 ); setZValue( CAN_F_UNIT ); } FightUnit::FightUnit( QGraphicsScene * canvas, GenericFightUnit * unit, bool mirror ) : AttalSprite( (*ImageTheme.getCreature(0))[0], canvas ), GenericFightUnit( *unit ) { _cpt = 0; _isMoving = false; _destroyed = false; _alpha = false; _isActive = false; setZValue( CAN_F_UNIT ); QList * sequence = (*ImageTheme.getCreature(DataTheme.creatures.computeSequence( unit )))[ (mirror ^ getCreature ()->isAnimated()) ? 1 : 0 ]; if( sequence ) { setSequence( sequence ); } _lookingToRight = mirror; setFrame( 0 ); } FightUnit::~FightUnit() { } void FightUnit::initCreatureForMove( GraphicalFightCell *cell ) { Creature* creature = getCreature (); //uint race = creature->getRace (); //uint level = creature->getLevel (); //bool lookingToRight = isLookingToRight (); //CreaturePixmap* basePixs = ImageTheme.getCreature ( race , level ); //setSequence ( (*basePixs)[ lookingToRight?0:1 ] ); setFrame ( creature->getFirstAnimationFrame( Moving ) ); // bounding rect is in item coordinate QRectF endRect = cell->boundingRect(); QPointF endPoint = endRect.topLeft(); QPointF sceneEndPoint = cell->mapToScene( endPoint ) ; if( _moving ) { QRectF startRect = _moving->boundingRect(); QPointF startPoint = startRect.topLeft(); QPointF sceneStartPoint = _moving->mapToScene( startPoint ) ; double dx = double ( sceneEndPoint.x() - sceneStartPoint.x() ) / 10.0; double dy = double ( sceneEndPoint.y() - sceneStartPoint.y() ) / 10.0; setVelocity( dx, dy ); } else { _cpt = 10; setVelocity( 0, 0 ); } } int FightUnit::hit( int nb ) { int ret = GenericFightUnit::hit( nb ); if( _number == 0 ) { if( canAnimate( Dying ) ) { animate(Dying); } else { setDestroyed( true ); } } return ret; } void FightUnit::goTo( FightCell * cell ) { AttalSettings::FightSettings fsettings = AttalSettings::getInstance()->getFightSettings(); Creature* creature = getCreature (); uint race = creature->getRace (); uint level = creature->getLevel (); if( fsettings.isAnimationEnabled ) { if( DataTheme.creatures.at( race , level )->isAnimated() ) { _currentAnimationType = Moving; _isMoving = true; if( creature->getNumFrames() > 0 ) { _cpt = 10; setAnimated ( true ); if( _fifo.count() == 0 ) { _moving = (FightCell*)getCell(); } _fifo.enqueue( cell ); } } else { setPosition( cell ); } } else { setPosition( cell ); } GenericFightUnit::goTo( (GenericFightCell *)cell ); } void FightUnit::setPosition( FightCell * cell ) { //logDD("set position, cell %p, x %f, y %f", cell, cell->x(), cell->y()); GenericFightUnit::goTo( (GenericFightCell *)cell ); if( (FightCell*)this->getNeibCell() && isLookingToRight()) { cell = (FightCell*)this->getNeibCell(); } QRectF rect = cell->boundingRect(); //logDD(" setPos X rect %f, offset %f, width %f\n Y rect %f, offset %f,height %f\n rect width %f, rect height %f ", rect.x() , creature->getXOffset() , boundingRect().width() , rect.y() , creature->getYOffset(), boundingRect().height() ,rect.width(), rect.height() ); int xoffset = _lookingToRight ? _creature->getXOffset() : _creature->getXOffsetMirror(); int yoffset = _creature->getYOffset(); setPos( cell->x() + xoffset - boundingRect().width() + 2 * rect.width(), cell->y() + ( rect.height() ) - boundingRect().height() + yoffset ); setZValue( CAN_F_UNIT + cell->getRow() ); } void FightUnit::advance( int stage ) { if( animated() ) { uint race = _creature->getRace (); uint level = _creature->getLevel (); int alphaFrame = _creature->numAnimation()-1; if( DataTheme.creatures.at( race , level )->isAnimated() ) { if( stage == 1 ) { switch ( _currentAnimationType ) { case Moving: if( frame() >= _creature->getLastAnimationFrame( Moving ) ) { setFrame( _creature->getFirstAnimationFrame( Moving ) ); } _cpt++; if( _cpt >= 10 ) { _cpt = 0; if( _fifo.count() > 0 ) { FightCell * temp = _fifo.dequeue(); initCreatureForMove( temp ); _moving = temp; } else { setFrame( _creature->getFirstAnimationFrame( Moving ) ); if( _moving ) { setPosition( _moving ); } setVelocity( 0, 0 ); _moving = 0; setAnimated( false ); setActive( false ); _isMoving = false; if( _alpha ) { setFrame( alphaFrame ); } } } break; case Shooting: case ShootHigh: case ShootLow: case Defending: case Fighting: case AttackHigh: case AttackLow: if( frame() >= _creature->getLastAnimationFrame( _currentAnimationType ) ) { setFrame( _creature->getFirstAnimationFrame( Moving ) ); setAnimated ( false ); if( _alpha ) { setFrame( alphaFrame ); } } _isMoving = false; setPosition( (FightCell*)this->getCell() ); break; case Selecting: if( frame() >= _creature->getLastAnimationFrame( Selecting ) ) { setFrame( _creature->getFirstAnimationFrame( Selecting ) ); //setAnimated ( false ); } _isMoving = false; break; case Dying: if( frame() >= _creature->getLastAnimationFrame( Dying ) ) { setFrame( _creature->getFirstAnimationFrame( Dying ) ); setAnimated ( false ); setDestroyed( true ); } _isMoving = false; break; default: break; } AttalSprite::advance ( stage ); } else { } } else { //logDD( "advance not animated %d %d", race, level ); _isMoving = false; } } } void FightUnit::paint ( QPainter * painter , const QStyleOptionGraphicsItem * option, QWidget * widget) { int numItems = getNumber (); QRectF r = boundingRect (); int x,y; int width = (int) r.width (); int height = (int) r.height (); if( numItems > 0 ) { if(!_destroyed) { int xoffset = _lookingToRight ? _creature->getXOffset() : _creature->getXOffsetMirror(); int yoffset = _creature->getYOffset(); x = width - 60 - xoffset; y = height - 32 - yoffset; } else { x = width - 30; y = height - 16; } } else { x = width - 30; y = height - 16; } if( ! _destroyed ) { QFont oldFont = painter->font (); QPen oldPen = painter->pen (); QBrush oldBrush = painter->brush (); QFont f = oldFont; QPen pen ( QColor ( 100, 255 , 255 ) ); painter->setPen ( pen ); QBrush br ( QColor ( 200, 150, 150 ) ); painter->setBrush ( br ); painter->drawRect ( int (r.left ()) + x , int( r.top ()) + y , 30, 16 ); QPen fontPen ( QColor ( 120, 130, 240 ) ); painter->setPen ( fontPen ); f.setPixelSize ( 12 ); painter->setFont ( f ); QString s = QString::number ( numItems ); painter->drawText ( int (r.left ()) + x , int( r.top () )+ y , 30, 16, Qt::AlignCenter, s ); painter->setFont ( oldFont ); painter->setPen ( oldPen ); painter->setBrush ( oldBrush ); } AttalSprite::paint( painter, option, widget ); } QPixmap FightUnit::imageAdvanced() { return image(); } void FightUnit::setDestroyed( bool state ) { if( state ) { _destroyed = state; setAnimated( false ); setZValue( CAN_F_UNIT_DEAD ); if( canAnimate( Dead )) { setFrame ( _creature->getFirstAnimationFrame( Dead ) ); } else { setSequence( ImageTheme.deadCreature ); setFrame( 0 ); } } } bool FightUnit::canAnimate (CreatureAnimationType current) { bool ret = false; AttalSettings::FightSettings fsettings = AttalSettings::getInstance()->getFightSettings(); if( fsettings.isAnimationEnabled ) { if (_creature->getFirstAnimationFrame( current )!= -1) { ret = true; } } return ret; } void FightUnit::animate(CreatureAnimationType current) { AttalSettings::FightSettings fsettings = AttalSettings::getInstance()->getFightSettings(); uint race = _creature->getRace (); uint level = _creature->getLevel (); if( fsettings.isAnimationEnabled ) { if( DataTheme.creatures.at( race , level )->isAnimated() ) { _currentAnimationType = current; setAnimated ( true ); setFrame ( _creature->getFirstAnimationFrame( current ) ); } } } bool FightUnit::hit( const QPointF & p ) { QImage ima = image().toImage(); bool ret = false; int ix = (int)(p.x()-scenePos().x()); int iy = (int)(p.y()-scenePos().y()); if ( ima.valid( ix , iy ) ) { QRgb pixel = ima.pixel( ix, iy ); ret = ( qAlpha( pixel ) != 0 ); } return ret; } void FightUnit::setActive( bool state ) { _isActive = state; if(!_creature->isAnimated()) { if(state) { if( _hpix.isNull() ) { QImage ima; QPixmap start = image( 0 ); ima = start.toImage(); ima.convertToFormat( QImage::Format_ARGB32 ); int w = ima.width(); int h = ima.height(); QImage img( w, h, QImage::Format_ARGB32 ); for ( int x = 0; x < w; x++ ) { for ( int y = 0; y < h/2; y++ ) { QRgb pixel = (xupdate(); } else { if(state) { animate(Selecting); } else { if(_currentAnimationType == Selecting) { setAnimated ( false ); } } } } void FightUnit::setAlpha(bool state) { if(_destroyed) { return; } bool anim = _creature->isAnimated(); _alpha = state; int frame; if( state ) { frame = anim ? _creature->numAnimation()-1 : 2; if( _alpix.isNull() ) { int startIndex = anim ? getCreature()->getFirstAnimationFrame( Moving ) : 0; QPixmap start = image( startIndex ); int w = start.width(); int h = start.height(); QPixmap pixmap = QPixmap(w, h); pixmap.fill(QColor( 0,0,0,190)); _alpix = start; _alpix.setAlphaChannel( pixmap.alphaChannel() ); setImage( _alpix, frame ); } } else { frame = anim ? _creature->getFirstAnimationFrame( Moving ) : 0; if( !anim && _isActive ) { frame = 1; } } if( animated() ) { return; } setFrame( frame ); update(); scene()->update(); } QRgb FightUnit::colorH( QRgb v ) { int ach = qAlpha(v); if ( ach == 255 ) return v; //int r = std::min ( (int) (qRed(v)* 2 *255 /255),255); //int g = std::min ( (int) (qGreen(v) * 2 *255 /255),255); //int b = std::min ( (int) (qBlue(v) *2 *255 /255),255); return qRgba(255,255,255,ach); } int FightUnit::type() const { // Enable the use of qgraphicsitem_cast with this item. return Type; } attal-src-1.0-rc2/libFight/fightUnit.h0000644000175000017500000000554611000761546015330 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightUnit.h ** Manage Units ** ** Version : $Id: fightUnit.h,v 1.26 2008/04/14 23:06:14 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 28/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef FIGHTUNIT_H #define FIGHTUNIT_H // generic include files // include files for QT #include #include // application specific include files #include "libCommon/attalSocket.h" #include "libCommon/unit.h" #include "libCommon/creature.h" #include "libClient/attalSprite.h" class FightCell; class GraphicalFightCell; /* ------------------------------ * FightUnit * ------------------------------ */ /** comment for the class */ class FightUnit : public AttalSprite, public GenericFightUnit { public: /** Constructor */ FightUnit( QGraphicsScene * canvas ); FightUnit( QGraphicsScene * canvas, GenericFightUnit * unit, bool mirror ); virtual ~FightUnit(); enum { Type = QGraphicsItem::UserType + 2234 }; /** Hit unit by 'nb' hitpoints */ int hit( int nb ); /** unit go to cell */ void goTo( FightCell * cell ); void setPosition( FightCell * cell ); virtual void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget ); /** Advance animation */ void advance( int stage ); /** Highlight (or not) the unit if active (or not) */ void setActive( bool state ); void setAlpha( bool state ); QRgb colorH( QRgb v ); /** Draw destroyed unit (or not) if destroyed (or not) */ void setDestroyed( bool state ); void animate (CreatureAnimationType current); bool canAnimate (CreatureAnimationType current); bool isAnimated () { return getCreature()->isAnimated(); } inline bool isMoving () { return _isMoving; } bool isAlpha() { return _alpha; } CreatureAnimationType getTypeAnimation() { return _currentAnimationType; } bool hit( const QPointF & ); static const int RTTI; int type() const; protected: void initCreatureForMove( GraphicalFightCell * cell ); QPixmap imageAdvanced() ; QPixmap _alpix, _hpix; uint _cpt; FightCell * _moving; QQueue _fifo; bool _destroyed, _isMoving, _alpha, _isActive; CreatureAnimationType _currentAnimationType; }; #endif // FIGHTUNIT_H attal-src-1.0-rc2/libFight/graphicalFightCell.cpp0000644000175000017500000000576710522705152017442 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalFightCell.cpp ** this class draws a hexagonal fightCell ** ** Version : $Id: graphicalFightCell.cpp,v 1.11 2006/11/03 18:28:58 fdarling Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 07/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "graphicalFightCell.h" // generic include files #include #include // include files for QT #include // application specific include #include "conf.h" #include "libCommon/genericFightCell.h" #include "libCommon/log.h" const double GraphicalFightCell::_sqrt3 = sqrt(3); const int GraphicalFightCell::_size = 15; int VShift = 150; int HShift = 0; /** this class draws a hexagonal fightCell */ GraphicalFightCell::GraphicalFightCell( int row, int col, QGraphicsScene * canvas, bool horizontalDraw ) : QGraphicsPolygonItem( 0,canvas ) { _horizontal = horizontalDraw; setColor( QColor( "grey" ) ); _pa = QPolygonF(7); if( _horizontal ) { _pa[0] = QPoint( int(_size * _sqrt3) , 4 * _size); _pa[1] = QPoint( 0, 3 * _size ); _pa[2] = QPoint( 0, _size ); _pa[3] = QPoint( int( _size * _sqrt3), 0 ); _pa[4] = QPoint( int( 2 * _size * _sqrt3), _size ); _pa[5] = QPoint( int( 2 * _size * _sqrt3), 3 * _size ); _pa[6] = _pa[0]; if( row % 2 == 0 ) { setPos( int (HShift + 2*_sqrt3*_size*col ), int ( 3*_size*row) + VShift ); } else { setPos( int (HShift + 2*_sqrt3*_size*(col + 0.5) ), int ( 3*_size*row) + VShift ); } } else { _pa[0] = QPoint( 4 * _size, int(_size * _sqrt3) ); _pa[1] = QPoint( 3 * _size, 0 ); _pa[2] = QPoint( _size, 0 ); _pa[3] = QPoint( 0, int(_size * _sqrt3) ); _pa[4] = QPoint( _size, int(2 * _size * _sqrt3) ); _pa[5] = QPoint( 3 * _size, int(2 * _size * _sqrt3) ); _pa[6] = _pa[0]; if( col % 2 == 0 ) { setPos( int ( 3*_size*col), int (VShift + 2*_sqrt3*_size*row ) ); } else { setPos( int ( 3*_size*col), int (VShift + 2*_sqrt3*_size*(row+0.5) ) ); } } setPolygon( _pa ); setEnabled( true ); setVisible( true ); //collisions( true ); setZValue( CAN_F_GROUND ); show(); } void GraphicalFightCell::paint( QPainter * p, const QStyleOptionGraphicsItem * /* option */, QWidget * /* widget */) { if(enabled()) { p->setPen( _color ); QPolygonF array = polygon(); //array.translate( (int)x(), (int)y() ); p->drawPolygon( array ); } } QPointF GraphicalFightCell::getCenter() { return boundingRect().center(); } attal-src-1.0-rc2/libFight/graphicalFightCell.h0000644000175000017500000000403710522705152017074 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalFightCell.h ** this class draws a hexagonal fightCell ** ** Version : $Id: graphicalFightCell.h,v 1.8 2006/11/03 18:28:58 fdarling Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 07/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GRAPHICALFIGHTCELL_H #define GRAPHICALFIGHTCELL_H // generic include files // include files for QT #include #include #include #include // application specific includes /* ------------------------------ * GraphicalFightCell * ------------------------------ */ /** this class draws a hexagonal fightCell */ class GraphicalFightCell : public QGraphicsPolygonItem { public: /** Constructor */ GraphicalFightCell( int row, int col, QGraphicsScene * canvas, bool horizontalDraw = false); /** Return the center point of the hexa cell */ QPointF getCenter(); void setColor( QColor color ) { _color = color; } bool enabled() {return _enabled; } void setEnabled ( bool enabled) { _enabled = enabled; } private: /** Reimplemented not to fill the hexa */ void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget ); static const double _sqrt3; static const int _size; QPolygonF _pa; QColor _color; bool _horizontal; bool _enabled; }; #endif // GRAPHICALFIGHTCELL_H attal-src-1.0-rc2/libFight/graphicalFightMap.cpp0000644000175000017500000000200407673141254017267 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalFightMap.cpp ** this class draws a fightMap of cells ** ** Version : $Id: graphicalFightMap.cpp,v 1.1.1.1 2003/06/15 19:02:04 audoux Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "graphicalFightMap.h" // generic include files // include files for QT // application specific includes attal-src-1.0-rc2/libFight/graphicalFightMap.h0000644000175000017500000000272310510307651016731 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** graphicalFightMap.h ** this class draws a fightMap of cells ** ** Version : $Id: graphicalFightMap.h,v 1.5 2006/10/02 22:16:09 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 07/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef GRAPHICALFIGHTMAP_H #define GRAPHICALFIGHTMAP_H // generic include files // include files for QT #include // application specific includes #include "libCommon/log.h" /* ------------------------------ * GraphicalFightMap * ------------------------------ */ /** this class draws a fightMap of cells */ class GraphicalFightMap : public QGraphicsScene { public: /** Constructor */ GraphicalFightMap( QObject * parent = 0 ) : QGraphicsScene( parent ) {}; }; #endif // GRAPHICALFIGHTMAP_H attal-src-1.0-rc2/libFight/libFight.pro0000644000175000017500000000246711015367574015500 0ustar aaaaTEMPLATE = lib include( ../config.pro ) INCLUDEPATH += .. LIBS += -L.. unix:LIBS += -lAttalCommon unix:LIBS += -lAttalClient win32:LIBS += -lAttalCommon9 win32:LIBS += -lAttalClient9 contains( DEFINES, WITH_SOUND ) { win32:INCLUDEPATH += "$$quote($${SDL_DIR})\include" } VERSION = 9.0.0 SOURCES += casualtiesReport.cpp SOURCES += fight.cpp SOURCES += fightCell.cpp SOURCES += fightControl.cpp SOURCES += fightMap.cpp SOURCES += fightResult.cpp SOURCES += fightMapView.cpp SOURCES += fightSettingsDialog.cpp SOURCES += fightUnit.cpp SOURCES += graphicalFightCell.cpp SOURCES += graphicalFightMap.cpp SOURCES += lordReport.cpp HEADERS += casualtiesReport.h HEADERS += fight.h HEADERS += fightCell.h HEADERS += fightControl.h HEADERS += fightMap.h HEADERS += fightResult.h HEADERS += fightMapView.h HEADERS += fightSettingsDialog.h HEADERS += fightUnit.h HEADERS += graphicalFightCell.h HEADERS += graphicalFightMap.h HEADERS += lordReport.h TRANSLATIONS += ../i18n/de/attal_libfight_de.ts TRANSLATIONS += ../i18n/fr/attal_libfight_fr.ts TRANSLATIONS += ../i18n/ru/attal_libfight_ru.ts TRANSLATIONS += ../i18n/it/attal_libfight_it.ts DESTDIR = .. OBJECTS_DIR=./obj MOC_DIR=./moc TARGET = AttalFight unix { target.path = $${ATT_LIB_PREFIX} INSTALLS += target } #The following line was inserted by qt3to4 QT += xml network attal-src-1.0-rc2/libFight/lordReport.cpp0000644000175000017500000000207110510307651016042 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** lordReport.cpp ** report about lord improvements ** ** Version : $Id: lordReport.cpp,v 1.2 2006/10/02 22:16:09 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 03/12/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "lordReport.h" // generic include files // include files for QT // application specific include files LordReport::LordReport( QWidget * parent, const char * /* name */ ) : QWidget( parent ) { } attal-src-1.0-rc2/libFight/lordReport.h0000644000175000017500000000245010344415321015507 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** lordReport.h ** report about lord improvements ** ** Version : $Id: lordReport.h,v 1.1 2005/12/03 22:23:13 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 03/12/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef LORDREPORT_H #define LORDREPORT_H // generic include files // include files for QT #include // application specific include files /* ------------------------------ * LordReport * ------------------------------ */ class LordReport : public QWidget { public: /** Constructor */ LordReport( QWidget * parent = 0, const char * name = 0 ); }; #endif // LORDREPORT_H attal-src-1.0-rc2/libServer/0000755000175000017500000000000011016113673013410 5ustar aaaaattal-src-1.0-rc2/libServer/.cvsignore0000644000175000017500000000025110331243514015403 0ustar aaaamoc obj moc_* *.moc.cpp *.o *.opt *.plg *.dsp .deps Makefile Makefile.Release Makefile.Debug Makefile.in attal-server duel-server server.plg libserver.plg Debug Release attal-src-1.0-rc2/libServer/attalServer.cpp0000644000175000017500000010531510770506550016423 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalServer.cpp ** the server : manage connections ** ** Version : $Id: attalServer.cpp,v 1.103 2008/03/20 16:14:32 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 28/10/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "attalServer.h" // generic include files // include files for QT #include // application specific includes #include "libCommon/artefact.h" #include "libCommon/artefactManager.h" #include "libCommon/dataTheme.h" #include "libCommon/genericBase.h" #include "libCommon/genericEvent.h" #include "libCommon/genericMapCreature.h" #include "libCommon/log.h" #include "libCommon/priceMarket.h" #include "libCommon/unit.h" extern QString VERSION; // // ----- AttalPlayerSocket ----- // AttalPlayerSocket::AttalPlayerSocket( ) : AttalSocket(), _player( 0 ) { _player = new GenericPlayer(); TRACE( "AttalPlayerSocket::AttalPlayerSocket, _player %p", _player); } AttalPlayerSocket::~AttalPlayerSocket( ) { TRACE( "AttalPlayerSocket::~AttalPlayerSocket, _player %p", _player); if( _player ) { delete _player; _player = NULL; } } bool AttalPlayerSocket::canSee( int row, int col ) { bool ret = false; if( _player ) { ret = _player->canSee( row, col ); } return ret; } bool AttalPlayerSocket::canSee( GenericCell * cell ) { bool ret = false; if( _player ) { ret = _player->canSee( cell ); } return ret; } /* * NOTE: All send fuction must be in the form sendSomething( destinationPlayer/s , data ) */ // // ----- AttalServer ----- // AttalServer::AttalServer( int port, QHostAddress address ) : QTcpServer( 0 ) { listen( address, port ); _num = 0; _mapper = new QSignalMapper( this ); connect( _mapper, SIGNAL( mapped( int ) ), SIGNAL( sig_readEvent( int ) ) ); connect( this, SIGNAL( sig_readEvent( int ) ), SLOT( slot_readSocket( int ) ) ); } AttalServer::~AttalServer() { while (!_theSockets.isEmpty()) { AttalPlayerSocket * uneso = _theSockets.takeFirst(); disconnect(uneso, 0, 0, 0); delete uneso; } while (!_oldSockets.isEmpty()) { AttalPlayerSocket * uneso = _oldSockets.takeFirst(); disconnect(uneso, 0, 0, 0); delete uneso; } } void AttalServer::incomingConnection( int socketDescriptor ) { TRACE("AttalServer::incomingConnection( int socketDescriptor %d)",socketDescriptor); GenericPlayer * player; AttalPlayerSocket * uneso = new AttalPlayerSocket(); uneso->setSocketDescriptor( socketDescriptor ); player = uneso->getPlayer(); _theSockets.append( uneso ); _mapper->setMapping( uneso, _theSockets.count()-1 ); connect( uneso, SIGNAL( readyRead() ), _mapper, SLOT( map() ) ); connect( uneso, SIGNAL( disconnected() ), SLOT( slot_socketClose() ) ); uneso->sendConnectionOk(); } void AttalServer::slot_socketClose() { TRACE("AttalServer:slot_socketClose" ); QString connectionName = ""; AttalPlayerSocket * uneso =(AttalPlayerSocket*)sender(); if( uneso->getPlayer()) { TRACE("Server:close connection player " ); TRACE("Disconnect: %s", uneso->getPlayer()->getConnectionName().toLatin1().constData()); sendMessage(uneso->getPlayer()->getConnectionName() + " disconnect"); connectionName = uneso->getPlayer()->getConnectionName(); } closeConnectionSocket( uneso ); emit sig_endConnection( connectionName ); } void AttalServer::closeConnectionSocket(AttalPlayerSocket * uneso) { TRACE("AttalServer::closeConnectionSocket" ); while (!_oldSockets.isEmpty()) { delete _oldSockets.takeFirst(); } unmapSockets(); int it = _theSockets.indexOf( uneso ); if (it != -1) { _theSockets.removeAt( it ); } //deferred removal caused by problems of SEGFAULT, no problems of memory leak ( only remain one socket in _oldSockets list and deleted at the end ) _oldSockets.append( uneso); uint nbSockets = (uint) _theSockets.count(); for( uint i = 0; i < nbSockets; ++i ) { _mapper->setMapping( _theSockets[ i ], i ); _theSockets[ i ]->sendConnectionId( i ); } TRACE("AttalServer::closeConnectionSocket end " ); } void AttalServer::unmapSockets() { uint oldNbSockets = (uint) _theSockets.count(); for( uint i = 0; i < oldNbSockets; ++i ) { AttalPlayerSocket * sock = NULL; sock = (AttalPlayerSocket *) _mapper->mapping( i ); if( sock ) { _mapper->removeMappings( sock ); } } } void AttalServer::closeConnectionPlayer( AttalPlayerSocket * uneso, ConnectionInfo info ) { if( uneso->getPlayer() ) { switch( info ) { case SK_KICKED: sendMessage(uneso->getPlayer()->getConnectionName() + " kicked"); break; case SK_WRONG_VERSION: sendMessage(uneso->getPlayer()->getConnectionName() + " wrong client version"); sendMessage(QString("This server use version "+VERSION )); break; default: break; } } if(uneso) { uneso->close(); } } void AttalServer::closeConnectionPlayer( QString name, ConnectionInfo info ) { TRACE("AttalServer::closeConnectionPlayer " ); AttalPlayerSocket * uneso = NULL; uint nbSockets = (uint) _theSockets.count(); for( uint i = 0; i < nbSockets; ++i ) { if( _theSockets[ i ]->getPlayer()->getConnectionName() == name ) { uneso = _theSockets[ i]; closeConnectionPlayer( uneso, info ); break; } } } void AttalServer::slot_readSocket( int num ) { AttalSocketData tmpData; getSocketData( num ); tmpData = getData( num ); //logDD( "Server socket received %d | %d | %d", getCla1(), getCla2(), getCla3() ); uchar c = getCla1(); switch( c ) { case SO_CONNECT: switch( getCla2() ) { case C_CONN_NAME: handleConnectionName( num ); break; case C_CONN_VERSION: handleConnectionVersion( num ); break; case C_CONN_PLAYER: logEE( "Should not happen (Server : SO_CONNECT/C_CONN_PLAYER)" ); break; case C_CONN_ID: logEE( "Should not happen (Server : SO_CONNECT/C_CONN_ID)" ); break; case C_CONN_OK: logEE( "Should not happen (Server : SO_CONNECT/C_CONN_OK)" ); break; } break; case SO_MSG: handleMessage( num ); break; default: //logEE( "Game not started...%d", c ); break; } emit sig_newData( num, tmpData ); if( isData( num ) ) { slot_readSocket( num ); } } void AttalServer::handleConnectionName( int num ) { TRACE("AttalServer::handleConnectionName"); QString res; QString name; /// XXX: CHECK build of 'res' _theSockets[ num ]->getPlayer()->setNum( num ); uint len = readChar(); for( uint i = 0; i < len; i++) { res.append( readChar() ); } name = res; if( name == QString("IA") ) { _theSockets[ num ]->getPlayer()->setRuledByAi( true ); } for( int j = 0; j < _theSockets.count(); j++ ) { if( j != num && _theSockets[ j ]->getPlayer()->getConnectionName() == name ) { name = res + QString("_%1").arg(j); } } _theSockets[ num ]->getPlayer()->setConnectionName( name ); TRACE("old name player %s", res.toLatin1().constData()); TRACE("current name %s",name.toLatin1().constData()); sendConnectionId( num ); sendConnectionName( name , num); emit sig_newPlayer( _theSockets[ num ] ); } void AttalServer::handleConnectionVersion( int num ) { TRACE("AttalServer::handleConnectionVersion"); QString res; uint len = readChar(); for( uint i = 0; i < len; i++) { res.append( readChar() ); } if( res != VERSION ) { AttalPlayerSocket * uneso = _theSockets.at( num ); closeConnectionPlayer( uneso, SK_WRONG_VERSION ); } } void AttalServer::handleMessage( int num ) { QString msg; uchar d = readChar(); for( uint i = 0; i < d; i++ ) { msg[i] = readChar(); } if( msg.contains(": /")) { sendMessage( _theSockets.at( num )->getPlayer(), msg ); QStringList list = msg.split(": /"); handleCommand( num, list.at(1) ); } } void AttalServer::handleCommand( int num, const QString & cmd ) { QString msg = ""; if( cmd.startsWith("list") ) { uint nbSockets = (uint) _theSockets.count(); for( uint i = 0; i < nbSockets; ++i ) { msg = _theSockets[i ]->getPlayer()->getConnectionName(); msg += " " + _theSockets[i ]->peerAddress().toString(); msg += "\n"; sendMessage( _theSockets.at( num )->getPlayer(), msg ); } } else if( cmd.startsWith("kick") ) { QStringList list = cmd.split(" "); QString name = list.at( 1 ); closeConnectionPlayer( name, AttalServer::SK_KICKED ); } else if( cmd.startsWith("version") ) { msg = "This server use version "+VERSION; sendMessage( _theSockets.at( num )->getPlayer(), msg ); } } void AttalServer::sendConnectionId( char num ) { _theSockets.at( num )->sendConnectionId( num ); } void AttalServer::sendConnectionPlayer( GenericPlayer * dest, GenericPlayer * player ) { findSocket( dest )->sendConnectionPlayer( player ); } void AttalServer::sendConnectionName(const QString & name, int num ) { _theSockets.at( num )->sendConnectionName( name ); } void AttalServer::sendMessage( QString msg ) { uint nbSockets = (uint) _theSockets.count(); for( uint i = 0; i < nbSockets; ++i ) { _theSockets[ i ]->sendMessage( msg ); } } void AttalServer::getSocketData( int num ) { _num = num; _theSockets.at( num )->readData(); } void AttalServer::reReadSocketData( int num ) { _num = num; _theSockets.at( num )->reReadData(); } void AttalServer::copyData( AttalSocket* data ) { _theSockets.at( _num )->setData( data ); } uchar AttalServer::getCla1() { return _theSockets.at( _num )->getCla1(); } uchar AttalServer::getCla2() { return _theSockets.at( _num )->getCla2(); } uchar AttalServer::getCla3() { return _theSockets.at( _num )->getCla3(); } int AttalServer::readInt() { return _theSockets.at( _num )->readInt(); } unsigned char AttalServer::readChar() { return _theSockets.at( _num )->readChar(); } void AttalServer::copyData( int num, AttalSocket* data ) { _theSockets.at( num )->setData( data ); } AttalSocketData AttalServer::getData( int num ) { return _theSockets.at( num )->getData(); } uchar AttalServer::getCla1( int num ) { return _theSockets.at( num )->getCla1(); } uchar AttalServer::getCla2( int num ) { return _theSockets.at( num )->getCla2(); } uchar AttalServer::getCla3( int num ) { return _theSockets.at( num )->getCla3(); } int AttalServer::readInt( int num ) { return _theSockets.at( num )->readInt(); } unsigned char AttalServer::readChar( int num ) { return _theSockets.at( num )->readChar(); } bool AttalServer::isData( int num ) { return (_theSockets.at(num)->bytesAvailable() > 0); } AttalPlayerSocket * AttalServer::findSocket( GenericPlayer * player ) { uint nbSockets = (uint) _theSockets.count(); for( uint i = 0; i < nbSockets; ++i ) { if( _theSockets[ i ]->getPlayer() == player ) { return _theSockets[ i ]; } } logEE( "AttalServer::findSocket Socket not found " ); logEE("findSocket player %p, player name %s", player, player->getConnectionName().toLatin1().constData() ); return 0; } GenericPlayer * AttalServer::getPlayer( int numsock ) { if( numsock < _theSockets.count() ) { return _theSockets[ numsock ]->getPlayer(); } return NULL; } /*! */ /* * engine specific methods */ void AttalServer::startGame( const QList & list ) { TRACE("AttalServer::startGame"); AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); TRACE("Socket %p", socket); TRACE("Name %s", qPrintable(list.at(k)->getConnectionName())); if( socket ) { socket->sendBegGame( nbSockets ); } } } void AttalServer::playerLose( const QList & list, GenericPlayer * player ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket ) { socket->sendLostGame( player ); } } } void AttalServer::playerWin( const QList & list, GenericPlayer * player ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket ) { socket->sendWinGame( player ); } } } void AttalServer::sendGameInfoPlayer( GenericPlayer * player, const QList & list ) { AttalPlayerSocket * socket = findSocket( player ); uint nbSockets = (uint) list.count(); for( uint i = 0; i < nbSockets; ++i ) { if( socket ) { socket->sendGameInfoPlayerTeam( list.at(i) ); } } } void AttalServer::sendGameCalendar( const QList & list, Calendar * calendar) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket ) { socket->sendGameCalendar( calendar ); } } } void AttalServer::sendGameCalendar( GenericPlayer * player, Calendar * calendar) { QList list; list.append( player ); sendGameCalendar( list, calendar ); } void AttalServer::sendEndGame( const QList & list ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket ) { socket->sendEndGame(); } } } void AttalServer::sendTavernInfo( GenericPlayer * player, uchar nbLord ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendTavernInfo( nbLord ); } } void AttalServer::sendTavernLord( GenericPlayer * player, GenericLord * lord ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendTavernLord( lord ); } } void AttalServer::beginTurn( const QList & list, GenericPlayer * player ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket ) { socket->sendTurnPlaying( player ); } } } void AttalServer::sendLordPlTurn( GenericPlayer * player, int count ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendLordPlTurn( count ); } } void AttalServer::startFight( GenericPlayer * attacker,GenericLord * myLord, GenericPlayer * opponent, GenericLord * opponentLord ) { int i; AttalPlayerSocket * attackerSocket = findSocket( attacker ); attackerSocket->sendFightInit( FIGHTER_ATTACK, myLord ); attackerSocket->sendFightLord( FIGHTER_DEFENSE, opponentLord ); for( i = 0; i < MAX_UNIT; i++ ) { if( opponentLord->getUnit( i ) ) { attackerSocket->sendFightNewUnit( FIGHTER_DEFENSE, i, opponentLord->getUnit( i ) ); } } AttalPlayerSocket * opponentSocket = findSocket( opponent ); opponentSocket->sendFightInit( FIGHTER_DEFENSE, opponentLord ); opponentSocket->sendFightLord( FIGHTER_ATTACK, myLord ); for( i = 0; i < MAX_UNIT; i++ ) { if( myLord->getUnit( i ) ) { opponentSocket->sendFightNewUnit( FIGHTER_ATTACK, i, myLord->getUnit( i ) ); } } } void AttalServer::startFight( GenericPlayer * attacker,GenericLord * myLord, GenericFightUnit * opponentUnits[MAX_UNIT] ) { AttalPlayerSocket * attackerSocket = findSocket( attacker ); attackerSocket->sendFightInit( FIGHTER_ATTACK, myLord ); attackerSocket->sendFightCreature(); for( int i = 0; i < MAX_UNIT; i++ ) { if( opponentUnits[i] ) { attackerSocket->sendFightNewUnit( FIGHTER_DEFENSE, i, opponentUnits[i] ); } } } void AttalServer::moveUnit( GenericPlayer * player, CLASS_FIGHTER fighter, int num, GenericFightCell * cell ) { AttalPlayerSocket * socket = findSocket( player ); socket->sendFightUnitMove( fighter, num, cell ); } void AttalServer::updateUnit( GenericPlayer * player, CLASS_FIGHTER fighter, int num, GenericFightUnit * unit ) { AttalPlayerSocket * socket = findSocket( player ); socket->sendFightModifyUnit( fighter, num, unit ); } void AttalServer::damageUnit( GenericPlayer * player, CLASS_FIGHTER attacker, int numAttacker, CLASS_ATTACK_TYPE attackType, CLASS_FIGHTER defender, int numDefender, uint damage ) { AttalPlayerSocket * socket = findSocket( player ); socket->sendFightDamageUnit( attacker, numAttacker, attackType, defender, numDefender, damage ); } void AttalServer::activateUnit( GenericPlayer * player, CLASS_FIGHTER fighter, int num ) { AttalPlayerSocket * socket = findSocket( player ); socket->sendFightActivate( fighter, num ); } void AttalServer::endFight(GenericPlayer * attackPlayer, GenericPlayer * defendPlayer, FightResultStatus result ) { AttalPlayerSocket * socket = findSocket( attackPlayer ); if( socket ) { socket->sendFightEnd( result ); } if( defendPlayer ) { socket = findSocket( defendPlayer ); if( socket ) { socket->sendFightEnd( result ); } } } void AttalServer::sendMessage( const QList & list, QString msg ) { uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { sendMessage( list.at(k), msg ); } } void AttalServer::sendMessage( GenericPlayer * player, QString msg ) { AttalPlayerSocket * socket = findSocket(player); socket->sendMessage( msg ); } void AttalServer::sendFightMessage( QString msg, GenericPlayer * attackPlayer, GenericPlayer * defendPlayer ) { AttalPlayerSocket * socket = findSocket( attackPlayer ); socket->sendFightMessage( msg ); if( defendPlayer ) { socket = findSocket( defendPlayer ); socket->sendFightMessage( msg ); } } void AttalServer::sendPlayerResource( GenericPlayer * player ,char ressource, int nb ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { if( DataTheme.resources.get( ressource )->isGlobal() ) { socket->sendPlayerResource( ressource, nb ); } } } void AttalServer::sendPlayerPrice( GenericPlayer * player , char ressource, int price ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendPlayerPrice( ressource, price ); } } void AttalServer::sendPlayerResources( GenericPlayer * player ) { AttalPlayerSocket * socket = findSocket( player ); for( int i = 0; i < DataTheme.resources.count(); i++ ) { if( socket ) { if( DataTheme.resources.get( i )->isGlobal() ) { socket->sendPlayerResource( i, player->getResourceList()->getValue( i ) ); } } } } void AttalServer::sendPlayerPrices( GenericPlayer * player ) { AttalPlayerSocket * socket = findSocket( player ); uint nbRes = DataTheme.resources.count(); int price; for( uint i = 0; i < nbRes; i++ ) { price = player->getPriceMarket()->getResourcePrice( i ); if( socket ) { socket->sendPlayerPrice( i, price ); } } } /* void AttalServer::sendPlayerPopulation( GenericPlayer * player ) { AttalPlayerSocket * socket = findSocket( player ); uint population = player->getPopulation(); if( socket ) { socket->sendPlayerPopulation( population ); } } */ void AttalServer::sendSizeMap( const QList & list, int h, int w ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket ) { socket->sendSizeMap( h, w ); } } } void AttalServer::sendCell( GenericPlayer * player, GenericCell * cell ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendCell( cell ); } } void AttalServer::sendAskNone( const QList & list, const QString & msg, uchar type ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket ) { socket->sendAskNone( msg, type ); } } } void AttalServer::sendAskChest(GenericPlayer * player) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendAskChest(); } } void AttalServer::sendAskCreatureJoin( GenericPlayer * player, GenericMapCreature * creature ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendAskCreatureJoin( creature ); } } void AttalServer::sendAskCreatureMercenary( GenericPlayer * player, GenericMapCreature * creature ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendAskCreatureMercenary( creature ); } } void AttalServer::sendAskCreatureFlee( GenericPlayer * player,GenericMapCreature * creature ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendAskCreatureFlee( creature ); } } void AttalServer::updateUnits( GenericPlayer * player,GenericLord * lord ) { AttalPlayerSocket * socket = findSocket( player ); if( lord && socket ) { if( player == lord->getOwner() ) { socket->sendLordUnits( lord ); } else { /// XXX: would be better to send category of units and not real values socket->sendLordUnits( lord ); } } } void AttalServer::updateUnits( const QList & list, GenericLord * lord ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( lord ) { if( socket && socket->canSee( lord->getCell() ) ) { socket->sendLordUnits( lord ); } } } } void AttalServer::updateUnit( GenericPlayer * player,GenericLord * lord , int num) { AttalPlayerSocket * socket = findSocket( player ); if( lord && socket) { if( player == lord->getOwner() ) { socket->sendLordUnit( lord , num ); } else { /// XXX: would be better to send category of units and not real values socket->sendLordUnit( lord , num); } } } void AttalServer::updateUnit( const QList & list, GenericLord * lord , int num ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( lord ) { if( socket && socket->canSee( lord->getCell() ) ) { socket->sendLordUnit( lord , num ); } } } } void AttalServer::newLord( const QList & list, GenericLord * lord ) { GenericPlayer * player = 0; uint nbPlayers = (uint) list.count(); for( uint k = 0; k < nbPlayers; ++k ) { player = list.at( k ); if( lord ) { if( player && player->canSee( lord->getCell() ) ) { newLord( player, lord ); } } } } void AttalServer::newLord( GenericPlayer * player, GenericLord * lord ) { AttalPlayerSocket * socket = findSocket( player ); if( lord && socket ) { if( player == lord->getOwner() ) { socket->sendLordNew( lord ); socket->sendLordBaseCharac( lord, MOVE ); socket->sendLordBaseCharac( lord, MAXMOVE ); socket->sendLordBaseCharac( lord, TECHNICPOINT ); socket->sendLordBaseCharac( lord, MAXTECHNICPOINT ); socket->sendLordBaseCharac( lord, MORALE ); socket->sendLordBaseCharac( lord, LUCK ); socket->sendLordBaseCharac( lord, EXPERIENCE ); socket->sendLordBaseCharac( lord, ATTACK ); socket->sendLordBaseCharac( lord, DEFENSE ); socket->sendLordBaseCharac( lord, POWER ); socket->sendLordBaseCharac( lord, KNOWLEDGE ); socket->sendLordBaseCharac( lord, CHARISMA ); socket->sendLordUnits( lord ); for( uint i = 0; i < lord->getArtefactManager()->getArtefactNumber(); i++ ) { socket->sendArtefactLord( lord->getArtefactManager()->getArtefact( i ), true ); } for( uint j = 0; j < lord->getMachineNumber(); j++ ) { socket->sendLordMachine( lord, lord->getMachine( j ) ); } } else { socket->sendLordVisit( lord ); /// XXX: would be better to send category of units and not real values socket->sendLordUnits( lord ); } } } void AttalServer::sendLordVisit( GenericLord * lord, GenericPlayer * player, bool state ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendLordVisit( lord, state ); } } /* void AttalServer::updateLordBaseUnits( GenericBase * base ,GenericLord * lord , int flag) { uint nbSockets = (uint) _theSockets.count(); for( uint i = 0; i < nbSockets; ++i ) { if( _theSockets[ i ] != _currentSocket ) { //_theSockets[ i ]->sendExchangeBaseUnitCl( base, unit1, lord, unit2 ); if( flag == 0 || flag == 2 ) { for( int i = 0; i < MAX_UNIT; ++i ) { _theSockets[ i ]->sendBaseUnit( base, base->getUnit( i ) ); } } if( flag == 1 || flag == 2 ) { _theSockets[ i ]->sendLordUnits( lord ); } } } } void AttalServer::updateLord( GenericLord * lord ) { uint nbSockets = (uint) _theSockets.count(); for( uint i = 0; i < nbSockets; ++i ) { _theSockets[ i ]->sendLordBaseCharac( lord, MOVE ); _theSockets[ i ]->sendLordBaseCharac( lord, MAXMOVE ); _theSockets[ i ]->sendLordBaseCharac( lord, TECHNICPOINT ); _theSockets[ i ]->sendLordBaseCharac( lord, MAXTECHNICPOINT ); _theSockets[ i ]->sendLordBaseCharac( lord, MORALE ); _theSockets[ i ]->sendLordBaseCharac( lord, LUCK ); _theSockets[ i ]->sendLordBaseCharac( lord, EXPERIENCE ); _theSockets[ i ]->sendLordBaseCharac( lord, ATTACK ); _theSockets[ i ]->sendLordBaseCharac( lord, DEFENSE ); _theSockets[ i ]->sendLordBaseCharac( lord, POWER ); _theSockets[ i ]->sendLordBaseCharac( lord, KNOWLEDGE ); _theSockets[ i ]->sendLordUnits( lord ); for( uint j = 0; j < lord->getArtefactManager()->getArtefactNumber(); j++ ) { _theSockets[ i ]->sendArtefactLord( lord->getArtefactManager()->getArtefact( j ), true ); } for( uint k = 0; k < lord->getMachineNumber(); k++ ) { _theSockets[ i ]->sendLordMachine( lord, lord->getMachine( k ) ); } } } */ void AttalServer::sendLordRemove( const QList & list, GenericLord * lord ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); //logDD(" nbSockets %d", nbSockets ); for( uint k = 0; k < nbSockets; ++k ) { //logDD(" k %d", k ); socket = findSocket(list.at(k)); if( socket && socket->canSee( lord->getCell() ) ) { socket->sendLordRemove( lord ); } } } void AttalServer::sendCreatureRemove( const QList & list, GenericCell * cell ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket && socket->canSee( cell ) ) { socket->sendDelCreature( cell ); } } } void AttalServer::setGarrison( const QList & list, GenericLord * lord, bool state ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket ) { socket->sendLordGarrison( lord, state ); } } } void AttalServer::newBase( GenericPlayer * player, GenericBase * base ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendBaseNew( base ); for( uint i = 0; i < base->getBuildingCount(); i++ ) { socket->sendBaseBuilding( base, base->getBuilding( i ), true ); } for(int i = 0; i < MAX_UNIT; i++ ) { socket->sendBaseUnit( base, base->getUnit(i), i ); } socket->sendBaseName( base ); } } void AttalServer::updateBaseBuilding( const QList & list, GenericBase * base, GenericInsideBuilding * building ) { GenericPlayer * player = 0; uint nbPlayers = (uint) list.count(); for( uint k = 0; k < nbPlayers; ++k ) { player = list.at( k ); if( base ) { if( player->canSee( base->getCell() ) ) { updateBaseBuilding( player, base, building ); } } } } void AttalServer::updateBaseBuilding( GenericPlayer * player, GenericBase * base, GenericInsideBuilding * building ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { bool found = false; for( uint i = 0; i < base->getBuildingCount(); i++ ) { GenericInsideBuilding * build = base->getBuilding( i ); if( build == building ) { socket->sendBaseBuilding( base, build, true ); found = true; } } if( ! found ) { socket->sendBaseBuilding( base, building, false ); } } } void AttalServer::sendBaseUnit( const QList & list, GenericBase * base, Creature * creature, int number, int pos ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket && socket->canSee( base->getCell() ) ) { socket->sendBaseUnit( base, creature, number, pos ); } } } void AttalServer::sendBaseUnits( const QList & list, GenericBase * base ) { for(int i = 0; i < MAX_UNIT; i++ ) { if( base->getUnit(i) ) { sendBaseUnit( list, base, base->getUnit(i)->getCreature(), base->getUnit(i)->getNumber() , i ); } else { sendBaseUnit( list, base, 0, 0, i ); } } } void AttalServer::sendBasePopulation( const QList & list, GenericBase * base) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket && socket->canSee( base->getCell() ) ) { socket->sendBasePopulation( base ); } } } void AttalServer::sendBaseResource( GenericPlayer * player, GenericBase * base,char ressource, int nb ) { AttalPlayerSocket * socket = findSocket( player ); if( socket && socket->canSee( base->getCell() )) { socket->sendBaseResource( base, ressource, nb ); } } void AttalServer::sendBaseResources( GenericPlayer * player, GenericBase * base ) { AttalPlayerSocket * socket = findSocket( player ); for( int i = 0; i < DataTheme.resources.count(); i++ ) { if( socket && socket->canSee( base->getCell() )) { socket->sendBaseResource( base, i, base->getResourceList()->getValue( i ) ); } } } void AttalServer::sendBaseProduction( GenericPlayer * player, GenericBase * base ) { AttalPlayerSocket * socket = findSocket( player ); if( socket && socket->canSee( base->getCell() ) ) { int creatCount = base->getCreatureNumber(); for( int i = 0; i < creatCount; i ++) { socket->sendBaseProduction(base , base->getCreatureProduced(i)); } } } void AttalServer::sendBaseProduction( const QList & list, GenericBase * base ) { uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { sendBaseProduction( list.at(k), base ); } } void AttalServer::sendLordExchange( GenericPlayer * player, GenericLord * lord1, GenericLord * lord2 ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendExchangeStart( lord1, lord2 ); } } void AttalServer::sendExchangeUnit( const QList & list, GenericLord * lord1, uchar unit1, GenericLord * lord2, uchar unit2 ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket && ( socket->canSee( lord1->getCell() ) || socket->canSee( lord2->getCell() )) ) { socket->sendExchangeUnit( lord1, unit1, lord2, unit2 ); } } } void AttalServer::sendExchangeArtefact( const QList & /*list*/, GenericLord * /* lord1 */, int /* item */, GenericLord * /* lord2 */ ) { /// XXX: _currentSocket->sendExchangeArtefact( lord1, item, lord2 ); unused ?? } void AttalServer::sendExchangeBaseUnitCl( const QList & list, GenericBase * base, uchar unit1, GenericLord * lord, uchar unit2 ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( base && socket && socket->canSee( base->getCell() ) ) { socket->sendExchangeBaseUnitCl( base, unit1, lord, unit2 ); } } } void AttalServer::ownBase( GenericPlayer * player, GenericBase * base ) { AttalPlayerSocket * socket = findSocket( player ); /// XXX: owner could be computed in AttalSocket GenericPlayer * owner = base->getOwner(); if( socket ) { socket->sendBaseOwner( base, owner ); socket->sendBasePopulation( base ); } } /*! */ void AttalServer::newBuilding( GenericPlayer * player, GenericBuilding * build ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendBuildingNew( build ); } } void AttalServer::ownBuilding( const QList & list, GenericBuilding * build ) { GenericPlayer * player = 0; uint nbPlayers = (uint) list.count(); for( uint k = 0; k < nbPlayers; ++k ) { player = list.at( k ); if( build ) { if( player->canSee( build->getCell() ) ) { ownBuilding( player, build ); } } } } void AttalServer::ownBuilding( GenericPlayer * player, GenericBuilding * build ) { AttalPlayerSocket * socket = findSocket( player ); /// XXX: owner could be computed in AttalSocket GenericPlayer * owner = build->getOwner(); if( socket && socket->canSee( build->getCell() ) ) { socket->sendBuildingOwner( build, owner ); } } void AttalServer::sendBuildingResource( GenericPlayer * player, GenericBuilding * build,char ressource, int nb ) { AttalPlayerSocket * socket = findSocket( player ); if( socket && socket->canSee( build->getCell() ) ) { socket->sendBuildingResource( build, ressource, nb ); } } void AttalServer::sendBuildingResources( GenericPlayer * player, GenericBuilding * build ) { AttalPlayerSocket * socket = findSocket( player ); for( int i = 0; i < DataTheme.resources.count(); i++ ) { if( socket && socket->canSee( build->getCell() ) ) { socket->sendBuildingResource( build, i, build->getResourceList()->getValue( i ) ); } } } void AttalServer::ownArtefact( GenericLordArtefact * artefact, GenericPlayer * player ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendArtefactLord( artefact, true ); } } void AttalServer::newCreature( GenericPlayer * player, GenericMapCreature * creature ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendNewCreature( creature ); } } void AttalServer::updateCreature( const QList & list, GenericMapCreature * creature ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket && socket->canSee( creature->getCell() ) ) { socket->sendUpdateCreature( creature ); } } } void AttalServer::newEvent( GenericPlayer * player, GenericEvent * event ) { AttalPlayerSocket * socket = findSocket( player ); if( socket && socket->canSee( event->getCell() ) ) { socket->sendNewEvent( event ); } } void AttalServer::delEvent( const QList & list, GenericEvent * event ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket->canSee( event->getCell() ) ) { socket->sendDelEvent( event ); } } } void AttalServer::sendMvt( const QList & list, int lord, int i, int j ) { AttalPlayerSocket * socket; uint nbSockets = (uint) list.count(); for( uint k = 0; k < nbSockets; ++k ) { socket = findSocket(list.at(k)); if( socket && socket->canSee( i, j ) ) { socket->sendMvt( lord, i, j ); } } } void AttalServer::sendLordCharac( GenericPlayer * player, GenericLord * lord, LordCharac charac ) { AttalPlayerSocket * socket = findSocket( player ); if( socket ) { socket->sendLordBaseCharac( lord, charac ); } } attal-src-1.0-rc2/libServer/attalServer.h0000644000175000017500000002652510770506550016075 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attalServer.h ** the server : manage connections ** ** Version : $Id: attalServer.h,v 1.63 2008/03/20 16:14:32 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 28/10/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ATTALSERVER_H #define ATTALSERVER_H // generic include files // include files for QT #include #include #include // application specific includes #include "libCommon/attalSocket.h" #include "libCommon/fightResultStatus.h" #include "libCommon/genericCell.h" #include "libCommon/genericLord.h" #include "libCommon/genericPlayer.h" class GenericArtefact; class GenericBase; class GenericEvent; class GenericInsideBuilding; class GenericLordArtefact; class GenericMapCreature; class Creature; /* ------------------------------ * AttalServer * ------------------------------ */ /** Socket with info about the player */ class AttalPlayerSocket : public AttalSocket { public: /** Constructor */ AttalPlayerSocket(); /** Destructor */ ~AttalPlayerSocket(); /** Return the playe rassociated to the socket */ GenericPlayer * getPlayer() { return _player; } /** Associate a player to the socket */ void setPlayer( GenericPlayer * player ) { _player = player; } bool canSee( int row, int col ); bool canSee( GenericCell * cell ); private: GenericPlayer * _player; }; /// XXX TODO: should be reimplemented, may be we don't need to inheritate now... /** Server */ class AttalServer : public QTcpServer { Q_OBJECT public: enum ConnectionInfo { SK_KICKED, SK_WRONG_VERSION }; /** Constructor */ AttalServer( int , QHostAddress address = QHostAddress::Any ); /** Destructor */ virtual ~AttalServer(); /* engine methods */ /** Start the game */ void startGame( const QList & list); /** Start a fight */ void startFight( GenericPlayer * attacker, GenericLord * myLord, GenericPlayer * opponent, GenericLord * opponentLord ); /** Start a fight */ void startFight( GenericPlayer * attacker, GenericLord * myLord, GenericFightUnit * opponentUnits[MAX_UNIT] ); void moveUnit( GenericPlayer * player, CLASS_FIGHTER fighter, int num, GenericFightCell * cell ); void updateUnit( GenericPlayer * player, CLASS_FIGHTER fighter, int num, GenericFightUnit * unit ); void damageUnit( GenericPlayer * player, CLASS_FIGHTER attacker, int numAttacker, CLASS_ATTACK_TYPE attackType, CLASS_FIGHTER defender, int numDefender, uint damage ); void activateUnit( GenericPlayer * player, CLASS_FIGHTER fighter, int num ); /** Begin turn */ void beginTurn( const QList & list, GenericPlayer * player ); void sendLordPlTurn( GenericPlayer * player, int count ); void playerLose( const QList & list, GenericPlayer * player ); void playerWin( const QList & list, GenericPlayer * player ); void sendGameInfoPlayer( GenericPlayer * player, const QList & list ); void sendGameCalendar( const QList & list, Calendar * calendar); void sendGameCalendar( GenericPlayer * player, Calendar * calendar ); /** End game */ void sendEndGame( const QList &list ); void sendTavernInfo( GenericPlayer * player, uchar nbLord); void sendTavernLord( GenericPlayer * player, GenericLord * lord ); /** End fight */ void endFight(GenericPlayer * attackPlayer, GenericPlayer * defendPlayer, FightResultStatus result ); /** Send id to connected player */ void sendConnectionId( char num ); /** Send info about 'player' to 'dest' */ void sendConnectionPlayer( GenericPlayer * dest, GenericPlayer * player ); /** Send ressources to the player */ void sendPlayerResource( GenericPlayer * player, char ressource, int nb ); /** Send prices to the player */ void sendPlayerPrice( GenericPlayer * player, char ressource, int price ); /** Send prices to the player */ void sendPlayerPrices( GenericPlayer * player ); /** Send ressources to the player */ void sendPlayerResources( GenericPlayer * player ); //void sendPlayerPopulation( GenericPlayer * player ); /** Send msg (chat) to every player */ void sendMessage( QString msg ); void sendMessage( GenericPlayer * player, QString msg ); /** Send msg (chat) to game's player */ void sendMessage( const QList & list, QString msg ); /** Send msg (chat) to fighting players */ void sendFightMessage( QString msg, GenericPlayer * attackPlayer, GenericPlayer * defendPlayer ); /** Send mvt to the player */ void sendMvt( const QList & list, int lord, int i, int j ); /** Send size of the map */ void sendSizeMap( const QList & list, int h, int w ); /** Send a cell */ void sendCell( GenericPlayer * player, GenericCell * cell ); /** Send a game message to the player */ void sendAskNone( const QList & list, const QString & msg, uchar type ); void sendAskChest(GenericPlayer * player); /** Ask for new skill to the player */ void sendAskLevel( GenericPlayer * dest, char lord, char level, char primSkill, char skill1, char skill2 ) { findSocket( dest )->sendAskLevel( lord, level, primSkill, skill1, skill2 ); } void sendAskCreatureJoin(GenericPlayer * player, GenericMapCreature * creature ); void sendAskCreatureMercenary(GenericPlayer * player, GenericMapCreature * creature ); void sendAskCreatureFlee(GenericPlayer * player, GenericMapCreature * creature ); /** Send new lord */ void newLord( GenericPlayer * player, GenericLord * lord ); void newLord( const QList & list, GenericLord * lord ); void sendLordVisit( GenericLord * lord, GenericPlayer * player, bool state ); /** update Lord data*/ //void updateLord( GenericLord * lord ); /**uodate lord units (send to one player) */ void updateUnit(GenericPlayer * player, GenericLord * lord , int num); /**uodate lord units (send to all players) */ void updateUnit( const QList & list, GenericLord * lord , int num ); void updateUnits(GenericPlayer * player, GenericLord * lord ); void updateUnits( const QList & list, GenericLord * lord ); /* update base units (flag==0) * lord units (flag==1) * or both (flag==2) */ //void updateLordBaseUnits( GenericBase * base, GenericLord * lord ,int flag); /** Send new base */ void newBase( GenericPlayer * player, GenericBase * base ); /** Send owner of base */ void ownBase( GenericPlayer * player, GenericBase * base ); /** Send new building */ void newBuilding( GenericPlayer * player, GenericBuilding * build ); /** Send owner of building */ void ownBuilding( GenericPlayer * player, GenericBuilding * build ); void ownBuilding( const QList & list, GenericBuilding * build ); /** update base (new buildings...) */ void updateBaseBuilding( GenericPlayer * player, GenericBase * base, GenericInsideBuilding * building ); void updateBaseBuilding( const QList & list, GenericBase * base, GenericInsideBuilding * building ); void sendBaseUnit( const QList & list, GenericBase * base, Creature * creature, int number, int pos ); void sendBaseUnits( const QList & list, GenericBase * base ); void sendBasePopulation( const QList & list, GenericBase * base); void sendBaseProduction( const QList & list, GenericBase * base ); void sendBaseProduction( GenericPlayer * player, GenericBase * base ); void sendBaseResource( GenericPlayer * player, GenericBase * base,char ressource, int nb ); void sendBaseResources( GenericPlayer * player, GenericBase * base ); void sendBuildingResource( GenericPlayer * player, GenericBuilding * build,char ressource, int nb ); void sendBuildingResources( GenericPlayer * player, GenericBuilding * build ); void sendLordExchange( GenericPlayer * player, GenericLord * lord1, GenericLord * lord2 ); void sendExchangeUnit( const QList & list, GenericLord * lord1, uchar unit1, GenericLord * lord2, uchar unit2 ); void sendExchangeArtefact( const QList & list, GenericLord * lord1, int item, GenericLord * lord2 ); void sendExchangeBaseUnitCl( const QList & list, GenericBase * base, uchar unit1, GenericLord * lord, uchar unit2 ); /** Get data from socket */ void getSocketData( int num ); void reReadSocketData( int num ); /** Tell if there is some data to read on socket */ bool isData( int num ); /** Clear server */ void clear() {}; void sendLordRemove( const QList & list, GenericLord * lord ); void sendCreatureRemove( const QList & list, GenericCell * cell ); void setGarrison( const QList & list, GenericLord * lord, bool state ); void ownArtefact( GenericLordArtefact * artefact, GenericPlayer * player ); void newCreature( GenericPlayer * player, GenericMapCreature * creature ); void updateCreature( const QList & list, GenericMapCreature * creature ); void newEvent( GenericPlayer * player, GenericEvent * event ); void delEvent( const QList & list, GenericEvent * event ); void sendLordCharac( GenericPlayer * player, GenericLord * lord, LordCharac charac ); /* server methods */ /** Return the nb of connections */ uint getNbSocket() { return _theSockets.count(); } int readInt(); int readInt( int num ); unsigned char readChar(); unsigned char readChar( int num ); uchar getCla1(); uchar getCla2(); uchar getCla3(); uchar getCla1( int num ); uchar getCla2( int num ); uchar getCla3( int num ); AttalPlayerSocket * findSocket( GenericPlayer * player ); GenericPlayer * getPlayer( int numsock ); void copyData( int num, AttalSocket* data ); void copyData( AttalSocket* data ); AttalSocketData getData( int num ); void closeConnectionPlayer( AttalPlayerSocket * uneso, ConnectionInfo info ); void closeConnectionPlayer( QString name, ConnectionInfo info ); void closeConnectionSocket(AttalPlayerSocket * uneso); void unmapSockets(); void handleConnectionName( int num ); void handleConnectionVersion( int num ); void handleMessage( int num ); void handleCommand( int num , const QString & cmd ); void sendConnectionName(const QString & name, int num); signals: void sig_readEvent( int ); void sig_newPlayer( AttalPlayerSocket * ); void sig_newData( int, AttalSocketData ); void sig_endConnection( QString name ); void sig_result( int id, bool result); void sig_endGame( int id ); public slots: /** Slot who reads socket */ void slot_readSocket( int ); void slot_socketClose(); protected: virtual void incomingConnection ( int socketDescriptor ); private: int _num; QList _theSockets; QList _oldSockets; QSignalMapper * _mapper; }; #endif // ATTALSERVER_H attal-src-1.0-rc2/libServer/engine.cpp0000644000175000017500000021352311010170657015366 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** engine.cpp ** the game engine ! ** ** Version : $Id: engine.cpp,v 1.121 2008/05/07 00:02:55 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 03/10/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "engine.h" // generic include files #include // include files for QT #include #include #include #include #include #include // application specific includes #include "libCommon/artefact.h" #include "libCommon/artefactManager.h" #include "libCommon/campaign.h" #include "libCommon/dataTheme.h" #include "libCommon/define.h" #include "libCommon/genericBonus.h" #include "libCommon/genericEvent.h" #include "libCommon/genericMapCreature.h" #include "libCommon/genericInsideBuilding.h" #include "libCommon/log.h" #include "libCommon/unit.h" #include "libCommon/parser.h" #include "libCommon/pathFinder.h" #include "libCommon/priceMarket.h" #include "libCommon/questManager.h" #include "libServer/questionManager.h" #include "libServer/scenarioDescription.h" #include "libServer/tavernManager.h" Engine::Engine( AttalServer * serv ) :QThread(), GameData() { _currentPlayer = NULL; _fight = NULL; _server = serv; _state = NOT_PLAYING; _isCreature = false; _isProcessing = false; _question = new QuestionManager(); _campaign = NULL; _tmpPlay = 0; _num = 0; _tavern = new TavernManager( this ); //connect( _server, SIGNAL( sig_readEvent( int ) ), SLOT( slot_readSocket( int ) ) ); connect( _server, SIGNAL( sig_newData( int, AttalSocketData ) ), SLOT( slot_readData( int, AttalSocketData ) ) ); connect( _server, SIGNAL( sig_newPlayer( AttalPlayerSocket * ) ), SLOT( slot_newPlayer( AttalPlayerSocket * ) ) ); //connect( _server, SIGNAL( sig_newPlayer( AttalPlayerSocket * ) ), SIGNAL( sig_newPlayer( AttalPlayerSocket * ) ) ); connect( _server, SIGNAL( sig_endConnection( QString ) ), SLOT( slot_endConnection( QString ) ) ); connect( this, SIGNAL( sig_result( int, bool ) ),_server, SIGNAL( sig_result( int , bool) ) ); connect( this, SIGNAL( sig_endGame( int ) ),_server, SIGNAL( sig_endGame( int ) ) ); } Engine::~Engine() { TRACE("Engine::~Engine()"); endGame(); if( _question ) { delete _question; } if( _tavern ) { delete _tavern; } if(_fight){ delete _fight; } _fight = NULL; } void Engine::run() { } void Engine::slot_readData( int num, AttalSocketData data ) { //_server->reReadSocketData( num ); _dataQueue.enqueue( data ); manageSocketState( num ); } void Engine::manageSocketState( int num ) { if(! _isProcessing ) { _isProcessing = true; _currentData = _dataQueue.dequeue(); _num = num; switch( _state ) { case NOT_PLAYING: stateNotPlaying( num ); break; case IN_GAME: stateInGame( num ); break; case IN_QUESTION: stateInQuestion( num ); break; case IN_FIGHT: stateInFight( num ); break; } _isProcessing = false; if( !_dataQueue.isEmpty() ) { manageSocketState( num ); } } } void Engine::slot_endConnection( QString name ) { for( int i = 0; i < _players.count(); i++ ) { if( _players.at( i )->getConnectionName() == name ) { _players.removeAll( _players.at( i ) ); } } } void Engine::handleMessage( int num ) { QString msg; uchar d = readChar(); for( uint i = 0; i < d; i++ ) { msg[i] = readChar(); } if( msg.contains(": /")) { QStringList list = msg.split(": /"); handleCommand( num, list.at(1) ); } else { _server->sendMessage( _players, msg ); } } void Engine::handleCommand( int num, const QString & cmd ) { QString msg = ""; if( cmd.startsWith("gameinfo") ) { msg = getScenarioName() + "\n"; msg +="Turn " + QString::number( getTurn() ); _server->sendMessage( _server->getPlayer( num ) , msg ); } else if( cmd.startsWith("gamelist") ) { uint nbPlayers = (uint) _players.count(); for( uint i = 0; i < nbPlayers; ++i ) { msg = _players[i]->getConnectionName(); _server->sendMessage( _server->getPlayer( num ), msg ); } } else { } } void Engine::stateNotPlaying( int num ) { TRACE("Engine::stateNotPlaying"); uchar c = getCla1(); switch( c ) { case SO_MSG: handleMessage( num ); break; case SO_CONNECT: break; default: logEE( "Game not started...%d", c ); break; } } void Engine::stateInGame( int num ) { if( num == _players.indexOf( _currentPlayer ) ) { uchar cla1 = getCla1(); switch( cla1 ) { case SO_MSG: handleMessage( num ); break; case SO_MVT: handleInGameMvt( num ); break; case SO_QR: logEE( "Should not happen (Server : SO_QR/... state must be IN_QUESTION)" ); break; case SO_TECHNIC: logDD( "Not yet implemented" ); break; case SO_EXCH: handleInGameExchange(); break; case SO_FIGHT: logEE( "Should not happen : state must be IN_FIGHT"); break; case SO_GAME:{ uchar cla2 = getCla2(); switch( cla2 ) { case C_GAME_TAVERN: handleGameTavern(); break; default: logDD( "Not yet implemented %d",cla2 ); break; } } break; case SO_MODIF: handleInGameModif(); break; case SO_TURN: handleInGameTurn(); break; case SO_CONNECT: break; default: logEE( "Unknown socket_class from %d , cla1 %d", num , cla1); } } else { switch( getCla1() ) { case SO_MSG: handleMessage( num ); break; default: logEE( "This player should not play now %d, should play %d", num, _players.indexOf( _currentPlayer )); logEE( "Num. players %d, currentPlayer %p", _players.count(), _currentPlayer ); logEE( "Players %d name %s, currentPlayer name %s", num, _players.at(num)->getConnectionName().toLatin1().constData(), _currentPlayer->getConnectionName().toLatin1().constData() ); logEE( "Server socket received %d | %d | %d", getCla1(), getCla2(), getCla3() ); break; } } } void Engine::handleGameTavern() { TRACE("Engine::handleGameTavern"); switch( getCla3() ) { case C_TAVERN_INFO: handleGameTavernInfo(); break; case C_TAVERN_LORD: handleGameTavernLord(); break; } } void Engine::handleGameTavernInfo() { TRACE("Engine::handleGameTavernInfo"); uint row, col; GenericCell * cell; GenericBase * base; row = readInt(); col = readInt(); cell = _map->at( row, col ); base = cell->getBase(); if( base ) { _server->sendTavernInfo( _currentPlayer, _tavern->getTavernLordNumber( base ) ); } else { logEE( "Should be a base ??" ); } } void Engine::handleGameTavernLord() { TRACE("Engine::handleGameTaverLord"); uint row, col; GenericCell * cell; GenericBase * base; uchar numLord; row = readInt(); col = readInt(); numLord = readChar(); cell = _map->at( row, col ); base = cell->getBase(); if( base ) { _server->sendTavernLord( _currentPlayer, _tavern->getTavernLord( base, numLord ) ); } else { logEE( "Should be a base ??" ); } } void Engine::stateInQuestion( uint num ) { uchar cla1 = getCla1(); uchar cla2 = getCla2(); if( num == (uint) _players.indexOf( _currentPlayer ) ) { switch( cla1 ) { case SO_MSG: handleMessage( num ); break; case SO_QR: switch( cla2 ) { case C_QR_ANSWER: handleAnswer(); break; default: logEE( "Should not happen (Server : SO_QR/...)" ); } break; default: logEE( "Should not happen cla1 %d, cla2 %d", cla1, cla2 ); break; } } } void Engine::handleAnswer() { switch( getCla3() ) { case ANSWER_ENUM:{ uchar choice = readChar(); if( choice == 0 ) { _currentPlayer->getResourceList()->increaseValue( 0, 1000 ); _server->sendPlayerResource( _currentPlayer, 0, _currentPlayer->getResourceList()->getValue( 0 ) ); } else { switch( _question->getType() ) { case C_QR_CHEST: { GenericLord * lord = _question->getLord(); if( lord ) { manageIncreaseExperience( lord, 2500 ); } else { logEE( "Lord in _question should not be NULL" ); } } break; default: logEE( "should not happen" ); } } _state = IN_GAME; } break; case ANSWER_YESNO: switch( _question->getType() ) { case C_QR_CREATURE_JOIN: handleAnswerCreatureJoin(); break; case C_QR_CREATURE_MERCENARY: handleAnswerCreatureMercenary(); break; case C_QR_CREATURE_FLEE: handleAnswerCreatureFlee(); break; default: logEE( "Should not happen" ); } } } void Engine::handleAnswerCreatureJoin() { bool accept = (bool) readChar(); GenericMapCreature * creature = _question->getCreature(); GenericLord * lord = _question->getLord(); uchar race = creature->getRace(); uchar level = creature->getLevel(); if( accept ) { _state = IN_GAME; GenericFightUnit * unit = 0; int place = -1; for( uint i = 0; i < MAX_UNIT; i++ ) { unit = lord->getUnit( i ); if( unit ) { if( ( unit->getRace() == race ) && ( unit->getLevel() == level ) ) { place = i; break; } } else { place = i; break; } } if( place >= 0 ) { unit = lord->getUnit( place ); if( ! unit ) { unit = new GenericFightUnit(); unit->setCreature( race, level ); } unit->addNumber( creature->getCreatureNumber() ); lord->setUnit( place, unit ); _server->updateUnit( _currentPlayer, lord, place ); } else { QList list; list.append( _currentPlayer ); _server->sendAskNone( list, tr( "You have no place for recruiting new creatures"), QR_INFO ); } removeCreature( creature ); } else { if( creature->isFleeing() ) { _question->setType( C_QR_CREATURE_FLEE ); _server->sendAskCreatureFlee( _currentPlayer, creature ); } else { _state = IN_GAME; startFight( lord->getId(), _question->getCreature() ); _isCreature = true; } } } void Engine::handleAnswerCreatureMercenary() { bool accept = (bool) readChar(); GenericMapCreature * creature = _question->getCreature(); GenericLord * lord = _question->getLord(); uchar race = creature->getRace(); uchar level = creature->getLevel(); if( accept ) { _state = IN_GAME; GenericFightUnit * unit = 0; int place = -1; for( uint i = 0; i < MAX_UNIT; i++ ) { unit = lord->getUnit( i ); if( unit ) { if( ( unit->getRace() == race ) && ( unit->getLevel() == level ) ) { place = i; break; } } else { place = i; break; } } if( place >= 0 ) { if( _currentPlayer->canBuy( creature->getCreature(), creature->getCreatureNumber() ) ) { _currentPlayer->buy( creature->getCreature(), creature->getCreatureNumber() ); _server->sendPlayerResources( _currentPlayer ); unit = lord->getUnit( place ); if( ! unit ) { unit = new GenericFightUnit(); unit->setCreature( race, level ); } unit->addNumber( creature->getCreatureNumber() ); lord->setUnit( place, unit ); _server->updateUnit( _currentPlayer, lord, place ); } else { QList list; list.append( _currentPlayer ); _server->sendAskNone( list, tr( "You have not enough resources for recruiting this creatures" ), QR_INFO ); } } else { QList list; list.append( _currentPlayer ); _server->sendAskNone( list, tr( "You have no place for recruiting new creatures" ), QR_INFO ); } removeCreature( creature ); } else { GenericMapCreature * creature = _question->getCreature(); if( creature->isFleeing() ) { _question->setType( C_QR_CREATURE_FLEE ); _server->sendAskCreatureFlee(_currentPlayer, creature ); } else { _state = IN_GAME; _isCreature = true; startFight( _question->getLord()->getId(), _question->getCreature() ); } } } void Engine::handleAnswerCreatureFlee() { bool accept = (bool) readChar(); if( accept ) { _state = IN_GAME; GenericMapCreature * creature = _question->getCreature(); removeCreature( creature ); } else { _state = IN_GAME; _isCreature = true; startFight( _question->getLord()->getId(), _question->getCreature() ); } } void Engine::handleInGameMvt( int num ) { if( getCla2() == C_MVT_ONE ) { uchar lord = readChar(); uint row = readInt(); uint col = readInt(); GenericCell * destCell = _map->at( row, col ); GenericLord * movingLord = _currentPlayer->getLordById( lord ); handleOneMove( movingLord, destCell, num ); } else if( getCla2() == C_MVT_MULTI ) { uchar lord = readChar(); uint nbCell = readInt(); uint i, row, col; GenericLord * movingLord = _currentPlayer->getLordById( lord ); QList list; for( i = 0; i < nbCell; i++ ) { row = readInt(); col = readInt(); if( _map->inMap( row, col ) ){ list.append( _map->at( row, col ) ); } } for( i = 0; i < nbCell; i++ ) { bool ret = handleOneMove( movingLord, list.at( i ) , num ); if( ! ret ) { list.clear(); break; } } } else { logEE( "Should not happen" ); } } bool Engine::handleOneMove( GenericLord * movingLord, GenericCell * destCell, int /*num*/ ) { /// XXX : to improve : all clients concerned bool ret = false; if(destCell == NULL) { logEE("Engine::handleOneMove, error, no cell"); return ret; } if(movingLord == NULL) { logEE("Engine::handleOneMove, error, no lord"); return ret; } GenericCell * start = movingLord->getCell(); uint lordRow = start->getRow(); uint lordCol = start->getCol(); uint row = destCell->getRow(); uint col = destCell->getCol(); TRACE( "Engine::handleOneMove (%d,%d) to (%d,%d)",lordRow, lordCol, row, col ); if( ! ( ( lordRow <= (row+1) ) && ( ( lordRow + 1 ) >= row ) && ( lordCol <= (col+1) ) && ( ( lordCol + 1 ) >= col ) ) ) { logWW( "Player should not request this mvt for lord (%d,%d) to (%d,%d)", lordRow, lordCol, row, col ); return ret; } if( destCell->getCoeff() < 0 || !destCell->isStoppable()){ logWW("move not allowed %d, %d", row,col); logWW("coeff %d, isStoppable %d", destCell->getCoeff(),destCell->isStoppable()); return ret; } int cost = PathFinder::computeCostMvt( start, destCell ); if( cost > movingLord->getCharac( MOVE ) ) { _server->sendLordCharac( _currentPlayer, movingLord, MOVE ); logWW( "not enough mvt pt : %d < %d", movingLord->getCharac( MOVE ), cost ); return ret; } GenericPlayer * tempPlayer; for( int index = 0; index < _players.count(); index++ ) { tempPlayer = _players.at( index ); if( tempPlayer != _currentPlayer ) { if( !tempPlayer->canSee( destCell ) && tempPlayer->canSee( movingLord->getCell() ) ) { QList list; list.append( tempPlayer ); _server->sendLordRemove( list, movingLord ); } } } if( destCell->getLord() ) { movingOnLord( movingLord, destCell ); } else if( destCell->getEvent() ) { movingOnEvent( movingLord, destCell ); } else if( destCell->getBuilding() ) { movingOnBuilding( movingLord, destCell ); } else if( destCell->getBase() ) { movingOnBase( movingLord, destCell ); } else if( destCell->getCreature() ) { movingOnCreature( movingLord, destCell ); } else { movingOnFreeCell( movingLord, destCell ); ret = true; } return ret; } void Engine::movingOnLord( GenericLord * movingLord, GenericCell * destCell ) { TRACE("Engine::movingOnLord"); if( destCell->getLord() == movingLord ) { logEE("Engine::Move on same lord"); return; } if( destCell->getLord()->getOwner() == _currentPlayer ) { _server->sendLordExchange( _currentPlayer, movingLord, destCell->getLord() ); } else if (destCell->getLord()->getOwner()->getTeamId() == _currentPlayer->getTeamId()){ } else { decreaseMove( movingLord, destCell ); _isCreature = false; startFight( movingLord->getId(), destCell->getLord() ); } } void Engine::movingOnEvent( GenericLord * movingLord, GenericCell * destCell ) { TRACE("Engine::movingOnEvent"); decreaseMove( movingLord, destCell ); GenericEvent * event = destCell->getEvent(); switch( event->getType() ) { case GenericEvent::EventArtefact: movingOnArtefact( movingLord, destCell ); break; case GenericEvent::EventBonus: movingOnBonus( movingLord, destCell ); break; case GenericEvent::EventChest: movingOnChest( movingLord, destCell ); break; default: logEE( "Should not happen" ); break; } } void Engine::movingOnArtefact( GenericLord * movingLord, GenericCell * destCell ) { TRACE("Engine::movingOnArtefact"); GenericEvent * event = destCell->getEvent(); movingLord->getArtefactManager()->addArtefact( event->getArtefact()->getType() ); destCell->setEvent( 0 ); _server->delEvent( _players, event ); _server->ownArtefact( movingLord->getArtefactManager()->getArtefactByType( event->getArtefact()->getType() ), _currentPlayer ); removeEvent( event ); } void Engine::movingOnBonus( GenericLord * movingLord, GenericCell * destCell ) { TRACE("Engine::movingOnBonus"); GenericEvent * event = destCell->getEvent(); GenericBonus * bonus = event->getBonus(); destCell->setEvent( 0 ); _server->delEvent( _players, event ); switch( bonus->getType() ) { case GenericBonus::BonusResource: movingOnBonusResource( bonus ); break; case GenericBonus::BonusPrimSkill: movingOnBonusPrimSkill( movingLord, bonus ); break; case GenericBonus::BonusSkill: break; case GenericBonus::BonusSpell: break; } removeEvent( event ); } void Engine::movingOnBonusResource( GenericBonus * bonus ) { uint typeResource = bonus->getParam( 0 ); uint numberType = bonus->getParam( 1 ); uint number = 0; if( numberType == 0 ) { number = bonus->getParam( 2 ); } else if( numberType == 1 ) { uint nbVar = bonus->getParam( 2 ); for( uint i = 0; i < nbVar; ++i ) { bonus->getParam( 3 + i ); } } else { /// Not finished //uint min = bonus->getParam( 2 ); //uint max = bonus->getParam( 3 ); //uint step = bonus->getParam( 4 ); } if( number > 0 ) { _currentPlayer->getResourceList()->increaseValue( typeResource, number ); _server->sendPlayerResource( _currentPlayer, typeResource, _currentPlayer->getResourceList()->getValue( typeResource ) ); } } void Engine::movingOnBonusPrimSkill( GenericLord * movingLord, GenericBonus * bonus ) { uint skill = bonus->getParam( 0 ); uint value = bonus->getParam( 1 ); LordCharac charac; switch( skill ) { case 0: charac = ATTACK; break; case 1: charac = DEFENSE; break; case 2: charac = POWER; break; case 3: charac = KNOWLEDGE; break; case 4: charac = MORALE; break; case 5: charac = LUCK; break; default: logEE( "Should not happen" ); charac = ATTACK; break; } movingLord->increaseBaseCharac( charac, value ); _server->sendLordCharac( movingLord->getOwner(), movingLord, charac ); } void Engine::movingOnChest( GenericLord * movingLord, GenericCell * destCell ) { TRACE("Engine::movingOnChest"); GenericEvent * event = destCell->getEvent(); _question->setLord( movingLord ); _question->setType( C_QR_CHEST ); _server->sendAskChest(_currentPlayer); _state = IN_QUESTION; destCell->setEvent( 0 ); _server->delEvent( _players, event ); removeEvent( event ); } void Engine::movingOnBuilding( GenericLord * movingLord, GenericCell * destCell ) { TRACE("Engine::movingOnBuilding"); uint j; // XXX: reread (cost computed ?... GenericBuilding * building = destCell->getBuilding(); if( handleBuildingEnter( building, movingLord ) ) { decreaseMove( movingLord, destCell ); movingLord->setCell( destCell ); if( ! _currentPlayer->hasBuilding( building ) ) { GenericPlayer * tempPlayer; for( int i = 0; i < _players.count(); i++ ) { tempPlayer = _players.at( i ); //bug fixed, tempPlayer->numBuilding instead a temporal variable: numBuilding change if you removeBuilding for( j = 0; j < tempPlayer->numBuilding(); j++ ) { if( tempPlayer->getBuilding( j ) == building ) { tempPlayer->removeBuilding( j ); } } } _currentPlayer->addBuilding( building ); building->setOwner( _currentPlayer ); _server->sendBuildingResources( _currentPlayer , building ); _server->ownBuilding( _players, building); } moveLord( movingLord, destCell ); } } void Engine::movingOnBase( GenericLord * movingLord, GenericCell * destCell ) { TRACE("Engine::movingOnBase"); GenericBase * base = destCell->getBase(); GenericLord * oplord = base->getGarrisonLord(); if( oplord ) { _server->newLord( _currentPlayer, oplord ); decreaseMove( movingLord, destCell ); startFight( movingLord->getId(), oplord ); return; } decreaseMove( movingLord, destCell ); movingLord->setCell( destCell ); if( ! _currentPlayer->hasBase( base ) ) { GenericPlayer * tempPlayer; if( base->getOwner() && base->getOwner()->getTeamId() == _currentPlayer->getTeamId() ) { decreaseMove( movingLord, destCell ); movingLord->setCell( destCell ); moveLord( movingLord, destCell ); return; } if( base->getOwner() ){ base->getOwner()->removeBase( base ); //base->getOwner()->removePopulation( base->getPopulation() ); //base->getOwner()->getResourceList()->removeResources( base->getResourceList() ); } _currentPlayer->addBase( base ); base->setOwner( _currentPlayer ); //base->getPopulationLoss(); QList list = base->getActionList( Action::CHANGEOWNER ); if( !list.isEmpty() ) { for( int i = 0; i < list.count(); i++ ) { handleAction( list.at(i), _currentPlayer, base->getResourceList() ); } } //_currentPlayer->addPopulation( base->getPopulation() ); //_server->sendPlayerPopulation( _currentPlayer ); //_server->sendPlayerResources( _currentPlayer ); _server->sendBaseResources( _currentPlayer, base ); for( int index = 0; index < _players.count(); index++ ) { tempPlayer = _players.at( index ); if( tempPlayer->canSee( destCell ) ) { updatePlayerPrices(tempPlayer); _server->ownBase( tempPlayer, base ); _server->sendPlayerPrices( tempPlayer ); } } } moveLord( movingLord, destCell ); } void Engine::movingOnCreature( GenericLord * movingLord, GenericCell * destCell ) { TRACE("Engine::movingOnCreature"); decreaseMove( movingLord, destCell ); GenericMapCreature * creature = destCell->getCreature(); uint lordForce = movingLord->computeForceIndicator(true); uint creatureForce = creature->computeForceIndicator(true); if( creatureForce > 0 ) { double ratio = double( lordForce ) / double( creatureForce ); CreatureAction action = computeCreatureAction( creature, ratio ); switch( action ) { case CreatureJoin: _question->setType( C_QR_CREATURE_JOIN ); _question->setLord( movingLord ); _question->setCreature( creature ); _state = IN_QUESTION; _server->sendAskCreatureJoin(_currentPlayer, creature ); break; case CreatureMercenary: _question->setType( C_QR_CREATURE_MERCENARY ); _question->setLord( movingLord ); _question->setCreature( creature ); _state = IN_QUESTION; _server->sendAskCreatureMercenary(_currentPlayer, creature ); break; case CreatureFlee: _question->setType( C_QR_CREATURE_FLEE ); _question->setLord( movingLord ); _question->setCreature( creature ); _state = IN_QUESTION; _server->sendAskCreatureFlee(_currentPlayer, creature ); break; case CreatureFight: _isCreature = true; startFight( movingLord->getId(), creature ); break; } } } void Engine::movingOnFreeCell( GenericLord * movingLord, GenericCell * destCell ) { TRACE("Engine::movingOnFreeCell"); uint i; int lordRow = movingLord->getCell()->getRow(); int lordCol = movingLord->getCell()->getCol(); decreaseMove( movingLord, destCell ); QList removedCells = _currentPlayer->removeLordVision( movingLord ); movingLord->setCell( destCell ); QList addedCells = _currentPlayer->addLordVision( movingLord ); updateMapVision( removedCells, addedCells ); // XXX: test if enter in vision field of other players... uint nbPlayers = _players.count(); GenericPlayer * tempPlayer; for( i = 0; i < nbPlayers; ++i ) { tempPlayer = _players.at( i ); if( tempPlayer != _currentPlayer ) { if( ( ! tempPlayer->canSee( lordRow, lordCol ) ) && ( tempPlayer->canSee( destCell ) ) ) { _server->sendLordVisit( movingLord, tempPlayer, true ); } if( ( tempPlayer->canSee( lordRow, lordCol ) ) && ( ! tempPlayer->canSee( destCell ) ) ) { _server->sendLordVisit( movingLord, tempPlayer, false ); } } } moveLord( movingLord, destCell ); } void Engine::handleInGameExchange() { switch( getCla2() ) { case C_EXCH_UNIT: exchangeUnits(); break; case C_EXCH_UNIT_SPLIT: exchangeUnitSplit(); break; case C_EXCH_ARTEFACT: exchangeArtefact(); break; case C_EXCH_BASEUNIT: exchangeBaseUnits(); break; default: break; } } void Engine::exchangeUnits() { uchar idLord1 = readChar(); uchar idUnit1 = readChar(); uchar idLord2 = readChar(); uchar idUnit2 = readChar(); GenericLord * lord1 = 0; GenericLord * lord2 = 0; TRACE("Engine::exchangeUnits idLord1 %d, idUnit1 %d, idLord2 %d, idUnit2 %d", idLord1,idUnit1,idLord2,idUnit2); if( idLord1 ) { lord1 = _currentPlayer->getLordById( idLord1 ); } if( idLord2 ) { lord2 = _currentPlayer->getLordById( idLord2 ); } if( lord1 && lord2 ) { if(lord1->getOwner() != lord2->getOwner()) { ///startFight( lord1->getId(), lord2 ); ///todo ?? return; } if( idUnit1 > MAX_UNIT || idUnit2 > MAX_UNIT ) { return; } GenericFightUnit * unit1 = lord1->getUnit( idUnit1 ); GenericFightUnit * unit2 = lord2->getUnit( idUnit2 ); TRACE(" unit1 %p, unit2 %p", unit1,unit2); if(!unit1 && !unit2) { return; } if( unit1 ) { if( unit2 ) { if( ( unit1->getRace() == unit2->getRace() ) && unit1->getLevel() == unit2->getLevel() ) { unit2->addNumber( unit1->getNumber() ); lord1->setUnit( idUnit1, 0 ); delete unit1; } else { lord1->setUnit( idUnit1, unit2 ); lord2->setUnit( idUnit2, unit1 ); } } else { if(lord1->countUnits() > 1 || lord1 == lord2){ lord2->setUnit( idUnit2, unit1 ); lord1->setUnit( idUnit1, 0 ); } else { return; } } } else if (!unit1) { if(lord2->countUnits() > 1 || lord1 == lord2){ lord1->setUnit( idUnit1, unit2 ); lord2->setUnit( idUnit2, 0 ); } else { return; } } else { return; } _server->updateUnits( _players, lord1 ); _server->updateUnits( _players, lord2 ); } } void Engine::exchangeUnitSplit() { uchar idLord = readChar(); uchar idUnit = readChar(); uchar num1 = readChar(); uchar pos2 = readChar(); uchar num2 = readChar(); GenericLord * lord = NULL; TRACE("Engine::exchangeUnitSplit idLord %d, idUnit %d, pos1 %d, num1 %d, pos2 %d, num2 %d", idLord, idUnit, num1, pos2, num2); if( idLord ) { lord = _currentPlayer->getLordById( idLord ); if( idUnit > MAX_UNIT && pos2 > MAX_UNIT ) { return; } GenericFightUnit * unit = lord->getUnit( idUnit ); GenericFightUnit * unit2 = lord->getUnit( pos2 ); TRACE(" unit %p", unit ); if( ! unit2 && num2 ) { unit2 = new GenericFightUnit(); unit2->setCreature( unit->getRace(), unit->getLevel() ); unit2->setMove( unit->getMove() ); unit2->setHealth( unit->getHealth() ); } if( unit && !num1 ) { delete unit; unit = NULL; } if( unit2 && !num2 ) { delete unit; unit = NULL; } if( unit ) { unit->setNumber( num1 ); } if( unit2 ) { unit2->setNumber( num2 ); } lord->setUnit( idUnit, unit ); lord->setUnit( pos2, unit2 ); _server->updateUnits( _players, lord ); } } void Engine::exchangeArtefact() { uchar idLord1 = readChar(); int item = readInt(); uchar idLord2 = readChar(); GenericLord * lord1 = 0; GenericLord * lord2 = 0; if( idLord1 ) { lord1 = _currentPlayer->getLordById( idLord1 ); } if( idLord2 ) { lord2 = _currentPlayer->getLordById( idLord2 ); } if( lord1 && lord2 ) { ArtefactManager * manag1 = lord1->getArtefactManager(); ArtefactManager * manag2 = lord2->getArtefactManager(); GenericLordArtefact * artefact = manag1->getArtefact( item ); manag1->removeArtefact( item ); manag2->addArtefact( artefact ); _server->sendExchangeArtefact( _players, lord1, item, lord2 ); } } void Engine::exchangeBaseUnits() { uchar idBase = readChar(); uchar idUnit1 = readChar(); uchar idLord = readChar(); uchar idUnit2 = readChar(); GenericBase * base = _currentPlayer->getBaseById( idBase ); GenericLord * lord = 0; if(idLord && idLord < GenericLord::MAX_LORDS){ lord = _currentPlayer->getLordById( idLord ); } GenericFightUnit * uni1 = 0; GenericFightUnit * uni2 = 0; if(base){ if(idUnit1<=MAX_UNIT){ uni1 = base->getUnit( idUnit1); } if(lord){ if(idUnit2<=MAX_UNIT){ uni2 = lord->getUnit( idUnit2 ); } if(!uni1 && !uni2) { return; } if( uni1 && uni2 ) { if( uni1->getCreature() != uni2->getCreature() ) { lord->setUnit( idUnit2, uni1 ); base->setUnit( idUnit1, uni2 ); } else { uni2->addNumber( uni1->getNumber() ); base->setUnit( idUnit1, 0 ); delete uni1; } } else if (!uni1) { if(lord->countUnits() > 1){ lord->setUnit( idUnit2, 0 ); base->setUnit( idUnit1, uni2 ); } else { return; } } else if (!uni2) { lord->setUnit( idUnit2, uni1 ); base->setUnit( idUnit1, 0 ); } } else { if(idUnit2<=MAX_UNIT){ uni2 = base->getUnit( idUnit2); } if(!uni1 && !uni2) { return; } if( uni1 && uni2 ) { if( uni1->getCreature() != uni2->getCreature() ) { base->setUnit( idUnit2, uni1 ); base->setUnit( idUnit1, uni2 ); } else { uni2->addNumber( uni1->getNumber() ); base->setUnit( idUnit1, 0 ); delete uni1; } } else { base->setUnit( idUnit2, uni1 ); base->setUnit( idUnit1, 0 ); } } if( lord ) { _server->updateUnits( _players, lord ); } _server->sendBaseUnits( _players, base ); } } void Engine::handleInGameModif() { switch( getCla2() ) { case C_MOD_MAP: case C_MOD_CELL: case C_MOD_PLAYER: logDD( "Not yet implemented" ); break; case C_MOD_BASE: handleInGameModifBase(); break; case C_MOD_BUILD: logDD( "Not yet implemented" ); break; case C_MOD_LORD: handleInGameModifLord(); break; } } void Engine::handleInGameModifBase() { switch( getCla3() ) { case C_BASE_BUILDING: handleInGameModifBaseBuilding(); break; case C_BASE_UNIT_BUY: handleInGameModifBaseUnit(); break; case C_BASE_MARKET: handleInGameModifBaseMarket(); break; default: logDD( "Not yet implemented" ); break; } } void Engine::handleInGameModifBaseBuilding() { int id = readChar(); int building = readChar(); bool isBuy = readChar(); GenericBase * base = _currentPlayer->getBaseById( id ); if( base ) { GenericBaseModel * baseModel = DataTheme.bases.at( base->getRace() ); InsideBuildingModel * buildingModel = baseModel->getBuildingModel( building ); GenericInsideBuilding * tmpbuil = base->getBuildingByType( building ); if( isBuy == true && !tmpbuil ) { if( base->canBuild() && _currentPlayer->canBuy( buildingModel ) && base->canBuildBuilding( buildingModel) ) { for( int i = 0; i < DataTheme.resources.count(); i++ ) { if( buildingModel->getCost( i ) != 0 ) { _currentPlayer->getResourceList()->decreaseValue( i, buildingModel->getCost( i ) ); _server->sendPlayerResource(_currentPlayer, i, _currentPlayer->getResourceList()->getValue( i ) ); } } base->addBuilding( building ); base->canBuild( false ); _server->updateBaseBuilding( _players, base, base->getBuildingByType( building ) ); if( buildingModel->getAction() ) { if( buildingModel->getAction()->getType() == INSIDE_MARKET ) { updatePlayerPrices( _currentPlayer ); _server->sendPlayerPrices( _currentPlayer ); } } } } else if( isBuy == false && tmpbuil ) { if( base->canSell() && buildingModel->getAction() && (buildingModel->getAction()->getType() != INSIDE_VILLAGE) ) { for( int i = 0; i < DataTheme.resources.count(); i++ ) { if( buildingModel->getCost( i ) != 0 ) { _currentPlayer->getResourceList()->increaseValue( i, buildingModel->getCost( i )/2 ); _server->sendPlayerResource( _currentPlayer,i, _currentPlayer->getResourceList()->getValue( i ) ); } } base->removeBuilding( tmpbuil ); base->canSell( false ); _server->updateBaseBuilding( _players, base , tmpbuil); } } } } void Engine::handleInGameModifBaseUnit() { int row = readInt(); int col = readInt(); if( _map->at( row, col )->getBase() ) { GenericBase * base = _map->at( row, col )->getBase(); uchar race = readChar(); uchar level = readChar(); int number = readInt(); Creature * creature = DataTheme.creatures.at( race, level ); if( base->getCreatureProduction( creature ) >= number && number != 0 ) { if( _currentPlayer->canBuy( creature, number ) ) { _currentPlayer->buy( creature, number ); base->addGarrison( creature, number ); base->buyCreature( creature, number ); _server->sendPlayerResources( _currentPlayer ); if( base->isGarrisonLord()) { _server->updateUnits( _players, base->getGarrisonLord() ); } else { _server->sendBaseUnits( _players, base ); } _server->sendBaseProduction( _players, base ); } } } } void Engine::handleInGameModifBaseMarket() { //XXX : not full implemented int res[2]; res[0] = readInt(); res[1] = readInt(); int value = readInt(); int cupr; int i; int reserve = _currentPlayer->getResourceList()->getValue( res[0] ); ResourceModel * model; for( i = 0; i < 2 ; i++ ) { model = DataTheme.resources.get( res[i] ); if( model->isPreservable() ) { return; } } if( res[0] != res[1] ) { PriceMarket * realPrice = _currentPlayer->getPriceMarket(); if( realPrice->getResourcePrice( res[0] ) >= realPrice->getResourcePrice( res[1] ) ) { cupr = realPrice->getResourceInResource( res[0],res[1] ); TRACE("res[0] %d, res[1] %d, value %d, cupr %d",res[0],res[1],value, cupr); if( value > reserve ) { value = reserve; } _currentPlayer->getResourceList()->increaseValue( res[1], value*cupr); _currentPlayer->getResourceList()->decreaseValue( res[0], value); } else { cupr= realPrice->getResourceInResource( res[1],res[0] ); TRACE("res[0] %d, res[1] %d, value %d, cupr",res[0],res[1],value, cupr); if( (value *cupr) > reserve ) { value = reserve/cupr; } _currentPlayer->getResourceList()->increaseValue( res[1], value); _currentPlayer->getResourceList()->decreaseValue( res[0], value*cupr); } for( i = 0; i < 2 ; i++ ) { _server->sendPlayerResource( _currentPlayer, res[i], _currentPlayer->getResourceList()->getValue(res[i])); } } } void Engine::handleInGameModifLord() { switch( getCla3() ) { case C_LORD_GARRISON: handleInGameModifLordGarrison(); break; case C_LORD_UNIT: handleInGameModifLordUnit(); break; case C_LORD_BUY: handleInGameModifLordBuy(); break; default: logDD( "Not yet implemented (modif lord)" ); break; } } void Engine::handleInGameModifLordGarrison() { uchar idLord = readChar(); bool garrison = ( readChar() == (uchar)1 ); GenericLord * lord = _currentPlayer->getLordById( idLord ); /// XXX: test if it is possible... if( lord && lord->getCell()->getBase() != 0 ) { lord->setVisible( !garrison ); GenericBase * base = lord->getCell()->getBase(); if( ( lord == base->getGarrisonLord() ) || ( lord == base->getVisitorLord() ) ) { if( ( garrison && ( lord == base->getVisitorLord() ) ) || ( ( lord == base->getGarrisonLord() ) && !garrison ) ) { base->exchangeLords(); _server->setGarrison( _players, lord, garrison ); } } else if( ( base->getGarrisonLord() == 0 ) || ( base->getVisitorLord() == 0 ) ) { if( garrison ) { if( base->getGarrisonLord() ) { base->exchangeLords(); } base->setGarrisonLord( lord ); _server->setGarrison( _players, lord, true ); } else { if( base->getVisitorLord() ) { base->exchangeLords(); } base->setVisitorLord( lord ); _server->setGarrison( _players, lord, false ); } } } } void Engine::handleInGameModifLordUnit() { uchar id = readChar(); uchar pos = readChar(); uchar race = readChar(); uchar level = readChar(); uint nb = readInt(); uchar move = readChar(); int health = readInt(); GenericLord * lord = 0; GenericFightUnit * unit = 0; if( id && id < GenericLord::MAX_LORDS ) { lord = _currentPlayer->getLordById( id ); } /* if( num < 0 || nb < 0 || move < 0 || health < 0 ) { logEE("Error, negative values"); }*/ unit =lord->getUnit( pos ); if( ! unit ) { unit = new GenericFightUnit(); unit->setCreature( race, level ); unit->setMove( move ); unit->setHealth( health ); } if( (uint) unit->getNumber() < nb ) { /* no cheat possible */ return; } if( nb == 0 ){ if( lord->countUnits() > 1 ) { unit->setNumber( nb ); } } else { unit->setNumber( nb ); } lord->setUnit( pos, unit ); _server->updateUnit( _currentPlayer, lord, pos ); if( unit->getNumber() == 0 ){ delete unit; unit = 0; lord->setUnit( pos, unit ); } } void Engine::handleInGameModifLordBuy() { uchar id = readChar(); uint row = readInt(); uint col = readInt(); /* add controls for cheats */ TRACE("Engine::handleInGameModifLordBuy row %d ,col %d", row, col); GenericLordModel * lordModel = DataTheme.lords.at(id); if(_currentPlayer->canBuy(lordModel) && !_map->at(row,col)->getLord()) { setLord2Player( id , _currentPlayer->getNum()); GenericLord * lord = _currentPlayer->getLord( _currentPlayer->numLord() - 1 ); lord->setId( id ); lord->setCell(_map->at(row,col)); _server->newLord( _players, lord ); lord->setBaseCharac( MOVE, lord->getCharac( MAXMOVE ) ); _server->sendLordCharac( _currentPlayer, lord, MOVE ); for( int i = 0; i < DataTheme.resources.count(); i++ ) { if( lordModel->getCost( i ) != 0 ) { _currentPlayer->getResourceList()->decreaseValue( i, lordModel->getCost( i ) ); _server->sendPlayerResource( _currentPlayer, i, _currentPlayer->getResourceList()->getValue( i ) ); } } } } bool Engine::handleBuildingEnter( GenericBuilding * building, GenericLord * lord ) { TRACE("Engine::handleBuildingEnter"); bool enter = false; QList list; if( ! building->hasBeenVisited() ) { if( building->getCondition() ) { } enter = true; list = building->getActionList( Action::FIRSTTIME ); if( list.isEmpty() ) { list = building->getActionList( Action::FIRSTTIMELORD ); } if( list.isEmpty() ) { list = building->getActionList( Action::NEXTTIME ); } if( list.isEmpty() ) { list = building->getActionList( Action::DATE ); } for( int i = 0; i < list.count(); i++ ) { handleAction( list.at( i ), lord ); handleAction( list.at( i ), lord->getOwner() ); } //_server->sendPlayerPopulation( lord->getOwner()); building->enter( lord ); } else if( ! building->hasBeenVisited( lord ) ) { if( building->getCondition() ) { } enter = true; list = building->getActionList( Action::FIRSTTIMELORD ); if( list.isEmpty() ) { list = building->getActionList( Action::NEXTTIME ); } for( int i = 0; i < list.count(); i++ ) { handleAction( list.at( i ), lord ); } building->enter( lord ); } else { if( building->getCondition() ) { } enter = true; list = building->getActionList( Action::NEXTTIME ); for( int i = 0; i < list.count(); i++ ) { handleAction( list.at( i ), lord ); } building->enter( lord ); } return enter; } void Engine::handleAction( Action * action, GenericLord * lord ) { for( int i = 0; i < action->getElementaryNumber(); i++ ) { ElementaryAction * _elementary = action->getElementaryAction( i ); switch( _elementary->getType() ) { case ElementaryAction::ATTACK: lord->increaseBaseCharac( ATTACK, _elementary->getCoeff() ); _server->sendLordCharac( _currentPlayer, lord, ATTACK ); break; case ElementaryAction::DEFENSE: lord->increaseBaseCharac( DEFENSE, _elementary->getCoeff() ); _server->sendLordCharac( _currentPlayer, lord, DEFENSE ); break; case ElementaryAction::POWER: lord->increaseBaseCharac( POWER, _elementary->getCoeff() ); _server->sendLordCharac( _currentPlayer, lord, POWER ); break; case ElementaryAction::KNOWLEDGE: lord->increaseBaseCharac( KNOWLEDGE, _elementary->getCoeff() ); _server->sendLordCharac( _currentPlayer, lord, KNOWLEDGE ); break; case ElementaryAction::MOVE: lord->increaseBaseCharac( MOVE, _elementary->getCoeff() ); _server->sendLordCharac( _currentPlayer, lord, MOVE ); break; case ElementaryAction::MAXMOVE: lord->increaseBaseCharac( MAXMOVE, _elementary->getCoeff() ); _server->sendLordCharac( _currentPlayer, lord, MAXMOVE ); break; case ElementaryAction::TECHNICPOINT: lord->increaseBaseCharac( TECHNICPOINT, _elementary->getCoeff() ); _server->sendLordCharac( _currentPlayer, lord, TECHNICPOINT ); break; case ElementaryAction::MAXTECHNICPOINT: lord->increaseBaseCharac( MAXTECHNICPOINT, _elementary->getCoeff() ); _server->sendLordCharac( _currentPlayer, lord, MAXTECHNICPOINT ); break; case ElementaryAction::MORALE: lord->increaseBaseCharac( MORALE, _elementary->getCoeff() ); _server->sendLordCharac( _currentPlayer, lord, MORALE ); break; case ElementaryAction::LUCK: lord->increaseBaseCharac( LUCK, _elementary->getCoeff() ); _server->sendLordCharac( _currentPlayer, lord, LUCK ); break; case ElementaryAction::VISION: lord->increaseBaseCharac( VISION, _elementary->getCoeff() ); _server->sendLordCharac( _currentPlayer, lord, VISION ); break; case ElementaryAction::EXPERIENCE: lord->increaseBaseCharac( EXPERIENCE, _elementary->getCoeff() ); manageIncreaseExperience( lord, _elementary->getCoeff()); //_server->sendLordCharac( _currentPlayer, lord, EXPERIENCE ); break; case ElementaryAction::SKILL: break; case ElementaryAction::ARTEFACT: break; case ElementaryAction::UNIT: break; case ElementaryAction::CHARISMA: lord->increaseBaseCharac( CHARISMA, _elementary->getCoeff() ); _server->sendLordCharac( _currentPlayer, lord, CHARISMA ); break; default: break; } } } void Engine::handleInGameTurn() { switch( getCla2() ) { case C_TURN_PLAY: logEE( "Should not happen (Server : SO_TURN/C_TURN_PLAY)" ); break; case C_TURN_LORD:{ int type = readInt(); _server->sendLordPlTurn( _currentPlayer, type ); } break; case C_TURN_PLORD: logEE( "Should not happen (Server : SO_TURN/C_TURN_PLORD)" ); break; case C_TURN_END: nextPlayer(); break; } } void Engine::stateInFight( int num ) { uchar cla1; if( _fight ) { cla1 = getCla1(); switch( cla1 ) { case SO_MSG: handleMessage( num ); break; case SO_FIGHT: _fight->handleSocket( _players.at( num ), _currentData ); break; default: logEE( "Should not happen %d", cla1 ); break; } } else { logEE( "Should not happen, _fight == 0" ); } } void Engine::appendPlayersList( QList sockets ) { for( int i = 0; i < sockets.count(); i++ ) { addPlayer( sockets.at( i ) ); } } void Engine::addPlayer( AttalPlayerSocket * socket ) { GenericPlayer * player = socket->getPlayer(); addPlayer( player ); } void Engine::addPlayer( GenericPlayer * player ) { _players.append( player ); } void Engine::removePlayer( AttalPlayerSocket * socket ) { GenericPlayer * player = socket->getPlayer(); removePlayer( player ); } void Engine::removePlayer( GenericPlayer * player ) { _players.removeAll( player ); } void Engine::slot_newPlayer( AttalPlayerSocket * socket ) { _players.append( socket->getPlayer() ); } void Engine::reinit() { _state = NOT_PLAYING; GameData::reinit(); _server->clear(); } void Engine::startCampaign() { //no more used /*if( _campaign ) { QString filename; uint nbScen = _campaign->getScenarioNumber(); for( uint i = 0; i < nbScen; i++ ) { filename = _campaign->getScenario( i ); if( loadGame( CAMPAIGN_PATH + filename , false) ) { startGame(); } } }*/ } void Engine::deleteCampaign() { TRACE("Engine::deleteCampaign"); if( _campaign ) { delete _campaign; _campaign = NULL; } } void Engine::startGame() { TRACE("Engine::StartGame"); if( _players.count() > (int)_server->getNbSocket() ) { return; } _state = IN_GAME; _server->startGame( _players ); //_calendar->newDay(); _server->sendSizeMap( _players, _map->getHeight(), _map->getWidth() ); for( int i = 0; i < _players.count(); i++ ) { _currentPlayer = _players.at( i ); _currentPlayer->setMap( _map ); _currentPlayer->setNum( i ); _currentPlayer->setAlive( true ); _currentPlayer->initMapVision(); _server->sendGameInfoPlayer( _currentPlayer, _players ); _server->sendGameCalendar(_currentPlayer, _calendar); /* vision */ for( uint j = 0; j < _currentPlayer->numLord(); j++ ) { QList removed; QList added = _currentPlayer->addLordVision( _currentPlayer->getLord( j ) ); } for( uint j = 0; j < _currentPlayer->numBase(); j++ ) { QList removed; QList added = _currentPlayer->addBaseVision( _currentPlayer->getBase( j ) ); } for( uint j = 0; j < _currentPlayer->numBuilding(); j++ ) { QList removed; QList added = _currentPlayer->addBuildingVision( _currentPlayer->getBuilding( j ) ); } for( uint col = 0; col < _map->getWidth(); ++col ) { for( uint row = 0; row < _map->getHeight(); ++row ) { if( _currentPlayer->canSee( row, col ) ) { updateCellVision( _map->at( row, col ) ); } } } /* end vision */ /* resources, production and prices */ for( uint j = 0; j < _currentPlayer->numBase(); j++ ) { GenericBase * base = _currentPlayer->getBase( j ); _server->sendBaseResources( _currentPlayer, base ); _server->sendBaseProduction( _currentPlayer, base ); } for( uint j = 0; j < _currentPlayer->numBuilding(); j++ ) { GenericBuilding * build = _currentPlayer->getBuilding( j ); _server->sendBuildingResources( _currentPlayer, build ); } for( int j = 0; j < DataTheme.resources.count(); j++ ) { _server->sendPlayerResource( _currentPlayer, j, _currentPlayer->getResourceList()->getValue( j ) ); } updatePlayerPrices(_currentPlayer); _server->sendPlayerPrices( _currentPlayer ); } _map->computeStoppable(); _currentPlayer = _players.at( 0 ); _currentPlayer->newWeek(); _currentPlayer->newTurn(); _server->beginTurn( _players, _currentPlayer ); _server->sendAskNone( _players, getScenarioDescription(), QR_SCEN_DESC ); TRACE("Engine::StartGame End"); } void Engine::endGame() { TRACE("Engine::endGame"); _state = NOT_PLAYING; if(_server) { if(_fight){ disconnect( _fight , 0, 0, 0 ); if( !_fight->hasEnded() ) { _fight->endFight(); slot_endFight( _fight->getResult() ); } delete _fight; } _fight = NULL; _server->sendEndGame( _players ); } _dataQueue.clear(); emit sig_endGame( _gameId ); } void Engine::startFight() { if( !_fight ) { _fight = new FightEngine( _server ); } _state = IN_FIGHT; _fight->init( _players.at( 0 ), _players.at( 0 )->getLord( 0 ), _players.at( 1 ), _players.at( 1 )->getLord( 0 ) ); } void Engine::startFight( int lordAttack, GenericLord *lordDefense ) { if( !_fight ) { _fight = new FightEngine( _server ); QObject::connect( _fight, SIGNAL( sig_endFight( FightResultStatus ) ), SLOT( slot_endFight( FightResultStatus ) ) ); } _fight->setDefendCell( lordDefense->getCell() ); _state = IN_FIGHT; _fight->init( _currentPlayer, _currentPlayer->getLordById( lordAttack ), lordDefense->getOwner(), lordDefense ); } void Engine::startFight( int lordAttack, GenericMapCreature * creature ) { if( !_fight ) { _fight = new FightEngine( _server ); QObject::connect( _fight, SIGNAL( sig_endFight( FightResultStatus ) ), SLOT( slot_endFight( FightResultStatus ) ) ); } _state = IN_FIGHT; _fight->setDefendCell( creature->getCell() ); GenericFightUnit * units[MAX_UNIT]; for( int i = 0; i < MAX_UNIT; i++ ) { if( creature->getStack( i ) > 0 ) { units[i] = new GenericFightUnit(); units[i]->setCreature( creature->getCreature() ); units[i]->setNumber( creature->getStack( i ) ); } else { units[i] = NULL; } } _fight->init( _currentPlayer, _currentPlayer->getLordById( lordAttack ), units, (GameData *)this ); /// XXX: destroy units... TRACE( "start fight finished" ); } void Engine::slot_endFight( FightResultStatus result ) { TRACE("Engine::slot_endFight"); //XXX: Handle result (flee, and so on...) GenericLord * loser, * winner; if( result.hasDefenseWin() ) { loser = _fight->getAttackLord(); winner = _fight->getDefendLord(); } else { loser = _fight->getDefendLord(); winner = _fight->getAttackLord(); } GenericBase * garrBase = 0; if( _isCreature ) { if( loser == _fight->getDefendLord() ) { GenericCell * cell = _fight->getDefendCell(); GenericMapCreature * creature = cell->getCreature(); _currentPlayer->getResourceList()->addResources( creature->getResourceList() ); _server->sendPlayerResources( _currentPlayer ); QString msg = creature->getResourceList()->getAutoDescription(); if( !msg.isEmpty() ) { msg.prepend( "You gain:"); _server->sendMessage( _currentPlayer , msg ); } removeCreature( creature ); uint experience = _fight->getExperience( winner ); manageIncreaseExperience( winner, experience ); } else { _server->sendLordRemove( _players, loser ); loser->removeFromGame(); } } else { garrBase = loser->getCell()->getBase(); _server->sendLordRemove( _players, loser ); loser->removeFromGame(); uint experience = _fight->getExperience( winner ); manageIncreaseExperience( winner, experience ); } if( winner->getOwner() == _currentPlayer ) { if( garrBase ) { movingOnBase( winner, garrBase->getCell() ); } } updatePlayers(); if(_fight){ delete _fight; } _fight = NULL; _state = IN_GAME; } void Engine::manageIncreaseExperience( GenericLord * lord, uint experience ) { TRACE("manageIncreaseExperience %d", experience); uint currentLevel, nextLevelExp; //currentLevel = DataTheme.lordExperience.computeLevelForExperience( lord->getCharac( EXPERIENCE ) ); currentLevel = lord->getBaseCharac( LEVEL ); int lordExperience = lord->getCharac( EXPERIENCE ); experience += lordExperience; while( experience > 0 ) { if( currentLevel < DataTheme.lordExperience.getLevelNumber() ) { nextLevelExp = DataTheme.lordExperience.getLevel( currentLevel + 1 ); if( experience >= nextLevelExp ) { lord->increaseBaseCharac( EXPERIENCE, experience - nextLevelExp ); GenericLordModel * model = DataTheme.lords.at( lord->getId() ); LordCharac charac = model->getCategory()->getRandomEvolution(); lord->increaseBaseCharac( charac, 1 ); _server->sendLordCharac( lord->getOwner(), lord, charac ); currentLevel++; lord->setBaseCharac( EXPERIENCE, experience ); lord->setBaseCharac( LEVEL, currentLevel ); experience -= nextLevelExp; } else { lord->setBaseCharac( EXPERIENCE, experience ); break; } } else { break; } } _server->sendLordCharac( lord->getOwner(), lord, LEVEL ); _server->sendLordCharac( lord->getOwner(), lord, EXPERIENCE ); } bool Engine::saveGame( const QString & filename ) { QString filename2 = filename; if( filename2.isNull() ) { return false; } if( !filename2.contains(".gam")){ filename2.append(".gam"); } QFile f( filename2 ); if (! f.open(QIODevice::WriteOnly) ) { logEE("Could not open file %s for writing\n", filename.toLatin1().constData() ); return false; } QTextStream ts( &f ); GameData::save( &ts ); f.close(); if(getCampaign()) { saveCampaign( filename2 ); } return true; } bool Engine::saveCampaign( const QString & filename ) { QString filenamecmp = filename; QString filename2; if( filenamecmp.contains(".gam")){ filenamecmp.remove(".gam"); } if( !filenamecmp.contains(".cms")){ filenamecmp.append(".cms"); } //filenamecmp = QFileDialog::getSaveFileName( this, "",CAMPAIGN_PATH , "*.cms" ); filename2 = filename.section(QDir::separator(),-1,-1); QFile f( filenamecmp ); if (! f.open(QIODevice::WriteOnly) ) { logEE( "Could not open file %s for writing\n", filename2.toLatin1().constData() ); return false; } Campaign * campaign = new Campaign; QTextStream ts( &f ); uint nbScen = getCampaign()->getScenarioNumber(); campaign->setCurrentScenario( getCampaign()->getCurrentScenario() ); for( uint i = 0; i < nbScen; i++ ) { if( i == getCampaign()->getCurrentScenario() ){ campaign->addScenario( filename2 ); } else { campaign->addScenario( getCampaign()->getScenario(i) ); } } campaign->setTheme( getCampaign()->getTheme() ); campaign->setName( getCampaign()->getName() ); campaign->setDescription( getCampaign()->getDescription() ); campaign->save( & ts ); f.close(); if( campaign ) { delete campaign; } return true; } void Engine::newDay() { TRACE("Engine::newDay"); _calendar->newDay(); _server->sendGameCalendar( _players, _calendar); checkNewWeek(); } void Engine::checkNewWeek() { TRACE("Engine::checkNewWeek"); if( _calendar->getDay() == 1 ) { // new week updateProduction(); updateCreatures(); } } void Engine::updateProduction() { TRACE("Engine::updateProduction"); uint nbItems = _bases.count(); for( uint i = 0; i < nbItems; ++i ) { _bases.at( i )->initCreatureProduction(); //_bases.at( i )->getPopulationGrowth(); //_server->sendBasePopulation( _players, _bases.at( i ) ); _server->sendBaseProduction( _players, _bases.at( i ) ); } } void Engine::updateCreatures() { TRACE("Engine::updateCreatures"); uint nbItems = _creatures.count(); for( uint i = 0; i < nbItems; ++i ) { _creatures.at( i )->grow(); _server->updateCreature( _players, _creatures.at( i ) ); /// XXX: we could update only if 'category' has changed... } } void Engine::nextPlayer() { TRACE("Engine::nextPlayer"); uint i; //Should not be necessary updatePlayers(); if( ! enoughPlayers() ) { checkResult(); endGame(); return; } checkMainQuest(); if (_state == NOT_PLAYING) { return; } checkPlayerShouldPlay(); TRACE("Engine::nextPlayer _currentPlayer %p", _currentPlayer ); //_currentPlayer->resetPopulation(); for( i = 0; i < _currentPlayer->numBuilding(); i++ ) { handleBuildingTurn( _currentPlayer, _currentPlayer->getBuilding( i ) ); } for( i = 0; i < _currentPlayer->numBase(); i++ ) { handleBaseTurn( _currentPlayer, _currentPlayer->getBase( i ) ); } for( i = 0; i < _currentPlayer->numLord(); i++ ) { handleCreatTurn( _currentPlayer, _currentPlayer->getLord( i ) ); } //handlePopulation( _currentPlayer ); _currentPlayer->newTurn(); _server->beginTurn( _players, _currentPlayer ); checkMainQuest(); TRACE("Engine::nextPlayer end _state %d", _state); } void Engine::checkPlayerShouldPlay() { TRACE("Engine::checkPlayerShouldPlay"); nextCurrentPlayer(); int i = 0; while( !_currentPlayer->isAlive() ) { nextCurrentPlayer(); //index placed for safety reason, should be not necessary i++; if( i == _players.count() ){ logEE("endless loop"); break; } } } void Engine::nextCurrentPlayer() { int num = _players.indexOf( _currentPlayer ); num++; if( num == _players.count() ) { _currentPlayer = _players.at( 0 ); newDay(); } else { _currentPlayer = _players.at( num ); } } void Engine::handleBuildingTurn( GenericPlayer * player, GenericBuilding * building ) { QList list = building->getActionList( Action::DATE ); handleActionListDate( list, player, building->getResourceList() ); _server->sendBuildingResources( player , building ); } void Engine::handleBaseTurn( GenericPlayer * player, GenericBase * base ) { //player->addPopulation( base->getPopulation() ); GenericBaseModel * baseModel = DataTheme.bases.at( base->getRace() ); QList list = base->getActionList( Action::DATE ); handleActionListDate( list, player, base->getResourceList() ); _server->sendBaseResources( player , base ); for( uint i = 0; i < base->getBuildingCount(); i++ ) { GenericInsideBuilding * inbuil = base->getBuilding(i); for( int j = 0; j < DataTheme.resources.count(); j++ ) { player->getResourceList()->decreaseValue( j,inbuil->getMantCost(j)); _server->sendPlayerResource( player,j, player->getResourceList()->getValue(j) ); } } for( int j = 0; j < DataTheme.resources.count(); j++ ) { player->getResourceList()->increaseValue( j, base->collectRessource(j)); _server->sendPlayerResource( player, j, player->getResourceList()->getValue(j) ); } } void Engine::handleCreatTurn( GenericPlayer * player, GenericLord * lord ) { for( uint i = 0; i < MAX_UNIT; i++ ) { GenericFightUnit * unit = lord->getUnit(i); if( unit ) { for( int j = 0; j < DataTheme.resources.count(); j++ ) { if(unit->getMantCost (j)) { int mant = ( unit->getMantCost( j ) * unit->getNumber() ); #if 0 int ress = player->getResource(j); uint decr = (mant - ress) / unit->getMantCost( j ) ; decr = decr > 0 ? decr : 0; if (decr > 0) { decr = decr > unit->getNumber() ? unit->getNumber() : unit->getNumber()-decr; unit->setNumber(decr); lord->setUnit(i,unit); } #endif player->getResourceList()->decreaseValue( j, mant ); _server->sendPlayerResource( player, j, player->getResourceList()->getValue( j ) ); } } } } //_server->updateUnits(lord); } void Engine::handleActionListDate( QList list, GenericPlayer * player, GenericResourceList * rlist ) { for( int i = 0; i < list.count(); i++ ) { // this procedure is used to estabilish a production every coeff days ( a % b ) // zero excluded, obv. int coeff = list.at( i )->getCoeff(); coeff = ( coeff == 0 ) ? 1 : coeff; int isTurn = _calendar->getCurrentAbsoluteDate() % coeff ; if( isTurn == 0 ) { handleAction( list.at( i ), player, rlist); } } } void Engine::handleAction( Action * action, GenericPlayer * player, GenericResourceList * rlist ) { GenericResourceList * plist = player->getResourceList(); for( int i = 0; i < action->getElementaryNumber(); i++ ) { ElementaryAction * elementary = action->getElementaryAction( i ); switch( elementary->getType() ) { case ElementaryAction::RESSOURCE: TRACE("Engine::handleAction RESSOURCE, arg %d, coeff %d", elementary->getArg(), elementary->getCoeff() ); if( DataTheme.resources.get( elementary->getArg() )->isGlobal() ) { plist->increaseValue( elementary->getArg() , elementary->getCoeff() ); _server->sendPlayerResource( player, elementary->getArg(), plist->getValue( elementary->getArg() ) ); } else { rlist->increaseValue( elementary->getArg() , plist->getValue( elementary->getArg() ) ); } break; case ElementaryAction::RANDRESSOURCE: TRACE("Engine::handleAction RANDRESSOURCE, arg %d, coeff %d", elementary->getArg(), elementary->getCoeff() ); if( DataTheme.resources.get( elementary->getArg() )->isGlobal() ) { plist->updateRandGrowth( elementary->getArg(), elementary->getCoeff() ); _server->sendPlayerResource( player, elementary->getArg(), plist->getValue( elementary->getArg() ) ); } else { rlist->updateRandGrowth( elementary->getArg(), elementary->getCoeff() ); } break; case ElementaryAction::RESOURCEPERC: { TRACE("Engine::handleAction RESOURCEPERC, arg %d, coeff %d", elementary->getArg(), elementary->getCoeff() ); if( DataTheme.resources.get( elementary->getArg() )->isGlobal() ) { plist->modPercValue( elementary->getArg(), elementary->getCoeff() ); _server->sendPlayerResource( player, elementary->getArg(), plist->getValue( elementary->getArg() ) ); } else { rlist->modPercValue( elementary->getArg(), elementary->getCoeff() ); } } break; case ElementaryAction::RESOURCEFROM: { TRACE("Engine::handleAction RESOURCEFROM, arg %d, coeff %d", elementary->getArg(), elementary->getCoeff() ); TRACE("Engine::handleAction RESOURCEFROM, arg1 %d", elementary->getArg1() ); if( ! rlist ) { return; } int increase = rlist->getValue( elementary->getArg() ) / elementary->getCoeff(); TRACE("Engine::increase RESOURCEFROM, %d", increase ); plist->increaseValue( elementary->getArg1(), increase ); _server->sendPlayerResource( player, elementary->getArg(), player->getResourceList()->getValue( elementary->getArg1() ) ); if( !DataTheme.resources.get( elementary->getArg1() )->isGlobal() ) { rlist->setValue( elementary->getArg(), plist->getValue( elementary->getArg() ) ); } } break; case ElementaryAction::POPULATION: //player->addPopulation( elementary->getCoeff() ); break; default: break; } } } /* void Engine::handlePopulation( GenericPlayer * player ) { TRACE("Engine::handlePopulation( GenericPlayer * player ) %p", player); TRACE( "Player name %s", player->getConnectionName().toLatin1().constData() ); _server->sendPlayerPopulation( player ); player->getResourceList()->increaseValue( 0, player->getPopulation()); _server->sendPlayerResource( player, 0, player->getResourceList()->getValue(0) ); } */ bool Engine::loadCampaign( const QString & filename ) { bool ret = true; if( _campaign ) { delete _campaign; } _campaign = new Campaign(); CampaignParser handler( _campaign ); QFile file( filename ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if( ! ok ) { delete _campaign; _campaign = 0; logEE( "Parse Error (%s) : %s", filename.toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); ret = false; } return ret; } bool Engine::checkGamePlayers( const QString & filename ) { bool ret = false; ScenarioDescription * desc = new ScenarioDescription(); desc->load( filename ); int players = _players.count(); int scenPlayers = desc->getNbPlayers(); TRACE( "Engine::checkGamePlayers real players %d ", _players.count()); TRACE( "Engine::checkGamePlayers scenario players %d ", scenPlayers); TRACE( "Engine::checkGamePlayers filename %s ", filename.toLatin1().constData()); if( players == scenPlayers ) { ret = true; } _tmpPlay = scenPlayers - players; delete desc; return ret; } bool Engine::loadGame( const QString & filename, bool silent ) { TRACE("bool Engine::loadGame( const QString & filename %s, bool silent %d)", filename.toLatin1().constData(), silent ); for( int i = 0; i < _players.count(); i++ ) { _currentPlayer = _players.at( i ); _currentPlayer->cleanData(); } reinit(); ScenarioParser handler( (GameData*)this ); QFile file( filename ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", filename.toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } TRACE( "Engine::loadGame real players %d ", _players.count()); TRACE( "Engine::loadGame scenario players %d ", _nbPlayer); if( _players.count() != _nbPlayer ) { if( ! silent ) { QMessageBox::critical( 0, tr( "Error with scenario" ), tr( "Wrong number of connected players" ) ); TRACE( "Engine::loadGame real players %d ", _players.count()); TRACE( "Engine::loadGame scenario players %d ", _nbPlayer); for( int i = 0; i < _players.count(); i++ ) { _currentPlayer = _players.at( i ); TRACE( "Engine::loadGame player num %d , lords %d ",i, _currentPlayer->numLord() ); } } _tmpPlay = _nbPlayer - _players.count(); _state = NOT_PLAYING; GameData::reinit(); return false; } else { return true; } } uint Engine::getAlivePlayersNumber() { uint ret = 0; for( int i = 0; i < _players.count(); i++ ) { if( _players.at( i )->isAlive() ) { ret++; } } return ret; } void Engine::checkResult() { TRACE("Engine::checkResult"); bool ret = false; for( int i = 0; i < _players.count(); i++ ) { if( /*!_players.at( i )->isRuledByAi() && */ _players.at( i )->isAlive() ) { _server->playerWin( _players, _players.at( i ) ); ret = true; } } emit sig_result( _gameId, ret ); } void Engine::updatePlayers() { TRACE("Engine::updatePlayers"); for( int i = 0; i < _players.count(); i++ ) { GenericPlayer * player = _players.at(i); if( player->isAlive() && ( player->numBase() == 0 ) and ( player->numLord() == 0 ) ) { player->setAlive( false ); for( uint i = 0; i < player->numBuilding(); i++ ) { GenericBuilding * build = player->getBuilding( i ); build->setOwner( NULL ); _server->ownBuilding( _players , build ); } _server->playerLose( _players, player ); } } } bool Engine::enoughPlayers() { TRACE("Engine::enoughPlayers"); uint ret = 0; uint num = _players.count(); ret = getAlivePlayersNumber(); TRACE(" num %d, ret %d", num, ret ); if( num == 1 && ret == 1 ) { return true; } if( num > 1 && ret > 1 ) { return true; } return false; } void Engine::updateMapVision( QList & removed, QList & added ) { for( int i = 0; i < added.count(); i++ ) { GenericCell * cell = added.at( i ); if( removed.indexOf( cell ) == -1 ) { updateCellVision( cell ); } } } void Engine::updateCellVision( GenericCell * cell ) { _server->sendCell( _currentPlayer , cell ); if( cell->getLord() ) { _server->newLord( _currentPlayer , cell->getLord() ); } if( cell->getCreature() ) { _server->newCreature( _currentPlayer , cell->getCreature() ); } if( cell->getBase() ) { _server->newBase( _currentPlayer , cell->getBase() ); if(cell->getBase()->getOwner()){ _server->ownBase( _currentPlayer , cell->getBase()); } } if( cell->getBuilding() ) { _server->newBuilding( _currentPlayer, cell->getBuilding() ); if(cell->getBuilding()->getOwner()){ _server->ownBuilding( _currentPlayer , cell->getBuilding() ); } } if( cell->getEvent() ) { _server->newEvent( _currentPlayer, cell->getEvent() );/* switch( cell->getEvent()->getType() ) { case GenericEvent::EventArtefact: _server->newArtefactMap( cell->getEvent()->getArtefact() ); break; }*/ }/// XXX: other cell attr to send... } Engine::CreatureAction Engine::computeCreatureAction( GenericMapCreature * creature, double ratio ) { CreatureAction ret = CreatureFight; switch( creature->getBehaviour() ) { case GenericMapCreature::Obedient: ret = CreatureJoin; break; case GenericMapCreature::Friendly: if( ratio < 0.75 ) { ret = CreatureFight; } else if( ratio < 1.25 ) { ret = CreatureMercenary; } else { ret = CreatureJoin; } break; case GenericMapCreature::Neutral: if( ratio < 1.0 ) { ret = CreatureFight; } else if( ratio < 1.5 ) { ret = CreatureFlee; } else if( ratio < 2.0 ) { ret = CreatureMercenary; } else { ret = CreatureJoin; } break; case GenericMapCreature::Aggressive: if( ratio < 1.5 ) { ret = CreatureFight; } else if( ratio < 3.0 ) { ret = CreatureFlee; } else { ret = CreatureMercenary; } break; case GenericMapCreature::Hostile: if( ratio < 2.5 ) { ret = CreatureFight; } else { ret = CreatureFlee; } break; } if( ( ! creature->isFleeing() ) && ( ret == CreatureFlee ) ) { ret = CreatureFight; } return ret; } bool Engine::checkMainQuest() { TRACE("Engine::checkMainQuest"); QuestData data; QuestCondition * failCondition, * successCondition; data.setPlayer( _currentPlayer ); data.setCurrentTurn( _calendar->getTurn() ); data.setCurrentAbsoluteDate( _calendar->getCurrentAbsoluteDate() ); Quest * main = _quests->getMainQuest(); if( main ) { failCondition = main->getFailCondition(); successCondition = main->getSuccessCondition(); uint nbLord = _currentPlayer->numLord(); for( uint i = 0; i < nbLord; i++ ) { data.setLord( _currentPlayer->getLord( i ) ); if( failCondition ) { if( failCondition->check( &data ) ) { _currentPlayer->setAlive( false ); _server->playerLose( _players, _currentPlayer ); for( int i = 0; i < _players.count(); i++ ) { if( _players.at( i )->isAlive() && _players.at( i ) != _currentPlayer ) { _server->playerWin( _players, _players.at( i ) ); } } if(!_currentPlayer->isRuledByAi()) { emit sig_result( _gameId, false); } endGame(); return true; } } if( successCondition ) { if( successCondition->check( &data ) ) { _server->playerWin( _players, _currentPlayer ); for( int i = 0; i < _players.count(); i++ ) { if( _players.at( i )->isAlive() && _players.at( i ) != _currentPlayer ) { _server->playerLose( _players, _players.at( i ) ); } } if(!_currentPlayer->isRuledByAi()) { emit sig_result( _gameId, true); } endGame(); return true; } } } } return false; } void Engine::updatePlayerPrices( GenericPlayer * player) { uint nbases; int cupr,tmpr; uint nbRes = DataTheme.resources.count(); PriceMarket * realPrice = player->getPriceMarket(); cupr = 10000; for( uint i = 0; i < nbRes; i++ ) { nbases = player->numBase(); for( uint j = 0 ; j < nbases ; j++){ PriceMarket * price = DataTheme.bases.at( player->getBase( j )->getRace())->getPriceMarket(); tmpr= price->getResourcePrice( i ) ; if( tmpr < cupr ) { cupr = tmpr; } } if(cupr==10000){ cupr=1; } realPrice->setResourcePrice(i,cupr); cupr = 10000; } } void Engine::moveLord( GenericLord * movingLord, GenericCell * cell ) { uchar lord = movingLord->getId(); int row = movingLord->getCell()->getRow(); int col = movingLord->getCell()->getCol(); cell->setLord( movingLord ); _server->sendMvt( _players, lord, row, col ); } void Engine::decreaseMove( GenericLord * movingLord, GenericCell * cell ) { GenericCell * start = movingLord->getCell(); int cost = PathFinder::computeCostMvt( start, cell ); movingLord->decreaseBaseCharac( MOVE, cost ); _server->sendLordCharac( _currentPlayer, movingLord, MOVE ); } void Engine::removeCreature( GenericMapCreature * creature ) { GenericCell * cell = creature->getCell(); _server->sendCreatureRemove( _players, cell ); cell->setCreature( NULL); removeMapCreature( creature ); } uchar Engine::getCla1() { return _currentData.getCla1(); } uchar Engine::getCla2() { return _currentData.getCla2(); } uchar Engine::getCla3() { return _currentData.getCla3(); } int Engine::readInt() { return _currentData.readInt(); } unsigned char Engine::readChar() { return _currentData.readChar(); } attal-src-1.0-rc2/libServer/engine.h0000644000175000017500000001651010763100243015026 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** engine.h ** the game engine ! ** ** Version : $Id: engine.h,v 1.35 2008/03/03 22:50:11 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 03/10/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ENGINE_H #define ENGINE_H // generic include files // include files for QT #include #include #include #include // application specific includes #include "libCommon/fightResultStatus.h" #include "libCommon/gameData.h" #include "libCommon/genericBase.h" #include "libCommon/genericMap.h" #include "libCommon/genericLord.h" #include "libCommon/genericPlayer.h" #include "libServer/attalServer.h" #include "libServer/fightEngine.h" class Campaign; class GenericBonus; class GenericMapCreature; class QuestionManager; class ScenarioParser; class TavernManager; /* ------------------------------ * Engine * ------------------------------ */ class Engine : public QThread, public GameData { Q_OBJECT public: /** Constructor */ Engine( AttalServer * serv ); ~Engine(); void run(); /** Start game (scenario) */ void startGame(); /** Start game (scenario) */ void startCampaign(); void deleteCampaign(); /** Load a game (scenario) */ bool loadGame( const QString & filename , bool silent); /** Load a game (scenario) */ bool loadCampaign( const QString & filename ); /** Save the game */ bool saveGame( const QString & filename ); /** End the game */ void endGame(); /** Start a fight */ void startFight(); void startFight( int lordAttack, GenericLord *lordDefense ); void startFight( int lordAttack, GenericMapCreature * creature ); /** End the fight */ void endFight(); /** Reinit game engine */ void reinit(); int getNumFillPlayers() { return _tmpPlay > 0 ? _tmpPlay : 0 ; } bool checkGamePlayers( const QString & filename ); Campaign * getCampaign() { return _campaign; } enum State { NOT_PLAYING, IN_GAME, IN_QUESTION, IN_FIGHT }; State getState() { return _state; } void setGameId( int id ) { _gameId = id; } int getGameId() { return _gameId; } void appendPlayersList( QList sockets ); void addPlayer( AttalPlayerSocket * socket ); void addPlayer( GenericPlayer * player ); void removePlayer( GenericPlayer * player ); void removePlayer( AttalPlayerSocket * socket ); public slots: /** Slot who reads socket */ //void slot_readSocket( int ); void slot_readData( int, AttalSocketData ); /** Slot for managing new players */ void slot_newPlayer( AttalPlayerSocket * player ); /** Slot for removing a player disconnected */ void slot_endConnection( QString name ); /** Slot catching end of fight */ void slot_endFight( FightResultStatus result ); signals: void sig_result( int, bool); void sig_endGame( int ); private: enum CreatureAction { CreatureJoin, CreatureMercenary, CreatureFlee, CreatureFight }; CreatureAction computeCreatureAction( GenericMapCreature * creature, double ratio ); void nextCurrentPlayer(); /** Activate the next player */ void nextPlayer(); bool checkMainQuest(); void updatePlayers(); void checkPlayerShouldPlay(); void manageSocketState( int num ); void stateNotPlaying( int num ); void stateInGame( int num ); void stateInQuestion( uint num ); void stateInFight( int num ); void handleMessage( int num ); void handleCommand( int num , const QString & cmd ); void handleAnswer(); void handleInGameMvt( int num ); void handleInGameExchange(); void handleInGameModif(); void handleInGameModifBase(); void handleInGameModifBaseBuilding(); void handleInGameModifBaseUnit(); void handleInGameModifBaseMarket(); void handleInGameModifLord(); void handleInGameModifLordGarrison(); void handleInGameModifLordUnit(); void handleInGameModifLordBuy(); void handleInGameTurn(); void handleGameTavern(); void handleGameTavernInfo(); void handleGameTavernLord(); void newDay(); void updateCreatures(); void removeCreature( GenericMapCreature * creature ); void updateProduction(); void checkNewWeek(); void handleAnswerCreatureJoin(); void handleAnswerCreatureMercenary(); void handleAnswerCreatureFlee(); // enter into building (if return == true) bool handleBuildingEnter( GenericBuilding * building, GenericLord * lord ); void handleAction( Action * action, GenericLord * lord ); void handleAction( Action * action, GenericPlayer * player, GenericResourceList * rlist = NULL ); void handleActionListDate( QList list, GenericPlayer * player, GenericResourceList * rlist = NULL ); void handleCreatTurn( GenericPlayer * player, GenericLord * lord ); void handleBaseTurn( GenericPlayer * player, GenericBase * base ); void handleBuildingTurn( GenericPlayer * player, GenericBuilding * building ); //void handlePopulation( GenericPlayer * player ); bool handleOneMove( GenericLord * movingLord, GenericCell * destCell, int num ); void movingOnLord( GenericLord * movingLord, GenericCell * destCell ); void movingOnEvent( GenericLord * movingLord, GenericCell * destCell ); void movingOnArtefact( GenericLord * movingLord, GenericCell * destCell ); void movingOnBonus( GenericLord * movingLord, GenericCell * destCell ); void movingOnBonusResource( GenericBonus * bonus ); void movingOnBonusPrimSkill( GenericLord * movingLord, GenericBonus * bonus ); void movingOnChest( GenericLord * movingLord, GenericCell * destCell ); void movingOnBuilding( GenericLord * movingLord, GenericCell * destCell ); void movingOnBase( GenericLord * movingLord, GenericCell * destCell ); void movingOnCreature( GenericLord * movingLord, GenericCell * destCell ); void movingOnFreeCell( GenericLord * movingLord, GenericCell * destCell ); void exchangeUnits(); void exchangeArtefact(); void exchangeBaseUnits(); void exchangeUnitSplit(); uint getAlivePlayersNumber(); bool enoughPlayers(); void checkResult(); void updatePlayerPrices( GenericPlayer * player); void updateMapVision( QList & removed, QList & added ); void updateCellVision( GenericCell * cell ); void manageIncreaseExperience( GenericLord * lord, uint experience ); void decreaseMove( GenericLord * movingLord, GenericCell * cell ); void moveLord( GenericLord * movingLord, GenericCell * cell ); /** Save a campaing **/ bool saveCampaign( const QString & filename ); int readInt(); unsigned char readChar(); uchar getCla1(); uchar getCla2(); uchar getCla3(); bool _isCreature; bool _isProcessing; int _tmpPlay; int _num; int _gameId; AttalServer * _server; FightEngine * _fight; State _state; GenericPlayer * _currentPlayer; Campaign * _campaign; QuestionManager * _question; TavernManager * _tavern; QQueue _dataQueue; AttalSocketData _currentData; }; #endif //ENGINE_H attal-src-1.0-rc2/libServer/fightAnalyst.cpp0000644000175000017500000003540210675337656016600 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightAnalyst.cpp ** analyst for the fight phase ** ** Version : $Id: fightAnalyst.cpp,v 1.36 2007/09/23 01:21:50 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "fightAnalyst.h" // generic include files #undef __USE_ISOC99 #include #include // include files for QT // application specific include files #include "libServer/fightEngine.h" #include "libCommon/gameData.h" #include "libCommon/dataTheme.h" #include "libCommon/genericFightMap.h" #include "libCommon/genericLord.h" #include "libCommon/genericPlayer.h" #include "libCommon/log.h" #include "libCommon/unit.h" Log aifLog; FakeSocket::FakeSocket() : AttalSocket() { } void FakeSocket::send() { for( int i = 0; i < 255; i++ ) { _bufIn[i] = _bufOut[i+1]; } _lenIn = 3; _bufOut[1] = 0; _bufOut[2] = 0; _bufOut[3] = 0; _lenOut = 4; } // // ----- FakeData ----- // class FakeData : public GameData { public: FakeData(); ~FakeData(); virtual void addPlayer(); }; FakeData::FakeData() : GameData() { } FakeData::~FakeData() { while( ! _players.isEmpty() ) { delete _players.takeFirst(); } } void FakeData::addPlayer() { _players.append( new GenericPlayer( 0 ) ); } /* FightAnalyst::FightAnalyst( Analyst * analyst ) */ FightAnalyst::FightAnalyst( GameData * data ) { _ownData = false; _data = data; _lordAttack = NULL; _lordDefense = NULL; _map = NULL; _engine = NULL; _isCreature = false; } FightAnalyst::FightAnalyst( GameData * data, FightEngine * engine ) { _ownData = true; _lordAttack = NULL; _lordDefense = NULL; _map = NULL; _isCreature = true; _data = (GameData *) new FakeData(); _data->reinit(); for( uint i = 0; i < data->getNbPlayer(); i++ ) { _data->addPlayer(); } for( int i = 0; i < DataTheme.lords.count(); i++ ) { if( data->getLord( i )->getOwner() ) { _data->setLord2Player( i, data->getLord( i )->getOwner()->getNum() ); } } _engine = engine; } FightAnalyst::~FightAnalyst() { //_map and other data set to 0 cause a weird behavior that cause a method ( endMove ) executed after destrutor int i; if( _map ) { delete _map; } _map = NULL; if( _ownData ) { if(_fighter == FIGHTER_ATTACK){ for(i = 0;i<= MAX_UNIT;i++){ if(_unitsDef[i]){ _unitsDef[i]->setFightMap(0); delete _unitsDef[i]; } } } else { for(i = 0;i<= MAX_UNIT;i++){ if(_unitsAtt[i]){ _unitsAtt[i]->setFightMap(0); delete _unitsAtt[i]; } } } delete _data; } _data = NULL; for(i = 0;i<= MAX_UNIT;i++){ _unitsAtt[i]= NULL; _unitsDef[i]= NULL; } _ownData = false; } void FightAnalyst::handleFightData( FakeSocket * data ) { _socket->setData( (AttalSocket*) data ); handleFightSocket(); } void FightAnalyst::handleFightSocket() { switch( _socket->getCla2() ) { case C_FIGHT_INIT: handleInit(); break; case C_FIGHT_CREATURE: break; case C_FIGHT_LORD: handleOpponent(); break; case C_FIGHT_CELL: handleCell(); break; case C_FIGHT_UNIT: handleNewUnit(); break; case C_FIGHT_MODUNIT: break; case C_FIGHT_MOVE: handleMove(); break; case C_FIGHT_ENDMOVE: break; case C_FIGHT_ACTIVE: handleActive(); break; case C_FIGHT_DISTATTACK: break; case C_FIGHT_WAIT: break; case C_FIGHT_FLEE: break; case C_FIGHT_DEFEND: break; case C_FIGHT_DAMAGE: handleDamage(); break; case C_FIGHT_END: if(!_isCreature){ updateUnits(); } break; } } void FightAnalyst::handleInit() { _fighter = (CLASS_FIGHTER) _socket->readChar(); uchar lord = _socket->readChar(); GenericLord * myLord; if( _fighter == FIGHTER_ATTACK ) { //_lordAttack = _analyst->getLord( lord ); _lordAttack = _data->getLord( lord ); myLord = _lordAttack; _lordDefense = NULL; //ialogV( "attack" ); aifLog.print( "attack" ); } else { //_lordDefense = _analyst->getLord( lord ); _lordDefense = _data->getLord( lord ); myLord = _lordDefense; _lordAttack = NULL; //ialogV( "defense" ); aifLog.print( "defense" ); } for( int i = 0; i < MAX_UNIT; i ++ ) { if( _fighter == FIGHTER_ATTACK ) { _unitsAtt[i] = myLord->getUnit( i ); _unitsDef[i] = NULL; } else { _unitsDef[i] = myLord->getUnit( i ); _unitsAtt[i] = NULL; } } if( _map ) { delete _map; } _map = 0; _map = new GenericFightMap(); /// XXX: hardcoded size !! _map->newFightMap( 9, 15 ); } void FightAnalyst::initCreatures( GenericLord * lord ) { _fighter = FIGHTER_DEFENSE; _lordDefense = lord; GenericFightUnit * newUnit, * lordUnit; for( int i = 0; i < MAX_UNIT; i ++ ) { lordUnit = lord->getUnit( i ); if( lordUnit ) { /// XXX: make copy constructor and operator = newUnit = new GenericFightUnit(); newUnit->setCreature( lordUnit->getRace(), lordUnit->getLevel() ); newUnit->setNumber( lordUnit->getNumber() ); newUnit->setMove( lordUnit->getMove() ); newUnit->setHealth( lordUnit->getHealth() ); _unitsDef[i] = newUnit; } else { _unitsDef[i] = NULL; } _unitsAtt[i] = NULL; } if( _map ) { delete _map; } _map = new GenericFightMap(); /// XXX: hardcoded size !! _map->newFightMap( 9, 15 ); } void FightAnalyst::handleCell() { // XXX: } void FightAnalyst::handleNewUnit() { CLASS_FIGHTER cla = (CLASS_FIGHTER) _socket->readChar(); uchar pos = _socket->readChar(); uchar race = _socket->readChar(); uchar level = _socket->readChar(); int nb = _socket->readInt(); uchar move = _socket->readChar(); int health = _socket->readInt(); GenericFightUnit * unit = new GenericFightUnit(); unit->setCreature( race, level ); unit->setNumber( nb ); unit->setMove( move ); unit->setHealth( health ); GenericFightUnit * oldUnit = NULL; if( pos < MAX_UNIT ) { if( cla == FIGHTER_ATTACK ) { oldUnit = _unitsAtt[pos]; if( oldUnit ) { oldUnit->setFightMap(0); delete oldUnit; } _unitsAtt[pos] = unit; _unitsAtt[pos]->setFightMap ( _map ); _unitsAtt[pos]->setLookingToRight( true ); _map->at( pos, 1 )->setUnit(_unitsAtt[pos]); } else { oldUnit = _unitsDef[pos]; if( oldUnit ) { oldUnit->setFightMap(0); delete oldUnit; } _unitsDef[pos] = unit; _unitsDef[pos]->setFightMap ( _map ); _unitsDef[pos]->setLookingToRight( false ); _map->at( pos, 14 )->setUnit(_unitsDef[pos]); } } } void FightAnalyst::handleMove() { uchar cla = _socket->readChar(); uchar pos = _socket->readChar(); int row = _socket->readInt(); int col = _socket->readInt(); if( ! checkValidUnit( pos, (CLASS_FIGHTER)cla) ) { return; } GenericFightUnit * unit = getUnit( pos, (CLASS_FIGHTER)cla ); if ( !unit->getFightMap () ) { unit->setFightMap ( _map ); }else { if(_map !=unit->getFightMap ()){ logEE("error, pos %d", pos); } } unit->goTo( _map->at( row, col ) ); } void FightAnalyst::handleOpponent() { GenericLord * opponentLord; uchar id = _socket->readChar(); uchar attack = _socket->readChar(); uchar defense = _socket->readChar(); //opponentLord = _analyst->getLord( id ); opponentLord = _data->getLord( id ); opponentLord->setBaseCharac( ATTACK, attack ); opponentLord->setBaseCharac( DEFENSE, defense ); //XXX: } void FightAnalyst::handleDamage() { /* XXX: unused ?? uchar claAtt = */ _socket->readChar(); /* XXX: unused ?? uchar posAtt = */ _socket->readChar(); /* XXX: unused ?? CLASS_ATTACK_TYPE type = (CLASS_ATTACK_TYPE) */ _socket->readChar (); uchar claDef = _socket->readChar(); uchar posDef = _socket->readChar(); int damages = _socket->readInt(); if( ! checkValidUnit( posDef, (CLASS_FIGHTER)claDef) ) { return; } GenericFightUnit * unit = getUnit( posDef, (CLASS_FIGHTER)claDef ); unit->hit( damages ); } void FightAnalyst::handleActive() { CLASS_FIGHTER cla = (CLASS_FIGHTER) _socket->readChar(); uchar pos = _socket->readChar(); if( ! checkValidUnit( pos, cla) ) { return; } if( ( cla == _fighter ) && ( pos < MAX_UNIT ) ) { GenericFightUnit * unit = getUnit( pos, (CLASS_FIGHTER)cla ); playUnit( unit, pos ); } } /* =================================================================== Read the unit structure and the unit position in fightmap, look for position and strenght of opponent units and move toward or attack the most powerful enemy unit; power=(num*att) =================================================================== */ void FightAnalyst::playUnit( GenericFightUnit * unit, int pos) { TRACE("FightAnalyst::playUnit( GenericFightUnit * unit %p, int pos %d)", unit, pos ); int i; int maxPower = 0; int unitPower = 0; int epos = -1; bool nea = false; bool twosize = false; if( unit->getCreature()->getSize() == 2 ) { twosize = true; } GenericFightCell * destination = NULL; _map->initPath( unit ); // check if exist an enemy unit reachable and if not, save position of most powerful for( i = 0; i < MAX_UNIT; i++ ) { GenericFightUnit * enemyUnit = getOpponentUnit(i, _fighter ); if( enemyUnit ) { unitPower = getPower( enemyUnit ); if( unitPower > maxPower ) { GenericFightCell * enemyCell = enemyUnit->getCell(); GenericFightCell * headCell = NULL; if( twosize ) { headCell = _map->getHeadCell( enemyCell, unit->isLookingToRight() ); } if( enemyCell->getAccess() == AttalCommon::NEAR_OCCUPIED || unit->isDistAttack()==true ){ maxPower = unitPower; destination = enemyCell; nea = true; } else if ( twosize && headCell && headCell->getAccess() == AttalCommon::NEAR_OCCUPIED ){ GenericFightUnit * headUnit = headCell->getHeadUnit(); GenericFightUnit * normalUnit = headCell->getUnit(); if( headUnit && headUnit == enemyUnit ) { maxPower = unitPower; destination = headCell; nea = true; } else if ( normalUnit && normalUnit == enemyUnit ) { maxPower = unitPower; destination = headCell; nea = true; } } epos = i ; } } } if( unit->isDistAttack() == false && nea == false ) { destination = getValidDestination( unit, epos ); } if( !destination || epos== -1 ) { return; } // movement algorithm if( unit->isDistAttack() == false ) { GenericFightCell * current; QStack path = _map->computePath( unit, destination ); while( ! path.isEmpty() ) { current = path.pop(); if( _ownData ) { FakeSocket socket; socket.sendFightUnitMove( _fighter, pos, current ); _engine->handleFakeSocket( &socket ); } else { _socket->sendFightUnitMove( _fighter, pos, current ); } } } else { // distant attack if( _ownData ) { FakeSocket socket; socket.sendFightDistAttack( getOpponentClass(), epos ); _engine->handleFakeSocket( &socket ); } else { _socket->sendFightDistAttack( getOpponentClass(), epos ); } } endMove(); } void FightAnalyst::endMove() { if( _ownData ) { FakeSocket socket; socket.sendFightUnitEndMove(); _engine->handleFakeSocket( &socket ); } else { _socket->sendFightUnitEndMove(); } /* * caused by a weird behaviour when creature gain, this class is destroyed * before this code, so _map is 0 and is useless clearPath * ( the destructor is executed before this method ) */ if(_map) _map->clearPath(); } GenericFightUnit * FightAnalyst::getUnit( int num, CLASS_FIGHTER fighter ) { if( fighter == FIGHTER_ATTACK ) { return _unitsAtt[num]; } else { return _unitsDef[num]; } } GenericFightUnit * FightAnalyst::getOpponentUnit( int num, CLASS_FIGHTER fighter ) { if( fighter == FIGHTER_ATTACK ) { return _unitsDef[num]; } else { return _unitsAtt[num]; } } CLASS_FIGHTER FightAnalyst::getOpponentClass() { if( _fighter == FIGHTER_DEFENSE ) { return FIGHTER_ATTACK; } else { return FIGHTER_DEFENSE; } } void FightAnalyst::updateUnits( void ) { TRACE( "FightAnalyst::updateUnits" ); GenericLord *oldLord; GenericFightUnit * oldUnit, * newUnit; uint i; if(_lordAttack){ oldLord = _data->getLord( _lordAttack->getId() ); for( i = 0; i < MAX_UNIT; i++ ) { newUnit = getUnit( i, FIGHTER_ATTACK ); if(newUnit){ if(newUnit->getNumber()==0){ newUnit=0; } } oldUnit = oldLord->getUnit( i ); if( newUnit && oldUnit ) { oldUnit->setNumber( newUnit->getNumber() ); oldUnit->setMove( newUnit->getMove() ); oldUnit->setHealth( newUnit->getHealth() ); oldUnit->setFightMap( 0 ); } else if (oldUnit) { oldLord->setUnit(i,0); } } } if( _lordDefense ) { oldLord = _data->getLord( _lordDefense->getId() ); for( i = 0; i < MAX_UNIT; i++) { newUnit = getUnit( i, FIGHTER_DEFENSE ); if(newUnit){ if(newUnit->getNumber()==0){ newUnit=0; } } oldUnit = oldLord->getUnit( i ); if( newUnit && oldUnit ) { oldUnit->setNumber( newUnit->getNumber() ); oldUnit->setMove( newUnit->getMove() ); oldUnit->setHealth( newUnit->getHealth() ); oldUnit->setFightMap( 0 ); } else if (oldUnit) { oldLord->setUnit(i,0); } } } } int FightAnalyst::getPower( GenericFightUnit * unit ) { int power = 0; if(unit) power +=unit->getAttack() * unit->getNumber(); return power; } bool FightAnalyst::checkValidUnit( int num , CLASS_FIGHTER cla ) { bool ret = true; if( (CLASS_FIGHTER)cla == FIGHTER_ATTACK ) { if( !_unitsAtt[ num ] ) { ret = false; } } else { if( !_unitsDef[ num ] ) { ret = false; } } if( !ret ) { logEE("error not exist unit num %d, cla %d", num, cla ); } return ret; } GenericFightCell * FightAnalyst::getValidDestination( GenericFightUnit * unit , int opponentPos) { int opponentRow = 0,opponentCol = 0; int pos = opponentPos; // move toward enemy unit int rotate = 0; // used to alternate a row and a col going toward an unit int startRow = unit->getCell()->getRow(); int startCol = unit->getCell()->getCol(); GenericFightCell * cell = getOpponentUnit(pos, _fighter )->getCell(); opponentRow = cell->getRow(); opponentCol = cell->getCol(); GenericFightCell * dcell = NULL; do { if( ( rotate % 2 ) == 0 ) { if( ( opponentCol - startCol ) > 0 ) { opponentCol -= 1; } else { opponentCol += 1; } } else { if( ( opponentRow - startRow ) > 0 ) { opponentRow -= 1; } else { opponentRow += 1; } } rotate++; if( !_map->inMap( opponentRow,opponentCol ) ) { logWW(" request movement outside map, row %d, col %d", opponentRow, opponentCol); endMove(); return NULL; } dcell = _map->at( opponentRow, opponentCol ); } while( dcell->getAccess()!=AttalCommon::NEAR_FREE ); return dcell; } attal-src-1.0-rc2/libServer/fightAnalyst.h0000644000175000017500000000570310650415175016230 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightAnalyst.h ** analyst for the fight phase ** ** Version : $Id: fightAnalyst.h,v 1.11 2007/07/21 14:38:53 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef FIGHTANALYST_H #define FIGHTANALYST_H // generic include files // include files for QT // application specific include files #include "libCommon/attalSocket.h" #include "libCommon/define.h" class GameData; class GenericLord; class GenericFightMap; class GenericFightUnit; class FightEngine; /** Fake socket, for AI of fightAnalyst */ class FakeSocket : public AttalSocket { public: /** Constructor */ FakeSocket(); protected: /** As it is a 'fake' socket, it doesn't send anything */ virtual void send(); }; /* ------------------------------ * FightAnalyst * ------------------------------ */ /** comment for the class */ class FightAnalyst { public: /** Constructor (for AI fights) */ FightAnalyst( GameData * data ); /** constructor for creatures fights */ FightAnalyst( GameData * data, FightEngine * engine ); /** Destructor */ virtual ~FightAnalyst(); void setSocket( AttalSocket * sock ) { _socket = sock; } void handleFightSocket(); void handleFightData( FakeSocket * data ); void initCreatures( GenericLord * lord ); void updateUnits( void ); bool IsCreature() { return (_lordDefense == 0) ? true : false;} int getPower( GenericFightUnit * unit ); protected: void handleInit(); void handleOpponent(); void handleCell(); void handleNewUnit(); void handleMove(); void handleDamage(); void handleActive(); void playUnit( GenericFightUnit * unit , int pos ); void endMove(); bool checkValidUnit( int num, CLASS_FIGHTER cla ); GenericFightCell * getValidDestination( GenericFightUnit * currentUnit ,int pos ); GenericFightUnit * getUnit( int num, CLASS_FIGHTER fighter ); GenericFightUnit * getOpponentUnit( int num, CLASS_FIGHTER fighter ); CLASS_FIGHTER getOpponentClass(); bool _oppIsAtt; bool _isCreature; AttalSocket * _socket; GameData * _data; GenericFightMap * _map; CLASS_FIGHTER _fighter; GenericLord * _lordAttack, * _lordDefense, * _lordOpp; GenericFightUnit * _unitsAtt[MAX_UNIT], * _unitsDef[MAX_UNIT]; bool _ownData; FightEngine * _engine; }; #endif // FIGHTANALYST_H attal-src-1.0-rc2/libServer/fightEngine.cpp0000644000175000017500000004405510762323655016365 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightEngine.cpp ** managing server-side fight ** ** Version : $Id: fightEngine.cpp,v 1.40 2008/03/01 18:59:57 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier - Sardi Carlo ** ** Date : 02/01/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "fightEngine.h" // generic include files #include // include files for QT // application specific include files #include "libCommon/attalCommon.h" #include "libCommon/dataTheme.h" #include "libCommon/gameData.h" #include "libCommon/genericCell.h" #include "libCommon/genericLord.h" #include "libCommon/genericMapCreature.h" #include "libCommon/genericPlayer.h" #include "libCommon/log.h" #include "libCommon/unit.h" FightEngine::FightEngine( AttalServer * server ) { _server = server; _currentUnit = NULL; _attackPlayer = NULL; _attackLord = NULL; _defendPlayer = NULL; _defendLord = NULL; _defendCell = NULL; _analyst = NULL; _fake = NULL; //_troops = 0; _map = NULL; _num = 0; /* _creatureLord used only in combacts with creatures */ _creatureLord = new GenericLord(); _creatureLord->setId( 0 ); _creatureLord->setCreatureLord( true ); } FightEngine::~FightEngine() { if(_fake) delete _fake; if(_analyst) delete _analyst; if( _map ) { delete _map; } if(_creatureLord) delete _creatureLord; _server= NULL; _currentUnit = NULL; _attackPlayer = NULL; _attackLord = NULL; _defendPlayer = NULL; _defendLord = NULL; _defendCell = NULL; _analyst = NULL; _fake = NULL; _map = NULL; _hasEnded = false; _creatureLord = NULL; } void FightEngine::print() { logDD("att play %p", _attackPlayer ); logDD("att lord %p", _attackLord ); logDD("att lord cell %p", _attackLord->getCell() ); logDD("def play %p", _defendPlayer ); logDD("def lord %p", _defendLord ); logDD("def lord cell %p", _defendLord->getCell() ); } void FightEngine::init( GenericPlayer * attackPlayer, GenericLord * attackLord, GenericPlayer * defendPlayer, GenericLord * defendLord ) { _result.clear(); _attackPlayer = attackPlayer; _attackLord = attackLord; _defendPlayer = defendPlayer; _defendLord = defendLord; _currentUnit = 0; _hasEnded = false; _fightCreature = false; //signals to clients _server->startFight( _attackPlayer, _attackLord, _defendPlayer, _defendLord ); if( _map ) { delete _map; _map = 0; } _map = new GenericFightMap(); _map->newFightMap( 9, 15 ); setupUnits(); newTurn(); } void FightEngine::init( GenericPlayer * attackPlayer, GenericLord * attackLord, GenericFightUnit * defendUnit[MAX_UNIT], GameData * data ) { _result.clear(); _defendExp = 0; _attackExp = 0; int i; _attackPlayer = attackPlayer; _attackLord = attackLord; _defendPlayer = NULL; _defendLord = _creatureLord; _fightCreature = true; _hasEnded = false; //initialisation ai if( _analyst ) { delete _analyst; } if( _fake ) { delete _fake; } _fake = new FakeSocket; _analyst = new FightAnalyst( data, this ); _analyst->setSocket( _fake ); //signals to clients _server->startFight( _attackPlayer, _attackLord, defendUnit ); for( i = 0; i < MAX_UNIT; i++ ) { _defendLord->setUnit( i, defendUnit[i] ); } _analyst->initCreatures( _defendLord ); _fake->sendFightLord( FIGHTER_ATTACK, _attackLord ); _analyst->handleFightData( _fake ); for( i = 0; i < MAX_UNIT; i++ ) { if( _attackLord->getUnit( i ) ) { _fake->sendFightNewUnit( FIGHTER_ATTACK, i, _attackLord->getUnit( i ) ); _analyst->handleFightData( _fake ); } } //end initialisation ai if( _map ) { delete _map; _map = 0; } _map = new GenericFightMap(); _map->newFightMap( 9, 15 ); setupUnits(); newTurn(); } void FightEngine::handleFakeSocket( FakeSocket * data ) { //_server->copyData( (AttalSocket*) data ); handleSocket( _defendPlayer, data->getData() ); } void FightEngine::handleSocket( GenericPlayer * player, AttalSocketData data ) { _currentData = data; if( ( player == _attackPlayer ) || ( player == _defendPlayer ) ) { _currentPlayer = player; switch( getCla2() ) { case C_FIGHT_INIT: logEE( "Should not happen FightEngine : FIGHT_INIT" ); break; case C_FIGHT_CREATURE: break; case C_FIGHT_LORD: break; case C_FIGHT_CELL: break; case C_FIGHT_UNIT: break; case C_FIGHT_MODUNIT: break; case C_FIGHT_MOVE: socketFightMove(); break; case C_FIGHT_ENDMOVE: socketFightEndMove(); break; case C_FIGHT_ACTIVE: logEE( "Should not happen" ); break; case C_FIGHT_DISTATTACK: socketFightDistAttack(); break; case C_FIGHT_WAIT: nextUnit( 1 ); break; case C_FIGHT_FLEE: socketFightFlee( player ); break; case C_FIGHT_DEFEND: if( _currentUnit ) { nextUnit( 1 ); /// XXX: for the moment, "defend" do nothing... } break; case C_FIGHT_DAMAGE: break; case C_FIGHT_END: break; default: logEE( "Should not happen" ); break; } } else { logEE( "Should not happen : fight socket from non fighting player" ); } } void FightEngine::socketFightFlee(GenericPlayer * player) { if( player == _attackPlayer ) { _result.setDefenseWin(); } else { _result.setAttackWin(); } _result.setFled(); endFight(); } void FightEngine::socketFightEndMove() { if( _currentUnit ) { postcomputeUnit(); //if( _troops.remove( _currentUnit ) ) // logDD( "Remove current unit" ); //_troops.last(); //GenericFightUnit *u = _currentUnit; nextUnit( 1 ); } } void FightEngine::socketFightDistAttack() { uchar cla = readChar(); uchar num = readChar(); //logDD(" cla %d, num %d",cla,num); GenericFightUnit * unit = giveUnit( (CLASS_FIGHTER)cla, num ); if(_currentUnit->isDistAttack()){ fightUnit( _currentUnit, unit, ATTACK_SHOOT ); } } void FightEngine::socketFightMove() { uchar cla = readChar(); uchar num = readChar(); int row = readInt(); int col = readInt(); //logDD("cla %d, num %d , row %d ,col %d ,", cla, num, row, col); if(row > 9 || col > 15) logEE("bug! cla %d, num %d , row %d ,col %d ,", cla, num, row, col); handleMove( giveUnit( (CLASS_FIGHTER)cla, num ), _map->at( row, col ) ); } void FightEngine::setupUnits() { TRACE("FightEngine::setupUnits"); /// XXX: improve algo for initial placement of units... for( int i = 0; i < MAX_UNIT; i++ ) { if( _attackLord->getUnit( i ) ) { _attackLord->getUnit ( i )->setLookingToRight( true ); _attackLord->getUnit ( i )->setFightMap ( _map ); moveUnit( _attackLord->getUnit( i ), _map->at( i, 0 ) ); } if( _defendLord->getUnit( i ) ) { _defendLord->getUnit ( i )->setLookingToRight( false ); _defendLord->getUnit ( i )->setFightMap ( _map ); moveUnit( _defendLord->getUnit( i ), _map->at( i, 14 ) ); } } } void FightEngine::newTurn() { TRACE("FightEngine::newTurn"); _currentUnit = 0; // initialize values (movement) for( int i = 0; i < MAX_UNIT; i++ ) { if( _attackLord->getUnit( i ) ) { _attackLord->getUnit( i )->setMaxMove(); } if( _defendLord->getUnit( i ) ) { _defendLord->getUnit( i )->setMaxMove(); } } // setup list of units; orderTroops(); activateUnit( _troops.last() ); } void FightEngine::endTurn() { TRACE("FightEngine::endTurn"); computeFightResultStatus(); if( _result.isFightFinished() ) { endFight(); } else { newTurn(); } } void FightEngine::updateUnits() { TRACE("FightEngine::updateUnits"); GenericFightUnit * newUnit; uint i; if(_attackLord) { for( i = 0; i < MAX_UNIT; i++) { newUnit = giveUnit( FIGHTER_ATTACK, i ); if(newUnit){ if(newUnit->getNumber()==0){ delete newUnit; newUnit=NULL; _attackLord->setUnit(i,NULL); } } } } if( _defendLord ) { for( i = 0; i < MAX_UNIT; i++) { newUnit = giveUnit( FIGHTER_DEFENSE, i ); if(newUnit){ if(newUnit->getNumber()==0){ delete newUnit; newUnit=NULL; _defendLord->setUnit(i,NULL); } } } } } void FightEngine::endFight() { TRACE("FightEngine::endFight"); updateUnits(); _server->endFight( _attackPlayer, _defendPlayer, _result ); if( _fightCreature ) { _fake->sendFightEnd( _result ); _analyst->handleFightData( _fake ); } _currentUnit = 0; _hasEnded = true; emit sig_endFight( _result ); } void FightEngine::moveUnit( GenericFightUnit * unit, GenericFightCell * cell ) { TRACE("FightEngine::moveUnit"); if( ! _fightCreature ) { _server->moveUnit( _defendPlayer, giveClass( unit ), giveNum( unit ), cell ); } else { _fake->sendFightUnitMove( giveClass( unit ), giveNum( unit ), cell ); _analyst->handleFightData( _fake ); } _server->moveUnit( _attackPlayer, giveClass( unit ), giveNum( unit ), cell ); unit->goTo( cell ); } void FightEngine::fightUnit( GenericFightUnit * unitAtt, GenericFightUnit * unitDef, CLASS_ATTACK_TYPE attackType ) { TRACE("FightEngine::fightUnit"); long int damage, bonus; if (unitAtt->canAttack()) { if( giveClass( unitAtt ) == giveClass( unitDef ) ) { logEE( "Allied units can't fight eachother !" ); return; } if( unitAtt->getAttack() > 0 ) { damage = ( ( rand() % unitAtt->getAttack() ) + 1 ) * unitAtt->getNumber(); } else { damage = unitAtt->getNumber(); } GenericLord * lordAtt = giveLord( unitAtt ); GenericLord * lordDef = giveLord( unitDef ); GenericPlayer * playAtt = lordAtt->getOwner(); GenericPlayer * playDef = lordDef->getOwner(); QString playAttName = playAtt ? playAtt->getConnectionName() : "server"; QString playDefName = playDef ? playDef->getConnectionName() : "server"; bonus = lordAtt->getCharac( ATTACK ) - lordDef->getCharac( DEFENSE ); bonus *= lordAtt->getCharac( ATTACK ) > lordDef->getCharac( DEFENSE ) ? 5 : -2; long luck = 0; if( unitAtt->getLuck() != 0 ) { if( unitAtt->getLuck() > 0 ) { luck = ( rand() % unitAtt->getLuck() ); } else { luck = - ( rand() % unitAtt->getLuck() ); } } bonus += ( luck * 5 ); bonus = ( bonus > 400 ) ? 400 : ( bonus < -100 ) ? -100 : bonus; damage += (damage * bonus) / 100; damage = ( damage >= 0 ) ? damage : 0; QString msg; int oldNum = unitDef->getNumber(); //logDD("hit server"); unitDef->hit( damage ); QString attName = unitAtt->getCreature()->getName(); QString defName = unitDef->getCreature()->getName(); msg.sprintf( "%s ( %s ) hit %s ( %s ) : %ld damages %li creatures died", qPrintable( attName ), qPrintable(playAttName), qPrintable( defName ), qPrintable( playDefName), damage,oldNum - unitDef->getNumber() ); logDD("%s" , qPrintable(msg)); _server->sendFightMessage( msg, _attackPlayer, _defendPlayer ); // manage experience earned uint exp = ( oldNum - unitDef->getNumber() ) * unitDef->getMaxHealth(); if( lordDef == _attackLord ) { _defendExp += exp; } else { _attackExp += exp; } //_server->updateUnit( _attackPlayer, giveClass( unitDef ), giveNum( unitDef ), unitDef ); //_server->updateUnit( _defendPlayer, giveClass( unitDef ), giveNum( unitDef ), unitDef ); _server->damageUnit( _attackPlayer, giveClass ( unitAtt ), giveNum ( unitAtt ), attackType, giveClass( unitDef ), giveNum( unitDef ), damage ); if( ! _fightCreature ) { _server->damageUnit( _defendPlayer, giveClass ( unitAtt ), giveNum ( unitAtt ), attackType, giveClass( unitDef ), giveNum( unitDef ), damage ); } else { _fake->sendFightDamageUnit ( giveClass ( unitAtt ), giveNum ( unitAtt ), attackType, giveClass( unitDef ), giveNum( unitDef ), damage ); _analyst->handleFightData( _fake ); } unitAtt->finishAttack(); } } void FightEngine::nextUnit( int remove ) { //this function search next unit in _troops list and remove used unit GenericFightUnit * unit; int pos; bool found = false; computeFightResultStatus(); //update units before end of fight if( _result.isFightFinished() ) { endFight(); return; } //remove current unit from list if( remove ) { pos = _troops.indexOf( _currentUnit ); _troops.removeAt( pos ); if( pos == _troops.count() ) { pos = 0; } if( _troops.count() > 0 ) { _troops.at( pos ); } } for ( int i = 0; i < _troops.count(); i++ ) { unit = _troops.at(i); if( !unit ) { unit = _troops.last(); } if( unit->getNumber() <= 0 ) { pos = _troops.indexOf( unit ); _troops.removeAt( pos ); if( pos == _troops.count() ) { pos = 0; } if( _troops.count() > 0 ) { _troops.at( pos ); } } else { found = true; } if ( found ) { break; } } if( found ) { activateUnit( unit ); } else { endTurn(); } } void FightEngine::activateUnit( GenericFightUnit * unit ) { _currentUnit = unit; _map->initPath( _currentUnit ); _currentUnit->activateAttack(); precomputeUnit(); _server->activateUnit( _attackPlayer, giveClass( _currentUnit ), giveNum( _currentUnit ) ); if( _defendPlayer ) { _server->activateUnit( _defendPlayer, giveClass( _currentUnit ), giveNum( _currentUnit ) ); } else { _fake->sendFightActivate( giveClass( _currentUnit ), giveNum( _currentUnit ) ); _analyst->handleFightData( _fake ); } } void FightEngine::computeFightResultStatus() { int sumAtt = 0, sumDef = 0; for( int i = 0; i < MAX_UNIT; i++ ) { GenericFightUnit * unit = _attackLord->getUnit( i ); if( unit ) { sumAtt += unit->getNumber(); } unit = _defendLord->getUnit( i ); if( unit ) { sumDef += unit->getNumber(); } } if( sumAtt <= 0 ) { _result.setDefenseWin(); //_server->sendLordRemove( _attackLord ); //XXX: Remove lord from server memory } if( sumDef <= 0 ) { _result.setAttackWin(); //_server->sendLordRemove( _defendLord ); //XXX: Remove lord from server memory } } void FightEngine::orderTroops() { GenericFightUnit * unit; _troops.clear(); for( int i = 0; i < MAX_UNIT; i++ ) { unit = _attackLord->getUnit( i ); if( unit && ( unit->getNumber() > 0 ) ) { _troops.add( unit ); } unit = _defendLord->getUnit( i ); if( unit && ( unit->getNumber() > 0 ) ) { _troops.add( unit ); } } } int FightEngine::giveNum( GenericFightUnit * unit ) { for( int i = 0; i < MAX_UNIT; i++ ) { if( ( _attackLord->getUnit( i ) == unit ) || ( _defendLord->getUnit( i ) == unit ) ) { return i; } } logEE( "Should not happen" ); return -1; } CLASS_FIGHTER FightEngine::giveClass( GenericFightUnit * unit ) { for( int i = 0; i < MAX_UNIT; i++ ) { if( _attackLord->getUnit( i ) == unit ) { return FIGHTER_ATTACK; } if( _defendLord->getUnit( i ) == unit ) { return FIGHTER_DEFENSE; } } logEE( "Should not happen" ); return FIGHTER_ATTACK; } GenericFightUnit * FightEngine::giveUnit( CLASS_FIGHTER fighter, int num ) { GenericFightUnit * unit; if( fighter == FIGHTER_ATTACK ) { unit = _attackLord->getUnit( num ); } else { unit = _defendLord->getUnit( num ); } return unit; } GenericLord * FightEngine::giveLord( GenericFightUnit * unit ) { GenericLord * ret; if( giveClass( unit ) == FIGHTER_ATTACK ) { ret = _attackLord; } else { ret = _defendLord; } return ret; } void FightEngine::handleMove( GenericFightUnit * unit, GenericFightCell * cell ) { TRACE("FightEngine::handleMove cell access %d, row %d , col %d", cell->getAccess(), cell->getRow(), cell->getCol()); if( unit != _currentUnit ) { logEE( "The unit moving is not active !!" ); return; } GenericFightCell* neib = NULL; // 2 cell unit test if ( unit->getCreature()->getSize () == 2 ){ neib = _map->getHeadCell( cell , unit->isLookingToRight() ); if( ! _map->areNeighbours( unit->getCell(), cell ) && ! _map->areNeighbours( neib, cell )) { logEE( "The dest cell is not a neighbour cell of the unit" ); printStatus( unit , cell ); return; } } else { // 1 cell unit test if( ! _map->areNeighbours( unit->getCell(), cell ) ) { logEE( "The dest cell is not a neighbour cell of the unit" ); printStatus( unit , cell ); return; } } switch( cell->getAccess() ) { case AttalCommon::UNKNOWN_ACCESS: logEE( "Should not happen (UNKNOWN_ACCESS)" ); break; case AttalCommon::NEAR_FREE: TRACE("NEAR_FREE"); moveUnit( unit, cell ); break; case AttalCommon::NEAR_OCCUPIED: { TRACE("NEAR_OCCUPIED"); GenericFightUnit * cellUnit = cell->getUnit(); if( cellUnit ){ if( cellUnit != unit){ fightUnit( unit, cellUnit, ATTACK_FIGHT ); } else if( neib ) { cellUnit = neib->getUnit(); if( cellUnit ){ if( cellUnit != unit){ fightUnit( unit, cellUnit, ATTACK_FIGHT ); } } } } else { logEE("NEAR_OCCUPIED Signal error, correct bug \n"); } } break; case AttalCommon::FAR_FREE: logEE( "Should not happen (AttalCommon::FAR_FREE)" ); printStatus( unit , cell ); break; case AttalCommon::FAR_OCCUPIED: logEE( "Should not happen (FAR_OCCUPIED)" ); printStatus( unit , cell ); break; case AttalCommon::NONE: logEE( "Should not happen (NONE)" ); printStatus( unit , cell ); break; default: logEE( "Should not happen" ); printStatus( unit , cell ); break; } } uint FightEngine::getExperience( GenericLord * lord ) { /// XXX: we could have 'lord' in parameter and know the winner... uint ret = 0; if( lord == _attackLord ) { ret = _attackExp; } else if( lord == _defendLord ) { ret = _defendExp; } return ret; } void FightEngine::printStatus( GenericFightUnit * unit, GenericFightCell * cell ) { #ifdef QT_DEBUG unit->display(); #endif logEE( "start <> dest"); logEE( "%d-%d <> %d-%d", unit->getCell()->getRow(), unit->getCell()->getCol(), cell->getRow(), cell->getCol() ); } uchar FightEngine::getCla1() { return _currentData.getCla1(); } uchar FightEngine::getCla2() { return _currentData.getCla2(); } uchar FightEngine::getCla3() { return _currentData.getCla3(); } int FightEngine::readInt() { return _currentData.readInt(); } unsigned char FightEngine::readChar() { return _currentData.readChar(); } attal-src-1.0-rc2/libServer/fightEngine.h0000644000175000017500000000775710671321071016027 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** fightEngine.h ** managing server-side fight ** ** Version : $Id: fightEngine.h,v 1.18 2007/09/10 19:59:53 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 19/05/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef FIGHTENGINE_H #define FIGHTENGINE_H // generic include files // include files for QT // application specific include files #include "libCommon/define.h" #include "libCommon/fightResultStatus.h" #include "libCommon/genericFightMap.h" #include "libCommon/unit.h" #include "libServer/attalServer.h" #include "libServer/fightAnalyst.h" #include "libServer/playingTroops.h" #include #include class FightAnalyst; class GameData; class GenericCell; class GenericFightUnit; /** ------------------------------ * FightEngine ** ------------------------------ */ class FightEngine : public QObject { Q_OBJECT public: /** Constructor */ FightEngine( AttalServer * server ); ~FightEngine(); void init( GenericPlayer * attackPlayer, GenericLord * attackLord, GenericPlayer * defendPlayer, GenericLord * defendLord ); void init( GenericPlayer * attackPlayer, GenericLord * attackLord, GenericFightUnit * defendUnit[MAX_UNIT], GameData * data ); void handleSocket( GenericPlayer * player, AttalSocketData data ); void print(); /** \return Returns the attackingf lord */ GenericLord * getAttackLord() { return _attackLord; } /** \return Returns the defending lord */ GenericLord * getDefendLord() { return _defendLord; } void handleFakeSocket( FakeSocket * data ); GenericCell * getDefendCell() { return _defendCell; } void setDefendCell( GenericCell * cell ) { _defendCell = cell; } uint getExperience( GenericLord * lord ); FightResultStatus getResult() { return _result; } void endFight(); bool hasEnded() { return _hasEnded; } signals: void sig_endFight( FightResultStatus result ); private: void socketFightMove(); void socketFightDistAttack(); void socketFightEndMove(); void socketFightFlee(GenericPlayer * player); void setupUnits(); void newTurn(); void endTurn(); void nextUnit( int remove ); void handleMove( GenericFightUnit * unit, GenericFightCell * cell ); void precomputeUnit() {} void activateUnit( GenericFightUnit * unit ); void postcomputeUnit() {} void moveUnit( GenericFightUnit * unit, GenericFightCell * cell ); void fightUnit( GenericFightUnit * unitAtt, GenericFightUnit * unitDef, CLASS_ATTACK_TYPE attackType ); void computeFightResultStatus(); void orderTroops(); void updateUnits(); void printStatus( GenericFightUnit * unit, GenericFightCell * cell ); int giveNum( GenericFightUnit * unit ); CLASS_FIGHTER giveClass( GenericFightUnit * unit ); GenericFightUnit * giveUnit( CLASS_FIGHTER fighter, int num ); GenericLord * giveLord( GenericFightUnit * unit ); int readInt(); unsigned char readChar(); uchar getCla1(); uchar getCla2(); uchar getCla3(); int _num; AttalServer * _server; GenericFightMap * _map; bool _fightCreature, _hasEnded; GenericPlayer * _attackPlayer, * _defendPlayer, * _currentPlayer; GenericLord * _attackLord, * _defendLord; GenericCell * _defendCell; FightAnalyst * _analyst; FakeSocket * _fake; GenericFightUnit * _currentUnit; PlayingTroops _troops; GenericLord * _creatureLord; uint _defendExp, _attackExp; FightResultStatus _result; AttalSocketData _currentData; }; #endif // FIGHTENGINE_H attal-src-1.0-rc2/libServer/libServer.pro0000644000175000017500000000200511015367574016076 0ustar aaaaTEMPLATE = lib include( ../config.pro ) INCLUDEPATH += .. LIBS += -L.. unix:LIBS += -lAttalCommon win32:LIBS += -lAttalCommon9 VERSION = 10.0.0 SOURCES += attalServer.cpp SOURCES += playingTroops.cpp SOURCES += fightEngine.cpp SOURCES += loadGame.cpp SOURCES += engine.cpp SOURCES += questionManager.cpp SOURCES += tavernManager.cpp SOURCES += scenarioDescription.cpp SOURCES += fightAnalyst.cpp HEADERS += attalServer.h HEADERS += playingTroops.h HEADERS += fightEngine.h HEADERS += loadGame.h HEADERS += engine.h HEADERS += questionManager.h HEADERS += tavernManager.h HEADERS += scenarioDescription.h HEADERS += fightAnalyst.h TRANSLATIONS += ../i18n/de/attal_libserver_de.ts TRANSLATIONS += ../i18n/fr/attal_libserver_fr.ts TRANSLATIONS += ../i18n/ru/attal_libserver_ru.ts TRANSLATIONS += ../i18n/it/attal_libserver_it.ts DESTDIR = .. OBJECTS_DIR=./obj MOC_DIR=./moc TARGET = AttalServer unix { target.path = $${ATT_LIB_PREFIX} INSTALLS += target } #The following line was inserted by qt3to4 QT += xml network attal-src-1.0-rc2/libServer/loadGame.cpp0000644000175000017500000001401710757136470015643 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** loadGame.ccppp ** manage loading of scenarii and campaigns ** ** Version : $Id: loadGame.cpp,v 1.30 2008/02/20 23:52:24 lusum Exp $ ** ** Author(s) : Sardi Carlo ** ** Date : 11/10/2006 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "loadGame.h" // generic include files // include files for QT #include #include #include // application specific includes #include "libCommon/log.h" #include "libCommon/campaign.h" #include "engine.h" extern QString THEME; extern QString SCENARIO_PATH; extern QString CAMPAIGN_PATH; extern QString SAVE_PATH; extern QString PORT; LoadGame::LoadGame() { _aiDbg = false; _inLoad = false; _winner = true; _readyIn = true; _readyOut = true; _server = NULL; _engine = NULL; } LoadGame::~LoadGame() { } void LoadGame::load(const QString & filename) { TRACE("void LoadGame::load(QString filename %s", qPrintable( filename )); if( ( _server->getNbSocket() > 0 ) && ( !filename.isNull() ) ) { /* semaphore to avoid process 2 signal at same time */ if(!_inLoad) { _inLoad = true; fillWithAI(filename); restart: if( _engine->loadGame( filename, false ) ) { /* keep these istructions in this order */ adjustWidgetLoading( W_ENGINE ); _engine->startGame(); } else { if ( _aiDbg ) { QMessageBox msb( "Problem" , "Do you want to continue game (control right number of AI)?" , QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape, 0, 0 ); if( msb.exec() == QMessageBox::Yes){ goto restart; } } } _inLoad = false; } } } void LoadGame::loadCampaign(QString filename) { TRACE("filename %s",filename.toLatin1().constData()); if( ( _server->getNbSocket() == 1 ) && ( ! filename.isNull() ) ) { if( _engine && _engine->loadCampaign( filename ) ) { if( _engine->getCampaign() ) { continueCampaign( false ); } } } } void LoadGame::loadSingle(const QString & filename) { TRACE("LoadGame::loadSingle filename %s", qPrintable( filename ) ); //newEngine(); load( filename ); } void LoadGame::addInternalAI() { _readyIn = true; } bool LoadGame::fillWithAI(const QString & filename) { TRACE("bool LoadGame::fillWithAI(QString filename %s)",qPrintable(filename)); if ( !_engine->checkGamePlayers( filename ) ) { int nplay = _engine->getNumFillPlayers(); TRACE("LoadGame::fillWithAI nplay %d",nplay); if( nplay > 0 ) { //QTimer::singleShot( (nplay+2)* 1000, this, SLOT( slot_ready() ) ); for( int i = 0; i < nplay; i++ ) { _readyIn = false; TRACE("ai %d",i); addInternalAI(); while( !_readyIn ){ qApp->processEvents(); } } return true; } } return false; } void LoadGame::loadScenario( int /* num */) { } void LoadGame::autosave() { TRACE("void LoadGame::autosave"); if( _engine ) { QString numTurn = QString::number(_engine->getTurn()); while( numTurn.size() < 3 ) { numTurn.prepend('0'); } QString gamename = _engine->getScenarioName(); QString savename = gamename + "-turn-" + numTurn +".gam"; TRACE("void LoadGame::savename %s", savename.toLatin1().constData()); save( QString( SAVE_PATH + savename ) ); save( QString( SAVE_PATH + "autosave.gam") ); } } void LoadGame::save() { if(_engine) { QString filen; filen = QFileDialog::getSaveFileName( 0 ,"", SAVE_PATH , "*.gam" ); save( filen ); } } void LoadGame::save(QString filename) { if(_engine) { _engine->saveGame( filename ); } } void LoadGame::handleResult( bool result ) { TRACE("LoadGame::handleResult( bool result %d)", result); _winner = result; if( _engine && _engine->getCampaign()) { TRACE("handleResult isCampaign"); int nbScen = _engine->getCampaign()->getScenarioNumber(); int actScen = _engine->getCampaign()->getCurrentScenario(); if( !_winner || actScen >= nbScen ) { endGame(); } else if( _winner ) { continueCampaign( true ); } } else { endGame(); } } void LoadGame::endGame() { TRACE("LoadGame::endGame"); reinitStatus(); if( _engine ) { _engine->deleteCampaign(); endEngine(); endServer(); } } /* void LoadGame::endEngine() { } */ void LoadGame::reinitStatus() { TRACE("LoadGame::reinitStatus"); _readyOut = true; if(!_aiDbg) { disconnectAI(); } while( !_readyOut ){ qApp->processEvents(); } if(!_aiDbg) { killAI(); } _winner = true; adjustWidgetLoading( W_NORMAL ); } QString LoadGame::getFileName(QString filename) { filename = filename.section(QDir::separator(),-1,-1); if(filename.contains(".gam")){ filename.remove(".gam"); } if(filename.contains(".scn")){ filename.remove(".scn"); } return filename; } void LoadGame::continueCampaign( bool next ) { TRACE("LoadGame::continueCampaign( bool next %d)", next ); reinitStatus(); QString currentPath; QString filename; int actScen = _engine->getCampaign()->getCurrentScenario(); int nbScen = _engine->getCampaign()->getScenarioNumber(); if( next ) { actScen++; } if( actScen < nbScen) { currentPath = CAMPAIGN_PATH; _engine->getCampaign()->setCurrentScenario( actScen ); filename = _engine->getCampaign()->getScenario( actScen ); if(filename.contains(".gam")){ currentPath = SAVE_PATH; } load( currentPath + filename ); } else { endGame(); } } void LoadGame::newEngine() { TRACE("LoadGame::newEngine()"); _engine = new Engine( _server ); qsrand(time(NULL)); int id = qrand() % INT_MAX; _engine->setGameId( id ); _engine->start(); } attal-src-1.0-rc2/libServer/loadGame.h0000644000175000017500000000404610707471226015305 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** loadGame.h ** manage loading of scenarii and campaigns ** ** Version : $Id: loadGame.h,v 1.17 2007/10/23 22:15:50 lusum Exp $ ** ** Author(s) : Sardi Carlo ** ** Date : 11/10/2006 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef LOADGAME_H #define LOADGAME_H // generic include files // include files for QT #include #include // application specific includes #include "libServer/attalServer.h" class Campaign; class Engine; class LoadGame { public: enum StatusWidget { W_NORMAL, W_CLIENT, W_ENGINE }; LoadGame(); virtual ~LoadGame(); void initEngine(); void load( const QString & filename); void loadCampaign(QString fileName); void loadSingle(const QString & filename); virtual void addInternalAI(); virtual void disconnectAI() = 0; bool fillWithAI(const QString & filename); void endGame(); void reinitStatus(); virtual void endEngine() = 0; virtual void endServer() = 0; virtual bool killAI() { return true; } virtual void adjustWidgetLoading( StatusWidget type ) = 0; void autosave(); void save(); void save(QString filename); QString getFileName(QString filename); void continueCampaign( bool next ); protected: void newEngine(); void loadScenario( int num ); void handleResult(bool result); bool _readyIn, _winner, _readyOut; bool _aiDbg; AttalServer * _server; Engine * _engine; private: bool _inLoad; }; #endif // LOADGAME_H attal-src-1.0-rc2/libServer/playingTroops.cpp0000644000175000017500000000270710475357534017012 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** playingTroops.cpp ** manage playing troops ** ** Version : $Id: playingTroops.cpp,v 1.1 2006/08/30 18:56:28 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 19/05/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "playingTroops.h" PlayingTroops::PlayingTroops( bool order ) { _order = order; //setAutoDelete( false ); } GenericFightUnit * PlayingTroops::take() { GenericFightUnit * ret = last(); removeLast(); return ret; } int PlayingTroops::compareItems( GenericFightUnit * unit1, GenericFightUnit * unit2 ) { int ret = 0; ///GenericFightUnit * unit1 = (GenericFightUnit *)i1; ///GenericFightUnit * unit2 = (GenericFightUnit *)i2; if( unit1->getMove() > unit2->getMove() ) { ret = 1; } else if( unit1->getMove() < unit2->getMove() ) { ret = -1; } if( !_order ) { ret = -ret; } return ret; } attal-src-1.0-rc2/libServer/playingTroops.h0000644000175000017500000000265310475357534016457 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** playingTroops.h ** manage playing troops ** ** Version : $Id: playingTroops.h,v 1.1 2006/08/30 18:56:28 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 19/05/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PLAYINIGTROOPS_H #define PLAYINIGTROOPS_H #include "libCommon/unit.h" #include /** ------------------------------ * PlayingTroops ** ------------------------------ */ class PlayingTroops : public QList { public: PlayingTroops( bool order = true ); void add( GenericFightUnit * unit ) { append( unit ); qSort(begin(), end()); } GenericFightUnit * take(); protected: int compareItems( GenericFightUnit * i1, GenericFightUnit * i2 ); private: bool _order; }; #endif //PLAYINIGTROOPS_H attal-src-1.0-rc2/libServer/questionManager.cpp0000644000175000017500000000300210455452130017251 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** questionManager.cpp ** Manages questions for the engine ** ** Version : $Id: questionManager.cpp,v 1.1 2006/07/13 14:10:32 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 05/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "questionManager.h" // generic include files // include files for QT // application specific include files QuestionManager::QuestionManager() { _lord = 0; _creature = 0; _type = C_QR_MSG_END; } CLASS_ANSWER QuestionManager::getAnswerType() { CLASS_ANSWER ret = ANSWER_YESNO; switch( _type ) { case C_QR_CHEST: ret = ANSWER_ENUM; break; case C_QR_QUEST: ret = ANSWER_YESNO; break; case C_QR_CREATURE_FLEE: ret = ANSWER_YESNO; break; case C_QR_CREATURE_MERCENARY: ret = ANSWER_YESNO; break; case C_QR_CREATURE_JOIN: ret = ANSWER_YESNO; break; default: //ret = ANSWER_YESNO; break; } return ret; } attal-src-1.0-rc2/libServer/questionManager.h0000644000175000017500000000337010455452130016726 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** questionManager.h ** Manages questions for the engine ** ** Version : $Id: questionManager.h,v 1.1 2006/07/13 14:10:32 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef QUESTIONMANAGER_H #define QUESTIONMANAGER_H // generic include files // include files for QT // application specific include files #include "libCommon/attalSocket.h" class GenericLord; class GenericMapCreature; /* ------------------------------ * QuestionManager * ------------------------------ */ class QuestionManager { public: /** Constructor */ QuestionManager(); void setLord( GenericLord * lord ) { _lord = lord; } GenericLord * getLord() { return _lord; } void setCreature( GenericMapCreature * creature ) { _creature = creature; } GenericMapCreature * getCreature() { return _creature; } void setType( CLASS_QR type ) { _type = type; } CLASS_QR getType() { return _type; } CLASS_ANSWER getAnswerType(); protected: GenericLord * _lord; GenericMapCreature * _creature; CLASS_QR _type; }; #endif // QUESTIONMANAGER_H attal-src-1.0-rc2/libServer/scenarioDescription.cpp0000644000175000017500000001315610605720100020121 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** scenarioDescription.cpp ** Desciption of a scenario ** ** Version : $Id: scenarioDescription.cpp,v 1.2 2007/04/07 13:44:32 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 09/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "scenarioDescription.h" // generic include files // include files for QT #include // application specific include files #include "libCommon/log.h" // // ----- ScenarioDescription ----- // ScenarioDescription::ScenarioDescription() { clear(); } void ScenarioDescription::clear() { _nbPlayers = 0; _width = 0; _height = 0; _name = QObject::tr( "Unknown" ); _description = ""; } bool ScenarioDescription::load( const QString & fileName ) { _fileName = fileName; ScenarioDescriptionParser handler( this ); QFile file( fileName ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", fileName.toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } return true; } // // ----- ScenarioDescriptionParser ----- // ScenarioDescriptionParser::ScenarioDescriptionParser( ScenarioDescription * desc ) { _desc = desc; } bool ScenarioDescriptionParser::startDocument() { // at the beginning of parsing: do some initialization _desc->clear(); _errorProt = ""; _state = StateInit; return true; } bool ScenarioDescriptionParser::startElement( const QString& /* namespaceURI */, const QString& /* localName */, const QString& qName, const QXmlAttributes& atts ) { int number; bool ret = true; if( qName == "scenario" && _state == StateInit ) { _state = StateDocument; _otherCpt = 0; _desc->clear(); _desc->setNbPlayers( atts.value( "nbPlayer" ).toInt() ); } else if( qName == "attalversion" && _state == StateDocument ) { _state = StateAttalVersion; } else if( qName == "name" && _state == StateDocument ) { _state = StateName; } else if( qName == "description" && _state == StateDocument ) { _state = StateDescription; } else if( qName == "calendar" && _state == StateDocument ) { _state = StateCalendar; } else if( qName == "value" && _state == StateCalendar ) { _state = StateCalendarDate; number = atts.value( "type" ).toInt(); } else if( qName == "startcalendar" && _state == StateCalendar ) { _state = StateCalendarStart; } else if( qName == "value" && _state == StateCalendarStart ) { _state = StateCalendarStartDate; number = atts.value( "type" ).toInt(); } else if( qName == "turn" && _state == StateCalendar ) { _state = StateCalendarTurn; } else if( qName == "map" && _state == StateDocument ) { _state = StateMap; } else if( qName == "width" && _state == StateMap ) { _state = StateWidth; } else if( qName == "height" && _state == StateMap ) { _state = StateHeight; } else if( ( _state == StateDocument ) || ( _state == StateDocumentOther ) ) { _state = StateDocumentOther; _otherCpt++; } else if( ( _state == StateMap ) || ( _state == StateMapOther ) ) { _state = StateMapOther; _otherCpt++; } return ret; } bool ScenarioDescriptionParser::endElement( const QString& /* namespaceURI */, const QString& /* localName */, const QString& /* qName */) { bool ret = true; switch ( _state ) { case StateName: _state = StateDocument; break; case StateAttalVersion: _state = StateDocument; break; case StateDescription: _state = StateDocument; break; case StateCalendar: _state = StateDocument; break; case StateCalendarDate: _state = StateCalendar; break; case StateCalendarStart: _state = StateCalendar; break; case StateCalendarStartDate: _state = StateCalendarStart; break; case StateCalendarTurn: _state = StateCalendar; break; case StateMap: _state = StateFinish; break; case StateWidth: _state = StateMap; break; case StateHeight: _state = StateMap; break; case StateDocumentOther: if( _otherCpt == 1 ) { _state = StateDocument; } _otherCpt--; case StateMapOther: if( _otherCpt == 1 ) { _state = StateMap; } _otherCpt--; break; default: break; } return ret; } bool ScenarioDescriptionParser::characters( const QString & ch ) { bool ret = true; QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) return true; switch( _state ) { case StateName: _desc->setName( ch_simplified ); break; case StateDescription: _desc->setDescription( ch_simplified ); break; case StateWidth: _desc->setWidth( ch_simplified.toUInt() ); break; case StateHeight: _desc->setHeight( ch_simplified.toUInt() ); break; default: break; } return ret; } bool ScenarioDescriptionParser::fatalError( const QXmlParseException& exception ) { logEE( "state %d", _state ); _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/libServer/scenarioDescription.h0000644000175000017500000000677510605720100017577 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** scenarioDescription.h ** Desciption of a scenario ** ** Version : $Id: scenarioDescription.h,v 1.2 2007/04/07 13:44:32 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 09/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SCENARIODESCRIPTION_H #define SCENARIODESCRIPTION_H // generic include files // include files for QT #include #include #include // application specific include files /* ------------------------------ * ScenarioDescription * ------------------------------ */ class ScenarioDescription { public: /** Constructor */ ScenarioDescription(); void clear(); bool load( const QString & fileName ); uint getWidth() { return _width; } void setWidth( uint width ) { _width = width; } uint getHeight() { return _height; } void setHeight( uint height ) { _height = height; } uint getNbPlayers() { return _nbPlayers; } void setNbPlayers( uint nbPlayers ) { _nbPlayers = nbPlayers; } const QString & getName() { return _name; } void setName( const QString & name ) { _name = name; } const QString & getDescription() { return _description; } void setDescription( const QString & description ) { _description = description; } QString getFileName() { return _fileName; } protected: QString _name, _description; uint _height, _width, _nbPlayers; QString _fileName; }; /* ------------------------------ * ScenarioDescriptionParser * ------------------------------ */ class ScenarioDescriptionParser : public QXmlDefaultHandler { public: /** Constructor */ ScenarioDescriptionParser( ScenarioDescription * desc ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); protected: void manageCondition( const QString & type ); void manageConditionParam( const QString & param ); private: ScenarioDescription * _desc; QString _errorProt; uint _otherCpt; enum State { StateInit, StateDocument, StateDocumentOther, StateAttalVersion, StateName, StateDescription, StateCalendar, StateCalendarDate, StateCalendarStart, StateCalendarStartDate, StateCalendarTurn, StateMap, StateWidth, StateHeight, StateMapOther, StateFinish }; State _state; }; #endif // SCENARIODESCRIPTION_H attal-src-1.0-rc2/libServer/tavernManager.cpp0000644000175000017500000000403110533124702016702 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** tavernManager.cpp ** Manages tavern (available lords) ** ** Version : $Id: tavernManager.cpp,v 1.2 2006/11/28 21:27:30 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/02/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "tavernManager.h" // generic include files // include files for QT // application specific include files #include "libCommon/log.h" #include "libCommon/gameData.h" // // ----- TavernManager ----- TavernManager::TavernManager( GameData * data ) { _data = data; } void TavernManager::reinit() { } uint TavernManager::getTavernLordNumber( GenericBase * /* base */) { return 1; } GenericLord * TavernManager::getTavernLord( GenericBase * base, uint /* numLord */ ) { GenericLord * ret = 0; GenericLord * tempLord; uint nbBase, nbLord, num, cpt; nbBase = _data->getBaseNumber(); nbLord = _data->getLordNumber(); num = nbBase; for( uint i = 0; i < nbBase; i++ ) { if( base == _data->getBase( i ) ) { num = i; break; } } if( num < nbBase ) { cpt = 0; for( uint i = 1; i < nbLord; i++ ) { tempLord = _data->getLord( i ); if( cpt == num ) { if( tempLord->getOwner() == 0 ) { ret = tempLord; break; } } else { if( tempLord->getOwner() == 0 ) { cpt++; } } } } return ret; } void TavernManager::newDay() { /// XXX: will be use later, when more complex tavern management mechanism will be implemented } attal-src-1.0-rc2/libServer/tavernManager.h0000644000175000017500000000277510455452130016366 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** tavernManager.h ** Manages tavern (available lords) ** ** Version : $Id: tavernManager.h,v 1.1 2006/07/13 14:10:32 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/02/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef TAVERNMANAGER_H #define TAVERNMANAGER_H // generic include files // include files for QT // application specific include files #include "libCommon/genericLord.h" class GameData; class GenericBase; /* ------------------------------ * TavernManager * ------------------------------ */ class TavernManager { public: /** Constructor */ TavernManager( GameData * data ); void reinit(); uint getTavernLordNumber( GenericBase * base ); GenericLord * getTavernLord( GenericBase * base, uint numLord ); void newDay(); private: GameData * _data; }; #endif // TAVERNMANAGER_H attal-src-1.0-rc2/scenarioEditor/0000755000175000017500000000000011016113673014425 5ustar aaaaattal-src-1.0-rc2/scenarioEditor/.cvsignore0000644000175000017500000000043710331243515016427 0ustar aaaamoc obj editor moc_* *.moc.cpp *.o *.opt *.plg *.dsp Makefile Makefile.Release Makefile.Debug Makefile.in .deps scenario-editor ScenarioEditor.plg Debug Release attal-scenario-editor_resource.rc object_ld_script.attal-scenario-editor.Debug object_ld_script.attal-scenario-editor.Release attal-src-1.0-rc2/scenarioEditor/displayQuests.cpp0000644000175000017500000001052710531067473020017 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayQuests.cpp ** Dialog for displaying quests ** ** Version : $Id: displayQuests.cpp,v 1.9 2006/11/22 15:39:39 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "displayQuests.h" // generic include files // include files for QT #include #include #include #include #include #include // application specific include files #include "libClient/gui.h" #include "libCommon/questManager.h" #include "scenarioEditor/questEditor.h" DisplayQuests::DisplayQuests( QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { _quests = 0; QLabel * labMain = new QLabel( this ); labMain->setText( tr( "Main quest: " ) ); FIXEDSIZE( labMain ); QPushButton * butMain = new QPushButton( this ); butMain->setText( tr( "Edit" ) ); FIXEDSIZE( butMain ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setMargin( 5 ); layH1->setSpacing( 5 ); layH1->addWidget( labMain ); layH1->addWidget( butMain ); layH1->addStretch( 1 ); QLabel * labOther = new QLabel( this ); labOther->setText( tr( "Other quests:" ) ); FIXEDSIZE( labOther ); _list = new QListWidget( this ); QPushButton * butEdit = new QPushButton( this ); butEdit->setText( tr( "Edit" ) ); FIXEDSIZE( butEdit ); QPushButton * butAdd = new QPushButton( this ); butAdd->setText( tr( "Add" ) ); FIXEDSIZE( butAdd ); QPushButton * butDel = new QPushButton( this ); butDel->setText( tr( "Del" ) ); FIXEDSIZE( butDel ); QVBoxLayout * layV1 = new QVBoxLayout(); layV1->setSpacing( 5 ); layV1->addWidget( butEdit ); layV1->addWidget( butAdd ); layV1->addWidget( butDel ); layV1->addStretch( 1 ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->setSpacing( 5 ); layH2->addWidget( _list, 1 ); layH2->addLayout( layV1 ); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCancel = new QPushButton( this ); pbCancel->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCancel ); QHBoxLayout * layH3 = new QHBoxLayout(); layH3->addStretch( 1 ); layH3->addWidget( pbOk ); layH3->addStretch( 1 ); layH3->addWidget( pbCancel ); layH3->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layH1 ); layout->addWidget( labOther ); layout->addLayout( layH2, 1 ); layout->addLayout( layH3 ); layout->activate(); connect( butMain, SIGNAL( clicked() ), SLOT( slot_main() ) ); connect( butEdit, SIGNAL( clicked() ), SLOT( slot_edit() ) ); connect( butAdd, SIGNAL( clicked() ), SLOT( slot_add() ) ); connect( butDel, SIGNAL( clicked() ), SLOT( slot_del() ) ); connect( pbOk, SIGNAL( clicked() ), SLOT( slot_accept() ) ); connect( pbCancel, SIGNAL( clicked() ), SLOT( reject() ) ); } void DisplayQuests::reinit( QuestManager * quests ) { Quest * quest; _quests = quests; _list->clear(); for( uint i = 0; i < _quests->getSecondaryQuestNumber(); i++ ) { quest = _quests->getSecondaryQuest( i ); if( quest ) { _list->addItem( quest->getName() ); } } } void DisplayQuests::slot_main() { QuestEditor editor( this ); Quest * quest = _quests->getMainQuest(); if( ! quest ) { quest = new Quest(); _quests->setMainQuest( quest ); } editor.init( quest ); if( editor.exec() ) { editor.save(); } } void DisplayQuests::slot_edit() { } void DisplayQuests::slot_add() { Quest * quest = new Quest(); QuestEditor editor( 0 ); editor.init( quest ); if( editor.exec() ) { editor.save(); _quests->appendSecondaryQuest( quest ); _list->addItem( quest->getName() ); } else { delete quest; } } void DisplayQuests::slot_del() { } void DisplayQuests::slot_accept() { accept(); } attal-src-1.0-rc2/scenarioEditor/displayQuests.h0000644000175000017500000000312510335464746017466 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayQuests.h ** Dialog for displaying quests ** ** Version : $Id: displayQuests.h,v 1.4 2005/11/12 22:17:10 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef DISPLAYQUESTS_H #define DISPLAYQUESTS_H // generic include files // include files for QT #include #include // application specific include files class QListWidget; class GameData; class QuestManager; /* ------------------------------ * DisplayQuests * ------------------------------ */ class DisplayQuests : public QDialog { Q_OBJECT public: /** Constructor */ DisplayQuests( QWidget * parent = 0, const char * name = 0 ); void reinit( QuestManager * quests ); public slots: void slot_main(); void slot_edit(); void slot_add(); void slot_del(); void slot_accept(); protected: QuestManager * _quests; QListWidget * _list; }; #endif // DISPLAYQUESTS_H attal-src-1.0-rc2/scenarioEditor/editorHandler.cpp0000644000175000017500000001264410522705153017725 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** editorHandler.cpp ** scenario parser for the editor ** ** Version : $Id: editorHandler.cpp,v 1.5 2006/11/03 18:28:59 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/02/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "editorHandler.h" // generic include files // include files for QT #include // application specific include files #include "scenarioEditor/screen.h" /** add comments here */ EditorHandler::EditorHandler( Screen * screen ) { _screen = screen; } bool EditorHandler::startDocument() { // at the beginning of parsing: do some initialization _errorProt = ""; _player = 0; _state = StateInit; return true; } bool EditorHandler::startElement( const QString &, const QString &, const QString& qName, const QXmlAttributes & ) { if( qName == "scenario" && _state == StateInit ) { _state = StateDocument; } else if( qName == "name" && _state == StateDocument ) { _state = StateName; } else if( qName == "theme" && _state == StateDocument ) { _state = StateTheme; } else if( qName == "description" && _state == StateDocument ) { _state = StateDescription; } else if( qName == "map" && _state == StateDocument ) { _state = StateMap; _buffer = new QByteArray(); _tempStream = new QTextStream( *_buffer, QIODevice::WriteOnly ); } else if( qName == "width" && _state == StateMap ) { _state = StateWidth; } else if ( qName == "height" && _state == StateMap ) { _state = StateHeight; } else if( qName == "base" && _state == StateDocument ) { _state = StateBase; } else if( qName == "building" && _state == StateDocument ) { _state = StateBuilding; } else if( qName == "lord" && _state == StateDocument ) { _state = StateLord; } else if( qName == "col" && _state == StateLord ) { _state = StateLordCol; } else if( qName == "row" && _state == StateLord ) { _state = StateLordRow; } else if( qName == "player" && _state == StateDocument ) { _state = StatePlayer; } else if( qName == "name" && _state == StatePlayer ) { _state = StatePlayerName; } else if( qName == "bases" && _state == StatePlayer ) { _buffer = new QByteArray(); _tempStream = new QTextStream( *_buffer, QIODevice::WriteOnly ); _state = StatePlayerBases; } else if( qName == "buildings" && _state == StatePlayer ) { _buffer = new QByteArray(); _tempStream = new QTextStream( *_buffer, QIODevice::WriteOnly ); _state = StatePlayerBuildings; } else if( qName == "lords" && _state == StatePlayer ) { _buffer = new QByteArray(); _tempStream = new QTextStream( *_buffer, QIODevice::WriteOnly ); _state = StatePlayerLords; } else { // error return false; } return true; } bool EditorHandler::endElement( const QString &, const QString &, const QString & ) { switch ( _state ) { case StateName: _state = StateDocument; break; case StateTheme: _state = StateDocument; break; case StateDescription: _state = StateDocument; break; case StateMap: delete _tempStream; delete _buffer; _state = StateDocument; break; case StateWidth: _state = StateMap; break; case StateHeight: _state = StateMap; break; case StateBase: _state = StateDocument; break; case StateBuilding: _state = StateDocument; break; case StateLord: _state = StateDocument; break; case StateLordCol: _state = StateLord; break; case StateLordRow: _state = StateLord; break; case StatePlayer: _player++; _state = StateDocument; break; case StatePlayerName: _state = StatePlayer; break; case StatePlayerBases: { delete _tempStream; delete _buffer; _state = StatePlayer; break; } case StatePlayerBuildings: { delete _tempStream; delete _buffer; _state = StatePlayer; break; } case StatePlayerLords: { delete _tempStream; delete _buffer; _state = StatePlayer; break; } default: // do nothing break; } return true; } bool EditorHandler::characters( const QString& ch ) { QString ch_simplified = ch.simplified(); if ( ch_simplified.isEmpty() ) return true; switch( _state ) { case StateName: break; case StateTheme: break; case StateDescription: break; case StateMap: *_tempStream << ch_simplified; break; case StateWidth: break; case StateHeight: break; case StateBase: break; case StateBuilding: break; case StateLordCol: break; case StateLordRow: break; case StatePlayerName: break; case StatePlayerBases: break; case StatePlayerBuildings: break; case StatePlayerLords: break; default: return false; } return true; } bool EditorHandler::fatalError( const QXmlParseException& exception ) { _errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) .arg( exception.message() ) .arg( exception.lineNumber() ) .arg( exception.columnNumber() ); return QXmlDefaultHandler::fatalError( exception ); } attal-src-1.0-rc2/scenarioEditor/editorHandler.h0000644000175000017500000000464310331243515017367 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** editorHandler.h ** scenario parser for the editor ** ** Version : $Id: editorHandler.h,v 1.2 2005/10/30 22:21:01 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/02/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef EDITORHANDLER_H #define EDITORHANDLER_H // generic include files // include files for QT #include #include // application specific include files class Screen; /** ------------------------------ * EditorHandler ** ------------------------------ */ class EditorHandler : public QXmlDefaultHandler { public: /** Constructor */ EditorHandler( Screen * screen ); /** Return the error protocol if parsing failed */ QString errorProtocol() { return _errorProt; } /** Before starting parsing */ bool startDocument(); /** Define Start elements and associated actions */ bool startElement( const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts ); /** Define End elements and associated actions */ bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); /** Define what to do of characters */ bool characters( const QString& ch ); /** Error function */ bool fatalError( const QXmlParseException& exception ); private: Screen * _screen; QTextStream * _tempStream; QByteArray * _buffer; QString _errorProt; int _player; enum State { StateInit, StateDocument, StateName, StateTheme, StateDescription, StateMap, StateWidth, StateHeight, StateBase, StateBuilding, StateLord, StateLordCol, StateLordRow, StatePlayer, StatePlayerName, StatePlayerBases, StatePlayerBuildings, StatePlayerLords }; State _state; }; #endif // EDITORHANDLER_H attal-src-1.0-rc2/scenarioEditor/itemSelection.cpp0000644000175000017500000003124110633341113017732 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** itemSelection.cpp ** Allow selection of specific item panels ** ** Version : $Id: itemSelection.cpp,v 1.47 2007/06/11 21:44:43 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 22/12/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "itemSelection.h" // generic include files #include // include files for QT #include #include #include #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/genericDecoration.h" #include "libCommon/genericCell.h" #include "libClient/attalButton.h" #include "libClient/bonus.h" #include "libClient/building.h" #include "libClient/chest.h" #include "libClient/event.h" #include "libClient/graphicalArtefact.h" #include "libClient/graphicalGameData.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/lord.h" #include "libClient/map.h" #include "libClient/mapCreature.h" #include "scenarioEditor/screen.h" extern Map * theMap; bool isOdd( int number ) { return( ( number % 2 ) == 1 ); } // // ----- ItemSelection ----- // ItemSelection::ItemSelection( QWidget * parent, const char * /* name */ ) :QWidget( parent ) { _bg = new QButtonGroup( this ); //_bg->hide(); _bg->setExclusive( true ); setMinimumWidth( 220 ); _currentX = 5; _currentY = 5; _currentHeight = 5; } void ItemSelection::addButton( QPixmap pixmap, int pos, bool breakLine ) { AttalButton * pb = new AttalButton( this ); pb->setPixmap( pixmap ); pb->setCheckable( true ); _bg->addButton( pb, pos ); pb->setFixedSize( QSize( 40, 40 ).expandedTo( pb->sizeHint() ) ); addNewWidget( pb, breakLine ); } void ItemSelection::addButton( const QString & text, int pos, bool breakLine ) { QPushButton * pb = new QPushButton( text, this ); pb->setCheckable( true ); _bg->addButton( pb, pos ); pb->setFixedSize( QSize(40,40).expandedTo(pb->sizeHint())); addNewWidget( pb, breakLine ); } void ItemSelection::addNewWidget( QWidget * widget, bool breakLine ) { if( ( _currentX + widget->width() ) > 210 ) { breakLine = true; } if( _currentX == 5 ) { breakLine = false; } if( breakLine ) { _currentY += _currentHeight + 5; _currentX = 5; _currentHeight = 0; } _currentHeight = std::max( _currentHeight, widget->height() ); widget->move( _currentX, _currentY ); _currentX += ( 5 + widget->width() ); setMinimumHeight( _currentY + _currentHeight + 5 ); } void ItemSelection::addNewLine() { _currentX = 5; _currentY += _currentHeight + 5; } bool ItemSelection::isPlace(GenericCell * cell) { //logDD("cell row %d, col %d, coeff %d , stop %d, free %d",cell->getRow(), cell->getCol(), cell->getCoeff(), cell->isStoppable() ,cell->isFree()); if((! cell->getBuilding() ) && ( ! cell->getBase() ) && cell->getCoeff() >= 0 && cell->isStoppable() && cell->isFree()){ return true; } return false; } int ItemSelection::button() { /// XXX: replace selectedId with Id (selected) //return _bg->id ( _bg->selected() ); return _bg->checkedId(); } // // ----- TransitionSelection ----- // TransitionSelection::TransitionSelection( QWidget * parent, const char * name ) :ItemSelection( parent, name ) { addButton("Auto",0); for( int i = 0; i < DataTheme.tiles.count() - 1; i++ ) { for( uint j = 0; j < NB_TRANSITION ; j++ ) { addButton( ImageTheme.transition[i]->at( j ), ( i * NB_TRANSITION ) + j + 1, j == 0 ); } } } void TransitionSelection::handleLeftClick( GenericCell * cell ) { if( button() == 0 ) { cell->setTransition( computeTransition( (GenericMap*)theMap, (GenericCell *)cell ) ); cell->setTransitionCellType( computeTransitionCellType( (GenericMap*)theMap, (GenericCell *)cell ) ); } else if( button() > -1 ) { cell->setTransition( ( ( button() - 1 ) % NB_TRANSITION ) + 1 ); cell->setTransitionCellType( ( ( button() - 1 ) / NB_TRANSITION ) + 1 ); } } // // ----- DecorationGroupSelection ----- // DecorationGroupSelection::DecorationGroupSelection( QWidget * parent, const char * name ) :ItemSelection( parent, name ) { DecorationSelection * item; uint nbGroups = DataTheme.decorations.count(); _groups = new QComboBox( this ); _stack = new QStackedWidget( this ); for( uint i = 1; i < nbGroups; i++ ) { _groups->addItem( DataTheme.decorations.at( i )->getName() ); item = new DecorationSelection( i ); _stack->addWidget( item ); } FIXEDSIZE( _groups ); slot_selectGroup( 0 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addWidget( _groups ); layout->addWidget( _stack, 1 ); layout->activate(); connect( _groups, SIGNAL( activated( int ) ), SLOT( slot_selectGroup( int ) ) ); } void DecorationGroupSelection::handleLeftClick( GenericCell * cell ) { ( (DecorationSelection*)_stack->currentWidget() )->handleLeftClick( cell ); } void DecorationGroupSelection::slot_selectGroup( int group ) { _stack->setCurrentIndex( group ); setFixedHeight( 10 + _groups->height() + _stack->currentWidget()->height() ); } // // ----- DecorationSelection ----- // DecorationSelection::DecorationSelection( uint group, QWidget * parent, const char * name ) :ItemSelection( parent, name ) { DecorationGroup * deco = DataTheme.decorations.at( group ); uint nbItems = deco->count(); _group = group; for( uint i = 0; i < nbItems; i++ ) { addButton( ImageTheme.decoration[ group-1 ]->at( i ), i ); } _isTree = false; _isRoad = false; if( deco->getEffectNumber() > 0 ) { for( uint i = 0 ; i < deco->getEffectNumber(); i++ ) { DecorationGroup::EffectType effect = deco->getEffectType( i ); if( ( effect == DecorationGroup::DECREASE_MOVECOST ) || ( effect == DecorationGroup::INCREASE_MOVECOST ) ) { _isRoad = true; addNewLine(); addButton( tr( "Auto-path" ), nbItems ); } if( ( effect == DecorationGroup::NO_BLOCK_DECO ) ) { _isTree = true; } } } setFixedHeight( minimumHeight() ); } void DecorationSelection::handleLeftClick( GenericCell * cell ) { if( button() != -1 ) { if( isPlace(cell) || _isTree) { if( _isRoad && ( button() == ( _bg->buttons().count() - 1 ) ) ) { computeAndChangeRoadType( (GenericMap *)theMap, (GenericCell *)cell, _group ); } else { GenericDecoration * deco = DataTheme.decorations.at( _group)->at(button()) ; if( theMap->isPlaceDecoFree( deco,(GenericCell *)cell) || _isTree) { cell->setDecoration( _group, button() ); theMap->computeStoppable(deco, cell); } } } } } // // ----- BuildingSelection ----- // BuildingSelection::BuildingSelection( QWidget * parent, const char * name ) :ItemSelection( parent, name ) { uint nb = DataTheme.buildings.count(); for ( uint i = 0; i < nb; i++ ) { addButton( ImageTheme.buildings[i]->at( 0 ), i ); } } void BuildingSelection::handleLeftClick( GenericCell * cell ) { if( button() != -1 ) { if( isPlace(cell)) { if( theMap->isPlaceBuilFree( button(),(GenericCell *)cell) ) { Building * building = (Building *)_data->getNewBuilding(); building->setType( button() ); _data->setBuildingId( building ); building->setPosition( (GenericCell *)cell ); theMap->computeStoppable(building); } } } } // // ----- BaseSelection ----- // BaseSelection::BaseSelection( QWidget * parent, const char * name ) :ItemSelection( parent, name ) { uint nb = ImageTheme.bases->count(); for( uint i = 0; i < nb; i++ ) { addButton( ImageTheme.bases->at(i), i ); } } void BaseSelection::handleLeftClick( GenericCell * cell ) { if( button() != -1 ) { if( isPlace(cell) ) { if( theMap->isPlaceBaseFree( button(), (GenericCell *)cell)) { Base * base = (Base *)_data->getNewBase(); base->setRace( button() ); base->setPosition( (GenericCell *)cell ); _data->setBaseId( (GenericBase *)base ); theMap->computeStoppable(base); } } } } // // ----- LordSelection ----- // LordSelection::LordSelection( QWidget * parent, const char * name ) :ItemSelection( parent, name ) { addButton( ImageTheme.lords->at( 0 ), 0 ); } void LordSelection::handleLeftClick( GenericCell * cell ) { if( button() != -1 && isPlace(cell)) { if( ! cell->getLord() && cell->getCoeff() >= 0 && cell->isStoppable() && cell->isFree()) { for( uint num = 1; num < _data->getLordNumber(); num++ ) { Lord * lord = (Lord*)_data->getLord( num ); if( !lord->getCell()) { lord->setId( num ); lord->setVisible( true ); lord->setCell( (GenericCell *)cell ); return; } } } } } // // ----- ArtefactSelection ----- // ArtefactSelection::ArtefactSelection( QWidget * parent, const char * name ) :ItemSelection( parent, name ) { uint nb = ImageTheme.artefacts->count(); for ( uint i = 0; i < nb; i++ ) { addButton( ImageTheme.artefacts->at(i), i ); } } void ArtefactSelection::handleLeftClick( GenericCell * cell ) { if( button() != -1 && isPlace(cell)) { Event * event = (Event*)_data->getNewArtefact(); Artefact * artefact = (Artefact*) event->getArtefact(); artefact->setType( button() ); if( cell->getEvent() ) { Event * temp = (Event*)( cell->getEvent() ); delete temp; } cell->setEvent( (GenericEvent*)event ); event->setCell( (GenericCell*)cell ); } } // // ----- BonusSelection ----- // BonusSelection::BonusSelection( QWidget * parent, const char * name ) :ItemSelection( parent, name ) { int i; addButton( ImageTheme.chest->at( 0 ), 0, true ); int nbRes = DataTheme.resources.count(); for( i = 0; i < nbRes; i++ ) { addButton( ImageTheme.bonus[0]->at( i ), i+1, i == (nbRes -1) ); } for( i = 0; i < 3; ++i ) { addButton( ImageTheme.bonus[1+i]->at( 0 ), nbRes+i+1 ); } } void BonusSelection::handleLeftClick( GenericCell * cell ) { if( button() != -1 && isPlace(cell)) { Event * event; if( button() == 0 ) { event = (Event*) _data->getNewChest(); ///Chest * chest = (Chest *) event->getChest(); } else { uint nbRes = DataTheme.resources.count(); event = (Event*) _data->getNewBonus(); Bonus * bonus = (Bonus *) event->getBonus(); if( button() <= (int)nbRes ) { bonus->setType( GenericBonus::BonusResource ); bonus->addParam( button() - 1 ); bonus->addParam( 0 ); bonus->addParam( 1 ); bonus->setupBonus(); } else { bonus->setType( (GenericBonus::BonusType) (button()-nbRes) ); bonus->setupBonus(); } } if( cell->getEvent() ) { Event * temp = (Event*)( cell->getEvent() ); delete temp; } cell->setEvent( (GenericEvent*)event ); event->setCell( (GenericCell*)cell ); } } // // ----- CreatureSelection ----- // CreatureSelection::CreatureSelection( QWidget * parent, const char * name ) :ItemSelection( parent, name ) { int cpt = 0; for( uint i = 0; i < DataTheme.countRace(); i++ ) { for( int j = 0; j < DataTheme.creatures.getRace( i )->count(); j++ ) { addButton(ImageTheme.getMapCreature( i, j ), cpt ); cpt++; } addNewLine(); } } void CreatureSelection::handleLeftClick( GenericCell * cell ) { if( button() != -1 && isPlace(cell)) { int race = 0, level = 0; int cpt = 0; for( uint i = 0; i < DataTheme.countRace(); i++ ) { for( int j = 0; j < DataTheme.creatures.getRace( i )->count(); j++ ) { if( cpt == button() ) { race = i; level = j; } cpt++; } } MapCreature * creature = (MapCreature*) _data->getNewMapCreature(); //new MapCreature( theMap ); creature->setCreature( race, level ); creature->setStack( 0, 1 ); /// XXX: to change creature->setCell( cell ); cell->setCreature( creature ); } } // // ----- ToolSelection ----- // ToolSelection::ToolSelection( Screen * screen, QWidget * parent, const char * name ) :ItemSelection( parent, name ) { _screen = screen; addButton("Eraser",0); addButton("Auto-transition",1); addButton("Auto-roads",2); } void ToolSelection::handleLeftClick( GenericCell * cell ) { switch( button() ) { case 0: _screen->handleDelete(); break; case 1: cell->setTransition( computeTransition( (GenericMap *)theMap, (GenericCell *)cell ) ); cell->setTransitionCellType( computeTransitionCellType( (GenericMap *)theMap, (GenericCell *)cell ) ); break; case 2: computeAndChangeRoadType( (GenericMap *)theMap, (GenericCell *)cell, 1 ); /// XXX: to change '1' -> road type break; } } attal-src-1.0-rc2/scenarioEditor/itemSelection.h0000644000175000017500000001130510620114145017375 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** itemSelection.h ** Allow selection of specific item panels ** ** Version : $Id: itemSelection.h,v 1.21 2007/05/08 15:33:57 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 22/12/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ITEMSELECTION_H #define ITEMSELECTION_H // generic include files // include files for QT #include #include #include #include #include // application specific include files class QComboBox; class QStackedWidget; class GenericCell; class GraphicalGameData; class Screen; /** Generic class for selecting items */ class ItemSelection : public QWidget { Q_OBJECT public: /** Constructor */ ItemSelection( QWidget * parent = 0, const char * name = 0 ); /** Manage left click */ virtual void handleLeftClick( GenericCell * ) {} /** Sets theme data to the selection panel */ void setGameData( GraphicalGameData * data ) { _data = data; } bool isPlace(GenericCell * cell); protected: void addButton( QPixmap pixmap, int pos, bool breakLine = false ); void addButton( const QString& text, int pos, bool breakLine = false ); void addNewWidget( QWidget * button, bool breakLine = false ); void addNewLine(); int button(); GraphicalGameData * _data; protected: QButtonGroup *_bg; int _currentX; int _currentY; int _currentHeight; }; /** Selection of transition */ class TransitionSelection : public ItemSelection { public: /** Constructor */ TransitionSelection( QWidget * parent = 0, const char * name = 0 ); /** Manage left click */ void handleLeftClick( GenericCell * ); }; /** Selection of decoration group */ class DecorationGroupSelection : public ItemSelection { Q_OBJECT public: /** Constructor */ DecorationGroupSelection( QWidget * parent = 0, const char * name = 0 ); /** Manage left click */ void handleLeftClick( GenericCell * ); public slots: void slot_selectGroup( int group ); protected: QComboBox * _groups; QStackedWidget * _stack; }; /** Selection of decoration */ class DecorationSelection : public ItemSelection { Q_OBJECT public: /** Constructor */ DecorationSelection( uint group, QWidget * parent = 0, const char * name = 0 ); /** Manage left click */ void handleLeftClick( GenericCell * ); protected: uint _group; bool _isRoad; bool _isTree; }; /** Selection of a building */ class BuildingSelection : public ItemSelection { public: /** Constructor */ BuildingSelection( QWidget * parent = 0, const char * name = 0 ); /** Manage left click */ void handleLeftClick( GenericCell * ); }; /** Selection of a base */ class BaseSelection : public ItemSelection { public: /** Constructor */ BaseSelection( QWidget * parent = 0, const char * name = 0 ); /** Manage left click */ void handleLeftClick( GenericCell * ); }; /** Selection of a lord */ class LordSelection : public ItemSelection { public: /** Constructor */ LordSelection( QWidget * parent = 0, const char * name = 0 ); /** Manage left click */ void handleLeftClick( GenericCell * ); }; /** Selection of an artefact */ class ArtefactSelection : public ItemSelection { public: /** Constructor */ ArtefactSelection( QWidget * parent = 0, const char * name = 0 ); /** Manage left click */ void handleLeftClick( GenericCell * ); }; /** Selection of a bonus/chest */ class BonusSelection : public ItemSelection { public: /** Constructor */ BonusSelection( QWidget * parent = 0, const char * name = 0 ); /** Manage left click */ void handleLeftClick( GenericCell * ); }; /** Selection of a creature */ class CreatureSelection : public ItemSelection { public: /** Constructor */ CreatureSelection( QWidget * parent = 0, const char * name = 0 ); /** Manage left click */ void handleLeftClick( GenericCell * ); }; /** Selection of a tool */ class ToolSelection : public ItemSelection { public: /** Constructor */ ToolSelection( Screen * screen, QWidget * parent = 0, const char * name = 0 ); /** Manage left click */ void handleLeftClick( GenericCell * ); protected: Screen * _screen; QPolygon _path; void findPath ( QPoint& point1, QPoint& point2 ); }; #endif // ITEMSELECTION_H attal-src-1.0-rc2/scenarioEditor/itemSelector.cpp0000644000175000017500000001254210620114145017567 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** itemSelector.cpp ** Allow selection of item panels ** ** Version : $Id: itemSelector.cpp,v 1.16 2007/05/08 15:33:57 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 21/12/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "itemSelector.h" // generic include files // include files for QT #include #include #include #include // application specific include files #include "scenarioEditor/itemSelection.h" #include "scenarioEditor/screen.h" #include "scenarioEditor/tileSelection.h" #include "libClient/map.h" #include "libClient/graphicalGameData.h" #include "libClient/gui.h" #include "libClient/cell.h" extern Map * theMap; ItemSelector::ItemSelector( GraphicalGameData * data, Screen * screen, const char * /* name */) :QWidget( screen ) { _data = data; _screen = screen; QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); _selector = new QComboBox( this ); _selector->setFixedHeight( _selector->sizeHint().height() ); layout->addWidget( _selector ); _stack = new QStackedWidget( this ); layout->addWidget( _stack, 1 ); layout->activate(); init(); connect( _selector, SIGNAL( activated( int ) ), _stack, SLOT( setCurrentIndex( int ) ) ); setFixedWidth( 235 ); } void ItemSelector::init() { _selector->addItem( QObject::tr( "Tile" ), ItemTile ); _selector->addItem( QObject::tr( "Transition" ), ItemTransition ); _selector->addItem( QObject::tr( "Decoration" ), ItemDecoration ); _selector->addItem( QObject::tr( "Building" ), ItemBuilding ); _selector->addItem( QObject::tr( "Base" ), ItemBase ); _selector->addItem( QObject::tr( "Lord" ), ItemLord ); _selector->addItem( QObject::tr( "Artefact" ), ItemArtefact ); _selector->addItem( QObject::tr( "Bonus" ), ItemBonus ); _selector->addItem( QObject::tr( "Creature" ), ItemCreature ); _selector->addItem( QObject::tr( "Tool" ), ItemTool ); ItemScroll * view0 = new ItemScroll(); TileSelection * wid0 = new TileSelection( view0 ); view0->addItem( wid0 ); view0->setWidgetResizable(true); _stack->addWidget( view0 ); wid0->setGameData( _data ); ItemScroll * view1 = new ItemScroll(); TransitionSelection * wid1 = new TransitionSelection( view1 ); view1->addItem( wid1 ); view1->setWidgetResizable(true); _stack->addWidget( view1 ); wid1->setGameData( _data ); ItemScroll * view2 = new ItemScroll(); DecorationGroupSelection * wid2 = new DecorationGroupSelection( view2 ); view2->addItem( wid2 ); view2->setWidgetResizable(true); _stack->addWidget( view2 ); wid2->setGameData( _data ); ItemScroll * view3 = new ItemScroll(); BuildingSelection * wid3 = new BuildingSelection( view3 ); view3->addItem( wid3 ); view3->setWidgetResizable(true); _stack->addWidget( view3 ); wid3->setGameData( _data ); ItemScroll * view4 = new ItemScroll(); BaseSelection * wid4 = new BaseSelection( view4 ); view4->addItem( wid4 ); view4->setWidgetResizable(true); _stack->addWidget( view4 ); wid4->setGameData( _data ); ItemScroll * view5 = new ItemScroll(); LordSelection * wid5 = new LordSelection( view5 ); view5->addItem( wid5 ); view5->setWidgetResizable(true); _stack->addWidget( view5 ); wid5->setGameData( _data ); ItemScroll * view6 = new ItemScroll(); ArtefactSelection * wid6 = new ArtefactSelection( view6 ); view6->addItem( wid6 ); view6->setWidgetResizable(true); _stack->addWidget( view6 ); wid6->setGameData( _data ); ItemScroll * view7 = new ItemScroll(); BonusSelection * wid7 = new BonusSelection( view7 ); view7->addItem( wid7 ); view7->setWidgetResizable(true); _stack->addWidget( view7 ); wid7->setGameData( _data ); ItemScroll * view8 = new ItemScroll(); CreatureSelection * wid8 = new CreatureSelection( view8 ); view8->addItem( wid8 ); view8->setWidgetResizable(true); _stack->addWidget( view8 ); wid8->setGameData( _data ); ItemScroll * view9 = new ItemScroll(); ToolSelection * wid9 = new ToolSelection( _screen, view9 ); view9->addItem( wid9 ); view9->setWidgetResizable(true); _stack->addWidget( view9 ); wid9->setGameData( _data ); _stack->setCurrentIndex( 0 ); } void ItemSelector::handleLeftClick( GenericCell * cell ) { ( (ItemScroll *)_stack->currentWidget() )->handleLeftClick( cell ); theMap->computeStoppable(); } // // ----- ItemScroll ----- // ItemScroll::ItemScroll( QWidget * parent ) :QScrollArea( parent ) { _item = 0; QPalette palette; palette.setColor(backgroundRole(), Qt::lightGray ); setPalette(palette); setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); } void ItemScroll::addItem( ItemSelection * item ) { _item = item; setWidget( item ); } void ItemScroll::handleLeftClick( GenericCell * c ) { if( _item ) { _item->handleLeftClick( c ); } } attal-src-1.0-rc2/scenarioEditor/itemSelector.h0000644000175000017500000000415010620114151017225 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** itemSelector.h ** Allow selection of item panels ** ** Version : $Id: itemSelector.h,v 1.8 2007/05/08 15:34:01 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 21/12/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ITEMSELECTOR_H #define ITEMSELECTOR_H // generic include files // include files for QT #include #include // application specific include files /* ------------------------------ * ItemSelector * ------------------------------ */ class QComboBox; class QStackedWidget; class GenericCell; class GraphicalGameData; class ItemSelection; class Screen; /** comment for the class */ class ItemSelector : public QWidget { public: /** Constructor */ ItemSelector( GraphicalGameData * data, Screen * screen = 0, const char * name = 0 ); void handleLeftClick( GenericCell * ); private: enum ItemType { ItemTile = 0, ItemTransition, ItemDecoration, ItemBuilding, ItemBase, ItemLord, ItemArtefact, ItemBonus, ItemCreature, ItemTool }; void init(); QScrollArea * view; QComboBox * _selector; QStackedWidget * _stack; GraphicalGameData * _data; Screen * _screen; }; /** Scrollview for ItemSelection objects */ class ItemScroll : public QScrollArea { public: ItemScroll( QWidget * parent = 0 ); void addItem( ItemSelection * item ); void handleLeftClick( GenericCell * ); private: ItemSelection * _item; }; #endif // ITEMSELECTOR_H attal-src-1.0-rc2/scenarioEditor/propertiesBase.cpp0000644000175000017500000001735510761121041020125 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** propertiesItem.cpp ** Defines properties box for bases on map ** ** Version : $Id: propertiesBase.cpp,v 1.26 2008/02/26 23:34:57 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 29/12/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "propertiesBase.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/genericInsideBuilding.h" #include "libCommon/genericLord.h" #include "libCommon/genericPlayer.h" #include "libCommon/dataTheme.h" #include "libClient/askWidget.h" #include "libClient/gui.h" // // ----- PropertiesBase ----- // PropertiesBase::PropertiesBase( QList * players, QWidget * parent, const char * /* name */ ) :QDialog( parent, Qt::Dialog ) { setWindowTitle( tr( "Base properties" ) ); _players = players; _base = 0; _general = new GeneralPropertiesBase( players, 0 ); _units = new PropertiesBaseUnits( 0 ); _tabWidget = new QTabWidget( this ); _tabWidget->addTab( _general, tr( "General" ) ); _tabWidget->addTab( _units, tr( "Units" ) ); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCancel = new QPushButton( this ); pbCancel->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCancel ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); layH1->addWidget( pbCancel ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _tabWidget, 1 ); layout->addLayout( layH1 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( pbCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); } void PropertiesBase::accept() { _general->accept(); _units->accept(); QDialog::accept(); } void PropertiesBase::init( GenericBase * base ) { _base = base; _general->init( base ); _units->init( base ); } // // ----- GeneralPropertiesBase ----- // GeneralPropertiesBase::GeneralPropertiesBase( QList * players, QWidget * parent, const char * /* name */ ) : QWidget( parent ) { _base = 0; QLabel * ownerLabel = new QLabel( this ); ownerLabel->setText( tr( "Owner:" ) ); _ownerList = new QComboBox( this ); refresh( players ); _resBase = new AskCost( tr( "Res Base: " ), this ); _listBuilding = new QTreeWidget( this ); _listBuilding->setColumnCount( 1 ); QStringList labels; labels << tr( "Buildings" ); labels << tr( "Description " ); labels << tr( "Actions " ); _listBuilding->setHeaderLabels( labels ); _listBuilding->setMinimumHeight( 50 ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setSpacing( 5 ); layH1->addWidget( ownerLabel ); layH1->addWidget( _ownerList, 1 ); _name = new AskString( tr( "Name: " ), this ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->setSpacing( 5 ); layH2->addWidget( _listBuilding, 1 ); QHBoxLayout * layH = new QHBoxLayout(); layH->setMargin( 5 ); layH->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layH1 ); layout->addWidget( _name ); layout->addWidget( _resBase ); layout->addLayout( layH2, 1 ); layout->addLayout( layH ); layout->activate(); } void GeneralPropertiesBase::refresh( QList * players ) { _players = players; _ownerList->clear(); _ownerList->addItem( tr( "None" ) ); for( int i = 0; i < players->count(); i++ ) { GenericPlayer * player = players->at( i ); if( player ) { _ownerList->addItem( player->getName() ); } } } void GeneralPropertiesBase::accept() { setOwner(); QTreeWidgetItem * item; int i =0; uint nbRes = DataTheme.resources.count(); for( int i = 0; i < nbRes; i++ ) { _base->getResourceList()->setValue( i, _resBase->getValue( i ) ); } while( i < _listBuilding->topLevelItemCount() ) { item = _listBuilding->topLevelItem( i ); if( item ) { if( item->checkState(0) == Qt::Checked ) { if( ! _base->hasBuildingType( i ) ) { GenericInsideBuilding * building = new GenericInsideBuilding(); building->setRace( _base->getRace() ); building->setLevel( i ); _base->addBuilding( building ); } } else { if( _base->hasBuildingType( i ) ) { _base->removeBuildingType( i ); } } i++; } } _base->setName( _name->getValue() ); } void GeneralPropertiesBase::setOwner() { if( _base->getOwner() ) { _base->getOwner()->removeBase( _base ); } int num = _ownerList->currentIndex() -1 ; if( num < 0 ) { _base->setOwner( 0 ); } else { _base->setOwner( _players->at( num ) ); _players->at( num )->addBase( _base ); } } void GeneralPropertiesBase::init( GenericBase * base ) { _base = base; _listBuilding->clear(); int m =0; QTreeWidgetItem * item; uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { _resBase->setValue( i , _base->getResourceList()->getValue( i ) ); } for( uint i = 0; i <= DataTheme.bases.at( _base->getRace() )->getBuildingCount() - 1; i++ ) { InsideBuildingModel * building = DataTheme.bases.at( _base->getRace() )->getBuildingModel( i ); QStringList strlist; strlist << building->getName(); strlist << building->getDescription(); strlist << building->getBuildDescActions(); item = new QTreeWidgetItem( _listBuilding, strlist ); item->setCheckState(0, Qt::Unchecked ); } for( int j = 0; j < (int)_base->getBuildingCount(); j++ ) { GenericInsideBuilding * building = _base->getBuilding( j ); m = 0; for( uint k = 0; k < building->getLevel(); k++ ) { m++; } item = _listBuilding->topLevelItem( m ); if( item ) { item->setCheckState(0, Qt::Checked ); } } if( _base->getOwner() ) { _ownerList->setCurrentIndex( _base->getOwner()->getNum()+1 ); } else { _ownerList->setCurrentIndex( 0 ); } _name->setValue( _base->getName() ); } // // ----- PropertiesBaseUnits ----- // PropertiesBaseUnits::PropertiesBaseUnits( QWidget * parent, const char * /* name */) : QWidget( parent ) { _base = 0; QHBoxLayout * layH1 = new QHBoxLayout(); QHBoxLayout * layH2 = new QHBoxLayout(); for( int i = 0; i < MAX_UNIT; i++ ) { _troop[i] = new EditTroop( i, this ); if( i <= (MAX_UNIT / 2 ) ) { layH1->addWidget( _troop[i] ); } else { layH2->addWidget( _troop[i] ); } } layH1->addStretch( 1 ); layH2->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->addLayout( layH1 ); layout->addLayout( layH2 ); layout->addStretch( 1 ); layout->activate(); } void PropertiesBaseUnits::init( GenericBase * base ) { _base = base; for( int i = 0; i < MAX_UNIT; i++ ) { _troop[i]->init (_base->getUnit (i)); } } void PropertiesBaseUnits::accept() { for( int i = 0; i < MAX_UNIT; i++ ) { _troop[i]->save( i, _base ); } } bool PropertiesBaseUnits::hasNoneUnits () { bool hasUnits = false; for( int i = 0; i < MAX_UNIT; i++ ) { if (_troop[i]->hasUnits ()) { hasUnits = true; } } return (!hasUnits); } attal-src-1.0-rc2/scenarioEditor/propertiesBase.h0000644000175000017500000000527610740437744017612 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** propertiesBase.h ** Defines properties box for bases on map ** ** Version : $Id: propertiesBase.h,v 1.12 2008/01/07 15:06:12 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 29/12/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PROPERTIESBASE_H #define PROPERTIESBASE_H #include "propertiesLord.h" // generic include files // include files for QT #include #include // application specific include files #include "libCommon/genericPlayer.h" #include "libClient/askCost.h" class QComboBox; class QTabWidget; class QTreeWidget; class AskString; class GenericLord; class GenericBase; class GenericPlayer; class GeneralPropertiesBase; class PropertiesBaseUnits; /* ------------------------------ * PropertiesBase * ------------------------------ */ class PropertiesBase : public QDialog { Q_OBJECT public: /** Constructor */ PropertiesBase( QList * players, QWidget * parent = 0, const char * name = 0 ); void init( GenericBase * base ); public slots: virtual void accept(); private: QList * _players; GenericBase * _base; QTabWidget * _tabWidget; GeneralPropertiesBase * _general; PropertiesBaseUnits * _units; }; /** Dialog for editing the properties of the base */ class GeneralPropertiesBase : public QWidget { Q_OBJECT public: /** Constructor */ GeneralPropertiesBase( QList * players, QWidget * parent = 0, const char * name = 0 ); void init( GenericBase * base ); void refresh( QList * players ); void accept(); void setOwner(); private: QList * _players; GenericBase * _base; QTreeWidget * _listBuilding; QComboBox * _ownerList; AskString * _name; AskCost * _resBase; }; class PropertiesBaseUnits : public QWidget { public: PropertiesBaseUnits( QWidget * parent = 0, const char * name = 0 ); void init( GenericBase * base ); void accept(); bool hasNoneUnits (); protected: GenericBase * _base; EditTroop * _troop[MAX_UNIT]; }; #endif // PROPERTIESBASE_H attal-src-1.0-rc2/scenarioEditor/propertiesBuilding.cpp0000644000175000017500000001033110740456012021001 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** propertiesBuilding.cpp ** Defines properties box for buildings on map ** ** Version : $Id: propertiesBuilding.cpp,v 1.19 2008/01/07 17:06:18 lusum Exp $ ** ** Author(s) : Sardi Carlo - Pascal Audoux ** ** Date : 22/04/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "propertiesBuilding.h" // generic include files // include files for QT #include #include #include #include #include #include // application specific include files #include "libCommon/genericLord.h" #include "libCommon/genericPlayer.h" #include "libCommon/dataTheme.h" #include "libCommon/action.h" #include "libClient/gui.h" // // ----- propertiesBuilding ----- // PropertiesBuilding::PropertiesBuilding( QList * players, QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { setWindowTitle( tr( "building properties" ) ); _building = 0; QLabel * ownerLabel = new QLabel( this ); ownerLabel->setText( tr( "Owner:" ) ); _name = new QLabel( this ); _resBuil = new AskCost( tr( "Res Buil: " ), this ); _ownerList = new QComboBox( this ); refresh( players ); _listBuilding = new QListWidget( this ); QPushButton * pb = new QPushButton( this ); pb->setText( tr( "Ok" ) ); FIXEDSIZE( pb ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setSpacing( 5 ); layH1->addWidget( ownerLabel ); layH1->addWidget( _ownerList, 1 ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->setSpacing( 5 ); layH2->addWidget( _listBuilding, 1 ); QHBoxLayout * layH = new QHBoxLayout(); layH->setMargin( 5 ); layH->addStretch( 1 ); layH->addWidget( pb ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layH1 ); layout->addStretch( 1 ); layout->addWidget( _name ); layout->addWidget( _resBuil ); layout->addWidget( _listBuilding ); layout->addLayout( layH ); layout->activate(); connect( pb, SIGNAL( clicked() ), SLOT( slot_accept() ) ); connect( _ownerList, SIGNAL( activated( int ) ), SLOT( slot_owner( int ) ) ); } void PropertiesBuilding::refresh( QList * players ) { _players = players; _ownerList->clear(); _ownerList->addItem( tr( "None" ) ); for( int i = 0; i < players->count(); i++ ) { GenericPlayer * player = players->at( i ); if( player ) { _ownerList->addItem( player->getName() ); } } } void PropertiesBuilding::slot_accept() { uint nbRes = DataTheme.resources.count(); for( int i = 0; i < nbRes; i++ ) { _building->getResourceList()->setValue( i, _resBuil->getValue( i ) ); } accept(); } void PropertiesBuilding::slot_owner( int num ) { if( _building->getOwner() ) { _building->getOwner()->removeBuilding( _building ); } if( num == 0 ) { _building->setOwner( 0 ); } else { _building->setOwner( _players->at( num-1 ) ); _players->at( num-1 )->addBuilding( _building ); } } void PropertiesBuilding::init( GenericBuilding * building ) { _building = building; _listBuilding->clear(); _name->setText( _building->getName() ); uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { _resBuil->setValue( i , _building->getResourceList()->getValue( i ) ); } for( int type = Action::DATE; type< Action::LAST; type++ ){ QList action = _building->getActionList((Action::ActionType) type); for( int i = 0; i < action.count(); i++ ) { _listBuilding->addItem( action.at(i)->getDescription( true )); } } if( _building->getOwner() ) { _ownerList->setCurrentIndex( _building->getOwner()->getNum()+1 ); } else { _ownerList->setCurrentIndex( 0 ); } } attal-src-1.0-rc2/scenarioEditor/propertiesBuilding.h0000644000175000017500000000400110740456013020444 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** propertiesBuilding.h ** Defines properties box for buildings on map ** ** Version : $Id: propertiesBuilding.h,v 1.6 2008/01/07 17:06:19 lusum Exp $ ** ** Author(s) : Sardi Carlo - Pascal Audoux ** ** Date : 22/04/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PROPERTIESBUILDING_H #define PROPERTIESBUILDING_H // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/genericPlayer.h" #include "libCommon/genericBuilding.h" #include "libClient/askCost.h" class QComboBox; class QListWidget; class GenericLord; class GenericBuilding; /* ------------------------------ * propertiesBuilding * ------------------------------ */ /** Dialog for editing the properties of the building */ class PropertiesBuilding : public QDialog { Q_OBJECT public: /** Constructor */ PropertiesBuilding( QList * players, QWidget * parent = 0, const char * name = 0 ); void init( GenericBuilding * building ); void refresh( QList * players ); public slots: void slot_accept(); void slot_owner( int ); private: QList * _players; GenericBuilding * _building; QListWidget * _listBuilding; QLabel * _name; QComboBox * _ownerList; AskCost * _resBuil; }; #endif // PROPERTIESBUILDING_H attal-src-1.0-rc2/scenarioEditor/propertiesCreature.cpp0000644000175000017500000001523110740456013021023 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** propertiesCreature.cpp ** Allow selection of specific creature panels ** ** Author(s) : Nickolay Semenov ** ** Date : 18/06/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "propertiesCreature.h" // generic include files // include files for QT #include #include #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/genericMapCreature.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" PropertiesCreature::PropertiesCreature (QWidget * parent, const char * name) :QDialog (parent, Qt::Dialog) { setWindowTitle( QString ( name)); _creaturePix = new QLabel( this ); _resCrea= new AskCost( tr( "Res Crea: " ), this ); _creatureBehaviour = new AskCombo( tr( "Behaviour of creatures: " ), this ); _creatureBehaviour->insertItem( GenericMapCreature::getBehaviourString( GenericMapCreature::Obedient ) ); _creatureBehaviour->insertItem( GenericMapCreature::getBehaviourString( GenericMapCreature::Friendly ) ); _creatureBehaviour->insertItem( GenericMapCreature::getBehaviourString( GenericMapCreature::Neutral ) ); _creatureBehaviour->insertItem( GenericMapCreature::getBehaviourString( GenericMapCreature::Aggressive ) ); _creatureBehaviour->insertItem( GenericMapCreature::getBehaviourString( GenericMapCreature::Hostile ) ); _creatureFlee = new AskBool( tr( "Never flee: " ), this ); _lookingRight = new AskBool( tr( "Looking at right side: " ), this ); _creatureGrowth = new AskCombo( tr( "Growth of creatures: " ), this ); _creatureGrowth->insertItem( GenericMapCreature::getGrowthString( GenericMapCreature::Stable ) ); _creatureGrowth->insertItem( GenericMapCreature::getGrowthString( GenericMapCreature::FixedPercentage ) ); _creatureGrowth->insertItem( GenericMapCreature::getGrowthString( GenericMapCreature::VariablePercentage ) ); _growthParam0 = new AskInt( tr( "Growth param 0: " ), this ); _growthParam0->setMinValue( 0 ); _growthParam0->setMaxValue( 1000 ); _growthParam0->setEnabled( false ); _growthParam1 = new AskInt( tr( "Growth param 1: " ), this ); _growthParam1->setMinValue( 0 ); _growthParam1->setMaxValue( 1000 ); _growthParam0->setEnabled( false ); QVBoxLayout * layV1 = new QVBoxLayout(); layV1->setMargin( 5 ); layV1->addWidget( _creaturePix, 1 ); layV1->addSpacing( 10 ); layV1->addWidget( _creatureBehaviour, 1 ); layV1->addWidget( _creatureFlee, 1 ); layV1->addWidget( _lookingRight, 1 ); layV1->addWidget( _creatureGrowth, 1 ); layV1->addWidget( _growthParam0, 1 ); layV1->addWidget( _growthParam1, 1 ); QVBoxLayout * layV2 = new QVBoxLayout(); layV2->setMargin( 5 ); layV2->setSpacing( 5 ); layV2->addStretch( 1 ); AskInt * stack; QString label; _creatureStacks.resize( MAX_UNIT ); for( uint i = 0; i < MAX_UNIT; i++ ) { label.sprintf( QString (tr( "Number of creatures in stack %1: " ).arg(i)).toLatin1().constData() ); stack = new AskInt( label, this ); stack->setMinValue( 0 ); stack->setMaxValue( 10000 ); layV2->addWidget( stack ); layV2->addStretch( 1 ); if( _creatureStacks[ i] ) { delete _creatureStacks[ i]; } _creatureStacks[ i] = stack ; } QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setSpacing( 5 ); layH1->setMargin( 5 ); layH1->addLayout( layV1, 1 ); layH1->addLayout( layV2, 1 ); QPushButton * butOk = new QPushButton( this ); butOk->setText( tr( "Ok" ) ); FIXEDSIZE( butOk ); QPushButton * butCan = new QPushButton( this ); butCan->setText( tr( "Cancel" ) ); FIXEDSIZE( butCan ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->setMargin( 5 ); layH2->setSpacing( 5 ); layH2->addStretch( 1 ); layH2->addWidget( butOk ); layH2->addStretch( 1 ); layH2->addWidget( butCan ); layH2->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layH1, 1 ); layout->addWidget( _resCrea ); layout->addLayout( layH2 ); layout->activate(); connect( butOk, SIGNAL( clicked() ), this, SLOT( slot_accept() ) ); connect( butCan, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( _creatureGrowth, SIGNAL( sig_activated( int ) ), SLOT( slot_growthMode( int ) ) ); } void PropertiesCreature::init( GenericMapCreature * creature ) { _creature = creature; _creaturePix->setPixmap( ImageTheme.getMapCreature( creature ) ); _creatureBehaviour->setCurrentItem( (int)creature->getBehaviour() ); _creatureFlee->setValue( ! creature->isFleeing() ); _lookingRight->setValue( creature->isLookingRight() ); _creatureGrowth->setCurrentItem( (int)creature->getGrowthMode() ); _growthParam0->setValue( creature->getGrowthParam( 0 ) ); _growthParam1->setValue( creature->getGrowthParam( 1 ) ); slot_growthMode( _creatureGrowth->currentItem() ); for( uint i = 0; i < MAX_UNIT; i++ ) { _creatureStacks[i]->setValue( creature->getStack( i ) ); } uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { _resCrea->setValue( i , _creature->getResourceList()->getValue( i ) ); } } void PropertiesCreature::slot_accept() { uint nbRes = DataTheme.resources.count(); for( int i = 0; i < nbRes; i++ ) { _creature->getResourceList()->setValue( i, _resCrea->getValue( i ) ); } _creature->setGrowthMode( (GenericMapCreature::GrowthMode)_creatureGrowth->currentItem() ); _creature->setGrowthParam( 0, _growthParam0->getValue() ); _creature->setGrowthParam( 1, _growthParam1->getValue() ); _creature->setBehaviour( (GenericMapCreature::CreatureBehaviour)_creatureBehaviour->currentItem() ); _creature->setFleeing( ! _creatureFlee->getValue() ); _creature->setLookingRight( _lookingRight->getValue() ); for( uint i = 0; i < MAX_UNIT; i++ ) { _creature->setStack( i, _creatureStacks[i]->getValue() ); } accept(); } void PropertiesCreature::slot_growthMode( int mode ) { if( mode == 0 ) { _growthParam0->setEnabled( false ); _growthParam1->setEnabled( false ); } else if( mode == 1 ) { _growthParam0->setEnabled( true ); _growthParam1->setEnabled( false ); } else { _growthParam0->setEnabled( true ); _growthParam1->setEnabled( true ); } } attal-src-1.0-rc2/scenarioEditor/propertiesCreature.h0000644000175000017500000000335610740456013020475 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** propertiesCreature.h ** Defines properties box for creatures on map ** ** ** Author(s) : Nickolay Semenov ** ** Date : 17/06/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PROPERTIESCREATURE_H #define PROPERTIESCREATURE_H // generic include files // include files for QT #include #include // application specific include files #include "libClient/askCost.h" #include "libClient/askWidget.h" class QLabel; class GenericMapCreature; /** Dialog for editing properties of the creature on map*/ class PropertiesCreature : public QDialog { Q_OBJECT public: PropertiesCreature( QWidget * parent = 0, const char * name = 0 ); void init( GenericMapCreature * creature ); private: GenericMapCreature * _creature; QLabel * _creaturePix; QVector _creatureStacks; AskCombo * _creatureBehaviour; AskCombo * _creatureGrowth; AskInt * _growthParam0, * _growthParam1; AskBool * _creatureFlee; AskBool * _lookingRight; AskCost * _resCrea; private slots: void slot_accept (); void slot_growthMode( int mode ); }; #endif // PROPERTIESCREATURE_H attal-src-1.0-rc2/scenarioEditor/propertiesEvent.cpp0000644000175000017500000001473410522705153020341 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** propertiesEvent.cpp ** Defines properties box for events on map ** ** Version : $Id: propertiesEvent.cpp,v 1.9 2006/11/03 18:28:59 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 24/04/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "propertiesEvent.h" // generic include files // include files for QT #include #include #include #include #include // application specific include files #include "libCommon/artefact.h" #include "libCommon/dataTheme.h" #include "libCommon/genericBonus.h" #include "libCommon/genericChest.h" #include "libCommon/genericEvent.h" #include "libCommon/log.h" #include "libClient/gui.h" PropertiesEvent::PropertiesEvent( GenericEvent * event, QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { _event = event; createContentView(); QPushButton * pbCondition = new QPushButton( this ); pbCondition->setText( tr( "Condition" ) ); FIXEDSIZE( pbCondition ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pbCondition ); layH1->addStretch( 1 ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addStretch( 1 ); layH2->addWidget( pbCan ); layH2->addStretch( 1 ); layH2->addWidget( pbOk ); layH2->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addWidget( _content, 1 ); layout->addLayout( layH1 ); layout->addLayout( layH2 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( slot_accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); } void PropertiesEvent::slot_accept() { _content->save(); accept(); } void PropertiesEvent::createContentView() { _content = 0; if( _event ) { switch( _event->getType() ) { case GenericEvent::EventArtefact: _content = (PropertiesEventContent *)( new PropertiesArtefact( _event->getArtefact(), this ) ); break; case GenericEvent::EventBonus: _content = (PropertiesEventContent *)( new PropertiesBonus( _event->getBonus(), this ) ); break; case GenericEvent::EventChest: _content = (PropertiesEventContent *)( new PropertiesChest( _event->getChest(), this ) ); break; default: logEE( "Should not happen" ); } } } // //----- PropertiesArtefact ----- // PropertiesArtefact::PropertiesArtefact( GenericArtefact * artefact, QWidget * parent, const char * name ) : PropertiesEventContent( parent, name ) { _artefact = artefact; } // //----- PropertiesBonus ----- // PropertiesBonus::PropertiesBonus( GenericBonus * bonus, QWidget * parent, const char * /* name*/ ) : PropertiesEventContent( parent ) { _bonus = bonus; switch( _bonus->getType() ) { case GenericBonus::BonusResource: displayResource(); break; case GenericBonus::BonusPrimSkill: displayPrimSkill(); break; case GenericBonus::BonusSkill: displaySkill(); break; case GenericBonus::BonusSpell: displaySpell(); break; } } void PropertiesBonus::displayResource() { QLabel * labResource = new QLabel( this ); labResource->setText( tr( "Resource: " ) + DataTheme.resources.getRessource( _bonus->getParam( 0 ) ) ); FIXEDSIZE( labResource ); _fixed = new AskInt( tr( "Fixed value: " ), this ); _fixed->setMinValue( 0 ); _fixed->setMaxValue( 10000 ); _fixed->setValue( _bonus->getParam( 2 ) ); FIXEDSIZE( _fixed ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( labResource ); layout->addWidget( _fixed ); layout->addStretch( 1 ); layout->activate(); } void PropertiesBonus::displayPrimSkill() { _primSkill = new AskCombo( tr( "Primary skill: " ), this ); _primSkill->insertItem( tr( "Attack" ) ); _primSkill->insertItem( tr( "Defense" ) ); _primSkill->insertItem( tr( "Power" ) ); _primSkill->insertItem( tr( "Knowledge" ) ); _primSkill->insertItem( tr( "Morale" ) ); _primSkill->insertItem( tr( "Luck" ) ); _primSkill->insertItem( tr( "Charisma" ) ); _primSkill->setCurrentItem( _bonus->getParam( 0 ) ); _value = new AskInt( tr( "Add value: " ), this ); _value->setValue( _bonus->getParam( 1 ) ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _primSkill ); layout->addWidget( _value ); layout->addStretch( 1 ); layout->activate(); } void PropertiesBonus::displaySkill() { QLabel * lab = new QLabel( this ); lab->setText( tr( "Bonus for secondary skills are not yet implemented" ) ); FIXEDSIZE( lab ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( lab ); layout->addStretch( 1 ); layout->activate(); } void PropertiesBonus::displaySpell() { QLabel * lab = new QLabel( this ); lab->setText( tr( "Bonus for spells are not yet implemented" ) ); FIXEDSIZE( lab ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( lab ); layout->addStretch( 1 ); layout->activate(); } void PropertiesBonus::save() { switch( _bonus->getType() ) { case GenericBonus::BonusResource: { uint resource = _bonus->getParam( 0 ); _bonus->clearParams(); _bonus->addParam( resource ); _bonus->addParam( 0 ); _bonus->addParam( _fixed->getValue() ); } break; case GenericBonus::BonusPrimSkill: _bonus->clearParams(); _bonus->addParam( _primSkill->currentItem() ); _bonus->addParam( _value->getValue() ); break; case GenericBonus::BonusSkill: break; case GenericBonus::BonusSpell: break; } } // //----- PropertiesChest ----- // PropertiesChest::PropertiesChest( GenericChest * chest, QWidget * parent, const char * /*name*/ ) : PropertiesEventContent( parent ) { _chest = chest; } attal-src-1.0-rc2/scenarioEditor/propertiesEvent.h0000644000175000017500000000627110616363716020014 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** propertiesEvent.h ** Defines properties box for events on map ** ** Version : $Id: propertiesEvent.h,v 1.7 2007/05/03 13:46:54 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 24/04/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PROPERTIESEVENT_H #define PROPERTIESEVENT_H // generic include files // include files for QT #include #include // application specific include files #include "libClient/askWidget.h" class GenericArtefact; class GenericBonus; class GenericChest; class GenericEvent; class PropertiesEventContent; /* ------------------------------ * PropertiesEvent * ------------------------------ */ class PropertiesEvent : public QDialog { Q_OBJECT public: /** Constructor */ PropertiesEvent( GenericEvent * event, QWidget * parent = 0, const char * name = 0 ); public slots: void slot_accept(); protected: void createContentView(); GenericEvent * _event; PropertiesEventContent * _content; }; /* ------------------------------ * PropertiesEventContent * ------------------------------ */ class PropertiesEventContent : public QWidget { public: /** Constructor */ PropertiesEventContent( QWidget * parent = 0, const char * /*name*/ = 0 ) : QWidget( parent ) {} virtual void save() = 0; }; /* ------------------------------ * PropertiesArtefact * ------------------------------ */ class PropertiesArtefact : public PropertiesEventContent { public: PropertiesArtefact( GenericArtefact * artefact, QWidget * parent = 0, const char * name = 0 ); void save() {} protected: GenericArtefact * _artefact; }; /* ------------------------------ * PropertiesBonus * ------------------------------ */ class PropertiesBonus : public PropertiesEventContent { Q_OBJECT public: PropertiesBonus( GenericBonus * bonus, QWidget * parent = 0, const char * name = 0 ); void save(); protected: void displayResource(); void displayPrimSkill(); void displaySkill(); void displaySpell(); GenericBonus * _bonus; AskInt * _fixed; AskCombo * _primSkill; AskInt * _value; }; /* ------------------------------ * PropertiesChest * ------------------------------ */ class PropertiesChest : public PropertiesEventContent { public: PropertiesChest( GenericChest * chest, QWidget * parent = 0, const char * name = 0 ); void save() {} protected: GenericChest * _chest; }; #endif // PROPERTIESEVENT_H attal-src-1.0-rc2/scenarioEditor/propertiesLord.cpp0000644000175000017500000005436310713710224020157 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** propertiesLord.cpp ** this is a template for all .cpp files ** ** Version : $Id: propertiesLord.cpp,v 1.34 2007/11/05 21:52:20 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 07/12/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "propertiesLord.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/artefactManager.h" #include "libCommon/dataTheme.h" #include "libCommon/genericLord.h" #include "libClient/askWidget.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" extern QString IMAGE_PATH; // // ----- PropertiesLord ----- // PropertiesLord::PropertiesLord( QList * players, QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { setWindowTitle( tr( "Lord properties" ) ); _players = players; _lord = 0; _tabWidget = new QTabWidget( this ); _general = new PropertiesLordGeneral( players, 0 ); _units = new PropertiesLordUnits( 0 ); _artefacts = new PropertiesLordArtefacts( 0 ); _warMachines = new PropertiesLordWarMachines( 0 ); _technics = new PropertiesLordTechnics( 0 ); _tabWidget->addTab( _general, tr( "General" ) ); _tabWidget->addTab( _units, tr( "Units" ) ); _tabWidget->addTab( _artefacts, tr( "Artefacts" ) ); _tabWidget->addTab( _warMachines, tr( "War Machines" ) ); _tabWidget->addTab( _technics, tr( "Technics" ) ); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCancel = new QPushButton( this ); pbCancel->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCancel ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); layH1->addWidget( pbCancel ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _tabWidget, 1 ); layout->addLayout( layH1 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( pbCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); } void PropertiesLord::accept() { if(_units->hasNoneUnits() ) { QMessageBox::warning( this, tr( "Lord's properties error" ), tr( "The lord must have at least 1 unit" ) ); return; } if( _general->hasNoOwner() ) { QMessageBox::warning( this, tr( "Lord's properties error" ), tr( "The lord must have an owner" ) ); return; } _general->accept(); _units->accept(); _artefacts->accept(); _warMachines->accept(); _technics->accept(); QDialog::accept(); } void PropertiesLord::init( GenericLord * lord, uint * ids, int numLords ) { _lord = lord; _general->init( lord, ids, numLords ); _units->init( lord ); _artefacts->init( lord ); _warMachines->init ( lord ); _technics->init ( lord ); } // // ----- GeneralCharacteristic----- // GeneralCharacteristic::GeneralCharacteristic (int number, QWidget* parent , const char * ) : PixmapSpinBox( parent ) { _num = number; setFrameStyle( QFrame::Panel | QFrame::Raised ); setLineWidth ( 1 ); getPixmap (); QString text = getText (); PixmapSpinBox::init( & _pix, text, true ); }; void GeneralCharacteristic::init (GenericLord* lord) { LordCharac charac = (LordCharac)_num; int value = lord->getBaseCharac ( charac ); setRange( 0, 10000 ); setValue( value ); } void GeneralCharacteristic::save ( GenericLord* lord ) { int value = getValue( ); LordCharac charac = (LordCharac)_num; lord->setBaseCharac( charac, value); } void GeneralCharacteristic::getPixmap () { QString path = IMAGE_PATH + "misc/ico_"; LordCharac charac = (LordCharac)_num; switch( charac ) { case ATTACK: path += "attack"; break; case DEFENSE: path += "defense"; break; case POWER: path += "power"; break; case KNOWLEDGE: path += "knowledge"; break; case MAXMOVE: path += "move"; break; case MOVE: break; case MAXTECHNICPOINT: break; case TECHNICPOINT: break; case MORALE: path += "morale"; break; case LUCK: path += "luck"; break; case VISION: path += "vision"; break; case EXPERIENCE: path += "experience"; break; case CHARISMA: path += "charisma"; break; default: break; } path += ".png"; if( ! _pix.load( path ) ) { _pix = QPixmap( 10, 10 ); _pix.fill (); } } QString GeneralCharacteristic::getText() { QString text = ""; LordCharac charac = (LordCharac)_num; switch( charac ) { case ATTACK: text = "Attack"; break; case DEFENSE: text = "Defense"; break; case POWER: text = "Power"; break; case KNOWLEDGE: text = "Knowledge"; break; case MOVE: break; case MAXMOVE: text = "Maxmove"; break; case MAXTECHNICPOINT: break; case TECHNICPOINT: break; case MORALE: text = "Morale"; break; case LUCK: text = "Luck"; break; case VISION: text = "Vision"; break; case EXPERIENCE: text = "Experience"; break; case CHARISMA: text = "Charisma"; break; default: break; } return text; } // // ----- PropertiesLordGeneral ----- // PropertiesLordGeneral::PropertiesLordGeneral( QList * players, QWidget * parent, const char * /* name*/ ) : QWidget( parent ) { QLabel* playerLabel = new QLabel( this ); playerLabel->setText( tr( "Select player:" ) ); FIXEDSIZE (playerLabel); _lord = 0; _comboPlayer = new QComboBox( this ); FIXEDSIZE( _comboPlayer ); _comboPlayer->setFixedWidth (250); _listLords = new QListWidget( this ); _listLords->setFixedSize( 250, 150 ); _listLords->setSelectionMode ( QAbstractItemView::SingleSelection ); _faceLord = new QLabel( this ); _defaultButton = new QPushButton (this); _defaultButton->setText( tr( "Default" ) ); FIXEDSIZE (_defaultButton); connect( _defaultButton, SIGNAL( clicked () ), this, SLOT( slot_defaultButtonPushed() ) ); QVBoxLayout * layout = new QVBoxLayout; layout->setSpacing( 5 ); layout->addWidget( playerLabel , 1, Qt::AlignHCenter ); layout->addWidget( _comboPlayer , 1 , Qt::AlignHCenter ); layout->addWidget( _listLords, 1 ); layout->addWidget( _faceLord, 1, Qt::AlignHCenter ); layout->addWidget( _defaultButton, 1, Qt::AlignHCenter ); layout->activate(); _players = players; QGridLayout* gridLayout = new QGridLayout (); gridLayout->setSpacing (2); int secondNum = 1; for( int num = 0; num < 9; ) { if( ( (LordCharac)secondNum == MOVE ) || ((LordCharac)secondNum == TECHNICPOINT) || ((LordCharac)secondNum == MAXTECHNICPOINT ) ) { secondNum++; } else { generalChar[num] = new GeneralCharacteristic (secondNum , this); secondNum++; FIXEDSIZE (generalChar[num]); gridLayout->addWidget (generalChar[num], (num) / 2 , num % 2); num++; } } gridLayout->activate (); QHBoxLayout* hlayout = new QHBoxLayout (this); hlayout->addLayout (layout); hlayout->addLayout (gridLayout , 1); hlayout->activate (); } void PropertiesLordGeneral::init( GenericLord * lord, uint * ids, uint numLords ) { uint num; _lord = lord; _comboPlayer->clear(); _comboPlayer->addItem( QString("No player"), 0 ); for( int i = 0; i < _players->count(); i++ ) { QString title = QString::number( i ) + " - " + _players->at( i )->getName(); _comboPlayer->addItem( title, i+1 ); } if( lord->getOwner() ) { _comboPlayer->setCurrentIndex( lord->getOwner()->getNum()+1 ); } else { _comboPlayer->setCurrentIndex( 0 ); } for( num = 0; num < 9; num++ ) { generalChar[num]->init(lord); } uint cnt = 0; uint nbLords = DataTheme.lords.count(); for( num = 1; num < nbLords; num++ ) { bool isIdUsed = false; for( uint i = 0; i < numLords; i++ ) { if( num == ids[i] ) { isIdUsed = true; } } if( !isIdUsed ) { QString string = QString::number (num) + " - " + DataTheme.lords.at(num)->getName() + " (" + DataTheme.creatures.getRace( DataTheme.lords.at(num)->getRace () )->getName() + ")"; _listLords->addItem( string ); _ids[cnt] = num; cnt++; } } connect( _listLords, SIGNAL( currentItemChanged ( QListWidgetItem *, QListWidgetItem * ) ), this, SLOT( slot_lordChanged() ) ); int numInList = 0; for( uint i = 0; i < cnt; i++ ) { if( _ids[i] == lord->getId() ) { numInList = i; } } _listLords->setCurrentRow( numInList ); slot_lordChanged(); } void PropertiesLordGeneral::slot_lordChanged () { int index = _listLords->currentRow(); TRACE("slot_lordChanged index %d", index); QPixmap* pix = ImageTheme.getLordPixmap(_ids[index] ); if (!pix) return; _faceLord->setPixmap (*pix); } void PropertiesLordGeneral::slot_defaultButtonPushed () { int index = _listLords->currentRow(); TRACE("slot_defaultButtonPushed index %d", index); GenericLord lord; lord.setId(_ids[index]); for (int num = 0; num < 9; num++) { generalChar[num]->init(&lord); } } void PropertiesLordGeneral::accept() { if( _lord->getId() != _ids[_listLords->currentRow() ] ) { _lord->setId( _ids[_listLords->currentRow() ] ); } if( _lord->getOwner() ) { _lord->getOwner()->removeLord( _lord ); } int idPlayer = _comboPlayer->currentIndex()-1 ; if( idPlayer > -1 ) { _lord->setOwner( _players->at( idPlayer ) ); _players->at( idPlayer )->addLord( _lord ); } for( int num = 0; num < 9; num++ ) { generalChar[num]->save( _lord ); } } bool PropertiesLordGeneral::hasNoOwner() { int idPlayer = _comboPlayer->currentIndex(); if ( idPlayer ) { return false; } return true; } // // ----- PropertiesLordUnits ----- // PropertiesLordUnits::PropertiesLordUnits( QWidget * parent, const char * /* name*/ ) : QWidget( parent ) { _lord = 0; QHBoxLayout * layH1 = new QHBoxLayout(); QHBoxLayout * layH2 = new QHBoxLayout(); for( int i = 0; i < MAX_UNIT; i++ ) { _troop[i] = new EditTroop( i, this ); if( i <= (MAX_UNIT / 2 ) ) { layH1->addWidget( _troop[i] ); } else { layH2->addWidget( _troop[i] ); } } layH1->addStretch( 1 ); layH2->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->addLayout( layH1 ); layout->addLayout( layH2 ); layout->addStretch( 1 ); layout->activate(); } void PropertiesLordUnits::init( GenericLord * lord ) { _lord = lord; for( int i = 0; i < MAX_UNIT; i++ ) { _troop[i]->init (_lord->getUnit (i)); } } void PropertiesLordUnits::accept() { for( int i = 0; i < MAX_UNIT; i++ ) { _troop[i]->save( i, _lord ); } } bool PropertiesLordUnits::hasNoneUnits () { bool hasUnits = false; for( int i = 0; i < MAX_UNIT; i++ ) { if (_troop[i]->hasUnits ()) { hasUnits = true; } } return (!hasUnits); } // // ----- EditTroop ----- // EditTroop::EditTroop( int num, QWidget * parent, const char * /*name*/ ) : QFrame( parent ) { _unit = 0; setFrameStyle( QFrame::Panel | QFrame::Raised ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); QLabel * label = new QLabel( this ); label->setText( "Unit " + QString::number( num ) ); FIXEDSIZE( label ); layout->addWidget( label ); _race = new AskCombo( tr( "Race : " ), this ); _race->setCurrentItem( 0 ); layout->addWidget( _race ); _name = new AskCombo( tr( "Name : " ), this ); layout->addWidget( _name ); _number = new AskInt( tr( "Number : " ), this ); _number->setMaxValue( 65535 ); layout->addWidget( _number ); layout->addStretch( 1 ); layout->activate(); updateData(); connect( _race, SIGNAL( sig_activated( int ) ), SLOT( slot_raceChanged( int ) ) ); } bool EditTroop::hasUnits () { return (_number->getValue () > 0); } void EditTroop::slot_raceChanged( int race ) { _name->clear(); for( int i = 0; i < DataTheme.creatures.getRace( race )->count(); i++ ) { _name->insertItem( DataTheme.creatures.getRace( race )->at( i )->getName() ); } } void EditTroop::updateData() { int race = _race->currentItem(); _race->clear(); for( uint i = 0; i < DataTheme.countRace(); i++ ) { _race->insertItem( DataTheme.creatures.getRace( i )->getName() ); } if( _unit ) { _race->setCurrentItem( _unit->getRace() ); } else { _race->setCurrentItem( race ); } _name->clear(); if(_race->currentItem() >= 0) { for( int i = 0; i < DataTheme.creatures.getRace( _race->currentItem() )->count(); i++ ) { _name->insertItem( DataTheme.creatures.getRace( _race->currentItem() )->at( i )->getName() ); } } } void EditTroop::clear() { _race->setCurrentItem( 0 ); _name->setCurrentItem( 0 ); _number->setValue( 0 ); } void EditTroop::init( GenericFightUnit * unit ) { _unit = unit; if( unit ) { _race->setCurrentItem( unit->getRace() ); slot_raceChanged( unit->getRace() ); _name->setCurrentItem( unit->getLevel() ); _number->setValue( unit->getNumber() ); } else { clear(); } } void EditTroop::save( int i, GenericLord * lord ) { GenericFightUnit * unit = lord->getUnit( i ); if( _number->getValue() > 0 ) { if( ! unit ) { unit = new GenericFightUnit(); } unit->setCreature( _race->currentItem(), _name->currentItem() ); unit->setNumber( _number->getValue() ); lord->setUnit( i, unit ); } else { if( unit ) { delete unit; } lord->setUnit( i, 0 ); } } void EditTroop::save( int i, GenericBase * base ) { GenericFightUnit * unit = base->getUnit( i ); if( _number->getValue() > 0 ) { if( ! unit ) { unit = new GenericFightUnit(); } unit->setCreature( _race->currentItem(), _name->currentItem() ); unit->setNumber( _number->getValue() ); base->setUnit( i, unit ); } else { if( unit ) { delete unit; } base->setUnit( i, 0 ); } } // // ----- PropertiesLordArtefacts ----- // PropertiesLordArtefacts::PropertiesLordArtefacts( QWidget * parent, const char * /*name*/ ) : DoubleTableWidget( parent ) { _leftList->setHorizontalHeaderLabels( QStringList(tr( "Common artefacts list" )) ); _rightList->setHorizontalHeaderLabels( QStringList(tr( "Lord's artefacts list" )) ); } void PropertiesLordArtefacts::accept() { _lord->getArtefactManager()->clearArtefacts(); uint nbArtefacts = DataTheme.artefacts.count(); for( uint i = 0; i < nbArtefacts; i++ ) { if( _listItems[i] ) { _lord->getArtefactManager()->addArtefact( i ); } } } void PropertiesLordArtefacts::fillList() { uint nbArtefacts = DataTheme.artefacts.count(); setRowTable(nbArtefacts); for( uint id = 0; id < nbArtefacts; id++ ) { GenericArtefactModel* artefactModel = DataTheme.artefacts.at(id); QString artefactName = artefactModel->getName(); QPixmap* pix = ImageTheme.getArtefactIcon( id ); QTableWidgetItem * item = new QTableWidgetItem(artefactName); item->setIcon(QIcon(*pix)); item->setFlags(Qt::ItemIsSelectable); item->setTextAlignment(Qt::AlignVCenter); _leftList->setItem(id, 0, item); QTableWidgetItem * item2 = new QTableWidgetItem(artefactName); item2->setIcon(QIcon(*pix)); item2->setFlags(Qt::ItemIsSelectable); item2->setTextAlignment(Qt::AlignVCenter); _rightList->setItem(id, 0, item2); _listItems[id] = false; for( uint cnt = 0; cnt < _lord->getArtefactManager()->getArtefactNumber(); cnt++ ) { GenericLordArtefact* lordsArtefact = _lord->getArtefactManager()->getArtefact(cnt); if( lordsArtefact->getType() == id ) { _listItems[id] = true; } } } refreshList (); } void PropertiesLordArtefacts::refreshList () { uint nbArtefacts = DataTheme.artefacts.count(); for( uint i = 0; i < nbArtefacts; i++ ) { if( ! _listItems[i] ) { _leftList->showRow( i ); _rightList->hideRow( i ); } else { _leftList->hideRow( i ); _rightList->showRow( i ); } } _leftList->resizeColumnsToContents(); _rightList->resizeColumnsToContents(); /// XXX: It's not ideal, I know - may be YOU can do it better :) } // // ----- PropertiesLordWarMachines ----- // PropertiesLordWarMachines::PropertiesLordWarMachines( QWidget * parent, const char * /* name*/ ) : DoubleTableWidget( parent ) { _leftList->setHorizontalHeaderLabels( QStringList(tr( "Common war machines list" )) ); _rightList->setHorizontalHeaderLabels( QStringList(tr( "Lord's war machines list" )) ); } void PropertiesLordWarMachines::accept() { uint nbMachineLord = _lord->getMachineNumber(); for( uint num = 0; num < nbMachineLord; num++ ) { _lord->removeMachine( 0 ); } uint nbMachine = DataTheme.machines.count(); for( uint id = 0; id < nbMachine; id++ ) { if( _listItems[id] ) { _lord->addMachine( id ); } } } void PropertiesLordWarMachines::fillList() { uint nbMachines = DataTheme.machines.count(); setRowTable(nbMachines); for( uint id = 0; id < nbMachines; id++ ) { QString machineName = DataTheme.machines.at(id)->getName(); // XXX: We need it ! QPixmap* pix = ImageTheme.getWarMachineIcon( id ); QTableWidgetItem * item = new QTableWidgetItem(machineName); item->setTextAlignment(Qt::AlignVCenter); item->setFlags(Qt::ItemIsSelectable); _leftList->setItem(id, 0, item); // XXX: _warMachinesList->setPixmap (id, 0, *pix); QTableWidgetItem * item2 = new QTableWidgetItem(machineName); item2->setTextAlignment(Qt::AlignVCenter); item2->setFlags(Qt::ItemIsSelectable); _rightList->setItem(id, 0, item2); // XXX: _lordsWarMachinesList->setPixmap (id, 0, *pix); _listItems[id] = false; for( uint cnt = 0; cnt < _lord->getMachineNumber(); cnt++) { if( _lord->getMachine(cnt) == id ) { _listItems[id] = true; } } } refreshList(); } void PropertiesLordWarMachines::refreshList () { uint nbMachines = DataTheme.machines.count(); for( uint id = 0; id < nbMachines; id++ ) { if( ! _listItems[id] ) { _leftList->showRow (id); _rightList->hideRow (id); } else { _leftList->hideRow (id); _rightList->showRow (id); } } _leftList->resizeColumnsToContents(); _rightList->resizeColumnsToContents(); } // // ----- PropertiesLordTechnics ----- // PropertiesLordTechnics::PropertiesLordTechnics( QWidget * parent, const char * /* name */ ) : DoubleTableWidget( parent ) { _leftList->setHorizontalHeaderLabels( QStringList(tr( "Common technics list" )) ); _rightList->setHorizontalHeaderLabels( QStringList(tr( "Lord's technics list" )) ); } void PropertiesLordTechnics::accept() { /* XXX: (class GeneralLord must be updated: there is TechnicalBook, but it's too... it's not ready :) ) for (int num = 0; num < _lord->getTechnicsNumber(); num++) { _lord->removeTechnic(0); } */ uint nbTech = DataTheme.techList.count(); for( uint id = 0; id < nbTech; id++ ) { if( _listItems[id] ) { /* XXX: _lord->addTechnic( id ); */ } } } void PropertiesLordTechnics::fillList () { uint nbTech = DataTheme.techList.count(); setRowTable(nbTech); for( uint id = 0; id < nbTech; id++ ) { QString technicName = DataTheme.techList.at(id)->getName(); // XXX: We need it ! QPixmap* pix = ImageTheme.getTechnicIcon( id ); QTableWidgetItem * item = new QTableWidgetItem(technicName); item->setTextAlignment(Qt::AlignVCenter); item->setFlags(Qt::ItemIsSelectable); _leftList->setItem(id, 0, item); // XXX: _technicsList->setPixmap (id, 0, *pix); QTableWidgetItem * item2 = new QTableWidgetItem(technicName); item2->setTextAlignment(Qt::AlignVCenter); item2->setFlags(Qt::ItemIsSelectable); _rightList->setItem(id, 0, item2); // XXX: _lordsTechnicsList->setPixmap (id, 0, *pix); /* XXX: for (int cnt = 0; cnt < _lord->getTechnicsNumber(); cnt++) { if (_lord->getTechnic(cnt) == id) { _technics[id] = true; } } */ } refreshList(); } void PropertiesLordTechnics::refreshList () { uint nbTech = DataTheme.techList.count(); for( uint id = 0; id < nbTech; id++ ) { if( !_listItems[id] ) { _leftList->showRow (id); _rightList->hideRow (id); } else { _leftList->hideRow (id); _rightList->showRow (id); } } _leftList->resizeColumnsToContents(); _rightList->resizeColumnsToContents(); } DoubleTableWidget::DoubleTableWidget( QWidget * parent, const char * /* name*/ ) : QWidget( parent ) { _lord = 0; // main layout QHBoxLayout* mainLayout = new QHBoxLayout (this); QPushButton* addButton = new QPushButton (this); QPushButton* removeButton = new QPushButton (this); addButton->setText ("->"); removeButton->setText ("<-"); _leftList = new QTableWidget (this); _leftList->setColumnCount(1); _leftList->setShowGrid (false); _leftList->verticalHeader()->hide(); _rightList = new QTableWidget (this); _rightList->setColumnCount(1); _rightList->setShowGrid (false); _rightList->verticalHeader()->hide(); QGridLayout* gridLayout = new QGridLayout (); gridLayout->addWidget (addButton,1,0, Qt::AlignCenter); gridLayout->addWidget (removeButton,3,0, Qt::AlignCenter); mainLayout->setMargin (20); mainLayout->addWidget (_leftList, 3); mainLayout->addLayout (gridLayout , 2); mainLayout->addWidget (_rightList, 3); connect (addButton, SIGNAL (clicked ()), this, SLOT (addButtonPushed ())); connect (removeButton, SIGNAL (clicked ()), this, SLOT (removeButtonPushed ())); } void DoubleTableWidget::init( GenericLord * lord ) { _lord = lord; fillList (); } void DoubleTableWidget::fillList () { } void DoubleTableWidget::addButtonPushed () { if (_leftList->selectedRanges().count() <= 0) return; QTableWidgetSelectionRange sel = _leftList->selectedRanges().at(0); int row = sel.topRow (); _listItems[row] = true; refreshList (); } void DoubleTableWidget::removeButtonPushed () { if (_rightList->selectedRanges().count() <= 0) return; QTableWidgetSelectionRange sel = _rightList->selectedRanges().at(0); int row = sel.topRow (); _listItems[row] = false; refreshList (); } void DoubleTableWidget::refreshList() { } void DoubleTableWidget::setRowTable(int rows) { _leftList->setRowCount(rows); _rightList->setRowCount(rows); } attal-src-1.0-rc2/scenarioEditor/propertiesLord.h0000644000175000017500000001262110621625615017622 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** propertiesLord.h ** Properties for lords ** ** Version : $Id: propertiesLord.h,v 1.15 2007/05/13 15:15:25 lusum Exp $ ** ** Author(s) : Pascal Audoux & Nick Semenov ** ** Date : 07/12/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PROPERTIESLORD_H #define PROPERTIESLORD_H // generic include files // include files for QT #include #include #include #include // application specific include files #include "libCommon/genericPlayer.h" #include "libClient/pixmapSpinBox.h" class QTableWidget; class QComboBox; class QLabel; class QListWidget; class QPushButton; class QTabWidget; class AskCombo; class AskInt; class GenericLord; class PropertiesLordGeneral; class PropertiesLordUnits; class PropertiesLordArtefacts; class PropertiesLordWarMachines; class PropertiesLordTechnics; /** ------------------------------ * PropertiesLord ** ------------------------------ */ class PropertiesLord : public QDialog { Q_OBJECT public: /** Constructor */ PropertiesLord( QList * players, QWidget * parent = 0, const char * name = 0 ); void init( GenericLord * lord, uint * ids, int numLords ); public slots: virtual void accept(); private: QList * _players; GenericLord * _lord; QTabWidget * _tabWidget; PropertiesLordGeneral * _general; PropertiesLordUnits * _units; PropertiesLordArtefacts * _artefacts; PropertiesLordWarMachines * _warMachines; PropertiesLordTechnics * _technics; }; /** Frame, which has one of characteristics of general (attack, defense..) */ class GeneralCharacteristic : public PixmapSpinBox { public: GeneralCharacteristic (int number, QWidget* parent = 0, const char* name = 0); void init ( GenericLord* lord); void save ( GenericLord* lord ); private: // gets Pixmap by number void getPixmap (); // gets Text by number QString getText (); /** rememeber the number of characteristic */ int _num; QPixmap _pix; }; class PropertiesLordGeneral : public QWidget { Q_OBJECT public: PropertiesLordGeneral( QList * players, QWidget * parent = 0, const char * name = 0 ); void init( GenericLord * lord, uint * ids, uint numLords ); void accept(); bool hasNoOwner(); protected: QComboBox * _comboPlayer; QListWidget * _listLords; QLabel* _faceLord; QList * _players; GenericLord * _lord; QPushButton* _defaultButton; /** ids, what user CAN use for this lord (they are not used by other lords)*/ int _ids[100]; /** characteristics of the general */ GeneralCharacteristic* generalChar[12]; private slots: void slot_lordChanged(); void slot_defaultButtonPushed(); }; class EditTroop : public QFrame { Q_OBJECT public: /** Constructor */ EditTroop( int num, QWidget * parent = 0, const char * name = 0 ); /** Clears the widget */ void clear(); /** Updates data */ void updateData(); /** Inits the widget with 'unit' */ void init( GenericFightUnit * unit ); /** Saves the data */ void save( int i, GenericLord * lord ); void save( int i, GenericBase * base ); bool hasUnits (); public slots: /** Slot if races have changed */ void slot_raceChanged( int race ); private: GenericFightUnit * _unit; AskCombo * _race, * _name; AskInt * _number; }; class PropertiesLordUnits : public QWidget { public: PropertiesLordUnits( QWidget * parent = 0, const char * name = 0 ); void init( GenericLord * lord ); void accept(); bool hasNoneUnits (); protected: GenericLord * _lord; EditTroop * _troop[MAX_UNIT]; }; /* very simple: 2 lists.. no checkboxes, only 2 buttons */ class DoubleTableWidget : public QWidget { Q_OBJECT public: DoubleTableWidget( QWidget * parent = 0, const char * name = 0 ); void init( GenericLord * lord ); void accept(); protected: GenericLord * _lord; QTableWidget * _leftList; QTableWidget * _rightList; /* true if belongs to lord, false elsethere*/ bool _listItems[100]; void setRowTable(int rows); virtual void fillList (); virtual void refreshList (); private slots: void addButtonPushed (); void removeButtonPushed (); }; class PropertiesLordWarMachines : public DoubleTableWidget { Q_OBJECT public: PropertiesLordWarMachines( QWidget * parent = 0, const char * name = 0 ); void accept(); protected: void fillList (); void refreshList (); }; class PropertiesLordTechnics : public DoubleTableWidget { Q_OBJECT public: PropertiesLordTechnics( QWidget * parent = 0, const char * name = 0 ); void accept(); protected: void fillList (); void refreshList (); }; class PropertiesLordArtefacts : public DoubleTableWidget { Q_OBJECT public: PropertiesLordArtefacts( QWidget * parent = 0, const char * name = 0 ); void accept(); protected: void fillList(); void refreshList(); }; #endif // PROPERTIESLORD_H attal-src-1.0-rc2/scenarioEditor/propertiesPlayers.cpp0000644000175000017500000001432410734030415020667 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** propertiesPlayers.cpp ** properties of players (like resources) ** ** Author(s) : Nickolay Semenov - Sardi Carlo ** ** Date : 12/07/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "propertiesPlayers.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libClient/askWidget.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" extern QString IMAGE_PATH; PropertiesPlayers::PropertiesPlayers( QWidget * parent, QList * players ) :QDialog (parent) { uint i; _screenPlayers = players; _numPlayers = players->count (); _players = new GenericPlayer[_numPlayers]; /** Copy parametrs, important for us (to accept or cancel later) */ for( i = 0; i < _numPlayers; i++ ) { _players[i] = *players->at( i ); } QVBoxLayout* vlayout = new QVBoxLayout (this); vlayout->setMargin (10); vlayout->setSpacing (10); QLabel* label = new QLabel (this); label->setText (tr("Players Properties")); FIXEDSIZE (label); vlayout->addWidget (label,1, Qt::AlignCenter); QGridLayout* gridLayout = new QGridLayout (); _comboPlayers = new QComboBox (this); _comboPlayers->setEditable (false); for( i = 0; i < _numPlayers; i++ ) { _comboPlayers->addItem( _players[i].getName(), i ); } connect( _comboPlayers, SIGNAL( activated( int ) ), this, SLOT( slot_comboBoxItemChanged( int ) ) ); gridLayout->addWidget (_comboPlayers, 0, 0, Qt::AlignCenter); _aiCheckBox = new QCheckBox (this); _aiCheckBox->setText (tr("Ruled by AI")); gridLayout->addWidget (_aiCheckBox, 1, 0, Qt::AlignCenter); _team = new AskInt (tr( "Team : "),this); for( i = 0; i < _numPlayers; i++ ) { _team->setValue( _players[i].getNum()); _players[i].setTeam (_team->getValue()); } gridLayout->addWidget (_team, 1, 0, Qt::AlignCenter); _flagButton = new QPushButton (this); connect( _flagButton, SIGNAL( clicked() ), this, SLOT( slot_flagButtonClicked() ) ); gridLayout->addWidget (_flagButton, 2, 0 , Qt::AlignCenter); uint nbRes = DataTheme.resources.count(); for( i = 0; i < nbRes; i++ ) { _spinBoxes[i] = new PixmapSpinBox (this); /** XXX: I couldn't find pixmaps for resources in ImageTheme... :( */ /** The number of resources is a problem too */ QPixmap* pix = 0; QString s = DataTheme.resources.getRessource (i); _spinBoxes[i]->setFrameStyle( QFrame::Panel | QFrame::Raised ); _spinBoxes[i]->setLineWidth( 1 ); _spinBoxes[i]->init( pix, s, false ); _spinBoxes[i]->setRange( 0, 1000000 ); FIXEDSIZE (_spinBoxes[i]); gridLayout->addWidget (_spinBoxes[i], i / 2, i %2 + 1); } QPushButton* okButton = new QPushButton( this ); okButton->setText( "Ok" ); okButton->setFixedWidth (75); connect( okButton, SIGNAL( clicked() ), this , SLOT( slot_okButtonClicked() ) ); gridLayout->addWidget (okButton, DataTheme.resources.count () / 2, 1, Qt::AlignCenter); QPushButton* cancelButton = new QPushButton (this); cancelButton->setText ("Cancel"); cancelButton->setFixedWidth (75); connect( cancelButton, SIGNAL( clicked() ), this, SLOT( slot_cancelButtonClicked() ) ); gridLayout->addWidget( cancelButton, DataTheme.resources.count () / 2, 2, Qt::AlignCenter ); vlayout->addLayout (gridLayout, 1); vlayout->activate (); _comboPlayers->setCurrentIndex (0); _currentNumber = 0; formFlagsList (_currentNumber); setParams (); } PropertiesPlayers::~PropertiesPlayers() { delete[] _players; } void PropertiesPlayers::setParams () { uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { _spinBoxes[i]->setValue( _players[_currentNumber].getResourceList()->getValue(i) ); } _aiCheckBox->setChecked (_players[_currentNumber].isRuledByAi ()); _team->setValue(_players[_currentNumber].getTeamId()); QPixmap* flag = ImageTheme.getFlag (_freeFlagsList[0]); _flagButton->setIcon (QIcon(*flag)); _currentFlag = 0; } void PropertiesPlayers::getParams () { uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { _players[_currentNumber].getResourceList()->setValue( i, _spinBoxes[i]->getValue() ); } _players[_currentNumber].setRuledByAi (_aiCheckBox->isChecked ()); _players[_currentNumber].setNum (_freeFlagsList[_currentFlag]); _players[_currentNumber].setTeam (_team->getValue()); } void PropertiesPlayers::accept () { getParams (); for( uint i = 0; i < _numPlayers; i++ ) { *_screenPlayers->at (i) = _players[i]; } QDialog::accept (); } void PropertiesPlayers::slot_comboBoxItemChanged( int i ) { getParams (); _currentNumber = i; formFlagsList( _currentNumber ); setParams (); } void PropertiesPlayers::slot_okButtonClicked () { accept (); } void PropertiesPlayers::slot_cancelButtonClicked () { QDialog::reject (); } void PropertiesPlayers::formFlagsList (int numPlayer) { uint numTeams = DataTheme.teams.count (); _numFreeFlags = 1; _freeFlagsList[0] = _players[numPlayer].getNum (); for( uint i = 0; i < numTeams; i++ ) { bool isFree = true; for( uint j = 0; j < _numPlayers; j++ ) { if( i == (uint) _players[i].getNum() ) { isFree = false; } } if( isFree ) { _freeFlagsList[_numFreeFlags] = i; _numFreeFlags++; } } } void PropertiesPlayers::slot_flagButtonClicked () { _currentFlag++; _team->setValue(_team->getValue()+1); if (_currentFlag == _numFreeFlags) { _currentFlag = 0; _team->setValue(0); } QPixmap* flag = ImageTheme.getFlag (_freeFlagsList[_currentFlag]); _flagButton->setIcon (QIcon(*flag)); } attal-src-1.0-rc2/scenarioEditor/propertiesPlayers.h0000644000175000017500000000440510334750470020341 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** propertiesPlayers.h ** Display properties of players ** ** Version : $Id: propertiesPlayers.h,v 1.6 2005/11/10 23:01:12 audoux Exp $ ** ** Author(s) : Nickolay Semenov - Sardi Carlo ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PROPERTIESPLAYERS_H #define PROPERTIESPLAYERS_H // generic include files // include files for QT #include #include // application specific include files #include "libCommon/genericPlayer.h" #include "libClient/pixmapSpinBox.h" class QComboBox; class QCheckBox; class QPushButton; class AskInt; /* ------------------------------------------- * PropertiesPlayers * ------------------------------------------ */ class PropertiesPlayers : public QDialog { Q_OBJECT public: /** Constructor */ PropertiesPlayers( QWidget * parent, QList * players ); /** Destructor */ virtual ~PropertiesPlayers(); void accept (); private slots: void slot_comboBoxItemChanged( int i ); void slot_okButtonClicked(); void slot_cancelButtonClicked(); void slot_flagButtonClicked(); private: void setParams (); void getParams (); void formFlagsList( int numPlayer ); /** Array of players*/ GenericPlayer * _players; /** Screen players */ QList * _screenPlayers; /** Number of players */ uint _numPlayers; AskInt * _team; QComboBox * _comboPlayers; QCheckBox* _aiCheckBox; QPushButton* _flagButton; PixmapSpinBox * _spinBoxes[10]; int _currentNumber; /** Free flags */ unsigned char _freeFlagsList[255]; int _numFreeFlags; int _currentFlag; }; #endif // PROPERTIESPLAYERS_H attal-src-1.0-rc2/scenarioEditor/questConditionEditor.cpp0000644000175000017500000002060610511545110021306 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** questConditionEditor.cpp ** Editor of conditions used in quests ** ** Version : $Id: questConditionEditor.cpp,v 1.13 2006/10/06 21:27:36 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 14/06/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "questConditionEditor.h" // generic include files // include files for QT #include #include #include #include #include #include #include // application specific include files #include "libCommon/log.h" #include "libCommon/quest.h" #include "libClient/gui.h" #include "scenarioEditor/questConditionProperties.h" QuestConditionEditor::QuestConditionEditor( QWidget * parent, const char * name ) : QWidget( parent ) { setWindowTitle( QString( name ) ); _condition = 0; _title = new QLabel( this ); _title->setText( tr( "Condition: " ) ); FIXEDSIZE( _title ); QPushButton * pbEdit = new QPushButton( this ); pbEdit->setText( tr( "Edit" ) ); FIXEDSIZE( pbEdit ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->addWidget( _title ); layout->addSpacing( 5 ); layout->addWidget( pbEdit ); layout->addStretch( 1 ); layout->activate(); connect( pbEdit, SIGNAL( clicked() ), SLOT( slot_edit() ) ); } void QuestConditionEditor::setTitle( const QString & title ) { _title->setText( title ); FIXEDSIZE( _title ); } void QuestConditionEditor::slot_edit() { if( ! _condition ) { _condition = new QuestConditionComposite(); } QuestConditionDialog dialog( _condition ); dialog.exec(); } // // ----- QuestConditionDialog ----- // QuestConditionDialog::QuestConditionDialog( QuestCondition * condition, QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { _contextItem = 0; _condition = condition; _menu = new QMenu(); _list = new QTreeWidget( this ); _list->setColumnCount( 1 ); QStringList labels; labels << tr( "Condition" ); _list->setHeaderLabels( labels ); buildTree(); _list->setContextMenuPolicy(Qt::DefaultContextMenu); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); layH1->addWidget( pbCan ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _list, 1 ); layout->addLayout( layH1 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); } void QuestConditionDialog::buildTree() { _list->clear(); if( _condition ) { QuestConditionItem * item = new QuestConditionItem( _list ); item->setExpanded( true ); item->setCondition( _condition ); if( _condition->getType() == QuestCondition::COMPOSITE ) { QuestConditionComposite * composite = ( QuestConditionComposite * ) _condition; uint nb = composite->getConditionNumber(); for( uint i = 0; i < nb; ++i ) { buildSubTree( item, composite->getCondition( i ) ); } } } } void QuestConditionDialog::buildSubTree( QuestConditionItem * root, QuestCondition * condition ) { QuestConditionItem * item = new QuestConditionItem( root ); item->setExpanded( true ); item->setCondition( condition ); if( condition->getType() == QuestCondition::COMPOSITE ) { QuestConditionComposite * composite = ( QuestConditionComposite * ) condition; uint nb = composite->getConditionNumber(); for( uint i = 0; i < nb; ++i ) { buildSubTree( item, composite->getCondition( i ) ); } } } void QuestConditionDialog::contextMenuEvent(QContextMenuEvent *e) { //QTreeWidgetItem *item = _list->itemAt(e->globalPos()); QTreeWidgetItem *item = _list->currentItem(); _menu->clear(); _contextItem = (QuestConditionItem *) item; if( _contextItem ) { _menu->addAction( tr( "&Properties" ), this, SLOT( slot_actionPropertiesCondition() ) ); if( _contextItem->getCondition()->getType() == QuestCondition::COMPOSITE ) { _menu->addAction( tr( "&Add condition" ), this, SLOT( slot_actionAddCondition() ) ); } if( _contextItem->parent() ) { _menu->addAction( tr( "&Delete condition" ), this, SLOT( slot_actionDelCondition() ) ); } _menu->popup( e->globalPos() ); } else { if( _list->topLevelItemCount() == 0 ) { _menu->addAction( tr( "&Add condition" ), this, SLOT( slot_actionAddCondition() ) ); _menu->popup( e->globalPos() ); } } } void QuestConditionDialog::slot_actionPropertiesCondition() { QuestCondition * condition = _contextItem->getCondition(); switch( condition->getType() ) { case QuestCondition::DATE: { QuestConditionDateProperties dialog( this ); dialog.setCondition( (QuestConditionDate*)condition ); dialog.exec(); } break; case QuestCondition::LORD: { QuestConditionLordProperties dialog( this ); dialog.setCondition( (QuestConditionLord*)condition ); dialog.exec(); } break; case QuestCondition::PLAYER: { QuestConditionPlayerProperties dialog( this ); dialog.setCondition( (QuestConditionPlayer*)condition ); dialog.exec(); } break; default: break; } } void QuestConditionDialog::slot_actionAddCondition() { NewQuestConditionDialog dialog; if( dialog.exec() ) { QuestConditionItem * item; QuestCondition * condition = dialog.getNewCondition(); if( _contextItem ) { QuestCondition * parentCondition = _contextItem->getCondition(); if( parentCondition->getType() == QuestCondition::COMPOSITE ) { ( ( QuestConditionComposite * )parentCondition )->addCondition( condition ); } buildTree(); } else { item = new QuestConditionItem( _list ); item->setCondition( condition ); } } } void QuestConditionDialog::slot_actionDelCondition() { if( _contextItem ) { QuestConditionItem * parentItem = dynamic_cast ( _contextItem->parent() ); QuestCondition * parentCondition = parentItem->getCondition(); if( parentCondition->getType() == QuestCondition::COMPOSITE ) { ( ( QuestConditionComposite * )parentCondition )->delCondition( _contextItem->getCondition() ); } buildTree(); } } // // ----- QuestConditionItem ----- // QuestConditionItem::QuestConditionItem( QTreeWidget * parent ) : QTreeWidgetItem( parent ) { _condition = 0; } QuestConditionItem::QuestConditionItem( QuestConditionItem * parent ) : QTreeWidgetItem( parent ) { _condition = 0; } void QuestConditionItem::setCondition( QuestCondition * condition ) { setText( 0, condition->getLabel() ); _condition = condition; } // // ----- NewQuestConditionDialog ----- // NewQuestConditionDialog::NewQuestConditionDialog( QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { _type = TC_NONE; _list = new QListWidget( this ); _list->insertItem( TC_AND, tr( "AND" ) ); _list->insertItem( TC_OR, tr( "OR" ) ); _list->insertItem( TC_DATE, tr( "Date" ) ); _list->insertItem( TC_LORD, tr( "Lord" ) ); _list->insertItem( TC_PLAYER, tr( "Player" ) ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( _list, 1 ); layout->activate(); connect( _list, SIGNAL( itemDoubleClicked( QListWidgetItem * ) ), this, SLOT( slot_select() ) ); } QuestCondition * NewQuestConditionDialog::getNewCondition() { QuestCondition * ret = 0; switch( _type ) { case TC_AND: ret = new QuestConditionComposite( QuestConditionComposite::AND ); break; case TC_OR: ret = new QuestConditionComposite( QuestConditionComposite::OR ); break; case TC_DATE: ret = new QuestConditionDate(); break; case TC_LORD: ret = new QuestConditionLord(); break; case TC_PLAYER: ret = new QuestConditionPlayer(); break; default: break; } return ret; } void NewQuestConditionDialog::slot_select() { _type = ( TypeCondition )_list->currentRow(); accept(); } attal-src-1.0-rc2/scenarioEditor/questConditionEditor.h0000644000175000017500000000605210511266241020757 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** questConditionEditor.h ** Editor of conditions used in quests ** ** Version : $Id: questConditionEditor.h,v 1.8 2006/10/05 20:35:45 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 14/06/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef QUESTCONDITIONEDITOR_H #define QUESTCONDITIONEDITOR_H // generic include files // include files for QT #include #include #include #include // application specific include files class QLabel; class QListWidget; class QPushButton; class QuestCondition; class QuestConditionItem; /* ------------------------------ * QuestConditionEditor * ------------------------------ */ class QuestConditionEditor : public QWidget { Q_OBJECT public: /** Constructor */ QuestConditionEditor( QWidget * parent = 0, const char * name = 0 ); void setTitle( const QString & title ); void setCondition( QuestCondition * condition ) { _condition = condition; } QuestCondition * getCondition() { return _condition; } public slots: void slot_edit(); protected: QLabel * _title; QuestCondition * _condition; }; /** */ class QuestConditionDialog : public QDialog { Q_OBJECT public: /** Constructor */ QuestConditionDialog( QuestCondition * condition, QWidget * parent = 0, const char * name = 0 ); void buildTree(); void buildSubTree( QuestConditionItem * root, QuestCondition * condition ); public slots: void contextMenuEvent(QContextMenuEvent *e); void slot_actionPropertiesCondition(); void slot_actionAddCondition(); void slot_actionDelCondition(); protected: QuestCondition * _condition; QTreeWidget * _list; QMenu * _menu; QuestConditionItem * _contextItem; }; /** */ class QuestConditionItem : public QTreeWidgetItem { public: /** Constructor */ QuestConditionItem( QTreeWidget * parent ); QuestConditionItem(QuestConditionItem*parent); void setCondition( QuestCondition * condition ); QuestCondition * getCondition() { return _condition; } protected: QuestCondition * _condition; }; /** */ class NewQuestConditionDialog : public QDialog { Q_OBJECT public: NewQuestConditionDialog( QWidget * parent = 0, const char * name = 0 ); QuestCondition * getNewCondition(); public slots: void slot_select(); protected: enum TypeCondition { TC_AND = 0, TC_OR, TC_DATE, TC_LORD, TC_PLAYER, TC_NONE }; QListWidget * _list; TypeCondition _type; }; #endif // QUESTCONDITIONEDITOR_H attal-src-1.0-rc2/scenarioEditor/questConditionProperties.cpp0000644000175000017500000004334710605300077022230 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** questConditionProperties.cpp ** Display/edit properties of quest conditions ** ** Version : $Id: questConditionProperties.cpp,v 1.16 2007/04/05 23:03:27 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 20/06/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "questConditionProperties.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/genericLord.h" #include "libCommon/log.h" #include "libCommon/quest.h" #include "libClient/gui.h" // // ----- QuestConditionProperties ----- // QuestConditionProperties::QuestConditionProperties( QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { } QuestConditionProperties::~QuestConditionProperties() { } // // ----- QuestConditionDateProperties ----- // QuestConditionDateProperties::QuestConditionDateProperties( QWidget * parent, const char * name ) : QuestConditionProperties( parent, name ) { _condition = 0; _radioDate = new QRadioButton( this ); _radioDate->setText( tr( "Before date: " ) ); FIXEDSIZE( _radioDate ); _day = new QSpinBox( this ); _day->setMinimum( 1 ); _day->setMaximum( 7 ); FIXEDSIZE( _day ); _labDay = new QLabel( tr( "Day" ), this ); FIXEDSIZE( _labDay ); _week = new QSpinBox( this ); _week->setMinimum( 0 ); _week->setMaximum( 3 ); FIXEDSIZE( _week ); _labWeek = new QLabel( tr( "Week" ), this ); FIXEDSIZE( _labWeek ); _month = new QSpinBox( this ); _month->setMinimum( 0 ); _month->setMaximum( 12 ); FIXEDSIZE( _month ); _labMonth = new QLabel( tr( "Month" ), this ); FIXEDSIZE( _labMonth ); _year = new QSpinBox( this ); _year->setMinimum( 0 ); _year->setMaximum( 9999 ); FIXEDSIZE( _month ); _labYear = new QLabel( tr( "Year" ), this ); FIXEDSIZE( _labYear ); QHBoxLayout * layHDate = new QHBoxLayout(); layHDate->setSpacing( 5 ); layHDate->setMargin( 5 ); layHDate->addWidget( _radioDate ); layHDate->addWidget( _labDay ); layHDate->addWidget( _day ); layHDate->addWidget( _labWeek ); layHDate->addWidget( _week ); layHDate->addWidget( _labMonth ); layHDate->addWidget( _month ); layHDate->addWidget( _labYear ); layHDate->addWidget( _year ); layHDate->addStretch( 1 ); _radioDelay = new QRadioButton( this ); _radioDelay->setText( tr( "Before " ) ); FIXEDSIZE( _radioDelay ); _delay = new QSpinBox( this ); _delay->setMinimum( 1 ); _delay->setMaximum( 336 ); FIXEDSIZE( _delay ); _labDelay = new QLabel( tr( "day(s)" ), this ); FIXEDSIZE( _labDelay ); QHBoxLayout * layHDelay = new QHBoxLayout(); layHDelay->setSpacing( 5 ); layHDelay->setMargin( 5 ); layHDelay->addWidget( _radioDelay ); layHDelay->addWidget( _delay ); layHDelay->addWidget( _labDelay ); layHDelay->addStretch( 1 ); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setMargin( 5 ); layH1->setSpacing( 5 ); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); layH1->addWidget( pbCan ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layHDate ); layout->addLayout( layHDelay ); layout->addStretch( 1 ); layout->addLayout( layH1 ); layout->activate(); connect( _radioDate, SIGNAL( clicked() ), SLOT( slot_date() ) ); connect( _radioDelay, SIGNAL( clicked() ), SLOT( slot_delay() ) ); connect( pbOk, SIGNAL( clicked() ), SLOT( slot_accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); slot_date(); } void QuestConditionDateProperties::slot_accept() { if( _condition ) { if( _radioDate->isChecked() ) { _condition->setConditionDate( _day->value(), _week->value(), _month->value(), _year->value() ); } else { _condition->setConditionDelay( _delay->value() ); } } accept(); } void QuestConditionDateProperties::setCondition( QuestConditionDate * condition ) { _condition = condition; if( _condition->getCategory() == QuestConditionDate::DATE ) { slot_date(); _day->setValue( _condition->getDay() ); _week->setValue( _condition->getWeek() ); _month->setValue( _condition->getMonth() ); _year->setValue( _condition->getYear() ); } else { slot_delay(); _delay->setValue( _condition->getDelay() ); } } void QuestConditionDateProperties::slot_date() { _radioDate->setChecked( true ); _radioDelay->setChecked( false ); _labDelay->setEnabled( false ); _delay->setEnabled( false ); _labDay->setEnabled( true ); _labWeek->setEnabled( true ); _labMonth->setEnabled( true ); _labYear->setEnabled( true ); _day->setEnabled( true ); _week->setEnabled( true ); _month->setEnabled( true ); _year->setEnabled( true ); } void QuestConditionDateProperties::slot_delay() { _radioDate->setChecked( false ); _radioDelay->setChecked( true ); _labDelay->setEnabled( true ); _delay->setEnabled( true ); _labDay->setEnabled( false ); _labWeek->setEnabled( false ); _labMonth->setEnabled( false ); _labYear->setEnabled( false ); _day->setEnabled( false ); _week->setEnabled( false ); _month->setEnabled( false ); _year->setEnabled( false ); } // // ----- QuestConditionLordProperties ----- // QuestConditionLordProperties::QuestConditionLordProperties( QWidget * parent, const char * name ) : QuestConditionProperties( parent, name ) { _radioPrimary = new QRadioButton( this ); _radioPrimary->setText( tr( "Primary skill" ) ); FIXEDSIZE( _radioPrimary ); _primCharac = new AskLordCharac( this ); FIXEDSIZE( _primCharac ); _primCheck = new QComboBox( this ); _primCheck->addItem( "<" ); _primCheck->addItem( "<=" ); _primCheck->addItem( "=" ); _primCheck->addItem( ">=" ); _primCheck->addItem( ">" ); FIXEDSIZE( _primCheck ); _primValue = new AskInt( tr( "value: " ), this ); FIXEDSIZE( _primValue ); QHBoxLayout * layPrimary = new QHBoxLayout(); layPrimary->setSpacing( 5 ); layPrimary->setMargin( 5 ); layPrimary->addWidget( _radioPrimary ); layPrimary->addWidget( _primCharac ); layPrimary->addWidget( _primCheck ); layPrimary->addWidget( _primValue ); layPrimary->addStretch( 1 ); _radioSecondary = new QRadioButton( this ); _radioSecondary->setText( tr( "Secondary skill" ) ); FIXEDSIZE( _radioSecondary ); QHBoxLayout * laySecondary = new QHBoxLayout(); laySecondary->setSpacing( 5 ); laySecondary->setMargin( 5 ); laySecondary->addWidget( _radioSecondary ); laySecondary->addStretch( 1 ); _radioArtefact = new QRadioButton( this ); _radioArtefact->setText( tr( "Artefact" ) ); FIXEDSIZE( _radioArtefact ); _artefact = new AskCombo( "", this ); uint nbArtefacts = DataTheme.artefacts.count(); for( uint i = 0; i < nbArtefacts; i++ ) { _artefact->insertItem( DataTheme.artefacts.at( i )->getName() ); } FIXEDSIZE( _artefact ); QHBoxLayout * layArtefact = new QHBoxLayout(); layArtefact->setSpacing( 5 ); layArtefact->setMargin( 5 ); layArtefact->addWidget( _radioArtefact ); layArtefact->addWidget( _artefact ); layArtefact->addStretch( 1 ); _radioNum = new QRadioButton( this ); _radioNum->setText( tr( "Number of creatures" ) ); FIXEDSIZE( _radioNum ); _numCheck = new QComboBox( this ); _numCheck->addItem( "<" ); _numCheck->addItem( "<=" ); _numCheck->addItem( "=" ); _numCheck->addItem( ">=" ); _numCheck->addItem( ">" ); FIXEDSIZE( _numCheck ); _numValue = new AskInt( tr( "value: " ), this ); FIXEDSIZE( _numValue ); QHBoxLayout * layNum = new QHBoxLayout(); layNum->setSpacing( 5 ); layNum->setMargin( 5 ); layNum->addWidget( _radioNum ); layNum->addWidget( _numCheck ); layNum->addWidget( _numValue ); layNum->addStretch( 1 ); _radioSpell = new QRadioButton( this ); _radioSpell->setText( tr( "Spell" ) ); FIXEDSIZE( _radioSpell ); QHBoxLayout * laySpell = new QHBoxLayout(); laySpell->setSpacing( 5 ); laySpell->setMargin( 5 ); laySpell->addWidget( _radioSpell ); laySpell->addStretch( 1 ); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setMargin( 5 ); layH1->setSpacing( 5 ); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); layH1->addWidget( pbCan ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layPrimary ); layout->addLayout( laySecondary ); layout->addLayout( layArtefact ); layout->addLayout( layNum ); layout->addLayout( laySpell ); layout->addStretch( 1 ); layout->addLayout( layH1 ); layout->activate(); connect( _radioPrimary, SIGNAL( clicked() ), SLOT( slot_primarySkill() ) ); connect( _radioSecondary, SIGNAL( clicked() ), SLOT( slot_secondarySkill() ) ); connect( _radioArtefact, SIGNAL( clicked() ), SLOT( slot_artefact() ) ); connect( _radioSpell, SIGNAL( clicked() ), SLOT( slot_spell() ) ); connect( _radioNum, SIGNAL( clicked() ), SLOT( slot_number() ) ); connect( pbOk, SIGNAL( clicked() ), SLOT( slot_accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); } void QuestConditionLordProperties::setCondition( QuestConditionLord * condition ) { _condition = condition; switch( _condition->getConditionType() ) { case QuestConditionLord::PRIMARY_SKILL: slot_primarySkill(); _primCharac->setCurrentItem( condition->getLordCharac() ); _primCheck->setCurrentIndex( condition->getCheckType() ); _primValue->setValue( condition->getValue() ); break; case QuestConditionLord::SECONDARY_SKILL: slot_secondarySkill(); break; case QuestConditionLord::ARTEFACT: slot_artefact(); _artefact->setCurrentItem( condition->getArtefact() ); break; case QuestConditionLord::NB_CREATURES: slot_number(); _numCheck->setCurrentIndex( condition->getCheckType() ); _numValue->setValue( condition->getValue() ); break; case QuestConditionLord::SPELL: slot_spell(); break; } } void QuestConditionLordProperties::slot_accept() { if( _condition ) { if( _radioPrimary->isChecked() ) { _condition->setPrimarySkillCondition( (LordCharac)_primCharac->currentItem(), (QuestCondition::CheckType)_primCheck->currentIndex(), _primValue->getValue()); } else if( _radioSecondary->isChecked() ) { //_condition->setSecondarySkillCondition(); } else if( _radioArtefact->isChecked() ) { _condition->setArtefactCondition( _artefact->currentItem(), true ); } else if( _radioNum->isChecked() ) { _condition->setNumberCondition( (QuestCondition::CheckType)_numCheck->currentIndex(), _numValue->getValue()); } else { //_condition->setSpellCondition(); } } accept(); } void QuestConditionLordProperties::slot_primarySkill() { _radioPrimary->setChecked( true ); _radioSecondary->setChecked( false ); _radioArtefact->setChecked( false ); _radioSpell->setChecked( false ); _radioNum->setChecked( false); } void QuestConditionLordProperties::slot_secondarySkill() { _radioPrimary->setChecked( false ); _radioSecondary->setChecked( true ); _radioArtefact->setChecked( false ); _radioSpell->setChecked( false ); _radioNum->setChecked( false); } void QuestConditionLordProperties::slot_artefact() { _radioPrimary->setChecked( false ); _radioSecondary->setChecked( false ); _radioArtefact->setChecked( true ); _radioSpell->setChecked( false ); _radioNum->setChecked( false); } void QuestConditionLordProperties::slot_spell() { _radioPrimary->setChecked( false ); _radioSecondary->setChecked( false ); _radioArtefact->setChecked( false ); _radioSpell->setChecked( true ); _radioNum->setChecked( false); } void QuestConditionLordProperties::slot_number() { _radioPrimary->setChecked( false ); _radioSecondary->setChecked( false ); _radioArtefact->setChecked( false ); _radioSpell->setChecked( false ); _radioNum->setChecked( true); } // // ----- QuestConditionPlayerProperties ----- // QuestConditionPlayerProperties ::QuestConditionPlayerProperties( QWidget * parent, const char * name ) : QuestConditionProperties( parent, name ) { _radioNbLords = new QRadioButton( this ); _radioNbLords->setText( tr( "Nb lords " ) ); FIXEDSIZE( _radioNbLords ); _lordCheck = new QComboBox( this ); _lordCheck->addItem( "<" ); _lordCheck->addItem( "<=" ); _lordCheck->addItem( "=" ); _lordCheck->addItem( ">=" ); _lordCheck->addItem( ">" ); FIXEDSIZE( _lordCheck ); _lordValue = new AskInt( "", this ); FIXEDSIZE( _lordValue ); QHBoxLayout * layNbLords = new QHBoxLayout(); layNbLords->setSpacing( 5 ); layNbLords->setMargin( 5 ); layNbLords->addWidget( _radioNbLords ); layNbLords->addWidget( _lordCheck ); layNbLords->addWidget( _lordValue ); layNbLords->addStretch( 1 ); _radioNbBases = new QRadioButton( this ); _radioNbBases->setText( tr( "Nb bases " ) ); FIXEDSIZE( _radioNbBases ); _baseCheck = new QComboBox( this ); _baseCheck->addItem( "<" ); _baseCheck->addItem( "<=" ); _baseCheck->addItem( "=" ); _baseCheck->addItem( ">=" ); _baseCheck->addItem( ">" ); FIXEDSIZE( _baseCheck ); _baseValue = new AskInt( "", this ); FIXEDSIZE( _baseValue ); QHBoxLayout * layNbBases = new QHBoxLayout(); layNbBases->setSpacing( 5 ); layNbBases->setMargin( 5 ); layNbBases->addWidget( _radioNbBases ); layNbBases->addWidget( _baseCheck ); layNbBases->addWidget( _baseValue ); layNbBases->addStretch( 1 ); _radioBasename = new QRadioButton( this ); _radioBasename->setText( tr( "Basename = " ) ); FIXEDSIZE( _radioBasename ); _basename = new AskString( "", this ); FIXEDSIZE( _basename ); QHBoxLayout * layBasename = new QHBoxLayout(); layBasename->setSpacing( 5 ); layBasename->setMargin( 5 ); layBasename->addWidget( _radioBasename ); layBasename->addWidget( _basename ); layBasename->addStretch( 1 ); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setMargin( 5 ); layH1->setSpacing( 5 ); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); layH1->addWidget( pbCan ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layNbLords ); layout->addLayout( layNbBases ); layout->addLayout( layBasename ); layout->addStretch( 1 ); layout->addLayout( layH1 ); layout->activate(); connect( _radioNbLords, SIGNAL( clicked() ), SLOT( slot_nbLords() ) ); connect( _radioNbBases, SIGNAL( clicked() ), SLOT( slot_nbBases() ) ); connect( _radioBasename, SIGNAL( clicked() ), SLOT( slot_basename() ) ); connect( pbOk, SIGNAL( clicked() ), SLOT( slot_accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); slot_nbLords(); } void QuestConditionPlayerProperties::slot_nbLords() { _radioNbLords->setChecked( true ); _radioNbBases->setChecked( false ); _radioBasename->setChecked( false ); } void QuestConditionPlayerProperties::slot_nbBases() { _radioNbLords->setChecked( false ); _radioNbBases->setChecked( true ); _radioBasename->setChecked( false ); } void QuestConditionPlayerProperties::slot_basename() { _radioNbBases->setChecked( false ); _radioNbLords->setChecked( false ); _radioBasename->setChecked( true ); } void QuestConditionPlayerProperties ::setCondition( QuestConditionPlayer * condition ) { _condition = condition; switch( _condition->getConditionType() ) { case QuestConditionPlayer::NB_LORD: slot_nbLords(); _lordCheck->setCurrentIndex( condition->getCheckType() ); _lordValue->setValue( condition->getValue() ); break; case QuestConditionPlayer::NB_BASE: _baseCheck->setCurrentIndex( condition->getCheckType() ); _baseValue->setValue( condition->getValue() ); slot_nbBases(); break; case QuestConditionPlayer::BASENAME: slot_basename(); _basename->setValue( condition->getName() ); break; } } void QuestConditionPlayerProperties::slot_accept() { if( _condition ) { if( _radioNbLords->isChecked() ) { _condition->setNbLordCondition( (QuestCondition::CheckType)_lordCheck->currentIndex(), _lordValue->getValue()); } else if( _radioNbBases->isChecked() ) { _condition->setNbBaseCondition( (QuestCondition::CheckType)_baseCheck->currentIndex(), _baseValue->getValue()); } else { _condition->setBasenameCondition( _basename->getValue() ); } } accept(); } // // ----- AskLordCharac ----- // AskLordCharac::AskLordCharac( QWidget * parent, const char * name ) : AskCombo( tr( "Charac" ), parent, name ) { insertItem( getCharacName( ATTACK ) ); insertItem( getCharacName( DEFENSE ) ); insertItem( getCharacName( POWER ) ); insertItem( getCharacName( KNOWLEDGE ) ); insertItem( getCharacName( MOVE ) ); insertItem( getCharacName( MAXMOVE ) ); insertItem( getCharacName( TECHNICPOINT ) ); insertItem( getCharacName( MAXTECHNICPOINT ) ); insertItem( getCharacName( MORALE ) ); insertItem( getCharacName( LUCK ) ); insertItem( getCharacName( CHARISMA ) ); insertItem( getCharacName( VISION ) ); insertItem( getCharacName( EXPERIENCE ) ); FIXEDSIZE( this ); } attal-src-1.0-rc2/scenarioEditor/questConditionProperties.h0000644000175000017500000001021210630076165021664 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** questConditionProperties.h ** Display/edit properties of quest conditions ** ** Version : $Id: questConditionProperties.h,v 1.13 2007/06/01 20:07:17 audoux Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 20/06/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef QUESTCONDITIONPROPERTIES_H #define QUESTCONDITIONPROPERTIES_H // generic include files // include files for QT #include #include // application specific include files #include "libClient/askWidget.h" class QComboBox; class QLabel; class QRadioButton; class QSpinBox; //class AskCheck; class AskLordCharac; class QuestConditionDate; class QuestConditionLord; class QuestConditionPlayer; /* ------------------------------ * QuestConditionProperties * ------------------------------ */ class QuestConditionProperties : public QDialog { Q_OBJECT public: QuestConditionProperties( QWidget * parent = 0, const char * name = 0 ); virtual ~QuestConditionProperties() = 0; }; /* ------------------------------ * QuestConditionDateProperties * ------------------------------ */ class QuestConditionDateProperties : public QuestConditionProperties { Q_OBJECT public: QuestConditionDateProperties( QWidget * parent = 0, const char * name = 0 ); ~QuestConditionDateProperties() {} void setCondition( QuestConditionDate * condition ); public slots: void slot_date(); void slot_delay(); void slot_accept(); protected: QuestConditionDate * _condition; QRadioButton * _radioDate, * _radioDelay; QSpinBox * _delay, * _day, * _week, * _month, * _year; QLabel * _labDay, * _labWeek, * _labMonth, * _labDelay, * _labYear; }; /* ------------------------------ * QuestConditionLordProperties * ------------------------------ */ class QuestConditionLordProperties : public QuestConditionProperties { Q_OBJECT public: QuestConditionLordProperties( QWidget * parent = 0, const char * name = 0 ); ~QuestConditionLordProperties() {} void setCondition( QuestConditionLord * condition ); public slots: void slot_primarySkill(); void slot_secondarySkill(); void slot_artefact(); void slot_spell(); void slot_number(); void slot_accept(); protected: QuestConditionLord * _condition; QRadioButton * _radioPrimary, * _radioSecondary, * _radioArtefact, * _radioSpell,* _radioNum; AskInt * _primValue, * _numValue; AskLordCharac * _primCharac; AskCombo * _artefact; QComboBox * _primCheck, * _numCheck; }; /* ------------------------------ * QuestConditionPlayerProperties * ------------------------------ */ class QuestConditionPlayerProperties : public QuestConditionProperties { Q_OBJECT public: QuestConditionPlayerProperties( QWidget * parent = 0, const char * name = 0 ); ~QuestConditionPlayerProperties() {} void setCondition( QuestConditionPlayer * condition ); public slots: void slot_accept(); void slot_nbLords(); void slot_nbBases(); void slot_basename(); protected: QuestConditionPlayer * _condition; QRadioButton * _radioNbLords, * _radioNbBases, * _radioBasename; QComboBox * _lordCheck, * _baseCheck; AskInt * _lordValue, * _baseValue; AskString * _basename; }; class AskLordCharac : public AskCombo { Q_OBJECT public: AskLordCharac( QWidget * parent = 0, const char * name = 0 ); }; #endif // QUESTCONDITIONPROPERTIES_H attal-src-1.0-rc2/scenarioEditor/questEditor.cpp0000644000175000017500000001102210522705153017436 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** questEditor.cpp ** Dialog for editing a quest ** ** Version : $Id: questEditor.cpp,v 1.10 2006/11/03 18:28:59 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "questEditor.h" // generic include files // include files for QT #include #include #include #include // application specific include files #include "libCommon/quest.h" #include "libClient/askWidget.h" #include "libClient/gui.h" #include "scenarioEditor/questConditionEditor.h" QuestEditor::QuestEditor( QWidget * parent, const char * name ) : QDialog( parent ) { setWindowTitle( QString ( name )); _quest = 0; _name = new AskString( tr( "Name: " ), this ); _description = new AskString( tr( "Description: " ), this ); _type = new AskCombo( tr( "Type: " ), this ); _type->insertItem( Quest::getTypeName( Quest::ONLY_ONE ) ); _type->insertItem( Quest::getTypeName( Quest::ONE_PERPLAYER ) ); _type->insertItem( Quest::getTypeName( Quest::ONE_PERLORD ) ); _type->insertItem( Quest::getTypeName( Quest::ANYONE ) ); _needConfirmation = new AskBool( tr( "Ask player confirmation of quest" ), this ); _confirmationQuestion = new AskString( tr( "Confirmation question: " ), this ); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCancel = new QPushButton( this ); pbCancel->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCancel ); QHBoxLayout * layH = new QHBoxLayout(); layH->addStretch( 1 ); layH->addWidget( pbOk ); layH->addStretch( 1 ); layH->addWidget( pbCancel ); layH->addStretch( 1 ); _editStartCondition = new QuestConditionEditor( this ); _editStartCondition->setTitle( tr( "Start condition: " ) ); _editFailCondition = new QuestConditionEditor( this ); _editFailCondition->setTitle( tr( "Fail condition: " ) ); _editSuccessCondition = new QuestConditionEditor( this ); _editSuccessCondition->setTitle( tr( "Success condition: " ) ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _name ); layout->addWidget( _description ); layout->addWidget( _type ); layout->addWidget( _needConfirmation ); layout->addWidget( _confirmationQuestion ); layout->addWidget( _editStartCondition ); layout->addWidget( _editFailCondition ); layout->addWidget( _editSuccessCondition ); layout->addStretch( 1 ); layout->addLayout( layH ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pbCancel, SIGNAL( clicked() ), SLOT( reject() ) ); connect( _needConfirmation, SIGNAL( sig_changed() ), SLOT( slot_confirmation() ) ); slot_confirmation(); } void QuestEditor::slot_confirmation() { _confirmationQuestion->setEnabled( _needConfirmation->getValue() ); } void QuestEditor::init( Quest * quest ) { _quest = quest; if( _quest ) { _name->setValue( _quest->getName() ); _description->setValue( _quest->getDescription() ); _type->setCurrentItem( (uint)_quest->getType() ); _needConfirmation->setValue( _quest->isConfirmationNeeded() ); _confirmationQuestion->setValue( _quest->getConfirmationQuestion() ); _editStartCondition->setCondition( quest->getStartCondition() ); _editFailCondition->setCondition( quest->getFailCondition() ); _editSuccessCondition->setCondition( quest->getSuccessCondition() ); slot_confirmation(); } } void QuestEditor::save() { if( _quest ) { _quest->setName( _name->getValue() ); _quest->setDescription( _description->getValue() ); _quest->setType( (Quest::QuestType)_type->currentItem() ); _quest->setConfirmationNeeded( _needConfirmation->getValue() ); _quest->setConfirmationQuestion( _confirmationQuestion->getValue() ); _quest->setStartCondition( _editStartCondition->getCondition() ); _quest->setFailCondition( _editFailCondition->getCondition() ); _quest->setSuccessCondition( _editSuccessCondition->getCondition() ); } } attal-src-1.0-rc2/scenarioEditor/questEditor.h0000644000175000017500000000336110331243515017107 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** questEditor.h ** Dialog for editing a quest ** ** Version : $Id: questEditor.h,v 1.6 2005/10/30 22:21:01 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef QUESTEDITOR_H #define QUESTEDITOR_H // generic include files // include files for QT #include // application specific include files class AskBool; class AskCombo; class AskString; class Quest; class QuestConditionEditor; /* ------------------------------ * QuestEditor * ------------------------------ */ class QuestEditor : public QDialog { Q_OBJECT public: /** Constructor */ QuestEditor( QWidget * parent = 0, const char * name = 0 ); void init( Quest * quest ); void save(); public slots: void slot_confirmation(); protected: Quest * _quest; AskString * _name, * _description; AskCombo * _type; AskBool * _needConfirmation; AskString * _confirmationQuestion; QuestConditionEditor * _editStartCondition; QuestConditionEditor * _editFailCondition; QuestConditionEditor * _editSuccessCondition; }; #endif // QUESTEDITOR_H attal-src-1.0-rc2/scenarioEditor/scenarioEditor.cpp0000644000175000017500000000463010630060445020105 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** scenarioEditor.cpp ** main file for the scenario editor ** ** Version : $Id: scenarioEditor.cpp,v 1.20 2007/06/01 18:10:45 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 27/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include using namespace std; // include files for QT #include #include #include #include #include #include #include // application specific includes #include "conf.h" #include "libCommon/attalCommon.h" #include "libCommon/log.h" #include "libClient/map.h" #include "libClient/gui.h" #include "scenarioEditor/scenarioInterface.h" extern QString IMAGE_PATH; extern QString THEME; extern QString THEME_PATH; int main( int argc, char **argv ) { QDir trfolder; trfolder = translationsDir(); QApplication app( argc, argv ); QTranslator translator( 0 ); translator.load( QString("scenario_editor_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibcomm( 0 ); translatorlibcomm.load( QString("attal_libcommon_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibclient( 0 ); translatorlibclient.load( QString("attal_libclient_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); app.installTranslator( &translator ); app.installTranslator( &translatorlibcomm ); app.installTranslator( &translatorlibclient ); if (parseArgs( argc, argv, AttalCommon::ATTALSCENARIOEDITOR) ) { return 1; } useTheme(); app.setWindowIcon(QIcon( IMAGE_PATH + "misc/ico_attal-scenario-editor.png")); if (app.windowIcon().isNull()) qDebug("Window icon is null!"); ScenarioInterface edit; //app.setMainWidget( &edit ); edit.show(); return app.exec(); } attal-src-1.0-rc2/scenarioEditor/scenarioEditor.pro0000644000175000017500000000360510761336143020132 0ustar aaaaTEMPLATE = app include( ../config.pro ) INCLUDEPATH += .. LIBS += -L.. unix:LIBS += -lAttalClient unix:LIBS += -lAttalCommon win32:LIBS += -lAttalClient9 win32:LIBS += -lAttalCommon9 contains( DEFINES, WITH_SOUND ) { win32:INCLUDEPATH += "$$quote($${SDL_DIR})\include" contains( CONFIG, staticlib ) { LIBS += -lSDL LIBS += -lSDL_mixer } } SOURCES += displayQuests.cpp #SOURCES += editorHandler.cpp SOURCES += itemSelection.cpp SOURCES += itemSelector.cpp SOURCES += propertiesBase.cpp SOURCES += propertiesBuilding.cpp SOURCES += propertiesCreature.cpp SOURCES += propertiesEvent.cpp SOURCES += propertiesLord.cpp SOURCES += propertiesPlayers.cpp SOURCES += questConditionEditor.cpp SOURCES += questConditionProperties.cpp SOURCES += questEditor.cpp SOURCES += scenarioEditor.cpp SOURCES += scenarioInfo.cpp SOURCES += scenarioInterface.cpp SOURCES += screen.cpp SOURCES += tilePresentation.cpp SOURCES += tileSelection.cpp HEADERS += displayQuests.h #HEADERS += editorHandler.h HEADERS += itemSelection.h HEADERS += itemSelector.h HEADERS += propertiesBase.h HEADERS += propertiesBuilding.h HEADERS += propertiesCreature.h HEADERS += propertiesEvent.h HEADERS += propertiesLord.h HEADERS += propertiesPlayers.h HEADERS += questConditionEditor.h HEADERS += questConditionProperties.h HEADERS += questEditor.h HEADERS += scenarioInfo.h HEADERS += scenarioInterface.h HEADERS += screen.h HEADERS += tilePresentation.h HEADERS += tileSelection.h DESTDIR = .. OBJECTS_DIR=./obj MOC_DIR=./moc TARGET = attal-scenario-editor TRANSLATIONS += ../i18n/de/scenario_editor_de.ts TRANSLATIONS += ../i18n/fr/scenario_editor_fr.ts TRANSLATIONS += ../i18n/ru/scenario_editor_ru.ts TRANSLATIONS += ../i18n/it/scenario_editor_it.ts unix:!macx { QMAKE_LFLAGS += -Wl,-rpath,. } unix { target.path = $${ATT_PREFIX}/bin/ INSTALLS += target } QT += xml win32 { contains( CONFIG, debug ) { CONFIG += console } } attal-src-1.0-rc2/scenarioEditor/scenarioInfo.cpp0000644000175000017500000001362210600241666017556 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** scenarioInfo.cpp ** Display/modif scenario info ** ** Version : $Id: scenarioInfo.cpp,v 1.11 2007/03/21 14:39:50 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 08/02/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "scenarioInfo.h" // generic include files // include files for QT #include #include #include #include #include #include // application specific include files #include "conf.h" #include "libCommon/log.h" #include "libClient/gui.h" int ScenarioInfo::_defaultVal = 1; ScenarioInfo::ScenarioInfo( QWidget * parent, const char * /* name */ ) : QDialog( parent, Qt::Dialog ) { setWindowTitle( tr( "General Scenario Informations" ) ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); QLabel * title = new QLabel( tr( "General Information" ), this ); title->setFont( QFont( "Helvetica", 20, QFont::Bold ) ); title->setAlignment( Qt::AlignCenter ); FIXEDSIZE( title ); layout->addWidget( title ); layout->addSpacing( 15 ); QHBoxLayout * layH1 = new QHBoxLayout(); QLabel * scenarName = new QLabel( tr( "Name: " ), this ); FIXEDSIZE( scenarName ); layH1->addWidget( scenarName ); _name = new QLineEdit( this ); _name->setFixedSize( 200, 20 ); layH1->addWidget( _name ); layH1->addStretch( 1 ); layout->addLayout( layH1 ); layout->addSpacing( 5 ); QHBoxLayout * layH2 = new QHBoxLayout(); QLabel * theme = new QLabel( tr( "Theme: " ), this ); FIXEDSIZE( theme ); layH2->addWidget( theme ); _theme = new QComboBox( this ); searchThemes( _theme ); FIXEDSIZE( _theme ); layH2->addWidget( _theme ); layH2->addStretch( 1 ); QLabel * nbPlayer = new QLabel( tr( "Number of players: " ), this ); FIXEDSIZE( nbPlayer ); layH2->addWidget( nbPlayer ); _nbPlayers = new QSpinBox( this ); FIXEDSIZE( _nbPlayers ); layH2->addWidget( _nbPlayers ); layH2->addStretch( 1 ); layout->addLayout( layH2 ); layout->addSpacing( 5 ); QHBoxLayout * layH3 = new QHBoxLayout(); QLabel * height = new QLabel( tr( "Map height: " ), this ); FIXEDSIZE( height ); layH3->addWidget( height ); _editHeight = new QLineEdit( this ); _editHeight->setFixedSize( 50, 20 ); layH3->addWidget( _editHeight ); layH3->addStretch( 1 ); QLabel * width = new QLabel( tr( "Map width: " ), this ); FIXEDSIZE( width ); layH3->addWidget( width ); _editWidth = new QLineEdit( this ); _editWidth->setFixedSize( 50, 25 ); layH3->addWidget( _editWidth ); layH3->addStretch( 1 ); layout->addLayout( layH3 ); layout->addSpacing( 5 ); QHBoxLayout * layH5 = new QHBoxLayout(); QLabel * day = new QLabel( tr( "Day: " ), this ); FIXEDSIZE( day ); layH5->addWidget( day ); _day = new QSpinBox( this ); FIXEDSIZE( _day ); layH5->addWidget( _day ); _day->setValue( 1 ); QLabel * week = new QLabel( tr( "Week: " ), this ); FIXEDSIZE( week ); layH5->addWidget( week ); _week = new QSpinBox( this ); FIXEDSIZE( _week ); layH5->addWidget( _week ); _week->setValue( 1 ); QLabel * month = new QLabel( tr( "Month: " ), this ); FIXEDSIZE( month ); layH5->addWidget( month ); _month = new QSpinBox( this ); FIXEDSIZE( _month ); layH5->addWidget( _month ); _month->setValue( 1 ); QLabel * year = new QLabel( tr( "Year: " ), this ); FIXEDSIZE( year ); layH5->addWidget( year ); _year = new QSpinBox( this ); _year->setMaximum( 9999 ); _year->setValue( 1044 ); FIXEDSIZE( _year ); layH5->addWidget( _year ); layH5->addStretch( 1 ); layout->addLayout( layH5 ); layout->addSpacing( 5 ); QHBoxLayout * layH4 = new QHBoxLayout(); QLabel * desc = new QLabel( tr( "Description: " ), this ); FIXEDSIZE( desc ); layH4->addWidget( desc ); layH4->addStretch( 1 ); layout->addLayout( layH4 ); _desc = new QTextEdit( this ); layout->addWidget( _desc, 1 ); QPushButton * butOk = new QPushButton( this ); butOk->setText( tr( "Ok" ) ); FIXEDSIZE( butOk ); QPushButton * butCan = new QPushButton( this ); butCan->setText( tr( "Cancel" ) ); FIXEDSIZE( butCan ); QHBoxLayout * layH6 = new QHBoxLayout(); layH6->addStretch( 1 ); layH6->addWidget( butOk ); layH6->addStretch( 1 ); layH6->addWidget( butCan ); layH6->addStretch( 1 ); layout->addSpacing( 5 ); layout->addLayout( layH6 ); layout->activate(); connect( butCan, SIGNAL( clicked() ), SLOT( reject() ) ); connect( butOk, SIGNAL( clicked() ), SLOT( slot_ok() ) ); setMapHeight( 50 ); setMapWidth( 50 ); setNbPlayer( 2 ); setName( tr( "Map " ) + QString::number( _defaultVal ) ); setDescription( tr( "Map for Attal" ) ); setTheme( "medieval" ); _defaultVal++; } void ScenarioInfo::slot_ok() { /// XXX: have to check values accept(); } void ScenarioInfo::searchThemes( QComboBox * combo ) { /// XXX: have to be changed for a real search of theme name combo->addItem( "cyberpunk" ); combo->addItem( "medieval" ); } void ScenarioInfo::setTheme( const QString & theme ) { int index = 0; do { _theme->setCurrentIndex( index ); index++; } while ( ( index < _theme->count() ) && ( _theme->currentText() != theme ) ); if( _theme->currentText() != theme ) { logEE( "Theme %s not found", theme.toLatin1().constData() ); _theme->setCurrentIndex( 0 ); } } void ScenarioInfo::clear() { setName( "" ); setTheme( THEME_DEFAULT ); setNbPlayer( 2 ); setMapWidth( 50 ); setMapHeight( 50 ); setDescription( "" ); } attal-src-1.0-rc2/scenarioEditor/scenarioInfo.h0000644000175000017500000000653310511545110017216 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** scenarioInfo.h ** Display/modif scenario info ** ** Version : $Id: scenarioInfo.h,v 1.6 2006/10/06 21:27:36 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier - Sardi Carlo ** ** Date : 08/02/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SCENARIOINFO_H #define SCENARIOINFO_H // generic include files // include files for QT #include #include #include #include #include #include // application specific include files /* ------------------------------ * ScenarioInfo * ------------------------------ */ class ScenarioInfo : public QDialog { Q_OBJECT public: /** Constructor */ ScenarioInfo( QWidget * parent = 0, const char * name = 0 ); /** Clear the infos */ void clear(); /** Set description of the scenario */ void setDescription( const QString & desc ) { _desc->setText( desc ); } /** Return description of the scenario */ QString getDescription() { return _desc->toPlainText(); } /** Set name of the scenario */ void setName( QString name ) { _name->setText( name ); } /** Return name of the scenario */ QString getName() { return _name->text(); } /** Set theme required by scenario */ void setTheme( const QString & theme ); /** Return theme required by scenario */ QString getTheme() { return _theme->currentText(); } /** Set nb of players required by the scenario */ void setNbPlayer( int nb ) { _nbPlayers->setValue( nb ); } /** Return nb of players required by the scenario */ uint getNbPlayer() { return _nbPlayers->value(); } /** Set height of the map */ void setMapHeight( int height ) { _editHeight->setText( QString::number( height ) ); } /** Return height of the map */ int getMapHeight() { return _editHeight->text().toInt(); } /** Set width of the map */ void setMapWidth( int width ) { _editWidth->setText( QString::number( width ) ); } /** Return width of the map */ int getMapWidth() { return _editWidth->text().toInt(); } void setDay( int nb ) { _day->setValue( nb ); } uint getDay() { return _day->value(); } void setWeek( int nb ) { _week->setValue( nb ); } uint getWeek() { return _week->value(); } void setMonth( int nb ) { _month->setValue( nb ); } uint getMonth() { return _month->value(); } void setYear( int nb ) { _year->setValue( nb ); } uint getYear() { return _year->value(); } public slots: /** Slot for 'Ok' button */ void slot_ok(); private: void searchThemes( QComboBox * combo ); QLineEdit * _name; QTextEdit * _desc; QComboBox * _theme; QSpinBox * _nbPlayers; QSpinBox * _day , * _month, * _week , * _year; QLineEdit * _editWidth, * _editHeight; static int _defaultVal; }; #endif // SCENARIOINFO_H attal-src-1.0-rc2/scenarioEditor/scenarioInterface.cpp0000644000175000017500000002452010762316275020572 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** scenarioInterface.cpp ** Manages the scenario editor ** ** Version : $Id: scenarioInterface.cpp,v 1.33 2008/03/01 18:13:17 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 27/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "scenarioInterface.h" // include files for QT #include #include #include #include #include #include #include #include #include #include // application specific include files #include "conf.h" #include "libCommon/dataTheme.h" #include "libClient/aboutDialog.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "scenarioEditor/screen.h" extern QString IMAGE_PATH; extern QString DATA_PATH; extern QString THEME; // // ----- ScenarioInterface ----- // ScenarioInterface::ScenarioInterface() { _filename = ""; _actions.resize( NB_ACTIONS ); _help = NULL; initActions(); initMenuBar(); initStatusBar(); activateMenuForScenario( false ); if( DataTheme.init() && ImageTheme.init() ) { _screen = new Screen( this ); setCentralWidget( _screen ); resize( 600, 600 ); connect( _screen, SIGNAL( sig_status( const QString & ) ), this, SLOT( slot_status( const QString & ) ) ); } else { /// XXX: we could manage this better (later :) ) QMessageBox::critical( this, tr( "Can't load theme" ), tr( "Theme " ) + THEME + tr( " has not been loaded successfully" ) ); } } ScenarioInterface::~ScenarioInterface() { delete _screen; //free before ImageTheme, after DataTheme (clear of ImageTheme depend on DataTheme data) ImageTheme.clear(); DataTheme.clear(); } void ScenarioInterface::changeEvent ( QEvent * e ) { //used to replace setCaption switch (e->type()){ case QEvent::WindowTitleChange: { setWindowTitle( "Scenario editor for 'Attal - Lords of Doom'" ); } break; default: QWidget::changeEvent ( e ); break; } } void ScenarioInterface::addAction( const QString & text, const QString & key, MENU_ACTION num, QSignalMapper * sigmap ) { QAction * action = new QAction( text, this ); action->setShortcut( QKeySequence( key ) ); _actions.insert( num, action ); sigmap->setMapping( action, num ); connect( action, SIGNAL( triggered() ), sigmap, SLOT( map() ) ); } void ScenarioInterface::initActions() { QSignalMapper * sigmap = new QSignalMapper( this ); addAction( tr( "&New" ), tr( "CTRL+N" ), ACTION_NEW, sigmap ); addAction( tr( "&Open" ), tr( "CTRL+O" ), ACTION_OPEN, sigmap ); addAction( tr( "&Save" ), tr( "CTRL+S" ), ACTION_SAVE, sigmap ); addAction( tr( "&Save as" ), "", ACTION_SAVEAS, sigmap ); addAction( tr( "&Quit" ), tr( "CTRL+Q" ), ACTION_QUIT, sigmap ); addAction( tr( "&Scenario information" ), tr( "CTRL+I" ), ACTION_INFO, sigmap ); addAction( tr( "&Players properties" ), tr( "CTRL+P" ), ACTION_PLAYERS, sigmap ); addAction( tr( "Quests management" ), "", ACTION_QUESTS, sigmap ); addAction( tr( "&Clear screen" ), tr( "CTRL+C" ), ACTION_CLEAR, sigmap ); addAction( tr( "&Fill screen" ), tr( "CTRL+F" ), ACTION_FILL, sigmap ); addAction( tr( "&Mini map" ), tr( "CTRL+M" ), ACTION_MINIMAP, sigmap ); _actions[ ACTION_MINIMAP ]->setCheckable( true ); _actions[ ACTION_MINIMAP ]->setChecked( true ); addAction( tr( "&Grid" ), tr( "CTRL+G" ), ACTION_GRID, sigmap ); _actions[ ACTION_GRID ]->setCheckable( true ); _actions[ ACTION_GRID ]->setChecked( false ); addAction( tr( "&Help" ), tr( "F1" ), ACTION_HELP, sigmap ); addAction( tr( "&About" ), tr( "CTRL+A" ), ACTION_ABOUT, sigmap ); connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_action( int ) ) ); } void ScenarioInterface::initStatusBar() { statusBar()->showMessage( "Status Bar", 0 ); } /*! define menus */ void ScenarioInterface::initMenuBar() { QMenu * menuFile = menuBar()->addMenu( tr( "&File" ) ); QMenu * menuScen = menuBar()->addMenu( tr( "&Scenario" ) ); QMenu * menuTools = menuBar()->addMenu( tr( "&Tools" ) ); QMenu * menuHelp = menuBar()->addMenu( tr( "&Help" ) ); menuFile->addAction( _actions[ ACTION_NEW ] ); menuFile->addAction( _actions[ ACTION_OPEN ] ); menuFile->addAction( _actions[ ACTION_SAVE ] ); menuFile->addAction( _actions[ ACTION_SAVEAS ] ); menuFile->addSeparator(); menuFile->addAction( _actions[ ACTION_QUIT ] ); menuScen->addAction( _actions[ ACTION_INFO ] ); menuScen->addAction( _actions[ ACTION_PLAYERS ] ); menuScen->addAction( _actions[ ACTION_QUESTS ] ); menuTools->addAction( _actions[ ACTION_CLEAR ] ); menuTools->addAction( _actions[ ACTION_FILL ] ); menuTools->addAction( _actions[ ACTION_MINIMAP ] ); menuTools->addAction( _actions[ ACTION_GRID ] ); menuHelp->addAction( _actions[ ACTION_HELP ] ); menuHelp->addAction( _actions[ ACTION_ABOUT ] ); } void ScenarioInterface::slot_action( int num ) { switch( num ) { case ACTION_NEW: actionNew(); break; case ACTION_OPEN: actionOpen(); break; case ACTION_SAVE: actionSave(); break; case ACTION_SAVEAS: actionSaveAs(); break; case ACTION_QUIT: actionQuit(); break; case ACTION_INFO: actionInfo(); break; case ACTION_PLAYERS: actionPlayers(); break; case ACTION_QUESTS: actionQuests(); break; case ACTION_CLEAR: actionClear(); break; case ACTION_FILL: actionFill(); break; case ACTION_MINIMAP: actionMinimap(); break; case ACTION_GRID: actionGrid(); break; case ACTION_HELP: actionHelp(); break; case ACTION_ABOUT: actionAbout(); break; } } void ScenarioInterface::activateMenuForScenario( bool state ) { _actions[ ACTION_SAVE ]->setEnabled( state ); _actions[ ACTION_SAVEAS ]->setEnabled( state ); _actions[ ACTION_INFO ]->setEnabled( state ); _actions[ ACTION_PLAYERS ]->setEnabled( state ); _actions[ ACTION_QUESTS ]->setEnabled( state ); _actions[ ACTION_CLEAR ]->setEnabled( state ); _actions[ ACTION_FILL ]->setEnabled( state ); } void ScenarioInterface::actionNew() { if( _screen->newScenario() ) { _actions[ ACTION_GRID ]->setChecked( false ); _filename = ""; activateMenuForScenario( true ); } } void ScenarioInterface::actionOpen() { QString filename = QFileDialog::getOpenFileName( this, tr( "Open scenario" ), "", "*.scn *.gam" ); if( !filename.isEmpty() ) { _actions[ ACTION_GRID ]->setChecked( false ); if( _screen->load( filename ) ) { _filename = filename; activateMenuForScenario( true ); } } } void ScenarioInterface::actionSave() { if( _filename.isEmpty() ) { slot_action( ACTION_SAVEAS ); } else { _screen->save( _filename ); } } void ScenarioInterface::actionSaveAs() { _filename = QFileDialog::getSaveFileName( this, tr( "Save scenario as" ), "", "*.scn" ); if( !_filename.isEmpty() ) { _screen->save( _filename ); } } void ScenarioInterface::actionQuit() { qApp->quit(); } void ScenarioInterface::actionInfo() { _screen->displayInfo(); } void ScenarioInterface::actionPlayers() { _screen->displayPlayersProperties(); } void ScenarioInterface::actionQuests() { _screen->manageQuests(); } void ScenarioInterface::actionClear() { _screen->clearMap(); } void ScenarioInterface::actionFill() { FillDialog dialog( this ); if( dialog.exec() ) { _screen->fillMap( dialog.getTileNumber(), dialog.getTileDiversification() ); } } void ScenarioInterface::actionMinimap() { _screen->displayMiniMap( _actions[ ACTION_MINIMAP ]->isChecked() ); } void ScenarioInterface::actionGrid() { _screen->gridMap(); } void ScenarioInterface::actionHelp() { if( ! _help ) { _help = new DisplayHelp( this ); } _help->resize( 800, 600 ); _help->show(); } void ScenarioInterface::actionAbout() { AboutDialog dialog( this ); dialog.exec(); } void ScenarioInterface::slot_status( const QString & text ) { statusBar()->showMessage( text, 0 ); } // // ----- FillDialog ----- // FillDialog::FillDialog( QWidget * parent, const char * /* name */ ) :QDialog( parent, Qt::Dialog ) { setWindowTitle( tr( "Choose tile" ) ); _comboTile = new QComboBox( this ); for( int i = 0; i < DataTheme.tiles.count(); i++ ) { QString name = QString::number( i ) + " - " + DataTheme.tiles.at( i )->getName(); _comboTile->addItem( name, i ); } FIXEDSIZE( _comboTile ); _comboDiversification = new QComboBox( this ); slot_updateDiversification( 0 ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setMargin( 5 ); layH1->setSpacing( 5 ); layH1->addWidget( _comboTile ); layH1->addWidget( _comboDiversification ); layH1->addStretch( 1 ); QPushButton * pb1 = new QPushButton( this ); pb1->setText( tr( "Ok" ) ); FIXEDSIZE( pb1 ); QPushButton * pb2 = new QPushButton( this ); pb2->setText( tr( "Cancel" ) ); FIXEDSIZE( pb2 ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->setMargin( 5 ); layH2->addStretch( 1 ); layH2->addWidget( pb1 ); layH2->addStretch( 1 ); layH2->addWidget( pb2 ); layH2->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layH1 ); layout->addStretch( 1 ); layout->addLayout( layH2 ); layout->activate(); connect( pb1, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pb2, SIGNAL( clicked() ), SLOT( reject() ) ); connect( _comboTile, SIGNAL( activated( int ) ), SLOT( slot_updateDiversification( int ) ) ); } void FillDialog::slot_updateDiversification( int tile ) { QString text; CellModel * cell; cell = DataTheme.tiles.at( tile ); _comboDiversification->clear(); _comboDiversification->addItem( "Random" ); uint nb = cell->getDiversificationNumber(); for( uint i = 0; i < nb; i++ ) { text = tr( "%1 (weight=%2)" ).arg(i+1).arg( cell->getDiversification( i )); _comboDiversification->addItem( text ); } _comboDiversification->setCurrentIndex( 0 ); FIXEDSIZE( _comboDiversification ); } uint FillDialog::getTileNumber() { return _comboTile->currentIndex(); } uint FillDialog::getTileDiversification() { return _comboDiversification->currentIndex(); } attal-src-1.0-rc2/scenarioEditor/scenarioInterface.h0000644000175000017500000000617710762316275020247 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** scenarioInterface.h ** Manages the scenario editor ** ** Version : $Id: scenarioInterface.h,v 1.17 2008/03/01 18:13:17 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 27/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SCENARIOINTERFACE_H #define SCENARIOINTERFACE_H // include files for QT #include #include #include #include #include // application specific includes #include "libCommon/displayHelp.h" class QComboBox; class QSignalMapper; class Screen; /* ------------------------------ * ScenarioInterface * ------------------------------ */ class ScenarioInterface : public QMainWindow { Q_OBJECT public: /** Constructor */ ScenarioInterface(); /** Destructor */ virtual ~ScenarioInterface(); public slots: /** Slot managing the actions */ void slot_action( int num ); /** Slot managing the status bar */ void slot_status( const QString & text ); protected: virtual void changeEvent ( QEvent * e ); private: enum MENU_ACTION { ACTION_NEW, ACTION_OPEN, ACTION_SAVE, ACTION_SAVEAS, ACTION_QUIT, ACTION_INFO, ACTION_PLAYERS, ACTION_QUESTS, ACTION_CLEAR, ACTION_FILL, ACTION_MINIMAP, ACTION_GRID, ACTION_HELP, ACTION_ABOUT, NB_ACTIONS }; void actionNew(); void actionOpen(); void actionSave(); void actionSaveAs(); void actionQuit(); void actionInfo(); void actionPlayers(); void actionQuests(); void actionClear(); void actionFill(); void actionMinimap(); void actionGrid(); void actionHelp(); void actionAbout(); /** Defines actions */ void initActions(); /** Define menus */ void initMenuBar(); /** Define statusBar */ void initStatusBar(); void activateMenuForScenario( bool state = true ); void addAction( const QString & text, const QString & key, MENU_ACTION num, QSignalMapper * sigmap ); Screen * _screen; QString _filename; DisplayHelp * _help; QVector _actions; }; /** Dialog asking to choose a tile for filling the map with */ class FillDialog : public QDialog { Q_OBJECT public: /** Constructor */ FillDialog( QWidget * parent = 0, const char * name = 0 ); /** \return Returns the num of the tile choosen */ uint getTileNumber(); /** \return Returns the diversification of the tile (0 means 'random') */ uint getTileDiversification(); public slots: void slot_updateDiversification( int tile ); private: QComboBox * _comboTile, * _comboDiversification; }; #endif // SCENARIOINTERFACE_H attal-src-1.0-rc2/scenarioEditor/scenario_editor_fr.ts0000644000175000017500000002151107720232635020644 0ustar aaaa EditTroop Race : Race : Name : Nom : Number : Nombre : FillDialog Choose tile Choisissez un sol Ok Ok Cancel Annuler PropertiesBase Base properties Owner: Buildings Ok Ok None PropertiesCreature Number of Creatures: Ok Ok Behaviour of Creatures: Never flee: PropertiesLord Lord properties General Units Artefacts War Machines Technics Lord's properties error The lord must have at least 1 unit PropertiesLordArtefacts Common artefacts list Lord's artefacts list PropertiesLordGeneral Select player: Default PropertiesLordTechnics Common technics list Lord's technics list PropertiesLordWarMachines Common war machines list Lord's war machines list QObject Tile Transition Decoration Building Base Lord Artefact Creature Tool ScenarioInterface New Nouveau &New &Nouveau CTRL+N CTRL+N Open Ouvrir &Open &Ouvrir CTRL+O CTRL+O Save Sauvegarder &Save &Sauvegarder CTRL+S CTRL+S Save as Sauvegarder sous &Save as &Sauvegarder sous Quit Quitter &Quit &Quitter CTRL+Q CTRL+Q Scenario information Informations sur le scenario &Scenario information &Information sur le scénario CTRL+I CTRL+I Players properties Propriétés des joueurs &Players properties &Propriétés des joueurs CTRL+P CTRL+P Clear screen Effacer la carte &Clear screen Effacer la &carte CTRL+C CTRL+C Fill screen Remplir la carte &Fill screen &Remplir la carte CTRL+F Help Aide &Help &Aide F1 F1 &File &Fichier &Scenario &Scenario &Tools &Outils attal-src-1.0-rc2/scenarioEditor/scenario_editor_ru.ts0000644000175000017500000002206407720232635020667 0ustar aaaa EditTroop Race : Name : Number : FillDialog Choose tile Ok Cancel PropertiesBase Base properties Owner: Buildings Ok None PropertiesCreature Number of Creatures: Ok Behaviour of Creatures: Never flee: PropertiesLord Lord properties General Units Artefacts War Machines Technics Lord's properties error The lord must have at least 1 unit PropertiesLordArtefacts Common artefacts list Lord's artefacts list PropertiesLordGeneral Select player: Default PropertiesLordTechnics Common technics list Lord's technics list PropertiesLordWarMachines Common war machines list Lord's war machines list QObject Tile Transition Decoration Building Base Lord Artefact Creature Tool ScenarioInterface New &New CTRL+N Open &Open CTRL+O Save &Save CTRL+S Save as &Save as Quit &Quit CTRL+Q Scenario information &Scenario information CTRL+I Players properties &Players properties CTRL+P Clear screen &Clear screen CTRL+C Fill screen &Fill screen CTRL+F Help &Help F1 &File &Scenario &Tools attal-src-1.0-rc2/scenarioEditor/screen.cpp0000644000175000017500000003312310761121720016410 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** screen.cpp ** main widget of the editor ** ** Version : $Id: screen.cpp,v 1.68 2008/02/26 23:42:08 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo - Forest Darling ** ** Date : 27/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "screen.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include #include #include #include // application specific includes #include "libCommon/genericMapCreature.h" #include "libCommon/genericPlayer.h" #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libCommon/parser.h" #include "libClient/event.h" #include "libClient/map.h" #include "libClient/mapView.h" #include "libClient/miniMap.h" #include "libClient/cell.h" #include "libClient/graphicalArtefact.h" #include "scenarioEditor/displayQuests.h" #include "scenarioEditor/itemSelector.h" #include "scenarioEditor/propertiesBase.h" #include "scenarioEditor/propertiesBuilding.h" #include "scenarioEditor/propertiesCreature.h" #include "scenarioEditor/propertiesEvent.h" #include "scenarioEditor/propertiesLord.h" #include "scenarioEditor/propertiesCreature.h" #include "scenarioEditor/propertiesPlayers.h" #include "scenarioEditor/scenarioInfo.h" extern Map * theMap; Screen::Screen( QWidget * parent, char * name ) : QWidget( parent ), GraphicalGameData() { setWindowTitle( QString ( name )); _leftPressed = false; _currentCell = 0; theMap = new Map( this ); _map = theMap; _view = new MapView( theMap, this ); _selector = new ItemSelector( this, this ); _miniMap = new MiniMap( theMap, this ); QVBoxLayout * layV1 = new QVBoxLayout(); layV1->addWidget( _selector, 1 ); layV1->addWidget( _miniMap ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->addLayout( layV1 ); layout->addWidget( _view, 1 ); layout->activate(); reinit(); _menu = new QMenu( this ); QSignalMapper * sigmap = new QSignalMapper( this ); addAction( tr( "&Delete" ), M_DELETE, sigmap ); addAction( tr( "&Properties" ), M_PROPERTIES, sigmap ); connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_popup( int ) ) ); connect( _view, SIGNAL( sig_mouseMoved ( GenericCell *) ), SLOT( slot_mouseMoved ( GenericCell *) ) ); connect( _view, SIGNAL( sig_mouseLeftPressed( GenericCell *) ), SLOT( slot_mouseLeftPressed( GenericCell *) ) ); connect( _view, SIGNAL( sig_mouseRightPressed( GenericCell *) ), SLOT( slot_mouseRightPressed( GenericCell *) ) ); connect( _view, SIGNAL( sig_mouseReleased() ), SLOT( slot_mouseReleased() ) ); connect( _view, SIGNAL( sig_viewportResized( double, double ) ), _miniMap, SLOT( slot_mapviewResized( double, double ) ) ); connect( _view, SIGNAL( sig_viewportScrolled( double, double ) ), _miniMap, SLOT( slot_mapviewScrolled( double, double ) ) ); connect( _miniMap , SIGNAL( sig_mouseReleasedMinimap( double, double ) ), _view, SLOT( slot_Center( double, double ) ) ); connect( this , SIGNAL( sig_cellChanged( int, int ) ), _miniMap, SLOT( slot_redrawCell( int, int ) ) ); } Screen::~Screen() { clearMap(); } void Screen::slot_mouseLeftPressed( GenericCell * c ) { _selector->handleLeftClick( c ); cellChanged( c ); _leftPressed = true; } void Screen::slot_mouseRightPressed( GenericCell * c ) { _currentCell = c; _menu->popup( QCursor::pos() ); } void Screen::slot_mouseReleased() { _leftPressed = false; } void Screen::slot_mouseMoved( GenericCell * c ) { if( _currentCell != c ) { updateStatusBar( c ); if( c->getLord() ) { setCursor( Qt::WaitCursor ); } else if( c->getBase() ) { setCursor( Qt::WaitCursor ); } else if( c->getBuilding() ) { setCursor( Qt::WaitCursor ); } else if( c->getEvent() ) { setCursor( Qt::WaitCursor ); } else if( c->getCreature() ) { setCursor( Qt::WaitCursor ); } else if( c->getDecorationGroup() ) { setCursor( Qt::PointingHandCursor ); } else if( c->getCoeff() < 0 || !c->isStoppable() || !c->isFree() ) { setCursor( Qt::ForbiddenCursor ); // } else if( c->getTransition() ) { // setCursor( Qt::upArrowCursor ); } else { setCursor( Qt::ArrowCursor ); } // XXX: _currentCell->setBorder( false ); _currentCell = c; if( _leftPressed ) { _selector->handleLeftClick( c ); cellChanged( c ); } // XXX: _currentCell->setBorder( true ); } } void Screen::slot_popup( int num ) { switch( num ) { case M_DELETE: handleDelete(); break; case M_PROPERTIES: handleProperties(); break; } } void Screen::slot_centerMinimap( qreal x, qreal y ) { _view->centerOn(x, y); } void Screen::displayMiniMap( bool state ) { if( _miniMap ) { if( state ) { _miniMap->show(); _miniMap->redrawMap( theMap ); } else { _miniMap->hide(); } } } void Screen::handleDelete() { if( _currentCell->getLord() ) { GenericLord * lord = _currentCell->getLord(); if(lord->getOwner()){ lord->getOwner()->removeLord(lord); } lord->setCell( NULL ); } else if( _currentCell->getCreature() ) { GenericMapCreature * creature = _currentCell->getCreature(); removeMapCreature(creature); _currentCell->setCreature( NULL ); } else if( _currentCell->getBuilding() ) { GenericBuilding * build = _currentCell->getBuilding(); removeBuilding( build ); _currentCell->setBuilding( NULL ); } else if( _currentCell->getBase() ) { GenericBase * base = _currentCell->getBase(); removeBase( base ); _currentCell->setBase( NULL ); } else if( _currentCell->getEvent() ) { Event * event = (Event *)( _currentCell->getEvent() ); removeEvent( event ); _currentCell->setEvent( NULL ); } else if( _currentCell->getDecorationGroup() ) { _currentCell->setDecoration( 0, 0 ); } else if( _currentCell->getTransition() ) { _currentCell->setTransition( 0 ); _currentCell->setTransitionCellType( 0 ); } cellChanged( _currentCell ); } void Screen::handleProperties() { if( _currentCell->getLord() ) { handlePropertiesLord(); } else if( _currentCell->getBase() ) { handlePropertiesBase(); } else if( _currentCell->getBuilding() ) { handlePropertiesBuilding(); } else if (_currentCell->getCreature() ) { handlePropertiesCreature(); } else if( _currentCell->getEvent() ) { handlePropertiesEvent(); } } void Screen::handlePropertiesLord() { /// XXX: to improve (member for PropeertiesLord... ?? ) PropertiesLord * propLord = new PropertiesLord( & _players ); //* Here we'll receive info about all lords and give this info to dialog (for ids...)*/ int numLords = 0; uint* ids = 0; for( uint i = 0; i < theMap->getHeight(); i++ ) { for( uint j = 0; j < theMap->getWidth(); j++ ) { if( theMap->at( i, j )->getLord() ) { GenericLord* lord = theMap->at( i, j )->getLord(); if( lord != _currentCell->getLord() ) { numLords++; } } } } if (numLords > 0) { ids = new uint [numLords]; numLords = 0; for( uint i = 0; i < theMap->getHeight(); i++ ) { for( uint j = 0; j < theMap->getWidth(); j++ ) { if (theMap->at( i, j )->getLord ()) { GenericLord* lord = theMap->at( i, j )->getLord (); if (lord != _currentCell->getLord ()) { ids[numLords] = lord->getId (); numLords++; } } } } } propLord->init( _currentCell->getLord(), ids, numLords ); propLord->exec(); if (ids) { delete[] ids; } delete propLord; } void Screen::handlePropertiesBase() { PropertiesBase * propBase = new PropertiesBase( & _players ); propBase->init( _currentCell->getBase() ); propBase->exec(); delete propBase; } void Screen::handlePropertiesBuilding() { PropertiesBuilding propBuilding( & _players ); propBuilding.init( _currentCell->getBuilding() ); propBuilding.exec(); } void Screen::handlePropertiesCreature() { PropertiesCreature propCreature; propCreature.init( _currentCell->getCreature() ); propCreature.exec(); } void Screen::handlePropertiesEvent() { PropertiesEvent propEvent( _currentCell->getEvent() ); propEvent.exec(); } void Screen::updateStatusBar( GenericCell * c ) { if( c ) { QString msg; msg = tr( "(Cell %1x%2)" ).arg( c->getRow()).arg( c->getCol() ); emit sig_status( msg ); } } void Screen::cellChanged( GenericCell * c ) { //int width = DataTheme.tiles.getWidth(); //int height = DataTheme.tiles.getHeight(); emit sig_cellChanged( c->getRow(), c->getCol() ); theMap->updateMap(); /* // TODO the graphicalMap/Map class should handle cell to rect updating // HACK large drawing for all cases for ( int row = std::max( 0, c->getRow() - 1 ); row < std::min( c->getRow() + 2, (int)_map->getHeight() ); row++ ) { for ( int col = std::max( 0, c->getCol() - 1); col < std::min( c->getCol() + 2, (int)_map->getWidth() ); col++ ) { theMap->updateMapRect( QRectF( col * width, row * height, width, height) ); } }*/ } void Screen::displayInfo() { ScenarioInfo info( this ); info.setNbPlayer( getNbPlayer() ); info.setName( getScenarioName() ); info.setTheme( getScenarioTheme() ); info.setDescription( getScenarioDescription() ); info.setDay(getDateByType( 0 ) ); info.setWeek(getDateByType( 2 ) ); info.setMonth(getDateByType( 3 ) ); info.setYear(getDateByType( 4 ) ); if(theMap) { info.setMapWidth( theMap->getWidth() ); info.setMapHeight( theMap->getHeight() ); } if( info.exec() ) { setNbPlayer( info.getNbPlayer() ); setScenarioName( info.getName() ); setScenarioTheme( info.getTheme() ); setScenarioDescription( info.getDescription() ); setDateByType( 0, info.getDay() > 0 ? info.getDay() : 1 ); setDateByType( 1, 1 ); setDateByType( 2, info.getWeek() ); setDateByType( 3, info.getMonth() ); setDateByType( 4, info.getYear() ); adjustPlayers(); } } bool Screen::load( const QString filename ) { reinit(); ScenarioParser handler( (GameData*)this ); QFile file( filename ); QXmlInputSource source( &file ); QXmlSimpleReader reader; reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); bool ok = reader.parse( source ); file.close(); if ( !ok ) { logEE( "Parse Error (%s) : %s", filename.toLatin1().constData(), handler.errorProtocol().toLatin1().constData() ); return false; } _map->computeStoppable(); _miniMap->redrawMap( theMap ); //HACK to workaround some widget problems layout()->update(); return true; } void Screen::save( QString filename ) { if(!filename.contains(".scn") && !filename.contains(".gam")){ filename.append(".scn"); } QFile f( filename ); if (! f.open(QIODevice::WriteOnly) ) { logEE("Could not open file %s for writing\n", filename.toLatin1().constData() ); return; } QTextStream ts( &f ); GraphicalGameData::save( &ts ); f.close(); } bool Screen::newScenario() { bool ret = false; ScenarioInfo info( this ); if( info.exec() ) { ret = true; reinit(); theMap->newUnknownMap( info.getMapHeight(), info.getMapWidth() ); _players.clear(); setScenarioName( info.getName() ); setScenarioTheme( info.getTheme() ); setScenarioDescription( info.getDescription() ); setNbPlayer( info.getNbPlayer() ); setDateByType( 0, info.getDay() > 0 ? info.getDay() : 1 ); setDateByType( 1, 1 ); setDateByType( 2, info.getWeek() > 0 ? info.getWeek() : 1 ); setDateByType( 3, info.getMonth() > 0 ? info.getMonth() : 1); setDateByType( 4, info.getYear() > 0 ? info.getYear() : 1044); for( uint i = 0; i < info.getNbPlayer(); i++ ) { GenericPlayer * player = new GenericPlayer( theMap ); player->setNum( i ); player->setName( QString("Player %1").arg(i) ); _players.append( player ); } _miniMap->redrawMap( theMap ); //HACK to workaround some widget problems _miniMap->slot_mapviewResized( _view->width() / theMap->width(), _view->height() / theMap->height() ); layout()->update(); } return ret; } void Screen::clearMap() { TRACE("Screen::clearMap"); if( theMap ) { int height = theMap->getHeight(); int width = theMap->getWidth(); theMap->clearData(); reinit(); theMap->newUnknownMap( height, width ); _miniMap->redrawMap( theMap ); _map->computeStoppable(); } } void Screen::fillMap( uint tile, uint divers ) { if( theMap ) { for( uint i = 0; i < theMap->getHeight(); i++ ) { for( uint j = 0; j < theMap->getWidth(); j++ ) { theMap->at( i, j )->setType( tile ); if( ( divers == 0 ) && ( tile != 0 ) ) { theMap->at( i, j )->setRandomDiversification(); } else { theMap->at( i, j )->setDiversification( divers - 1 ); } } } } theMap->updateMap(); _miniMap->redrawMap( theMap ); } void Screen::displayPlayersProperties () { PropertiesPlayers propertiesPlayerDialog (this, &_players); propertiesPlayerDialog.exec (); } void Screen::manageQuests() { DisplayQuests * quests = new DisplayQuests( this ); quests->reinit( _quests ); quests->exec(); delete quests; } void Screen::gridMap() { if(theMap) { theMap->activateGrid(); } } QAction * Screen::addAction( const QString & label, POPUP_ITEM id, QSignalMapper * sigmap ) { QAction * action; action = new QAction( label, this ); _actions.insert( id, action ); _menu->addAction( action ); sigmap->setMapping( action, id ); connect( action, SIGNAL( triggered() ), sigmap, SLOT( map() ) ); return action; } attal-src-1.0-rc2/scenarioEditor/screen.h0000644000175000017500000000617410642276761016101 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** screen.h ** main widget of the editor ** ** Version : $Id: screen.h,v 1.24 2007/07/02 22:36:33 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 27/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SCREEN_H #define SCREEN_H // generic include files // include files for QT #include #include // application specific include files #include "libClient/graphicalGameData.h" class QMenu; class Cell; class GenericCell; class ItemSelector; class MapView; class MiniMap; class QSignalMapper; /* ------------------------------ * Screen * ------------------------------ */ enum POPUP_ITEM { M_DELETE, M_PROPERTIES }; /** comment for the class */ class Screen : public QWidget, public GraphicalGameData { Q_OBJECT public: /** Constructor */ Screen( QWidget * parent = 0, char * name = 0 ); ~Screen(); /** Display Info Scenario dialog */ void displayInfo(); /** Load scenario */ bool load( const QString filename ); /** Save scenario */ void save( QString filename ); /** Create new scenario */ bool newScenario(); /** clear the current map */ void clearMap(); void gridMap(); /** fill the current map with the tile 'tile' and diversification 'divers' (0 means random) */ void fillMap( uint tile, uint divers ); void displayPlayersProperties(); void handleDelete(); void manageQuests(); void displayMiniMap( bool state ); /** Add new action */ QAction * addAction( const QString & label, POPUP_ITEM id, QSignalMapper * sigmap ); public slots: /** Slot when mouse button pressed */ void slot_mouseLeftPressed( GenericCell * c ); void slot_mouseRightPressed( GenericCell * c ); /** Slot when mouse button is released */ void slot_mouseReleased(); /** Handle popup menu */ void slot_popup( int id ); /** Slot when mouse moved */ void slot_mouseMoved( GenericCell * c ); /** Slot for center map on a cell */ void slot_centerMinimap( qreal x, qreal y ); signals: void sig_status( const QString & ); void sig_cellChanged( int , int ); private: void handleProperties(); void handlePropertiesLord(); void handlePropertiesBase(); void handlePropertiesBuilding(); void handlePropertiesCreature(); void handlePropertiesEvent(); void updateStatusBar( GenericCell * c ); void cellChanged( GenericCell * c ); bool _leftPressed; ItemSelector * _selector; GenericCell * _currentCell; MapView * _view; MiniMap * _miniMap; QVector _actions; QMenu * _menu; }; #endif // SCREEN_H attal-src-1.0-rc2/scenarioEditor/tilePresentation.cpp0000644000175000017500000000506710533124702020470 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** template.cpp ** this is a template for all .cpp files ** ** Version : $Id: tilePresentation.cpp,v 1.10 2006/11/28 21:27:30 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "tilePresentation.h" // generic include files #include // include files for QT #include #include #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/gameData.h" #include "libCommon/genericCell.h" #include "libCommon/log.h" #include "libClient/attalButton.h" #include "libClient/cell.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/map.h" // // ----- TilePresentation ----- // TilePresentation::TilePresentation( QWidget * parent, const char * name ) : QWidget( parent ) { setWindowTitle( QString ( name )); _button = new AttalButton( this ); _button->setFixedSize( 40, 40 ); _combo = new QComboBox( this ); FIXEDSIZE( _combo ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setSpacing( 5 ); layout->addWidget( _button ); layout->addSpacing( 10 ); layout->addWidget( _combo ); layout->addStretch( 1 ); layout->activate(); setFixedWidth( 220 ); setFixedHeight( 40 ); } void TilePresentation::setCell( CellModel * cell ) { uint nb = cell->getDiversificationNumber(); uint index; QString text; _cell = cell; index = DataTheme.tiles.indexOf( cell ); _button->setPixmap( ImageTheme.cells[index]->at( 0 ) ); _combo->clear(); _combo->addItem( "Random" ); for( uint i = 0; i < nb; i++ ) { text = tr( "%1 (weight=%2)" ).arg(i+1).arg( cell->getDiversification( i ) ); _combo->addItem( text ); } FIXEDSIZE( _combo ); } uint TilePresentation::getDiversification() { uint ret = 0; ret = _combo->currentIndex(); if( ret == 0 ) { ret = _cell->getRandomDiversification(); } else { ret--; } return ret; } attal-src-1.0-rc2/scenarioEditor/tilePresentation.h0000644000175000017500000000311410335641067020134 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** tilePresentation.h ** Displays tiles with diversification ** ** Version : $Id: tilePresentation.h,v 1.3 2005/11/13 13:40:07 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 11/01/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef TILEPRESENTATION_H #define TILEPRESENTATION_H // generic include files // include files for QT #include // application specific include files class QComboBox; class AttalButton; class CellModel; /* ------------------------------ * TilePresentation * ------------------------------ */ class TilePresentation : public QWidget { Q_OBJECT public: /** Constructor */ TilePresentation( QWidget * parent = 0, const char * name = 0 ); void setCell( CellModel * cell ); AttalButton * getButton() { return _button; } uint getDiversification(); protected: AttalButton * _button; QComboBox * _combo; CellModel * _cell; }; #endif // TILEPRESENTATION_H attal-src-1.0-rc2/scenarioEditor/tileSelection.cpp0000644000175000017500000000570310620114151017731 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** tileSelection.cpp ** Manages selection of tiles ** ** Version : $Id: tileSelection.cpp,v 1.14 2007/05/08 15:34:01 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 11/01/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "tileSelection.h" // generic include files #include // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/genericCell.h" #include "libCommon/log.h" #include "libClient/attalButton.h" #include "libClient/cell.h" #include "libClient/graphicalGameData.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "libClient/map.h" extern Map * theMap; // // ----- TileSelection ----- // TileSelection::TileSelection( QWidget * parent, const char * name ) :ItemSelection( parent, name ) { TilePresentation * pres; _tiles = new QList; _sizeG = new QButtonGroup( this ); _sizeG->setExclusive( true ); for( int i = 1; i < 4; i++ ) { QPushButton * pb = new QPushButton( QString("x%1").arg(i), this ); pb->setCheckable( true ); pb->setFixedWidth( 50 ); _sizeG->addButton( pb, i ); addNewWidget( pb ); } addNewLine(); //_sizeG->setId(1); for( int i = 1; i < DataTheme.tiles.count(); i++ ) { //addButton( ImageTheme.cells[i]->image( 0 ), i, i == 0 ); pres = new TilePresentation( this ); pres->setCell( DataTheme.tiles.at(i) ); pres->getButton()->setCheckable( true ); _bg->addButton( pres->getButton(), i ); pres->getButton()->setFixedSize( QSize(40,40).expandedTo(pres->getButton()->sizeHint() ) ); addNewWidget( pres ); _tiles->append( pres ); } } void TileSelection::handleLeftClick( GenericCell * cell ) { uint row = cell->getRow(); uint col = cell->getCol(); if( button() != -1 ) { /// XXX: replace selectedId () with id( buttonGroup->selected() ) uint shift = ( std::max(_sizeG->id ( _sizeG->checkedButton()) ,1) - 1 ) / 2; tileSquare( row - shift, col - shift ); } } void TileSelection::tileSquare( uint row, uint col ) { int i, j; GenericCell * cell; int id = _sizeG->id ( _sizeG->checkedButton() ); for( i = 0; i < id ; i++ ) { for( j = 0; j < id; j++ ) { cell = _data->getCell( row+i, col+j ); if( cell ) { cell->setType( button() ); cell->setDiversification( _tiles->at( button()-1 )->getDiversification() ); } } } } attal-src-1.0-rc2/scenarioEditor/tileSelection.h0000644000175000017500000000326510522157601017407 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** tileSelection.h ** Manages selection of tiles ** ** Version : $Id: tileSelection.h,v 1.6 2006/11/01 17:55:13 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 11/01/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef TILESELECTION_H #define TILESELECTION_H // generic include files // include files for QT #include #include #include // application specific include files #include "scenarioEditor/itemSelection.h" #include "scenarioEditor/tilePresentation.h" class QComboBox; class QPushButton; /* ------------------------------ * TileSelection * ------------------------------ */ /** Selection of tiles */ class TileSelection : public ItemSelection { Q_OBJECT public: /** Constructor */ TileSelection( QWidget * parent = 0, const char * name = 0 ); /** Manage left click */ void handleLeftClick( GenericCell * ); protected: void tileSquare( uint row, uint col ); QButtonGroup * _sizeG; QList * _tiles; }; #endif // TILESELECTION_H attal-src-1.0-rc2/server/0000755000175000017500000000000011016113673012761 5ustar aaaaattal-src-1.0-rc2/server/.cvsignore0000644000175000017500000000041410331243515014756 0ustar aaaaattal-server_resource.rc object_ld_script.attal-server.Debug object_ld_script.attal-server.Release moc obj moc_* *.moc.cpp *.o *.opt *.plg *.dsp .deps Makefile Makefile.Release Makefile.Debug Makefile.in attal-server duel-server server.plg libserver.plg Debug Release attal-src-1.0-rc2/server/displayScenarii.cpp0000644000175000017500000001524510461651143016621 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayScenarii.cpp ** Smart display of scenarii ** ** Version : $Id: displayScenarii.cpp,v 1.7 2006/07/26 11:30:43 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 09/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "displayScenarii.h" // generic include files #include #include #include #include #include #include #include // application specific include files #include "libCommon/log.h" #include "libServer/scenarioDescription.h" extern QString SCENARIO_PATH; // // ----- DisplayScenarioDescription ----- // DisplayScenarioDescription::DisplayScenarioDescription( QWidget * parent ) : QWidget( parent ) { _labName = new QLabel( this ); _labName->setFixedSize( _labName->sizeHint() ); _labDescription = new QLabel( this ); _labDescription->setFixedSize( _labDescription->sizeHint() ); _labPlayers = new QLabel( this ); _labPlayers->setFixedSize( _labPlayers->sizeHint() ); _labSize = new QLabel( this ); _labSize->setFixedSize( _labSize->sizeHint() ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addWidget( _labName ); layout->addWidget( _labSize ); layout->addWidget( _labPlayers ); layout->addWidget( _labDescription ); layout->addStretch( 1 ); layout->activate(); clear(); setFixedWidth( 300 ); } void DisplayScenarioDescription::init( ScenarioDescription * desc ) { if( desc ) { _labName->setText( tr( "Name: %1" ).arg( desc->getName() ) ); _labName->setFixedSize( _labName->sizeHint() ); _labPlayers->setText( tr( "Player(s): %1" ).arg( desc->getNbPlayers() ) ); _labPlayers->setFixedSize( _labPlayers->sizeHint() ); _labSize->setText( tr( "Size: %1x%2" ).arg( desc->getWidth() ).arg( desc->getHeight() ) ); _labSize->setFixedSize( _labSize->sizeHint() ); _labDescription->setText( tr( "Description: %1" ).arg( desc->getDescription() ) ); _labDescription->setFixedSize( _labDescription->sizeHint() ); } } void DisplayScenarioDescription::clear() { _labName->setText( tr( "Name: " ) ); _labName->setFixedSize( _labName->sizeHint() ); _labPlayers->setText( tr( "Player(s): " ) ); _labPlayers->setFixedSize( _labPlayers->sizeHint() ); _labSize->setText( tr( "Size: " ) ); _labSize->setFixedSize( _labSize->sizeHint() ); _labDescription->setText( tr( "Description: " ) ); _labDescription->setFixedSize( _labDescription->sizeHint() ); } // // ----- ScenarioListViewItem ----- // ScenarioListViewItem::ScenarioListViewItem( QTreeWidget * list, ScenarioDescription * desc ) : QTreeWidgetItem( list ) { _desc = desc; QString temp; temp.sprintf( "%dx%d", _desc->getWidth(), _desc->getHeight() ); setText( 0, temp ); setText( 1, QString::number( _desc->getNbPlayers() ) ); setText( 2, _desc->getName() ); } ScenarioListViewItem::~ScenarioListViewItem() { if( _desc ) { delete _desc; } } ScenarioDescription * ScenarioListViewItem::getScenario() { return _desc; } // // ----- DisplayScenarii ----- // DisplayScenarii::DisplayScenarii( QWidget * parent ) : QWidget( parent ) { _currentScen = 0; _list = new QTreeWidget( this ); _list->setSelectionBehavior( QAbstractItemView::SelectRows ); _list->setColumnCount( 3 ); QStringList labels; labels << tr( "Size" ); labels << tr( "Players" ); labels << tr( "Name" ); _list->setHeaderLabels( labels ); _description = new DisplayScenarioDescription( this ); _description->setMinimumWidth( 250 ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->addWidget( _list, 1 ); layout->addWidget( _description ); layout->activate(); init(); connect( _list, SIGNAL( itemClicked( QTreeWidgetItem *, int ) ), SLOT( slot_clicked( QTreeWidgetItem * ) ) ); connect( _list, SIGNAL( itemDoubleClicked( QTreeWidgetItem *, int ) ), SIGNAL( sig_dbleClicked() ) ); setMinimumWidth( 600 ); } void DisplayScenarii::slot_clicked( QTreeWidgetItem * item ) { ScenarioListViewItem * scenarioItem = ( ScenarioListViewItem * ) item; _currentScen = scenarioItem->getScenario(); _description->init( scenarioItem->getScenario() ); } void DisplayScenarii::init() { QDir scenarioDir( SCENARIO_PATH ); scenarioDir.setFilter( QDir::Files | QDir::Hidden ); scenarioDir.setSorting( QDir::Size | QDir::Reversed ); scenarioDir.setNameFilters( QStringList( "*.scn" ) ); const QList fileList = scenarioDir.entryInfoList(); ScenarioDescription * desc; uint nbItems = (uint)fileList.count(); for( uint i = 0; i < nbItems; ++i ) { desc = new ScenarioDescription(); desc->load( fileList[ i ].absoluteFilePath() ); new ScenarioListViewItem( _list, desc ); } /* was while ( (fileInfo = it.value() ) != 0 ) { desc = new ScenarioDescription(); desc->load( fileInfo->absFilePath() ); new ScenarioListViewItem( _list, desc ); ++it; }*/ } void DisplayScenarii::clear() { _list->clear(); } // // ----- DisplayScenariiDialog ----- // DisplayScenariiDialog::DisplayScenariiDialog( QWidget * parent ) : QDialog( parent ) { _display = new DisplayScenarii( this ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addWidget( _display, 1 ); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); pbOk->setFixedSize( pbOk->sizeHint() ); QPushButton * pbCancel = new QPushButton( this ); pbCancel->setText( tr( "Cancel" ) ); pbCancel->setFixedSize( pbCancel->sizeHint() ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addStretch( 1 ); layH2->addWidget( pbOk ); layH2->addStretch( 1 ); layH2->addWidget( pbCancel ); layH2->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addLayout( layH1, 1 ); layout->addLayout( layH2 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pbCancel, SIGNAL( clicked() ), SLOT( reject() ) ); connect( _display, SIGNAL( sig_dbleClicked() ), SLOT( accept() ) ); } QString DisplayScenariiDialog::getFileName() { QString ret = ""; ret = _display->getCurrentScenario()->getFileName(); return ret; } attal-src-1.0-rc2/server/displayScenarii.h0000644000175000017500000000542010371471264016264 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** displayScenarii.h ** Smart display of scenarii ** ** Version : $Id: displayScenarii.h,v 1.6 2006/02/05 21:48:36 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 09/08/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef DISPLAYSCENARII_H #define DISPLAYSCENARII_H // generic include files // include files for QT #include #include #include // application specific include files class QLabel; class ScenarioDescription; /* ------------------------------ * DisplayScenarioDescription * ------------------------------ */ class DisplayScenarioDescription : public QWidget { Q_OBJECT public: /** Constructor */ DisplayScenarioDescription( QWidget * parent = 0 ); void init( ScenarioDescription * desc ); void clear(); protected: QLabel * _labName; QLabel * _labDescription; QLabel * _labPlayers; QLabel * _labSize; }; class ScenarioListViewItem : public QTreeWidgetItem { public: /** Constructor */ ScenarioListViewItem( QTreeWidget * list, ScenarioDescription * desc ); /** Destructor */ virtual ~ScenarioListViewItem(); ScenarioDescription * getScenario(); protected: ScenarioDescription * _desc; }; /* ------------------------------ * DisplayScenarii * ------------------------------ */ class DisplayScenarii : public QWidget { Q_OBJECT public: /** Constructor */ DisplayScenarii( QWidget * parent = 0 ); void init(); void clear(); ScenarioDescription * getCurrentScenario() { return _currentScen; } public slots: void slot_clicked( QTreeWidgetItem * item ); signals: void sig_dbleClicked(); protected: DisplayScenarioDescription * _description; ScenarioDescription * _currentScen; QTreeWidget * _list; }; /* ------------------------------ * DisplayScenariiDialog * ------------------------------ */ class DisplayScenariiDialog : public QDialog { Q_OBJECT public: /** Constructor */ DisplayScenariiDialog( QWidget * parent = 0 ); QString getFileName(); protected: DisplayScenarii * _display; }; #endif // DISPLAYSCENARII_H attal-src-1.0-rc2/server/duel.cpp0000644000175000017500000000373010401056021014407 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** duel.cpp ** main file for duel server ** ** Version : $Id: duel.cpp,v 1.4 2006/02/28 14:20:01 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 29/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ // include files for QT #include #include #include #include #include // application specific include #include "conf.h" #include "libServer/interfaceDuel.h" QString DATA_PATH; QString THEME( THEME_DEFAULT ); void useTheme() { QDir folder; folder.setPath( "./themes/" + THEME ); if( ! folder.exists() ) { folder.setPath( "/usr/local/share/games/attal/themes/" + THEME ); if( ! folder.exists() ) { folder.setPath( "/usr/share/games/attal/themes/" + THEME ); } } if( ! folder.exists() ) { folder.setPath( "./themes/" + THEME_DEFAULT ); logEE( "Theme %s not found", THEME.toLatin1() ); THEME = THEME_DEFAULT; } QString THEME_PATH = folder.absPath() + "/"; DATA_PATH = THEME_PATH + DATA_DEFAULT_PATH; /// XXX: need more tests of existence } int main( int argc, char **argv ) { QApplication app( argc, argv ); for( int i = 1; i < argc; i++ ) { if ( strcmp( argv[i], "-theme" ) == 0 ) { i++; if( i < argc ) THEME = QString( argv[i] ); } } useTheme(); InterfaceDuel game; app.setMainWidget( &game ); game.show(); return app.exec(); } attal-src-1.0-rc2/server/interfaceDuel.cpp0000644000175000017500000000726510354614545016261 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** interfaceDuel.cpp ** interface for the server of The Duel ** ** Version : $Id: interfaceDuel.cpp,v 1.4 2005/12/28 23:01:57 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 29/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "interfaceDuel.h" // include files for QT #include #include #include #include #include #include #include #include // application specific includes #include "conf.h" #include "common/log.h" extern QString DATA_PATH; extern QString PORT; /** add comments here */ InterfaceDuel::InterfaceDuel() { _server = new AttalServer( PORT.toInt() ); setWindowTitle("Attal - Lords of Doom (Server)"); initMenuBar(); initStatusBar(); _widget = new ServerWidget( this ); setCentralWidget( _widget ); } void InterfaceDuel::initStatusBar() { statusBar()->message( "Status Bar", 0 ); } /*! define menus */ void InterfaceDuel::initMenuBar() { QPopupMenu * menuFile = new QPopupMenu(); CHECK_PTR( menuFile ); menuFile->insertItem( "Load Game", FIL_LOAD ); menuFile->insertItem( "Save Game", FIL_SAVE ); menuFile->insertItem( "Start Game", FIL_START ); menuFile->insertItem( "End Game", FIL_END ); menuFile->insertItem( "Quit", FIL_QUIT ); connect( menuFile, SIGNAL( activated( int ) ), this, SLOT( slot_menuFileActivated( int ) ) ); QPopupMenu * menuGame = new QPopupMenu(); CHECK_PTR( menuGame ); menuGame->insertItem( "Fight", GAM_FIG ); menuGame->insertItem( "End Fight", GAM_END ); connect( menuGame, SIGNAL( activated( int ) ), this, SLOT( slot_menuGameActivated( int ) ) ); menuBar()->insertItem( "&File", menuFile ); menuBar()->insertItem( "&Game", menuGame ); } void InterfaceDuel::slot_menuFileActivated( int num ) { switch( num ) { case FIL_LOAD:{ QString filename; filename = QFileDialog::getOpenFileName( "", "*.map", this ); if (!filename.isNull()) { } break; } case FIL_SAVE:{ QString filename; filename = QFileDialog::getSaveFileName( "", "*.map", this ); if (!filename.isNull()) { } break; } case FIL_START: if( (uint) _widget->getNbPlayer() == _server->getNbSocket() ) { } else { QMessageBox::critical( this, "Unable to start game", "There is not enough players connected.", 0, 1 ); } break; case FIL_END: _server->endGame(); break; case FIL_QUIT: qApp->quit(); } } void InterfaceDuel::slot_menuGameActivated( int num ) { switch( num ) { case GAM_FIG: break; case GAM_END: break; } } void InterfaceDuel::slot_status( QString text ) { statusBar()->message( text, 0 ); } ServerWidget::ServerWidget( QWidget * parent , const char * name ) : QWidget( parent, name ) { QLabel labPlayer( this ); labPlayer.setText( "Nb of players : " ); labPlayer.setFixedSize( labPlayer.sizeHint() ); labPlayer.move( 10, 10 ); _editLine = new QLineEdit( this ); _editLine->setFixedSize( _editLine->sizeHint() ); _editLine->move( 20 + labPlayer.size().width(), 10 ); _editLine->setText( "1" ); } /*! */ int ServerWidget::getNbPlayer() { return( _editLine->text().toInt() ); } attal-src-1.0-rc2/server/interfaceDuel.h0000644000175000017500000000417110331243515015705 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** interfaceDuel.h ** interface for the server of The Duel ** ** Version : $Id: interfaceDuel.h,v 1.2 2005/10/30 22:21:01 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 29/12/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef INTERFACEDUEL_H #define INTERFACEDUEL_H // include files for QT #include #include // application specific includes #include "server/attalServer.h" class ServerWidget; class QLineEdit; /* ------------------------------ * Interface * ------------------------------ */ /** comment for the class */ class InterfaceDuel : public QMainWindow { Q_OBJECT public: /** Constructor */ InterfaceDuel(); public slots: /** Slot managing 'File' menu */ void slot_menuFileActivated( int num ); /** Slot managing 'Game' menu */ void slot_menuGameActivated( int num ); /** Slot managing the status bar */ void slot_status( QString text ); private: enum MENU_FIL { FIL_LOAD, FIL_SAVE, FIL_START, FIL_END, FIL_QUIT }; enum MENU_GAM { GAM_FIG, GAM_END }; /** Define menus */ void initMenuBar(); /** Define statusBar */ void initStatusBar(); AttalServer * _server; ServerWidget * _widget; }; class ServerWidget : public QWidget { public: /** Constructor */ ServerWidget( QWidget * parent = 0, const char * name = 0 ); /** Return nb of player written in the lineEdit */ int getNbPlayer(); private: QLineEdit * _editLine; }; #endif // INTERFACEDUEL_H attal-src-1.0-rc2/server/main.cpp0000644000175000017500000000440210630060445014410 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** attal.cpp ** main file ** ** Version : $Id: main.cpp,v 1.23 2007/06/01 18:10:45 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier - Sardi Carlo ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ // include files for QT #include #include #include #include #include // application specific include #include "conf.h" #include "libCommon/attalCommon.h" #include "server/serverInterface.h" extern QString IMAGE_PATH; extern QString THEME; extern QString THEME_PATH; extern QString PORT; extern bool FAST; int main( int argc, char **argv ) { QDir trfolder; trfolder = translationsDir(); QApplication app( argc, argv ); QTranslator translator( 0 ); translator.load( QString("attal_server_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibs( 0 ); translatorlibs.load( QString("attal_libserver_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibai( 0 ); translatorlibai.load( QString("attal_libai_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); app.installTranslator( &translator ); app.installTranslator( &translatorlibs ); app.installTranslator( &translatorlibai ); if (parseArgs( argc, argv, AttalCommon::ATTALSERVER ) ) { return 1; } useTheme(); app.setWindowIcon(QIcon( IMAGE_PATH + "misc/ico_attal-server.png")); if (app.windowIcon().isNull()) qDebug("Window icon is null!"); ServerInterface game; //app.setMainWidget( &game ); game.show(); if(!game.initServer()) { exit(0); } return app.exec(); } attal-src-1.0-rc2/server/server.pro0000644000175000017500000000166210634007747015027 0ustar aaaaTEMPLATE = app include( ../config.pro ) INCLUDEPATH += .. LIBS += -L.. unix:LIBS += -lAttalServer unix:LIBS += -lAttalCommon unix:LIBS += -lAttalAi win32:LIBS += -lAttalServer9 win32:LIBS += -lAttalCommon9 win32:LIBS += -lAttalAi2 win32:DEFINE += WIN32 win32 { contains( CONFIG, debug ) { CONFIG += console } } SOURCES += displayScenarii.cpp SOURCES += serverWidgets.cpp SOURCES += serverInterface.cpp SOURCES += main.cpp HEADERS += displayScenarii.h HEADERS += serverWidgets.h HEADERS += serverInterface.h TRANSLATIONS += ../i18n/de/attal_server_de.ts TRANSLATIONS += ../i18n/fr/attal_server_fr.ts TRANSLATIONS += ../i18n/ru/attal_server_ru.ts TRANSLATIONS += ../i18n/it/attal_server_it.ts DESTDIR = .. OBJECTS_DIR=./obj MOC_DIR=./moc TARGET = attal-server unix:!macx { QMAKE_LFLAGS += -Wl,-rpath,. } unix { target.path = $${ATT_PREFIX}/bin/ INSTALLS += target } #The following line was inserted by qt3to4 QT += network xml attal-src-1.0-rc2/server/serverInterface.cpp0000644000175000017500000002767410707471226016643 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** serverInterface.cpp ** interface for the server ** ** Version : $Id: serverInterface.cpp,v 1.82 2007/10/23 22:15:50 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 01/11/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "serverInterface.h" // generic include files #include #include #include /// XXX: usefull ? #ifndef WIN32 #include #include #endif #include // include files for QT #include #include #include #include #include #include #include #include #include #include #include #include // application specific includes #include "conf.h" #include "libCommon/campaign.h" #include "libCommon/dataTheme.h" #include "libCommon/log.h" #include "libClient/gui.h" #include "serverWidgets.h" #include "displayScenarii.h" extern QString DATA_PATH; extern QString SCENARIO_PATH; extern QString CAMPAIGN_PATH; extern QString SAVE_PATH; extern QString THEME; extern QString PORT; extern bool FAST; #define CLIENT ServerInterface::ServerInterface() :QMainWindow() { initActions(); initMenuBar(); initStatusBar(); if( ! DataTheme.init() ) { /// XXX: we could manage this better (later :) ) QMessageBox::critical( this, tr( "Can't load theme" ), tr( "Theme " ) + THEME + tr( " has not been loaded successfully" ) ); } _widget = new ServerWidget( this ); setCentralWidget( _widget ); connect( _widget, SIGNAL( sig_stop() ), SLOT( slot_stop() ) ); connect( _widget, SIGNAL( sig_load( QString ) ), SLOT( slot_load( QString ) ) ); connect( _widget, SIGNAL( sig_save() ), SLOT( slot_save() ) ); connect( _widget, SIGNAL( sig_banned( QString ) ), SLOT( slot_banned( QString ) ) ); _config = 0; _hide = false; setMinimumSize( 350, 200 ); srand( time( NULL ) ); connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( slot_stop() ) ); //connect( qApp, SIGNAL( destroyed() ), this, SLOT( slot_stop() ) ); } ServerInterface::~ServerInterface() { killAI(); DataTheme.clear(); if( _engine ) { delete _engine; } if( _server ) { delete _server; } } void ServerInterface::changeEvent ( QEvent * e ) { //used to replace setCaption switch (e->type()){ case QEvent::WindowTitleChange: { setWindowTitle( tr( "Attal - Lords of Doom (Server)" ) ); } break; default: QWidget::changeEvent ( e ); break; } } void ServerInterface::closeEvent( QCloseEvent* ce ) { ce->accept(); } bool ServerInterface::initServer() { bool ret = false; _config = new ConfigConnection( this ); _config->setHost( "localhost" ); _config->setPort( PORT.toInt() ); if(FAST){ _config->accept(); } else { _config->exec(); } if( _config->result() == QDialog::Accepted ) { _server = new AttalServer( _config->getPort() ); if( _server->isListening() ) { connect( _server, SIGNAL( sig_newPlayer( AttalPlayerSocket * ) ), this, SLOT( slot_ready() ) ); connect( _server, SIGNAL( sig_newPlayer( AttalPlayerSocket * ) ), _widget, SLOT( slot_newPlayer( AttalPlayerSocket * ) ) ); connect( _server, SIGNAL( sig_endConnection( QString ) ), this , SLOT( slot_endConnection( QString ) ) ); connect( _server, SIGNAL( sig_endConnection( QString ) ), _widget, SLOT( slot_endConnection( QString ) ) ); connect( _server, SIGNAL( sig_result( int, bool) ), this, SLOT( slot_result(int, bool)) ); connect( _server, SIGNAL( sig_endGame( int ) ), this, SLOT( slot_endGame( int )) ); ret = true; newEngine(); } else { delete _server; _server = NULL; if( QMessageBox::warning( this, tr( "Server error" ), tr( "Could not listen for sockets." ), tr( "Try again" ), tr( "Quit" ), 0, 0, 1 ) == 0 ) { ret = initServer(); } else { ret = false; qApp->quit(); } } } else { ret = false; qApp->quit(); } if (_config){ delete _config; } _config = NULL; return ret; } void ServerInterface::initStatusBar() { statusBar()->showMessage( tr( "Status Bar" ), 0 ); } QAction * ServerInterface::addAction( const QString & label, MENU_ACTIONS id, QSignalMapper * sigmap ) { QAction * action; action = new QAction( label, this ); _actions.insert( id, action ); sigmap->setMapping( action, id ); connect( action, SIGNAL( triggered() ), sigmap, SLOT( map() ) ); return action; } void ServerInterface::initActions() { _actions.resize( NB_ACTIONS ); QAction * action; QSignalMapper * sigmap = new QSignalMapper( this ); addAction( tr( "Load scenario" ), ACTION_LOADSCENARIO, sigmap ); addAction( tr( "Load campaign" ), ACTION_LOADCAMPAIGN, sigmap ); addAction( tr( "Continue campaign" ), ACTION_CONTCAMPAIGN, sigmap ); addAction( tr( "Load game" ), ACTION_LOADGAME, sigmap ); addAction( tr( "Save game" ), ACTION_SAVE, sigmap ); addAction( tr( "End game" ), ACTION_END, sigmap ); addAction( tr( "Quit" ), ACTION_QUIT, sigmap ); addAction( tr( "Fill with AI" ), ACTION_FILLAI, sigmap ); addAction( tr( "Fill with External AI" ), ACTION_FILL_EXTERNAL_AI, sigmap ); addAction( tr( "Add external AI player" ), ACTION_ADDAI, sigmap ); action = addAction( tr( "Debug AI" ), ACTION_AIDBG, sigmap ); action->setCheckable( true ); action->setChecked( _aiDbg ); action = addAction( tr( "Hide AI" ), ACTION_HIDE, sigmap ); action->setCheckable( true ); action->setChecked( _hide ); connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_action( int ) ) ); } void ServerInterface::initMenuBar() { QMenu * menuFile = menuBar()->addMenu( tr( "&File" ) ); QMenu * menuGame = menuBar()->addMenu( tr( "&Game" ) ); menuFile->addAction( _actions[ ACTION_LOADSCENARIO ] ); menuFile->addAction( _actions[ ACTION_LOADCAMPAIGN ] ); menuFile->insertSeparator(_actions[ ACTION_LOADCAMPAIGN ]); menuFile->addAction( _actions[ ACTION_CONTCAMPAIGN ] ); menuFile->addAction( _actions[ ACTION_LOADGAME ] ); menuFile->addAction( _actions[ ACTION_SAVE ] ); menuFile->addAction( _actions[ ACTION_END ] ); menuFile->addAction( _actions[ ACTION_QUIT ] ); menuGame->addAction( _actions[ ACTION_FILLAI ] ); menuGame->addAction( _actions[ ACTION_FILL_EXTERNAL_AI ] ); menuGame->addAction( _actions[ ACTION_ADDAI ] ); menuGame->addAction( _actions[ ACTION_AIDBG ] ); menuGame->addAction( _actions[ ACTION_HIDE ] ); menuGame->addAction( _actions[ ACTION_HIDE ] ); } void ServerInterface::slot_action( int num ) { switch( num ) { case ACTION_LOADSCENARIO:{ DisplayScenariiDialog * scen = new DisplayScenariiDialog( this ); if( scen->exec() ) { slot_load( scen->getFileName() ); } } break; case ACTION_LOADCAMPAIGN:{ QString filename; filename = QFileDialog::getOpenFileName( this, tr( "Load campaign" ), CAMPAIGN_PATH, "*.cmp" ); loadCampaign( filename ); } break; case ACTION_CONTCAMPAIGN:{ QString filename; filename = QFileDialog::getOpenFileName( this, tr( "Load campaign" ), SAVE_PATH, "*.cms" ); loadCampaign( filename ); } break; case ACTION_LOADGAME:{ QString filename; filename = QFileDialog::getOpenFileName( this, tr( "Load game" ), SAVE_PATH, "*.scn *.gam" ); slot_load( filename ); } break; case ACTION_SAVE: slot_save(); break; case ACTION_END: slot_stop(); break; case ACTION_QUIT: qApp->quit(); break; case ACTION_FILLAI:{ QString filename = _widget->getFilename(); fillWithAI(filename); } break; case ACTION_FILL_EXTERNAL_AI:{ QString filename = _widget->getFilename(); fillWithExternalAI(filename); } break; case ACTION_ADDAI: addAI(false); break; case ACTION_AIDBG:{ _aiDbg = !_aiDbg; _actions[ ACTION_AIDBG ]->setChecked( _aiDbg ); } break; case ACTION_HIDE:{ _hide = !_hide; _actions[ ACTION_HIDE ]->setChecked( _hide ); } break; } } bool ServerInterface::killAI() { int count; Analyst * ai; AttalSocket * socket; count = _aiList.count(); TRACE("ServerInterface::killAI count %d",count); if( _aiList.count() > 0 ) { for( int i = 0; i < count; i++ ) { ai = _aiList.takeFirst(); socket = ai->getSocket(); disconnect(socket, 0, 0, 0); delete ai; delete socket; } return true; } count = _proclist.count(); if( _proclist.count() > 0 && !_aiDbg) { for( int i = 0; i < count; i++ ) { _proclist.at(0)->terminate(); _proclist.at(0)->waitForFinished(); //QTimer::singleShot( 5000, _proclist.at(0), SLOT( kill() ) ); delete _proclist.takeFirst(); } return true; } return false; } void ServerInterface::disconnectAI() { TRACE("ServerInterface::disconnectAI"); AttalSocket * socket; Analyst * ai; int count = _aiList.count(); if( _aiList.count() > 0 ) { for( int i = 0; i < count; i++ ) { ai = _aiList.at(i); socket = ai->getSocket(); socket->disconnectFromHost(); } _readyOut = false; } } bool ServerInterface::fillWithExternalAI(QString filename) { //logDD("filename %s",filename.toLatin1().constData()); if ( !_engine->checkGamePlayers( filename ) ) { int nplay = _engine->getNumFillPlayers(); if( nplay > 0 ) { QTimer::singleShot( (nplay+2)* 1000, this, SLOT( slot_ready() ) ); for( int i = 0; i < nplay; i++ ) { _readyIn = false; //logDD("ai %d",i); addAI(_hide); while( !_readyIn ){ qApp->processEvents(); } } return true; } } return false; } void ServerInterface::addInternalAI() { TRACE("ServerInterface::addInternalAI"); QStringList arglist; AttalSocket * socket = new AttalSocket; Analyst * ai = new Analyst( socket ); socket->connectToHost( "localhost", PORT.toInt() ); _aiList.append( ai ); ai->start(); } void ServerInterface::addAI(bool hide) { QProcess * proc = new QProcess(this); QStringList arglist; connect(proc, SIGNAL(started()), SLOT(slot_started())); _proclist.append( proc ); if( hide ) { arglist.append( "--hide" ); } arglist.append( "--fast" ); _readyIn = false; #ifdef WIN32 proc->start( "attal-ai.exe", arglist ); #else QFile file("./attal-ai"); if (file.exists()) { proc->start( "./attal-ai", arglist ); } else { proc->start( "attal-ai", arglist ); } #endif } void ServerInterface::slot_started() { qApp->processEvents(); } void ServerInterface::slot_banned( QString name) { _server->closeConnectionPlayer( name, AttalServer::SK_KICKED ); } void ServerInterface::slot_ready() { TRACE("ServerInterface::slot_ready"); _readyIn = true; } void ServerInterface::slot_endConnection( QString name ) { TRACE("ServerInterface::slot_endConnection"); _readyOut = true; } void ServerInterface::slot_status( QString text ) { statusBar()->showMessage( text, 0 ); } void ServerInterface::slot_stop() { TRACE("ServerInterface::slot_stop"); if( _engine ) { _engine->endGame(); } //endGame(); } void ServerInterface::slot_load( QString filename ) { load( filename ); } void ServerInterface::slot_save() { TRACE("ServerInterface::slot_save"); save(); } void ServerInterface::slot_result( int id, bool result ) { TRACE("ServerInterface::slot_result( bool result %d )", result ); _winner = result; } void ServerInterface::slot_endGame( int id ) { TRACE("ServerInterface::slot_endGame"); if( _engine && _engine->getCampaign()) { handleResult( _winner ); } else { endGame(); } } void ServerInterface::adjustWidgetLoading( StatusWidget type ) { TRACE("ServerInterface::adjustWidgetLoading( StatusWidget type %d)", type); switch( type ) { case W_ENGINE: _widget->setGameLoaded( true ); break; case W_NORMAL: _widget->setGameLoaded( false ); break; default: break; } } attal-src-1.0-rc2/server/serverInterface.h0000644000175000017500000000644310707471227016300 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** serverInterface.h ** interface for the server ** ** Version : $Id: serverInterface.h,v 1.36 2007/10/23 22:15:51 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 01/11/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SERVERINTERFACE_H #define SERVERINTERFACE_H // include files for QT #include #include #include #include #include #include #include #include #include #include #include // application specific includes #include "libServer/attalServer.h" #include "libAi/analyst.h" #include "libServer/engine.h" #include "libServer/loadGame.h" class QAction; class QLineEdit; class QListWidget; class QSignalMapper; class ServerWidget; class ConfigConnection; /* ------------------------------ * ServerInterface * ------------------------------ */ /** comment for the class */ class ServerInterface : public QMainWindow, public LoadGame { Q_OBJECT public: /** Constructor */ ServerInterface(); ~ServerInterface(); bool initServer(); public slots: /** Slot for managing 'actions' */ void slot_action( int num ); /** Slot managing the status bar */ void slot_status( QString text ); /** Slot for ending game */ void slot_stop(); /** Slot for loading scenario */ void slot_load( QString ); /** Slot for saving game */ void slot_save(); void slot_result( int, bool); void slot_endGame( int ); void slot_endConnection( QString name ); void slot_started(); void slot_banned( QString ); void slot_ready(); bool fillWithExternalAI(QString filename); void adjustWidgetLoading( StatusWidget type ); void endEngine() {}; void endServer() {}; protected: void closeEvent(QCloseEvent* ce); virtual void changeEvent ( QEvent * e ); private: enum MENU_ACTIONS { ACTION_LOADSCENARIO, ACTION_LOADCAMPAIGN, ACTION_CONTCAMPAIGN, ACTION_LOADGAME, ACTION_SAVE, ACTION_END, ACTION_QUIT, ACTION_FILLAI, ACTION_FILL_EXTERNAL_AI, ACTION_ADDAI, ACTION_AIDBG, ACTION_HIDE, NB_ACTIONS }; /** define actions */ void initActions(); /** Define menus */ void initMenuBar(); /** Define statusBar */ void initStatusBar(); /** Add new action */ QAction * addAction( const QString & label, MENU_ACTIONS id, QSignalMapper * sigmap ); void addAI(bool hide); void addInternalAI(); void disconnectAI(); bool killAI(); ServerWidget * _widget; ConfigConnection * _config; uint _actScen, _nbScen; QVector _actions; QList _proclist; QList _aiList; bool _hide; }; #endif // SERVERINTERFACE_H attal-src-1.0-rc2/server/serverWidgets.cpp0000644000175000017500000002124510672760324016336 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** serverWidgets.cpp ** Various dialog for server ** ** Version : $Id: serverWidgets.cpp,v 1.4 2007/09/15 13:40:36 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 11/10/2006 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "serverWidgets.h" // generic include files #include #include #include #include #include #include #include // application specific include files #include "libCommon/log.h" extern QString SCENARIO_PATH; // // ----- ChooseFileRadioButton ----- // ChooseFileWidget::ChooseFileWidget( QWidget * parent, const char * /* name */) :QWidget( parent ) { QHBoxLayout * layout = new QHBoxLayout( this ); //layout->addSpacing( 20 ); _edit = new QLineEdit( this ); layout->addWidget( _edit, 1 ); layout->addSpacing( 10 ); _choose = new QPushButton( this ); _choose->setText( tr( "Choose" ) ); FIXEDSIZE( _choose ); layout->addWidget( _choose ); layout->activate(); connect( _choose, SIGNAL( clicked() ), SLOT( slot_choose() ) ); setFixedHeight( _choose->size().height() + 12 ); } void ChooseFileWidget::slot_choose() { QString filename = QFileDialog::getOpenFileName( this, tr( "Choose scenario" ), "", "*.scn *.gam" ); if( ! filename.isNull() ) { _edit->setText( filename ); } } void ChooseFileWidget::slot_toggle( bool st ) { _choose->setEnabled( st ); _edit->setEnabled( st ); } // // ----- ServerWidget ----- // ServerWidget::ServerWidget( QWidget * parent, const char * /* name */) : QWidget( parent ) { _groupWidget = new QGroupBox( this ); _radio1 = new QRadioButton( _groupWidget ); _radio1->setText( "Demo 1 player" ); _radio2 = new QRadioButton( _groupWidget ); _radio2->setText( "Demo 2 players" ); _radio3 = new QRadioButton( _groupWidget ); _radio3->setText( "Load game" ); _choose = new ChooseFileWidget( _groupWidget ); _choose->slot_toggle( false ); _choose->setMinimumHeight( 50 ); _playerList = new QTreeWidget( this ); _playerList->setColumnCount( 2 ); QStringList labels; labels << tr( "Name" ); labels << tr( "Address" ); _playerList->setHeaderLabels( labels ); _playerList->setMinimumHeight( 50 ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->setSpacing( 5 ); layH2->addWidget( _radio3 ); layH2->addWidget( _choose, 1 ); QVBoxLayout * layV1 = new QVBoxLayout( _groupWidget ); layV1->setMargin( 5 ); layV1->addWidget( _radio1 ); layV1->addSpacing( 5 ); layV1->addWidget( _radio2 ); layV1->addLayout( layH2 ); layV1->addStretch( 1 ); layV1->activate(); _butStart = new QPushButton( this ); _butStart->setText( tr( "Start" ) ); FIXEDSIZE( _butStart ); _butSave = new QPushButton( this ); _butSave->setText( tr( "Save" ) ); FIXEDSIZE( _butSave ); _butStop = new QPushButton( this ); _butStop->setText( tr( "End" ) ); FIXEDSIZE( _butStop ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->setMargin( 5 ); layH1->setSpacing( 5 ); layH1->addStretch( 1 ); layH1->addWidget( _butStart ); layH1->addStretch( 1 ); layH1->addWidget( _butSave ); layH1->addStretch( 1 ); layH1->addWidget( _butStop ); layH1->addStretch( 1 ); _butStart->setEnabled( true ); _butStop->setEnabled( false ); _butSave->setEnabled( false ); _groupWidget->setEnabled( true ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addWidget( _groupWidget ); layout->addSpacing( 5 ); layout->addWidget( _playerList, 1 ); layout->addSpacing( 5 ); layout->addLayout( layH1 ); layout->activate(); _group = new QButtonGroup( this ); _group->setExclusive( true ); _group->addButton( _radio1, 0 ); _group->addButton( _radio2, 1 ); _group->addButton( _radio3, 2 ); _radio1->setChecked( true ); connect( _butStart, SIGNAL( clicked() ), SLOT( slot_start() ) ); connect( _butSave, SIGNAL( clicked() ), SIGNAL( sig_save() ) ); connect( _butStop, SIGNAL( clicked() ), SIGNAL( sig_stop() ) ); connect( _radio3, SIGNAL( toggled( bool ) ), _choose, SLOT( slot_toggle( bool ) ) ); connect( _playerList, SIGNAL( itemClicked ( QTreeWidgetItem *, int ) ), SLOT( slot_clicked( QTreeWidgetItem *, int ) ) ); } void ServerWidget::slot_newPlayer( AttalPlayerSocket * player ) { TRACE("ServerWidget::slot_newPlayer( AttalPlayerSocket * player %p)",player); TRACE("ServerWidget::slot_newPlayer connectionName %s", player->getPlayer()->getConnectionName().toLatin1().constData() ); QStringList entry; entry << player->getPlayer()->getConnectionName(); entry << player->peerAddress().toString(); new QTreeWidgetItem( _playerList, entry ); /// XXX: to check localAddress or peerAddress ? } void ServerWidget::slot_endConnection( QString name ) { TRACE("ServerWidgets::slot_endConnection name: %s", name.toLatin1().constData()); bool found = false; QTreeWidgetItem * item; int i = 0; while( i < _playerList->topLevelItemCount() ) { item = _playerList->topLevelItem( i ); if( item ) { if( item->text( 0 ) == name ) { found = true; _playerList->takeTopLevelItem( i ); delete item; break; } else { ++i; } } else { found = true; break; } } /* QTreeWidgetItem * item = _playerList->firstChild(); do { if( item ) { if( item->text( 0 ) == name ) { found = true; _playerList->takeItem( item ); delete item; } else { item = item->nextSibling(); } } else { found = true; } } while( !found );*/ } void ServerWidget::setGameLoaded( bool b ) { _loaded = b; if( _loaded ) { _butStart->setEnabled( false ); _butStop->setEnabled( true ); _butSave->setEnabled( true ); _groupWidget->setEnabled( false ); } else { _butStart->setEnabled( true ); _butStop->setEnabled( false ); _butSave->setEnabled( false ); _groupWidget->setEnabled( true ); } } QString ServerWidget::getFilename() { QString filename; logDD(" %d", _group->checkedId() ); switch( _group->checkedId() ) { case 0: filename = SCENARIO_PATH + "demo_1player.scn"; break; case 1: filename = SCENARIO_PATH + "demo_2players.scn"; break; case 2: filename = _choose->getText(); break; } return filename; } void ServerWidget::slot_start() { QString filename = getFilename(); emit sig_load( filename ); } void ServerWidget::slot_clicked(QTreeWidgetItem * item, int column) { //logDD("clicked %s, column %d",item->text(column).toLatin1().constData(), column); if(column == 0) { QMessageBox msb( "Player", "Do you want kick this player ?", QMessageBox::Warning, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape, 0, this ); if ( msb.exec() == QMessageBox::Yes ) { emit sig_banned( item->text(0) ); } } } // // ----- ConfigConnection ----- // ConfigConnection::ConfigConnection( QWidget * parent ) : QDialog( parent, Qt::Dialog ) { setWindowTitle( tr( "Start server" ) ); QLabel * labHost = new QLabel( tr( "Host : " ), this ); FIXEDSIZE( labHost ); _host = new QLineEdit( this ); _host->setFixedSize( 160, 20 ); _host->setEnabled(false); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addSpacing( 5 ); layH1->addWidget( labHost ); layH1->addSpacing( 5 ); layH1->addWidget( _host ); layH1->addStretch( 1 ); QLabel * labPort = new QLabel( tr( "Port : " ), this ); FIXEDSIZE( labPort ); _port = new QLineEdit( this ); _port->setFixedSize( 80, 20 ); QHBoxLayout * layH2 = new QHBoxLayout(); layH2->addSpacing( 5 ); layH2->addWidget( labPort ); layH2->addSpacing( 5 ); layH2->addWidget( _port ); layH2->addStretch( 1 ); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Start" ) ); pbOk->setFixedSize( 60, 60 ); FIXEDSIZE( pbOk ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Quit" ) ); FIXEDSIZE( pbCan ); QHBoxLayout * layH3 = new QHBoxLayout(); layH3->addStretch( 1 ); layH3->addWidget( pbOk ); layH3->addStretch( 1 ); layH3->addWidget( pbCan ); layH3->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->addLayout( layH1, 1 ); layout->addLayout( layH2, 1 ); layout->addLayout( layH3, 2 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); setFixedSize( 250, 150 ); } attal-src-1.0-rc2/server/serverWidgets.h0000644000175000017500000000657410513210371015775 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** serverWidgets.h ** Various dialog for server ** ** Version : $Id: serverWidgets.h,v 1.1 2006/10/11 15:42:49 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 26/07/2006 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SERVERWIDGETS_H #define SERVERWIDGETS_H // generic include files // include files for QT #include #include #include #include #include #include // application specific include files #include "libServer/attalServer.h" class QButtonGroup; class QGroupBox; class QLabel; class QPushButton; class QRadioButton; /** radio button allowing to choose a file on the disk */ class ChooseFileWidget : public QWidget { Q_OBJECT public: /** Constructor */ ChooseFileWidget( QWidget * parent = 0, const char * name = 0 ); /** Return file in the lineedit */ QString getText() { return _edit->text(); } public slots: /** Slot for choosing file */ void slot_choose(); /** Toggle radio button */ void slot_toggle( bool ); private: QLineEdit * _edit; QPushButton * _choose; }; /** Main widget for the server */ class ServerWidget : public QWidget { Q_OBJECT public: /** Constructor */ ServerWidget( QWidget * parent = 0, const char * name = 0 ); /** Toggle buttons state as game started or not */ void setGameLoaded( bool b ); /** returns filename to load */ QString getFilename(); public slots: /** Slot for start button */ void slot_start(); /** Slot for handling new players */ void slot_newPlayer( AttalPlayerSocket * player ); /** slot for handling disconnected players */ void slot_endConnection( QString name ); void slot_clicked(QTreeWidgetItem * item, int column); signals: /** Signal for buttopn 'End' */ void sig_stop(); /** Signal for button 'Load' */ void sig_load( QString ); /** Signal for button 'Save' */ void sig_save(); void sig_banned( QString name); private: QButtonGroup * _group; QGroupBox * _groupWidget; QPushButton * _butStart, * _butStop, * _butSave; QRadioButton * _radio1, * _radio2, * _radio3; ChooseFileWidget * _choose; QTreeWidget * _playerList; bool _loaded; }; /** Dialog for configuring connection to server */ class ConfigConnection : public QDialog { Q_OBJECT public: /** Constructor */ ConfigConnection( QWidget * parent = 0 ); /** Setting hostname */ void setHost( QString host ) { _host->setText( host ); } /** Getting hostname */ QString getHost() { return _host->text(); } int getPort() { return _port->text().toInt(); } /** Setting port number */ void setPort( int port ) { _port->setText( QString::number( port ) ); } void accept() { QDialog::accept(); } private: QLineEdit * _host, * _port; }; #define FIXEDSIZE( wid ) (wid)->setFixedSize( (wid)->sizeHint() ) #endif // SERVERWIDGETS_H attal-src-1.0-rc2/test/0000755000175000017500000000000011016113673012432 5ustar aaaaattal-src-1.0-rc2/test/test.pro0000644000175000017500000000106410762325055014142 0ustar aaaa###################################################################### # Automatically generated by qmake (2.01a) mer feb 27 23:47:49 2008 ###################################################################### CONFIG += qtestlib TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += . INCLUDEPATH += .. LIBS += -L.. DESTDIR = .. unix:LIBS += -lAttalClient unix:LIBS += -lAttalFight unix:LIBS += -lAttalAi unix:LIBS += -lAttalServer unix:LIBS += -lAttalCommon QT += xml network TARGET = attal-test # Input HEADERS += testattal.moc SOURCES += testattal.cpp attal-src-1.0-rc2/test/testattal.cpp0000644000175000017500000000341511010170660015137 0ustar aaaa #include #include "client/clientInterface.h" #include "libCommon/attalCommon.h" #include "libClient/imageTheme.h" #include "libCommon/define.h" #include "conf.h" class TestAttal: public QObject { Q_OBJECT private slots: void testLord(); void testPlayer(); void testGame(); }; void TestAttal::testLord() { useTheme(); DataTheme.init(); GenericLord lord; GenericLordModel * model = DataTheme.lords.at( 1 ); lord.setId( 1 ); lord.reinit(); QCOMPARE( lord.getCharac( LEVEL ) , 0 ); QCOMPARE( lord.getOwner() , (GenericPlayer *)0 ); QCOMPARE( lord.getId() , 1 ); QCOMPARE( lord.getBaseCharac( MOVE ) , model->getBaseCharac( MOVE ) ); lord.setBaseCharac( MOVE, lord.getCharac( MAXMOVE ) ); lord.decreaseBaseCharac( MOVE, 2 ); QCOMPARE( lord.getBaseCharac( MOVE ) , model->getBaseCharac( MAXMOVE ) -2 ); lord.endTurn(); QCOMPARE( lord.getBaseCharac( MOVE ) , model->getBaseCharac( MAXMOVE ) ); QCOMPARE( ( uint ) lord.getRace() , model->getRace() ); int count = lord.countUnits(); Creature * crea = new Creature(); lord.addCreatures( crea, 10 ); lord.clearUnits(); QCOMPARE( lord.countUnits() , 0 ); lord.setCost( 0, 100); QCOMPARE( ( int ) lord.getCost(0) ,100 ); lord.setVisible( false ); QCOMPARE( lord.isVisible() ,false ); GenericCell * cell = new GenericCell(); lord.setCell( cell ); QCOMPARE( lord.getCell() ,cell ); QCOMPARE( cell->getLord() ,(GenericLord *)&lord ); lord.removeFromGame(); QCOMPARE( lord.getCell() , (GenericCell * )0 ); QCOMPARE( cell->getLord() ,(GenericLord *)0 ); QCOMPARE( lord.hasMachineType( 0 ) , false ); delete crea; delete cell; } void TestAttal::testPlayer() { GenericPlayer player; QCOMPARE( player.isAlive() , true ); } void TestAttal::testGame() { } QTEST_MAIN(TestAttal) #include "testattal.moc" attal-src-1.0-rc2/themeEditor/0000755000175000017500000000000011016113673013724 5ustar aaaaattal-src-1.0-rc2/themeEditor/.cvsignore0000644000175000017500000000042010331243516015717 0ustar aaaamoc obj editor moc_* *.moc.cpp *.o *.opt *.plg *.dsp Makefile Makefile.Release Makefile.Debug Makefile.in .deps theme-editor ThemeEditor.plg Debug Release attal-theme-editor_resource.rc object_ld_script.attal-theme-editor.Debug object_ld_script.attal-theme-editor.Release attal-src-1.0-rc2/themeEditor/artefactAction.cpp0000644000175000017500000001652310616355757017406 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** artefactAction.cpp ** Widget for editing actions of artefact ** ** Version : $Id: artefactAction.cpp,v 1.6 2007/05/03 12:56:15 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 07/03/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "artefactAction.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/artefact.h" #include "libCommon/genericLord.h" #include "libCommon/log.h" #include "libClient/gui.h" // // ----- ArtefactAction ----- // ArtefactAction::ArtefactAction( QWidget * parent, const char * name ) : EditWidget( parent, name ) { _artefact = 0; connect( _pbAdd, SIGNAL( clicked() ), SLOT( slot_add() ) ); connect( _pbEdit, SIGNAL( clicked() ), SLOT( slot_edit() ) ); connect( _pbDel, SIGNAL( clicked() ), SLOT( slot_del() ) ); } void ArtefactAction::init( GenericArtefactModel * artefact ) { _artefact = artefact; _listBox->clear(); if( artefact ) { uint nb = artefact->getActionNumber(); for( uint i = 0; i < nb; ++i ) { ArtefactActionItem * actionItem; ArtefactElementaryAction * action = artefact->getAction( i ); actionItem = new ArtefactActionItem( action->getActionType(), action->getModifType(), action->getParam(), action->getValue() ); _listBox->addItem( actionItem ); } } } void ArtefactAction::slot_add() { DialogArtefactAction dialog; if( dialog.exec() ) { ArtefactActionItem * actionItem; ArtefactElementaryAction::ActionType actionType = dialog.getActionType(); ArtefactElementaryAction::ModifType modifType = dialog.getModifType(); uint param = dialog.getParam(); int value = dialog.getValue(); actionItem = new ArtefactActionItem( actionType, modifType, param, value ); _listBox->addItem( actionItem ); } } void ArtefactAction::slot_edit() { int item = _listBox->currentRow(); if( item != -1 ) { DialogArtefactAction dialog; dialog.setActionType( ( (ArtefactActionItem*)(_listBox->item( item ) ) )->getActionType() ); dialog.setModifType( ( (ArtefactActionItem*)(_listBox->item( item ) ) )->getModifType() ); dialog.setParam( ( (ArtefactActionItem*)(_listBox->item( item ) ) )->getParam() ); dialog.setValue( ( (ArtefactActionItem*)(_listBox->item( item ) ) )->getValue() ); if( dialog.exec() ) { ArtefactElementaryAction::ActionType actionType = dialog.getActionType(); ArtefactElementaryAction::ModifType modifType = dialog.getModifType(); uint param = dialog.getParam(); int value = dialog.getValue(); ArtefactActionItem * action = (ArtefactActionItem*) _listBox->item( item ); action->setActionType( actionType ); action->setModifType( modifType ); action->setParam( param ); action->setValue( value ); } } } void ArtefactAction::slot_del() { int item = _listBox->currentRow(); if( item != -1 ) { _listBox->takeItem( item ); } } void ArtefactAction::save() { ArtefactElementaryAction * action; _artefact->clearActions(); uint nb = _listBox->count(); for( uint i = 0; i < nb; ++i ) { ArtefactActionItem * item = (ArtefactActionItem*) _listBox->item( i ); action = new ArtefactElementaryAction( item->getActionType(), item->getModifType() ); action->setParam( item->getParam() ); action->setValue( item->getValue() ); _artefact->addAction( action ); } } // // ----- ArtefactActionItem ----- // ArtefactActionItem::ArtefactActionItem( ArtefactElementaryAction::ActionType action, ArtefactElementaryAction::ModifType modif, uint param, int value ) : QListWidgetItem() { _action = action; _modif = modif; _param = param; _value = value; computeLabel(); } void ArtefactActionItem::computeLabel() { QString text = QObject::tr( "Action: " ); if( _action == ArtefactElementaryAction::AT_CHARAC ) { text += QObject::tr( "Charac " ); text += getCharacName( (LordCharac)_param ); } else { text += QObject::tr( "Spell " ); text += QString::number( _param ); } if( _modif == ArtefactElementaryAction::MT_VALUE ) { text += QObject::tr( " modify by " ) + QString::number( _value ); } else { text += QObject::tr( " modify by " ) + QString::number( _value ) + QObject::tr( "%" ); } setText( text ); } // // ----- DialogArtefactAction ----- // DialogArtefactAction::DialogArtefactAction( QWidget * parent, const char * /*name*/ ) : QDialog( parent, Qt::Dialog ) { QLabel * labAction = new QLabel( tr( "Action type: " ), this ); FIXEDSIZE( labAction ); _comboAction = new QComboBox( this ); _comboAction->addItem( tr( "Characteristic" ) ); _comboAction->addItem( tr( "Spell" ) ); FIXEDSIZE( _comboAction ); _comboModif = new QComboBox( this ); _comboModif->addItem( tr( "Fixed value" ) ); _comboModif->addItem( tr( "Ratio" ) ); FIXEDSIZE( _comboAction ); QLabel * labModif = new QLabel( tr( "Modification type: " ), this ); FIXEDSIZE( labModif ); QLabel * labParam = new QLabel( tr( "Parameter: " ), this ); FIXEDSIZE( labParam ); QLabel * labValue = new QLabel( tr( "Value: " ), this ); FIXEDSIZE( labParam ); _spinParam = new QSpinBox( this ); _spinParam->setMinimum( 0 ); _spinValue = new QSpinBox( this ); QGridLayout * grid = new QGridLayout(); grid->addWidget( labAction, 1, 0 ); grid->addWidget( _comboAction, 1, 1 ); grid->addWidget( labModif, 2, 0 ); grid->addWidget( _comboModif, 2, 1 ); grid->addWidget( labParam, 3, 0 ); grid->addWidget( _spinParam, 3, 1 ); grid->addWidget( labValue, 4, 0 ); grid->addWidget( _spinValue, 4, 1 ); grid->addItem(new QSpacerItem(5, 0), 0, 0); grid->addItem(new QSpacerItem(5, 0), 0, 5); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pbCan ); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addLayout( grid, 1 ); layout->addLayout( layH1 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); FIXEDSIZE( this ); } void DialogArtefactAction::updateDialog() { _comboAction->setCurrentIndex( (int)_action ); _comboModif->setCurrentIndex( (int)_modif ); _spinParam->setValue( _param ); _spinValue->setValue( _value ); } void DialogArtefactAction::accept() { _action = (ArtefactElementaryAction::ActionType) _comboAction->currentIndex(); _modif = (ArtefactElementaryAction::ModifType) _comboModif->currentIndex(); _param = _spinParam->value(); _value = _spinValue->value(); QDialog::accept(); } attal-src-1.0-rc2/themeEditor/artefactAction.h0000644000175000017500000000732410510545314017031 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** artefactAction.h ** Widget for editing actions of artefact ** ** Version : $Id: artefactAction.h,v 1.4 2006/10/03 20:40:44 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 07/03/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ARTEFACTACTION_H #define ARTEFACTACTION_H // generic include files // include files for QT #include #include // application specific include files #include "libCommon/artefact.h" #include "themeEditor/editWidget.h" class QSpinBox; class QComboBox; /* ------------------------------ * ArtefactAction * ------------------------------ */ class ArtefactAction : public EditWidget { Q_OBJECT public: ArtefactAction( QWidget * parent = 0, const char * name = 0 ); void init( GenericArtefactModel * artefact ); void save(); public slots: void slot_add(); void slot_edit(); void slot_del(); protected: GenericArtefactModel * _artefact; }; /* ------------------------------ * ArtefactActionItem * ------------------------------ */ class ArtefactActionItem : public QListWidgetItem { public: ArtefactActionItem( ArtefactElementaryAction::ActionType action, ArtefactElementaryAction::ModifType modif, uint param, int value ); ArtefactElementaryAction::ActionType getActionType() { return _action; } void setActionType( ArtefactElementaryAction::ActionType action ) { _action = action; computeLabel(); } ArtefactElementaryAction::ModifType getModifType() { return _modif; } void setModifType( ArtefactElementaryAction::ModifType modif ) { _modif = modif; computeLabel(); } uint getParam() { return _param; } void setParam( uint param ) { _param = param; computeLabel(); } int getValue() { return _value; } void setValue( int value ) { _value = value; computeLabel(); } void computeLabel(); protected: ArtefactElementaryAction::ActionType _action; ArtefactElementaryAction::ModifType _modif; uint _param; int _value; }; /* ------------------------------ * DialogArtefactAction * ------------------------------ */ class DialogArtefactAction : public QDialog { Q_OBJECT public: DialogArtefactAction( QWidget * parent = 0, const char * name = 0 ); ArtefactElementaryAction::ActionType getActionType() { return _action; } void setActionType( ArtefactElementaryAction::ActionType action ) { _action = action; updateDialog(); } ArtefactElementaryAction::ModifType getModifType() { return _modif; } void setModifType( ArtefactElementaryAction::ModifType modif ) { _modif = modif; updateDialog(); } uint getParam() { return _param; } void setParam( uint param ) { _param = param; updateDialog(); } int getValue() { return _value; } void setValue( int value ) { _value = value; updateDialog(); } void updateDialog(); public slots: void accept(); protected: ArtefactElementaryAction::ActionType _action; ArtefactElementaryAction::ModifType _modif; uint _param; int _value; QComboBox * _comboAction, * _comboModif; QSpinBox * _spinParam, * _spinValue; }; #endif // ARTEFACTACTION_H attal-src-1.0-rc2/themeEditor/askDiversification.cpp0000644000175000017500000001115710616363716020270 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** askDiversification.cpp ** Displays and asks diversification of tiles ** ** Version : $Id: askDiversification.cpp,v 1.11 2007/05/03 13:46:54 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 12/01/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "askDiversification.h" // generic include files // include files for QT #include #include #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/genericCell.h" #include "libCommon/log.h" #include "libClient/askWidget.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" extern QString DATA_PATH; extern QString IMAGE_PATH; // // ----- AskDiversification ----- // AskDiversification::AskDiversification( const QString & destination, QWidget * parent, const char * /*name*/ ) : QDialog( parent, Qt::Dialog ) { _pixmap = new AskPixmap( true, destination, "Tile: ", this ); _weight = new AskInt( "Weight: ", this ); QPushButton * pbOk = new QPushButton( "Ok", this ); FIXEDSIZE( pbOk ); QPushButton * pbCan = new QPushButton( "Cancel", this ); FIXEDSIZE( pbCan ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pbCan ); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addWidget( _pixmap ); layout->addWidget( _weight ); layout->addStretch( 1 ); layout->addLayout( layH1 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( slot_accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); } uint AskDiversification::getWeight() { return _weight->getValue(); } void AskDiversification::setWeight( uint weight ) { _weight->setValue( weight ); } QString AskDiversification::getPixmapPath() { return _pixmap->getValue(); } void AskDiversification::setPixmapPath( const QString & path ) { _pixmap->setValue( path ); } void AskDiversification::slot_accept() { _pixmap->save(); accept(); } // // ----- AskDiversificationList ----- // AskDiversificationList::AskDiversificationList( QWidget * parent, const char * /*name*/ ) :QWidget( parent ) { _cell = 0; _list = new QListWidget( this ); _pbNew = new QPushButton( tr("New"), this ); FIXEDSIZE( _pbNew ); _pbDel = new QPushButton( tr("Del"), this ); FIXEDSIZE( _pbDel ); QVBoxLayout * layV1 = new QVBoxLayout(); layV1->setMargin( 5 ); layV1->setSpacing( 5 ); layV1->addWidget( _pbNew ); layV1->addWidget( _pbDel ); layV1->addStretch( 1 ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _list, 1 ); layout->addLayout( layV1 ); layout->activate(); connect( _pbNew, SIGNAL( clicked() ), SLOT( slot_new() ) ); connect( _pbDel, SIGNAL( clicked() ), SLOT( slot_del() ) ); } void AskDiversificationList::slot_new() { AskDiversification dialog( IMAGE_PATH + "/tiles/new.png", this ); if( dialog.exec() ) { /* This code works but is commented cause bugs in ImageThemes.cells ( don't load new picture ) * _cell->addDiversification( dialog.getWeight() ); setValue( _cell ); */ } } void AskDiversificationList::slot_del() { if( _list->count() > 1 ) { _cell->removeDiversification( _list->currentRow() ); setValue( _cell ); } } void AskDiversificationList::setValue( CellModel * cell ) { uint nb, val, index = 0; QString text; _cell = cell; _list->clear(); nb = _cell->getDiversificationNumber(); for( int j = 0; j < DataTheme.tiles.count(); j++ ) { if( DataTheme.tiles.at(j) == cell ) { index = j; break; } } for( uint i = 0; i < nb; i++ ) { val = _cell->getDiversification( i ); text.sprintf( "(weight = %d)", val ); QListWidgetItem * item = new QListWidgetItem( _list ); item->setIcon( ImageTheme.cells[index]->at( i ) ); item->setText( text ); } } void AskDiversificationList::save() { } void AskDiversificationList::clear() { _list->clear(); } attal-src-1.0-rc2/themeEditor/askDiversification.h0000644000175000017500000000435310600232332017713 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** askDiversification.h ** Displays and asks diversification of tiles ** ** Version : $Id: askDiversification.h,v 1.4 2007/03/21 13:36:26 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 12/01/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef ASKDIVERSIFICATION_H #define ASKDIVERSIFICATION_H // generic include files // include files for QT #include #include #include // application specific include files class QPushButton; class QListWidget; class AskInt; class AskPixmap; class CellModel; /* ------------------------------ * AskDiversification * ------------------------------ */ class AskDiversification : public QDialog { Q_OBJECT public: /** Constructor */ AskDiversification( const QString & destination, QWidget * parent = 0, const char * name = 0 ); uint getWeight(); void setWeight( uint weight ); QString getPixmapPath(); void setPixmapPath( const QString & path ); protected slots: virtual void slot_accept(); protected: AskInt * _weight; AskPixmap * _pixmap; }; /* ------------------------------ * AskDiversificationList * ------------------------------ */ class AskDiversificationList : public QWidget { Q_OBJECT public: /** Constructor */ AskDiversificationList( QWidget * parent = 0, const char * name = 0 ); void setValue( CellModel * cell ); void save(); void clear(); public slots: void slot_new(); void slot_del(); protected: QPushButton * _pbNew, * _pbDel; QListWidget * _list; CellModel * _cell; }; #endif // ASKDIVERSIFICATION_H attal-src-1.0-rc2/themeEditor/buildingAction.cpp0000644000175000017500000002545710740430161017375 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** buildingAction.cpp ** Widget for editing actions of building ** ** Version : $Id: buildingAction.cpp,v 1.19 2008/01/07 14:00:17 lusum Exp $ ** ** Author(s) : Sardi Carlo -Pascal Audoux ** ** Date : 29/04/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "buildingAction.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/genericBuilding.h" #include "libCommon/genericLord.h" #include "libCommon/log.h" #include "libCommon/action.h" #include "libCommon/dataTheme.h" #include "libClient/gui.h" // // ----- buildingAction ----- // BuildingAction::BuildingAction( QWidget * parent, const char * name ) : EditWidget( parent,name) { connect( _pbAdd, SIGNAL( clicked() ), SLOT( slot_add() ) ); connect( _pbEdit, SIGNAL( clicked() ), SLOT( slot_edit() ) ); connect( _pbDel, SIGNAL( clicked() ), SLOT( slot_del() ) ); } void BuildingAction::init( QList * list ) { TRACE("BuildingAction::init"); QList * action = list; _listBox->clear(); if( action->count() ) { for( int i = 0; i < action->count(); i++ ) { for( int j = 0; j < action->at(i)->getElementaryNumber(); j++ ) { ElementaryAction * elementary = action->at(i)->getElementaryAction( j ); BuildingActionItem * actionItem; actionItem = new BuildingActionItem( action->at(i)->getType(),action->at(i)->getCoeff(), elementary->getType(), elementary->getArg(), elementary->getArg1() ,elementary->getCoeff() ); _listBox->addItem( actionItem ); } } } } void BuildingAction::slot_add() { DialogBuildingAction dialog; if( dialog.exec() ) { BuildingActionItem * actionItem; Action::ActionType actionType = dialog.getActionType(); int actValue = dialog.getActValue(); ElementaryAction::ElementaryType ElementaryType = dialog.getModifType(); uint param = dialog.getParam(); uint param1 = dialog.getParam1(); int value = dialog.getValue(); actionItem = new BuildingActionItem( actionType, actValue , ElementaryType, param, param1, value ); _listBox->addItem( actionItem ); } } void BuildingAction::slot_edit() { int item = _listBox->currentRow(); if( item != -1 ) { DialogBuildingAction dialog; dialog.setActionType( ( (BuildingActionItem*)(_listBox->item( item ) ) )->getActionType() ); dialog.setActValue( ( (BuildingActionItem*)(_listBox->item( item ) ) )->getActValue() ); dialog.setModifType( ( (BuildingActionItem*)(_listBox->item( item ) ) )->getModifType() ); dialog.setParam( ( (BuildingActionItem*)(_listBox->item( item ) ) )->getParam() ); dialog.setParam1( ( (BuildingActionItem*)(_listBox->item( item ) ) )->getParam1() ); dialog.setValue( ( (BuildingActionItem*)(_listBox->item( item ) ) )->getValue() ); if( dialog.exec() ) { Action::ActionType actionType = dialog.getActionType(); int actValue = dialog.getActValue(); ElementaryAction::ElementaryType ElementaryType = dialog.getModifType(); uint param = dialog.getParam(); uint param1 = dialog.getParam1(); int value = dialog.getValue(); BuildingActionItem * action = (BuildingActionItem*) _listBox->item( item ); action->setActionType( actionType ); action->setActValue( actValue ); action->setModifType( ElementaryType ); action->setParam( param ); action->setParam1( param1 ); action->setValue( value ); } } } void BuildingAction::slot_del() { int item = _listBox->currentRow(); if( item != -1 ) { _listBox->takeItem( item ); } } QList BuildingAction::save() { QList list; uint nb = _listBox->count(); for( uint i = 0; i < nb; ++i ) { BuildingActionItem * item = (BuildingActionItem*) _listBox->item( i ); ElementaryAction * eleaction = new ElementaryAction(); eleaction->setType(item->getModifType() ); eleaction->setArg( item->getParam() ); eleaction->setArg1( item->getParam1() ); eleaction->setCoeff( item->getValue() ); Action * builAction = new Action(); builAction->setType(item->getActionType()); builAction->setCoeff( item->getActValue() ); builAction->addElementaryAction(eleaction); list.append( builAction ); } return list; } // // ----- buildingActionItem ----- // BuildingActionItem::BuildingActionItem( Action::ActionType action, int actValue, ElementaryAction::ElementaryType modif, uint param, uint param1 , int value ) : QListWidgetItem() { _action = action; _actValue = actValue; _modif = modif; _param = param; _param1 = param1; _value = value; computeLabel(); } void BuildingActionItem::computeLabel() { Action * tmpa = new Action(); tmpa->setType(_action); tmpa->setCoeff(_actValue ); ElementaryAction * tmpe = new ElementaryAction(); tmpe->setType(_modif); tmpe->setArg( _param ); tmpe->setArg1( _param1 ); tmpe->setCoeff(_value ); tmpa->addElementaryAction( tmpe ); QString text = tmpa->getDescription( false ); setText( text ); delete tmpa; } // // ----- DialogbuildingAction ----- // DialogBuildingAction::DialogBuildingAction( QWidget * parent, const char * /*name*/ ) : QDialog( parent, Qt::Dialog ) { QLabel * labAction = new QLabel( tr( "Action type: " ), this ); FIXEDSIZE( labAction ); int i; QString string; _comboAction = new QComboBox( this ); for( i = 0; i < Action::LAST; i++ ) { Action::ActionType atype = ( Action::ActionType)i; string = Action::getActionTypeString( atype ); string.replace( 0, 1, string[0].toUpper() ); _comboAction->addItem( string ); } FIXEDSIZE( _comboAction ); _spinActValue = new QSpinBox( this ); _spinActValue->setMaximum( 100000 ); _labActValue = new QLabel( tr( "Coeff: " ), this ); _comboModif = new QComboBox( this ); for( i = 1; i < ElementaryAction::LAST; i++ ) { ElementaryAction::ElementaryType etype = ( ElementaryAction::ElementaryType)i; string = ElementaryAction::getElemTypeString( etype ); string.replace( 0, 1, string[0].toUpper() ); _comboModif->addItem( string ); } FIXEDSIZE( _comboAction ); QLabel * labModif = new QLabel( tr( "Elementary Action: " ), this ); FIXEDSIZE( labModif ); _labParam = new QLabel( tr( "Arg0: " ), this ); _labParam1 = new QLabel( tr( "Arg1: " ), this ); _labValue = new QLabel( tr( "Coeff: " ), this ); _spinParam = new QSpinBox( this ); _spinParam->setMinimum( 0 ); _spinParam1 = new QSpinBox( this ); _spinParam1->setMinimum( 0 ); _spinValue = new QSpinBox( this ); _spinValue->setRange( -100000, 100000 ); _labParam->hide(); _labParam1->hide(); _spinParam->hide(); _spinParam1->hide(); QGridLayout * grid = new QGridLayout(); grid->addWidget( labAction, 1, 0 ); grid->addWidget( _comboAction, 1, 1 ); grid->addWidget( _labActValue, 2, 0 ); grid->addWidget( _spinActValue, 2, 1 ); grid->addWidget( labModif, 3, 0 ); grid->addWidget( _comboModif, 3, 1 ); grid->addWidget( _labParam, 4, 0 ); grid->addWidget( _spinParam, 4, 1 ); grid->addWidget( _labParam1, 5, 0 ); grid->addWidget( _spinParam1, 5, 1 ); grid->addWidget( _labValue, 6, 0 ); grid->addWidget( _spinValue, 6, 1 ); grid->addItem(new QSpacerItem(5, 0), 0, 0); grid->addItem(new QSpacerItem(5, 0), 0, 5); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pbCan ); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addLayout( grid, 1 ); layout->addLayout( layH1 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); connect( _comboModif,SIGNAL( currentIndexChanged ( int ) ), SLOT( slot_modif( int ) ) ); connect( _comboAction,SIGNAL( currentIndexChanged ( int ) ), SLOT( slot_action( int ) ) ); FIXEDSIZE( this ); } void DialogBuildingAction::updateDialog() { _comboAction->setCurrentIndex( (uint)_action ); _spinActValue->setValue( _actValue ); _comboModif->setCurrentIndex( (uint)_modif-1 ); _spinParam->setValue( _param ); _spinParam1->setValue( _param1 ); _spinValue->setValue( _value ); } void DialogBuildingAction::accept() { _action = (Action::ActionType) _comboAction->currentIndex(); _actValue = _spinActValue->value(); _modif = (ElementaryAction::ElementaryType) (_comboModif->currentIndex() + 1); _param = _spinParam->value(); _param1 = _spinParam1->value(); _value = _spinValue->value(); QDialog::accept(); } void DialogBuildingAction::slot_modif( int index ) { ElementaryAction::ElementaryType etype =( ElementaryAction::ElementaryType ) (index + 1); switch( etype ) { case ElementaryAction::ATTACK: case ElementaryAction::DEFENSE: case ElementaryAction::POWER: case ElementaryAction::KNOWLEDGE: case ElementaryAction::MOVE: case ElementaryAction::MAXMOVE: case ElementaryAction::TECHNICPOINT: case ElementaryAction::MAXTECHNICPOINT: case ElementaryAction::MORALE: case ElementaryAction::LUCK: case ElementaryAction::VISION: case ElementaryAction::EXPERIENCE: case ElementaryAction::CHARISMA: case ElementaryAction::POPULATION: _labParam->hide(); _labParam1->hide(); _spinParam->hide(); _spinParam1->hide(); break; case ElementaryAction::SKILL: break; case ElementaryAction::ARTEFACT: break; case ElementaryAction::RESOURCEPERC: case ElementaryAction::RESSOURCE: case ElementaryAction::RANDRESSOURCE: _labParam1->hide(); _spinParam1->hide(); _labParam->show(); _spinParam->show(); break; case ElementaryAction::RESOURCEFROM: case ElementaryAction::UNIT: _labParam->show(); _labParam1->show(); _spinParam->show(); _spinParam1->show(); break; default: _labParam->show(); _labParam1->show(); _spinParam->show(); _spinParam1->show(); break; } } void DialogBuildingAction::slot_action( int index ) { Action::ActionType action = ( Action::ActionType ) index; switch( action ) { case Action::DATE : _labActValue->show(); _spinActValue->show(); break; default: _labActValue->hide(); _spinActValue->hide(); break; } } attal-src-1.0-rc2/themeEditor/buildingAction.h0000644000175000017500000001036610733736225017047 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** buildingAction.h ** Widget for editing actions of building ** ** Version : $Id: buildingAction.h,v 1.8 2007/12/24 14:05:09 lusum Exp $ ** ** Author(s) : Sardi Carlo - Pascal Audoux ** ** Date : 29/04/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef BUILDINGACTION_H #define BUILDINGACTION_H // generic include files // include files for QT #include #include // application specific include files #include "libCommon/action.h" #include "libClient/askWidget.h" #include "themeEditor/editWidget.h" class QSpinBox; class QComboBox; /* ------------------------------ * buildingAction * ------------------------------ */ class BuildingAction : public EditWidget { Q_OBJECT public: BuildingAction( QWidget * parent = 0, const char * name = 0 ); void init( QList * list ); QList save(); public slots: void slot_add(); void slot_edit(); void slot_del(); }; /* ------------------------------ * buildingActionItem * ------------------------------ */ class BuildingActionItem : public QListWidgetItem { public: /** Constructor */ BuildingActionItem( Action::ActionType action, int actValue, ElementaryAction::ElementaryType modif, uint param, uint param1, int value ); Action::ActionType getActionType() { return _action; } void setActionType( Action::ActionType action ) { _action = action; computeLabel(); } ElementaryAction::ElementaryType getModifType() { return _modif; } void setModifType( ElementaryAction::ElementaryType modif ) { _modif = modif; computeLabel(); } uint getParam() { return _param; } void setParam( uint param ) { _param = param; computeLabel(); } uint getParam1() { return _param1; } void setParam1( uint param ) { _param1 = param; computeLabel(); } int getValue() { return _value; } void setValue( int value ) { _value = value; computeLabel(); } int getActValue() { return _actValue; } void setActValue( int value ) { _actValue = value; computeLabel(); } void computeLabel(); protected: Action::ActionType _action; ElementaryAction::ElementaryType _modif; uint _param, _param1; int _value, _actValue; }; /* ------------------------------ * DialogbuildingAction * ------------------------------ */ class DialogBuildingAction : public QDialog { Q_OBJECT public: DialogBuildingAction( QWidget * parent = 0, const char * name = 0 ); Action::ActionType getActionType() { return _action; } void setActionType( Action::ActionType action ) { _action = action; updateDialog(); } ElementaryAction::ElementaryType getModifType() { return _modif; } void setModifType( ElementaryAction::ElementaryType modif ) { _modif = modif; updateDialog(); } uint getParam() { return _param; } void setParam( uint param ) { _param = param; updateDialog(); } uint getParam1() { return _param1; } void setParam1( uint param ) { _param1 = param; updateDialog(); } int getValue() { return _value; } void setValue( int value ) { _value = value; updateDialog(); } int getActValue() { return _actValue; } void setActValue( int value ) { _actValue = value; updateDialog(); } void updateDialog(); public slots: void accept(); void slot_modif( int index ); void slot_action( int index ); protected: Action::ActionType _action; ElementaryAction::ElementaryType _modif; uint _param, _param1; int _value, _actValue; QComboBox * _comboAction, * _comboModif; QSpinBox * _spinParam, * _spinParam1,* _spinValue, * _spinActValue; QLabel * _labParam, * _labParam1, * _labValue, * _labActValue; }; #endif // BUILDINGACTION_H attal-src-1.0-rc2/themeEditor/creatureAnimation.cpp0000644000175000017500000001522710622156542020115 0ustar aaaa/***************************************************************** ** ** Attal : Lords of Doom ** ** creatureAnimation.cpp ** Widget for editing animations of creatures ** ** Version : $Id: creatureAnimation.cpp,v 1.12 2007/05/14 22:06:26 lusum Exp $ ** ** Author(s) : Sardi Carlo - Pascal Audoux ** ** Date : 29/07/2005 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "creatureAnimation.h" // generic include files // include files for QT #include #include #include #include #include // application specific include files #include "libCommon/creature.h" #include "libCommon/genericLord.h" #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libClient/gui.h" // // ----- CreatureAnimation ----- // CreatureAnimation::CreatureAnimation( QWidget * parent, const char * name ) : EditWidget( parent, name ) { _creature = 0; connect( _pbAdd, SIGNAL( clicked() ), SLOT( slot_add() ) ); connect( _pbEdit, SIGNAL( clicked() ), SLOT( slot_edit() ) ); connect( _pbDel, SIGNAL( clicked() ), SLOT( slot_del() ) ); } void CreatureAnimation::init( Creature * creature ) { _creature = creature; uint num = _creature->numAnimation(); _listBox->clear(); if( num ) { for( uint i = 0; i < num; i++ ) { Creature::CreatureAnimation * animation = _creature->getCreatureAnimation(i); CreatureAnimationItem * actionItem; actionItem = new CreatureAnimationItem( animation->getType(), animation->getFirst(), animation->getLast() ); _listBox->addItem( actionItem ); } } } void CreatureAnimation::slot_add() { DialogCreatureAnimation dialog; if( dialog.exec() ) { CreatureAnimationItem * actionItem; CreatureAnimationType AnimationType = dialog.getModifType(); uint first = dialog.getFirst(); int last = dialog.getLast(); actionItem = new CreatureAnimationItem( AnimationType, first, last ); _listBox->addItem( actionItem ); } } void CreatureAnimation::slot_edit() { int item = _listBox->currentRow(); if( item != -1 ) { DialogCreatureAnimation dialog; dialog.setModifType( ( (CreatureAnimationItem*)(_listBox->item( item ) ) )->getModifType() ); dialog.setFirst( ( (CreatureAnimationItem*)(_listBox->item( item ) ) )->getFirst() ); dialog.setLast( ( (CreatureAnimationItem*)(_listBox->item( item ) ) )->getLast() ); if( dialog.exec() ) { CreatureAnimationType ElementaryType = dialog.getModifType(); uint first = dialog.getFirst(); int last = dialog.getLast(); CreatureAnimationItem * action = (CreatureAnimationItem*) _listBox->item( item ); action->setModifType( ElementaryType ); action->setFirst( first ); action->setLast( last ); } } } void CreatureAnimation::slot_del() { int item = _listBox->currentRow(); if( item != -1 ) { delete _listBox->takeItem( item ); } } void CreatureAnimation::save() { _creature->clearAnimations(); uint nb = _listBox->count(); for( uint i = 0; i < nb; ++i ) { CreatureAnimationItem * item = (CreatureAnimationItem*) _listBox->item( i ); _creature->setAnimation( (CreatureAnimationType) item->getModifType(), item->getFirst(),item->getLast()); } } // // ----- CreatureAnimationItem ----- // CreatureAnimationItem::CreatureAnimationItem( CreatureAnimationType type, uint first, uint last ) : QListWidgetItem() { _type = type; _first = first; _last = last; computeLabel(); } void CreatureAnimationItem::computeLabel() { Creature * creature = new Creature(); QString text = QObject::tr("AnimationType: "); text += creature->getAnimationTypeName( _type ); text += QObject::tr( " first frame " ); text += QString::number( _first ); text += QObject::tr( " last frame " ) + QString::number( _last ); setText( text ); delete creature; } // // ----- DialogCreatureAnimation ----- // DialogCreatureAnimation::DialogCreatureAnimation( QWidget * parent, const char * /*name*/ ) : QDialog( parent, Qt::Dialog ) { _comboModif = new QComboBox( this ); _comboModif->addItem( tr( "Moving" ) ); _comboModif->addItem( tr( "Fighting" ) ); _comboModif->addItem( tr( "Schooting" ) ); _comboModif->addItem( tr( "SchootHigh" ) ); _comboModif->addItem( tr( "SchootLow" ) ); _comboModif->addItem( tr( "Defending" ) ); _comboModif->addItem( tr( "StartMoving" ) ); _comboModif->addItem( tr( "EndMoving" ) ); _comboModif->addItem( tr( "Dying" ) ); _comboModif->addItem( tr( "Dead" ) ); _comboModif->addItem( tr( "AttackHigh" ) ); _comboModif->addItem( tr( "AttackLow" ) ); _comboModif->addItem( tr( "Selecting" ) ); QLabel * labModif = new QLabel( tr( "Action: " ), this ); FIXEDSIZE( labModif ); QLabel * labFirst = new QLabel( tr( "Start Frame: " ), this ); QLabel * labLast = new QLabel( tr( "End Frame: " ), this ); _spinFirst = new QSpinBox( this ); _spinFirst->setMinimum( 0 ); _spinLast = new QSpinBox( this ); _spinLast->setMaximum( 100000 ); QGridLayout * grid = new QGridLayout(); grid->addWidget( labModif, 2, 0 ); grid->addWidget( _comboModif, 2, 1 ); grid->addWidget( labFirst, 3, 0 ); grid->addWidget( _spinFirst, 3, 1 ); grid->addWidget( labLast, 4, 0 ); grid->addWidget( _spinLast, 4, 1 ); grid->addItem(new QSpacerItem(5, 0), 0, 0); grid->addItem(new QSpacerItem(5, 0), 0, 5); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pbCan ); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addLayout( grid, 1 ); layout->addLayout( layH1 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); FIXEDSIZE( this ); } void DialogCreatureAnimation::updateDialog() { _comboModif->setCurrentIndex( (uint)_modif ); _spinFirst->setValue( _first ); _spinLast->setValue( _last ); } void DialogCreatureAnimation::accept() { _modif = (CreatureAnimationType) (_comboModif->currentIndex()); _first = _spinFirst->value(); _last = _spinLast->value(); QDialog::accept(); } attal-src-1.0-rc2/themeEditor/creatureAnimation.h0000644000175000017500000000621610510545314017553 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** CreatureAnimation.h ** Widget for editing actions of building ** ** Version : $Id: creatureAnimation.h,v 1.4 2006/10/03 20:40:44 lusum Exp $ ** ** Author(s) : Sardi Carlo - Pascal Audoux ** ** Date : 29/04/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CREATUREANIMATION_H #define CREATUREANIMATION_H // generic include files // include files for QT #include #include // application specific include files #include "libCommon/creature.h" #include "themeEditor/editWidget.h" class QSpinBox; class QComboBox; /* ------------------------------ * CreatureAnimation * ------------------------------ */ class CreatureAnimation : public EditWidget { Q_OBJECT public: CreatureAnimation( QWidget * parent = 0, const char * name = 0 ); void init( Creature * creature ); void save(); public slots: void slot_add(); void slot_edit(); void slot_del(); protected: Creature * _creature; }; /* ------------------------------ * CreatureAnimationItem * ------------------------------ */ class CreatureAnimationItem : public QListWidgetItem { public: /** Constructor */ CreatureAnimationItem( CreatureAnimationType type, uint first, uint last ); CreatureAnimationType getModifType() { return _type; } void setModifType( CreatureAnimationType type ) { _type = type; computeLabel(); } uint getFirst() { return _first; } void setFirst( uint first ) { _first = first; computeLabel(); } uint getLast() { return _last; } void setLast( int last ) { _last = last; computeLabel(); } void computeLabel(); protected: CreatureAnimationType _type; uint _first; uint _last; }; /* ------------------------------ * DialogCreatureAnimation * ------------------------------ */ class DialogCreatureAnimation : public QDialog { Q_OBJECT public: DialogCreatureAnimation( QWidget * parent = 0, const char * name = 0 ); CreatureAnimationType getModifType() { return _modif; } void setModifType( CreatureAnimationType modif ) { _modif = modif; updateDialog(); } uint getFirst() { return _first; } void setFirst( uint first ) { _first = first; updateDialog(); } int getLast() { return _last; } void setLast( uint last ) { _last = last; updateDialog(); } void updateDialog(); public slots: void accept(); protected: CreatureAnimationType _modif; uint _first; uint _last; QComboBox * _comboModif; QSpinBox * _spinFirst, * _spinLast; }; #endif // CREATUREANIMATION_H attal-src-1.0-rc2/themeEditor/decorationEffect.cpp0000644000175000017500000001340310511275026017675 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** decorationEfefct.cpp ** Widget for editing effects of decoration ** ** Version : $Id: decorationEffect.cpp,v 1.11 2006/10/05 21:33:10 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 15/08/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "decorationEffect.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/genericDecoration.h" #include "libCommon/log.h" #include "libClient/gui.h" // // ----- DecorationEffect ----- // DecorationEffect::DecorationEffect( QWidget * parent, const char * name ) : EditWidget( parent, name ) { _group = 0; connect( _pbAdd, SIGNAL( clicked() ), SLOT( slot_add() ) ); connect( _pbEdit, SIGNAL( clicked() ), SLOT( slot_edit() ) ); connect( _pbDel, SIGNAL( clicked() ), SLOT( slot_del() ) ); } void DecorationEffect::init( DecorationGroup * group ) { _group = group; _listBox->clear(); if( _group ) { uint nb = _group->getEffectNumber(); for( uint i = 0; i < nb; ++i ) { DecorationGroup::EffectType type = _group->getEffectType( i ); uint param = _group->getEffectParam( i ); _listBox->addItem( new EffectItem( type, param ) ); } } } void DecorationEffect::slot_add() { DialogEffect dialog; if( dialog.exec() ) { DecorationGroup::EffectType type = dialog.getType(); uint param = dialog.getParam(); _listBox->addItem( new EffectItem( type, param ) ); } } void DecorationEffect::slot_edit() { int item = _listBox->currentRow(); if( item != -1 ) { DialogEffect dialog; dialog.setType( ( (EffectItem*)(_listBox->item( item ) ) )->getType() ); dialog.setParam( ( (EffectItem*)(_listBox->item( item ) ) )->getParam() ); if( dialog.exec() ) { DecorationGroup::EffectType type = dialog.getType(); uint param = dialog.getParam(); EffectItem * effect = (EffectItem*) _listBox->item( item ); effect->setType( type ); effect->setParam( param ); } } } void DecorationEffect::slot_del() { int item = _listBox->currentRow(); if( item != -1 ) { delete _listBox->takeItem( item ); } } void DecorationEffect::save() { _group->clearEffects(); uint nb = _listBox->count(); for( uint i = 0; i < nb; ++i ) { EffectItem * effect = (EffectItem*) _listBox->item( i ); if( effect->getType() != DecorationGroup::NONE ) { _group->addEffect( effect->getType(), effect->getParam() ); } } } // // ----- EffectItem ----- // EffectItem::EffectItem( DecorationGroup::EffectType type, uint param ) : QListWidgetItem() { _param = param; _type = type; computeLabel(); } void EffectItem::computeLabel() { QString text = QObject::tr( "Effect '" ); text += DecorationGroup::getEffectTypeString( _type ); text += QObject::tr( "' with param " ); text += QString::number( _param ); setText( text ); } // // ----- DialogEffect ----- // DialogEffect::DialogEffect( QWidget * parent, const char * name ) : QDialog( parent, Qt::Dialog ) { setWindowTitle(QString (name)); QLabel * labType = new QLabel( tr( "Effect type: " ), this ); FIXEDSIZE( labType ); _combo = new QComboBox( this ); _combo->addItem( DecorationGroup::getEffectTypeString( DecorationGroup::NONE ) ); _combo->addItem( DecorationGroup::getEffectTypeString( DecorationGroup::NO_MOVE ) ); _combo->addItem( DecorationGroup::getEffectTypeString( DecorationGroup::DECREASE_MOVECOST ) ); _combo->addItem( DecorationGroup::getEffectTypeString( DecorationGroup::INCREASE_MOVECOST ) ); _combo->addItem( DecorationGroup::getEffectTypeString( DecorationGroup::NO_TECHNICAL ) ); _combo->addItem( DecorationGroup::getEffectTypeString( DecorationGroup::MAX_TECHNICAL ) ); _combo->addItem( DecorationGroup::getEffectTypeString( DecorationGroup::NO_BLOCK_DECO ) ); FIXEDSIZE( _combo ); QLabel * labParam = new QLabel( tr( "Effect value: " ), this ); FIXEDSIZE( labParam ); _spin = new QSpinBox( this ); _spin->setMinimum( 0 ); QGridLayout * grid = new QGridLayout(); grid->addWidget( labType, 1, 0 ); grid->addWidget( labParam, 2, 0 ); grid->addWidget( _combo, 1, 1 ); grid->addWidget( _spin, 2, 1 ); grid->addItem(new QSpacerItem(5, 0), 0, 0); grid->addItem(new QSpacerItem(5, 0), 0, 3); QPushButton * pbOk = new QPushButton( this ); pbOk->setText( tr( "Ok" ) ); FIXEDSIZE( pbOk ); QPushButton * pbCan = new QPushButton( this ); pbCan->setText( tr( "Cancel" ) ); FIXEDSIZE( pbCan ); QHBoxLayout * layH1 = new QHBoxLayout(); layH1->addStretch( 1 ); layH1->addWidget( pbOk ); layH1->addStretch( 1 ); layH1->addWidget( pbCan ); layH1->addStretch( 1 ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setSpacing( 5 ); layout->setMargin( 5 ); layout->addLayout( grid, 1 ); layout->addLayout( layH1 ); layout->activate(); connect( pbOk, SIGNAL( clicked() ), SLOT( accept() ) ); connect( pbCan, SIGNAL( clicked() ), SLOT( reject() ) ); FIXEDSIZE( this ); } void DialogEffect::updateDialog() { _spin->setValue( _param ); _combo->setCurrentIndex( (int)_type ); } void DialogEffect::accept() { _param = _spin->value(); _type = (DecorationGroup::EffectType) _combo->currentIndex(); QDialog::accept(); } attal-src-1.0-rc2/themeEditor/decorationEffect.h0000644000175000017500000000552410510545314017346 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** decorationEffect.h ** Widget for editing effects of decoration ** ** Version : $Id: decorationEffect.h,v 1.5 2006/10/03 20:40:44 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 15/08/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef DECORATIONEFFECT_H #define DECORATIONEFFECT_H // generic include files // include files for QT #include #include // application specific include files #include "libCommon/genericDecoration.h" #include "themeEditor/editWidget.h" class QSpinBox; class QComboBox; /* ------------------------------ * DecorationEffect * ------------------------------ */ class DecorationEffect : public EditWidget { Q_OBJECT public: DecorationEffect( QWidget * parent = 0, const char * name = 0 ); void init( DecorationGroup * group ); void save(); public slots: void slot_add(); void slot_edit(); void slot_del(); protected: DecorationGroup * _group; }; /* ------------------------------ * EffectItem * ------------------------------ */ class EffectItem : public QListWidgetItem { public: EffectItem( DecorationGroup::EffectType type, uint param ); DecorationGroup::EffectType getType() { return _type; } void setType( DecorationGroup::EffectType type ) { _type = type; computeLabel(); } uint getParam() { return _param; } void setParam( uint param ) { _param = param; computeLabel(); } void computeLabel(); protected: uint _param; DecorationGroup::EffectType _type; }; /* ------------------------------ * DialogEffect * ------------------------------ */ class DialogEffect : public QDialog { Q_OBJECT public: DialogEffect( QWidget * parent = 0, const char * name = 0 ); DecorationGroup::EffectType getType() { return _type; } void setType( DecorationGroup::EffectType type ) { _type = type; updateDialog(); } uint getParam() { return _param; } void setParam( uint param ) { _param = param; updateDialog(); } void updateDialog(); public slots: void accept(); protected: uint _param; DecorationGroup::EffectType _type; QComboBox * _combo; QSpinBox * _spin; }; #endif // DECORATIONEFFECT_H attal-src-1.0-rc2/themeEditor/editWidget.cpp0000644000175000017500000000337010511275026016524 0ustar aaaa/***************************************************************** ** ** Attal : Lords of Doom ** ** editWidget.cpp ** Widget for editing ** ** Version : $Id: editWidget.cpp,v 1.2 2006/10/05 21:33:10 lusum Exp $ ** ** Author(s) : Sardi Carlo ** ** Date : 03/09/2006 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "editWidget.h" // generic include files // include files for QT #include #include #include // application specific include files #include "libClient/gui.h" EditWidget::EditWidget( QWidget * parent, const char * name ) : QWidget( parent ) { setWindowTitle( QString ( name )); _listBox = new QListWidget( this ); _pbAdd = new QPushButton( this ); _pbAdd->setText( tr( "Add" ) ); FIXEDSIZE( _pbAdd ); _pbEdit = new QPushButton( this ); _pbEdit->setText( tr("Edit") ); FIXEDSIZE( _pbEdit ); _pbDel = new QPushButton( this ); _pbDel->setText( tr( "Del" ) ); FIXEDSIZE( _pbDel ); QGridLayout * layout = new QGridLayout( this ); layout->setRowStretch( 3, 1 ); layout->setColumnStretch( 0, 1 ); layout->addWidget( _listBox, 0, 0, 3, 0 ); layout->addWidget( _pbAdd, 0, 1 ); layout->addWidget( _pbEdit, 1, 1 ); layout->addWidget( _pbDel, 2, 1 ); layout->activate(); } attal-src-1.0-rc2/themeEditor/editWidget.h0000644000175000017500000000231310510545407016167 0ustar aaaa/***************************************************************** ** ** Attal : Lords of Doom ** ** editWidget.h ** Widget for editing ** ** Version : $Id: editWidget.h,v 1.1 2006/10/03 20:41:43 lusum Exp $ ** ** Author(s) : Sardi Carlo ** ** Date : 03/09/2006 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef EDITWIDGET_H #define EDITWIDGET_H // generic include files // include files for QT #include // application specific include files class QPushButton; class EditWidget : public QWidget { Q_OBJECT public: EditWidget( QWidget * parent = 0, const char * name = 0 ); protected: QListWidget * _listBox; QPushButton * _pbAdd, * _pbEdit, * _pbDel; }; #endif attal-src-1.0-rc2/themeEditor/mapDispositionEditor.cpp0000644000175000017500000002537210777473607020635 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** mapDispositionEditor.cpp ** Edit map disposition ** ** Version : $Id: mapDispositionEditor.cpp,v 1.17 2008/04/10 20:24:39 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 22/07/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "mapDispositionEditor.h" // generic include files // include files for QT #include #include #include #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/genericMapDisposition.h" #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" extern QString IMAGE_PATH; // // ----- MapDispositionEditor ----- // MapDispositionEditor::MapDispositionEditor( QWidget * parent, const char * name ) : QWidget( parent ) { setWindowTitle( QString ( name )); _mapDisposition = NULL; QButtonGroup * group = new QButtonGroup( this ); QGroupBox * box = new QGroupBox( this ); QPushButton * pbFree = new QPushButton(); pbFree->setText( tr( "Free" ) ); pbFree->setCheckable( true ); pbFree->setChecked( true ); FIXEDSIZE( pbFree ); QPushButton * pbOccupied = new QPushButton(); pbOccupied->setText( tr( "Occupied" ) ); pbOccupied->setCheckable( true ); FIXEDSIZE( pbOccupied ); QPushButton * pbDoor = new QPushButton(); pbDoor->setText( tr( "Door" ) ); pbDoor->setCheckable( true ); FIXEDSIZE( pbDoor ); group->setExclusive( true ); group->addButton( pbFree, 0 ); group->addButton( pbOccupied, 1 ); group->addButton( pbDoor, 2 ); QVBoxLayout * layV1 = new QVBoxLayout(); layV1->setMargin( 5 ); layV1->addStretch( 1 ); layV1->addWidget( pbFree ); layV1->addStretch( 1 ); layV1->addWidget( pbOccupied ); layV1->addStretch( 1 ); layV1->addWidget( pbDoor ); layV1->addStretch( 1 ); layV1->activate(); box->setLayout( layV1 ); QLabel * labCol = new QLabel( this ); labCol->setText( tr( "Columns:" ) ); FIXEDSIZE( labCol ); QLabel * labRow = new QLabel( this ); labRow->setText( tr( "Rows:" ) ); FIXEDSIZE( labRow ); QVBoxLayout * layV2 = new QVBoxLayout(); layV2->setMargin( 5 ); layV2->addStretch( 1 ); layV2->addWidget( labCol ); layV2->addStretch( 1 ); layV2->addWidget( labRow ); layV2->addStretch( 1 ); _spinCol = new QSpinBox( this ); _spinCol->setMinimum( 1 ); _spinCol->setValue( 5 ); FIXEDSIZE( _spinCol ); _spinRow = new QSpinBox( this ); _spinRow->setMinimum( 1 ); _spinRow->setValue( 5 ); FIXEDSIZE( _spinRow ); QVBoxLayout * layV3 = new QVBoxLayout(); layV3->setMargin( 5 ); layV3->addStretch( 1 ); layV3->addWidget( _spinCol ); layV3->addStretch( 1 ); layV3->addWidget( _spinRow ); layV3->addStretch( 1 ); _dispositionCanvas = new MapDispositionCanvas( this ); _dispositionCanvasView = new MapDispositionCanvasView( _dispositionCanvas, this ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( box ); layout->addStretch( 1 ); layout->addWidget( _dispositionCanvasView ); layout->addLayout( layV2 ); layout->addLayout( layV3 ); layout->addStretch( 1 ); layout->activate(); connect( group, SIGNAL( buttonClicked( int ) ), SLOT( slot_clicked( int ) ) ); connect( _spinCol, SIGNAL( valueChanged( int ) ), SLOT( slot_resize_col( int ) ) ); connect( _spinRow, SIGNAL( valueChanged( int ) ), SLOT( slot_resize_row( int ) ) ); } void MapDispositionEditor::slot_clicked( int id ) { _dispositionCanvas->setCurrentType( ( GenericMapDisposition::DispositionType )id ); } void MapDispositionEditor::slot_resize_row(int value) { dispoResize( true, value ); } void MapDispositionEditor::slot_resize_col(int value) { dispoResize( false, value ); } void MapDispositionEditor::dispoResize( bool isrow , int value ) { int row, col; if( isrow ) { row = value; col = _mapDisposition->getWidth(); } else { col = value; row = _mapDisposition->getHeight(); } _dispositionCanvas->clear(); _mapDisposition->resize( row, col ); _dispositionCanvas->init( _mapDisposition, _pixmapPath ); _dispositionCanvas->setSceneRect(0,0, _mapDisposition->getWidth() * DataTheme.tiles.getWidth() , _mapDisposition->getHeight() * DataTheme.tiles.getHeight() ); _dispositionCanvasView->setMinimumSize( _mapDisposition->getWidth() * DataTheme.tiles.getWidth() , _mapDisposition->getHeight() * DataTheme.tiles.getHeight() ); //_dispositionCanvas->reinit(); update(); } void MapDispositionEditor::init( GenericMapDisposition * mapDisposition, const QString & pixmapPath ) { int width, height; _mapDisposition = mapDisposition; _pixmapPath = pixmapPath; _dispositionCanvas->init( mapDisposition, pixmapPath ); if( mapDisposition ) { _dispositionCanvas->setSceneRect( 0,0, mapDisposition->getWidth() * DataTheme.tiles.getWidth(), mapDisposition->getHeight() * DataTheme.tiles.getHeight() ); width = mapDisposition->getWidth(); height = mapDisposition->getHeight(); /* we need to use width and height on this point cause using directly mapDisposition->getWidth() * and mapDisposition->getHeigth() is not possible because _spinCol and _spinRow * call (by a signal) a function that change the value of mapDisposition * in this case _spinCol change the value of mapDisposition->getHeigth() before _spinRow */ _spinCol->setValue( width ); _spinRow->setValue( height ); _dispositionCanvasView->resize( mapDisposition->getWidth() * DataTheme.tiles.getWidth() + 10, mapDisposition->getHeight() * DataTheme.tiles.getHeight() + 10 ); setMinimumHeight( height * DataTheme.tiles.getHeight() + 10 ); _dispositionCanvas->reinit(); } update(); } void MapDispositionEditor::clear() { logEE( "Not yet implemented." ); } // // ----- MapDispositionCanvas ----- // MapDispositionCanvas::MapDispositionCanvas( QObject * parent, const char * /* name */ ) : QGraphicsScene( parent ) { setSceneRect(0,0, 150, 150 ); setBackgroundBrush(QBrush(Qt::white) ); //_listPixmaps.setAutoDelete( true ); _listPixmaps.append( QPixmap( *ImageTheme.getWidgetPixmap( EDIT_FREE ) ) ); _listPixmaps.append( QPixmap( *ImageTheme.getWidgetPixmap( EDIT_OCC ) ) ); _listPixmaps.append( QPixmap( *ImageTheme.getWidgetPixmap( EDIT_DOOR ) ) ); _pixmaps = new QList( _listPixmaps ); _dispositionSprites = 0; _disposition = 0; _background = 0; _currentType = GenericMapDisposition::FREE; } MapDispositionCanvas::~MapDispositionCanvas() { clear(); if( _pixmaps ) { delete _pixmaps; } /* while( ! _listPixmaps.isEmpty() ) { delete _listPixmaps.takeFirst(); } }*/ } void MapDispositionCanvas::clear() { uint i, j; if( _background ) { delete _background; _background = 0; } if( _disposition && _dispositionSprites ) { for( i = 0; i < _height; i++ ) { for( j = 0; j < _width; j++ ) { delete _dispositionSprites[ i ][ j ]; _dispositionSprites[ i ][ j ] = 0; } delete [] _dispositionSprites[ i ]; } delete [] _dispositionSprites; _dispositionSprites = 0; } update(); } void MapDispositionCanvas::init( GenericMapDisposition * mapDisposition, const QString & pixmapPath ) { uint i, j; clear(); _disposition = mapDisposition; _height = _disposition->getHeight(); _width = _disposition->getWidth(); _background = new DispositionSprite( this ); _background->setBackground( pixmapPath ); _background->setPos( 0, _height * DataTheme.tiles.getHeight() - _background->boundingRect().height() ); _dispositionSprites = new DispositionSprite ** [ _height ]; for( i = 0; i < _height; i++ ) { _dispositionSprites[ i ] = new DispositionSprite * [ _width ]; for( j = 0; j < _width; j++ ) { _dispositionSprites[ i ][ j ] = new DispositionSprite( this ); _dispositionSprites[ i ][ j ]->setPos( j * DataTheme.tiles.getWidth(), i * DataTheme.tiles.getHeight() ); _dispositionSprites[ i ][ j ]->setSpriteType( _disposition->getDisposition( i, j ) ); } } update(); } void MapDispositionCanvas::reinit() { for( uint i = 0; i < _height; i++ ) { for( uint j = 0; j < _width; j++ ) { _dispositionSprites[ i ][ j ]->setSpriteType( _disposition->getDisposition( i, j ) ); } } update(); } void MapDispositionCanvas::changeCell( uint row, uint col ) { _disposition->setDisposition( row, col, _currentType ); _dispositionSprites[ row ][ col ]->setSpriteType( _currentType ); reinit(); } // // ----- MapDispositionCanvasView ----- // MapDispositionCanvasView::MapDispositionCanvasView( MapDispositionCanvas * canvas , QWidget * parent, const char * /*name */, Qt::WFlags/* f*/ ) : QGraphicsView( (QGraphicsScene*)canvas, parent ) { setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff ); viewport()->setMouseTracking( true ); _canvas = canvas; } void MapDispositionCanvasView::mouseReleaseEvent( QMouseEvent * e ) { /* view coordinate could be different from scene coordinate */ QPointF pos = mapToScene( e->pos()); if (scene()->sceneRect().contains( pos )) { if( e->button() == Qt::LeftButton ) { uint col = (uint)pos.x() / DataTheme.tiles.getWidth(); uint row = (uint)pos.y() / DataTheme.tiles.getHeight(); _canvas->changeCell( row, col ); } } } // // ----- DispositionSprite ----- // const int DispositionSprite::RTTI = Type; DispositionSprite::DispositionSprite( MapDispositionCanvas * canvas ) : AttalSprite( canvas->getPixmaps(), (QGraphicsScene *)canvas ) { _tryi = NULL; setEnabled( true ); setFrame( 0 ); setZValue( 10 ); } DispositionSprite::~DispositionSprite() { clearData(); } void DispositionSprite::clearData() { _listPixmap.clear(); delete _tryi; /* while( ! _listPixmap.isEmpty() ) { delete _listPixmap.takeFirst(); } } */ } void DispositionSprite::setSpriteType( GenericMapDisposition::DispositionType type ) { setFrame( (uint)type ); } void DispositionSprite::setBackground( const QString & pixmapPath ) { clearData(); setZValue( 5 ); _listPixmap.append( QPixmap( pixmapPath ) ); if( _tryi ) { delete _tryi; } _tryi = new QList( _listPixmap ); //todo only in this case setSequence( _tryi ); setFrame(0); } int DispositionSprite::type() const { // Enable the use of qgraphicsitem_cast with this item. return Type; } attal-src-1.0-rc2/themeEditor/mapDispositionEditor.h0000644000175000017500000001020510622155635020252 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** mapDispositionEditor.h ** Edit map disposition ** ** Version : $Id: mapDispositionEditor.h,v 1.11 2007/05/14 21:58:53 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 22/07/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef MAPDISPOSITIONEDITOR_H #define MAPDISPOSITIONEDITOR_H // generic include files // include files for QT #include #include #include #include #include #include #include #include // application specific include files #include "libCommon/genericMapDisposition.h" #include "libClient/attalSprite.h" class QSpinBox; class DispositionSprite; class MapDispositionCanvas; class MapDispositionCanvasView; /* ------------------------------ * MapDispositionEditor * ------------------------------ */ class MapDispositionEditor : public QWidget { Q_OBJECT public: /** Constructor */ MapDispositionEditor( QWidget * parent = 0, const char * name = 0 ); void init( GenericMapDisposition * mapDisposition, const QString & pixmapPath ); void clear(); public slots: void slot_clicked( int id ); void slot_resize_row( int value); void slot_resize_col( int value); private: void dispoResize( bool isrow , int value ); protected: GenericMapDisposition * _mapDisposition; QString _pixmapPath; MapDispositionCanvas * _dispositionCanvas; MapDispositionCanvasView * _dispositionCanvasView; QSpinBox * _spinCol, * _spinRow; }; /* ------------------------------ * MapDispositionCanvas * ------------------------------ */ class MapDispositionCanvas : public QGraphicsScene { public: /** Constructor */ MapDispositionCanvas( QObject * parent = 0, const char * name = 0 ); virtual ~MapDispositionCanvas(); void changeCell( uint row, uint col ); void init( GenericMapDisposition * mapDisposition, const QString & pixmapPath ); void reinit(); QList * getPixmaps() { return _pixmaps; } void setCurrentType( GenericMapDisposition::DispositionType type ) { _currentType = type; } void clear(); protected: DispositionSprite * _background; QList _listPixmaps; QList * _pixmaps; GenericMapDisposition * _disposition; GenericMapDisposition::DispositionType _currentType; DispositionSprite *** _dispositionSprites; uint _height, _width; }; /* ------------------------------ * MapDispositionCanvasView * ------------------------------ */ class MapDispositionCanvasView : public QGraphicsView { public: /** Constructor */ MapDispositionCanvasView( MapDispositionCanvas * canvas , QWidget * parent = 0, const char * name = 0, Qt::WFlags f = 0 ); protected: void mouseReleaseEvent( QMouseEvent * e ); MapDispositionCanvas * _canvas; }; /* ------------------------------ * DispositionSprite * ------------------------------ */ class DispositionSprite : public AttalSprite { public: /** Constructor */ DispositionSprite( MapDispositionCanvas * ); /** Destructor */ virtual ~DispositionSprite(); enum { Type = QGraphicsItem::UserType + 61 }; void setSpriteType( GenericMapDisposition::DispositionType type ); void setBackground( const QString & pixmapPath ); static const int RTTI; int type() const; void setType( const int type ); protected: void clearData(); GenericMapDisposition::DispositionType _type; QList _listPixmap; QList * _tryi; }; #endif // MAPDISPOSITIONEDITOR_H attal-src-1.0-rc2/themeEditor/previewBaseDialog.cpp0000644000175000017500000000616110751372503020034 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** previewBaseDialog.cpp ** dialog for preview of a base with buildings ** ** Version : $Id: previewBaseDialog.cpp,v 1.10 2008/02/03 17:09:23 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 28/06/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "previewBaseDialog.h" // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/genericBase.h" #include "libCommon/genericInsideBuilding.h" #include "libClient/gui.h" #include "libClient/insideBase.h" PreviewBaseDialog::PreviewBaseDialog( QWidget * parent, const char * name ) : QDialog( parent, Qt::Dialog ) { setWindowTitle( QString ( name ) ); _base = 0; _inside = new InsideBase( this ); InsideBaseView * view = new InsideBaseView( _inside, this ); _listBuilding = new QTreeWidget( this ); _listBuilding->setColumnCount( 1 ); QStringList labels; labels << tr( "Buildings" ); _listBuilding->setHeaderLabels( labels ); QHBoxLayout * layout = new QHBoxLayout( this ); layout->addWidget( view, 1 ); layout->addWidget( _listBuilding ); layout->activate(); connect( _listBuilding, SIGNAL( itemClicked( QTreeWidgetItem *, int ) ), SLOT( slot_clickBuilding( QTreeWidgetItem * , int) ) ); } PreviewBaseDialog::~PreviewBaseDialog() { delete _base; } void PreviewBaseDialog::init( GenericBaseModel * model ) { delete _base; QTreeWidgetItem * item; _base = new GenericBase( model->getRace() ); _inside->setBase( _base ); _listBuilding->clear(); for( int i = 0 ; i <= (int)DataTheme.bases.at( _base->getRace() )->getBuildingCount() - 1; i++ ) { InsideBuildingModel * building = DataTheme.bases.at( _base->getRace() )->getBuildingModel( i ); item = new QTreeWidgetItem( _listBuilding, QStringList(building->getName()) ); item->setCheckState(0, Qt::Unchecked ); } FIXEDSIZE( _listBuilding ); } void PreviewBaseDialog::slot_clickBuilding( QTreeWidgetItem * check, int /*column*/ ) { QTreeWidgetItem * item; int i = 0; while( i < _listBuilding->topLevelItemCount() ) { item = _listBuilding->topLevelItem( i ); if( item == check ) { break; } i++; } if( check->checkState(0) == Qt::Checked ) { _base->addBuilding( i ); GenericInsideBuilding * build = _base->getBuildingByType( i ); _inside->addBuilding( build ); } else { GenericInsideBuilding * build = _base->getBuildingByType( i ); _inside->delBuilding( build ); _base->removeBuildingType( i ); } _inside->update(); } attal-src-1.0-rc2/themeEditor/previewBaseDialog.h0000644000175000017500000000326010511270000017455 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** previewBaseDialog.h ** dialog for preview of a base with buildings ** ** Version : $Id: previewBaseDialog.h,v 1.5 2006/10/05 20:50:08 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 28/06/2003 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef PREVIEWBASEDIALOG_H #define PREVIEWBASEDIALOG_H // generic include files // include files for QT #include // application specific include files class QTreeWidget; class QTreeWidgetItem; class GenericBase; class GenericBaseModel; class InsideBase; /* ------------------------------ * PreviewBaseDialog * ------------------------------ */ class PreviewBaseDialog : public QDialog { Q_OBJECT public: /** Constructor */ PreviewBaseDialog( QWidget * parent = 0, const char * name = 0 ); ~PreviewBaseDialog(); void init( GenericBaseModel * model ); public slots: void slot_clickBuilding( QTreeWidgetItem * , int column ); protected: InsideBase * _inside; GenericBase * _base; QTreeWidget * _listBuilding; }; #endif // PREVIEWBASEDIALOG_H attal-src-1.0-rc2/themeEditor/sectionArtefact.cpp0000644000175000017500000000745610522705153017563 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionArtefact.cpp ** section for specifying artefacts ** ** Version : $Id: sectionArtefact.cpp,v 1.7 2006/11/03 18:28:59 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 20/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionArtefact.h" // generic include files #include // include files for QT #include #include // application specific include files #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libCommon/artefact.h" #include "libClient/imageTheme.h" #include "libClient/graphicalArtefact.h" #include "themeEditor/artefactAction.h" extern QString IMAGE_PATH; SectionArtefact::SectionArtefact( QWidget * parent , const char * name ) : GenericSection( parent, name ) { _num = 0; setTitle( tr( "Artefact" ) ); _name = new AskString( tr( "Name: " ), _mainWidget ); _position = new AskInt( tr( "Position: " ), _mainWidget ); _position->setMinValue( 0 ); _position->setMaxValue( 10 ); _icon = new AskPixmap( true, "", tr( "Icon: " ), _mainWidget ); _item = new AskPixmap( true, "", tr( "Item: " ), _mainWidget ); _actions = new ArtefactAction( _mainWidget ); QVBoxLayout * layout = new QVBoxLayout( _mainWidget ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _name ); layout->addWidget( _position ); layout->addWidget( _icon ); layout->addWidget( _item ); layout->addWidget( _actions ); layout->addStretch( 1 ); layout->activate(); init(); } void SectionArtefact::clear() { _name->setValue( "" ); _position->setValue( 0 ); } void SectionArtefact::init() { if( (int)DataTheme.artefacts.count() > _num ) { GenericArtefactModel * artefact = DataTheme.artefacts.at( _num ); _name->setValue( artefact->getName() ); _position->setValue( artefact->getPosition() ); QString dest; dest = IMAGE_PATH + QString( "artefacts/artefactIcon_" ) + QString::number( _num ) + QString( ".png" ); _icon->setDestination( dest ); dest = IMAGE_PATH + QString( "artefacts/artefactItem_" ) + QString::number( _num ) + QString( ".png" ); _item->setDestination( dest ); _actions->init( artefact ); } } void SectionArtefact::save() { if( (int)DataTheme.artefacts.count() > _num ) { GenericArtefactModel * artefact = DataTheme.artefacts.at( _num ); artefact->setName( _name->getValue() ); artefact->setPosition( _position->getValue() ); _icon->save(); _item->save(); _actions->save(); } } void SectionArtefact::selectFirst() { save(); _num = 0; init(); } void SectionArtefact::selectPrevious() { save(); _num = std::max( 0, _num - 1 ); init(); } void SectionArtefact::selectNext() { save(); _num = std::min( int(DataTheme.artefacts.count() - 1), _num + 1 ); init(); } void SectionArtefact::selectLast() { save(); _num = DataTheme.artefacts.count() - 1; init(); } void SectionArtefact::selectNew() { save(); GenericArtefactModel * artefact = new GenericArtefactModel(); _num = DataTheme.artefacts.count(); DataTheme.artefacts.append( artefact ); clear(); } void SectionArtefact::selectDel() { if( DataTheme.artefacts.count() > 0 ) { delete DataTheme.artefacts.takeAt( _num ); _num = std::min( _num, int(DataTheme.artefacts.count() - 1) ); init(); } } attal-src-1.0-rc2/themeEditor/sectionArtefact.h0000644000175000017500000000371310022705034017211 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionArtefact.h ** section for specifying artefacts ** ** Version : $Id: sectionArtefact.h,v 1.2 2004/03/07 20:46:20 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 20/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONARTEFACT_H #define SECTIONARTEFACT_H // generic include files // include files for QT // application specific include files #include "sectionWidget.h" class ArtefactAction; /* ------------------------------ * SectionArtefact * ------------------------------ */ /** comment for the class */ class SectionArtefact : public GenericSection { Q_OBJECT public: /** Constructor */ SectionArtefact( QWidget * parent = 0, const char * name = 0 ); /** Selects the first item */ void selectFirst(); /** Selects the previous item */ void selectPrevious(); /** Selects the nextt item */ void selectNext(); /** Selects the last item */ void selectLast(); /** Creates a new item */ void selectNew(); /** Deletes the current item */ void selectDel(); /** Clears the section */ void clear(); /** Inits the section */ void init(); /** Saves the section */ void save(); private: AskString * _name; AskInt * _position; AskPixmap * _icon, * _item; ArtefactAction * _actions; int _num; }; #endif // SECTIONARTEFACT_H attal-src-1.0-rc2/themeEditor/sectionBase.cpp0000644000175000017500000002730211015372700016670 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionBase.cpp ** section specifying bases ** ** Version : $Id: sectionBase.cpp,v 1.31 2008/05/22 22:37:52 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionBase.h" // generic include files #include // include files for QT #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/log.h" #include "libCommon/priceMarket.h" #include "libClient/gui.h" #include "themeEditor/mapDispositionEditor.h" #include "themeEditor/previewBaseDialog.h" extern QString IMAGE_PATH; SectionBase::SectionBase( QWidget * parent, const char * name ) : GenericSection( parent, name ) { setTitle( tr( " Base " ) ); _idBase = 0; _name = new AskString( tr( "Name: " ), _mainWidget ); /*_population = new AskInt( tr( "Population: " ), _mainWidget ); _population->setMaxValue(90000); _growth = new AskInt( tr( "Growth: " ), _mainWidget ); _growth->setMaxValue(100); _loss = new AskInt( tr( "Loss: " ), _mainWidget ); _loss->setMaxValue(100); */ _resBase = new AskCost( tr( "Res Base: " ), _mainWidget ); _resCost = new AskCost( tr( "Res Cost: " ), _mainWidget ); _inside = new SectionInsideBuilding( _mainWidget ); _dispo = new MapDispositionEditor( _mainWidget ); QPushButton * preview = new QPushButton( _mainWidget ); preview->setText( tr( "Preview inside" ) ); FIXEDSIZE( preview ); _buildingAction = new BuildingAction( _mainWidget ); QVBoxLayout * layout = new QVBoxLayout( _mainWidget ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _name ); //layout->addWidget( _population ); //layout->addWidget( _growth ); //layout->addWidget( _loss ); layout->addWidget( _resBase ); layout->addWidget( _resCost ); layout->addWidget( _dispo ); layout->addWidget( preview ); layout->addWidget( _buildingAction ); layout->addWidget( _inside, 1 ); layout->activate(); updateData(); init(); connect( preview, SIGNAL( clicked() ), SLOT( slot_preview() ) ); } void SectionBase::slot_preview() { save(); PreviewBaseDialog preview; preview.init( DataTheme.bases.at( _idBase ) ); preview.exec(); } void SectionBase::updateData() { } void SectionBase::init() { if( _idBase < DataTheme.bases.count() ) { QString text; text.sprintf( QString (tr( " Base : %1/%2" ).arg( _idBase + 1 ).arg(DataTheme.bases.count())).toLatin1().constData() ); setTitle( text ); uint nbRes = DataTheme.resources.count(); GenericBaseModel * base = DataTheme.bases.at( _idBase ); _name->setValue( base->getModelName() ); /*_population->setEnabled( true ); if( base->getPopulation()){ _population->setValue( base->getPopulation() ); } else { _population->setValue( 0 ); } _growth->setEnabled( true ); if( base->getPopulationGrowth() ) { _growth->setValue( base->getPopulationGrowth() ); } else { _growth->setValue( 0 ); } _loss->setEnabled( true ); if( base->getPopulationLoss() ) { _loss->setValue( base->getPopulationLoss() ); } else { _loss->setValue( 0 ); } */ for( uint i = 0; i < nbRes; i++ ) { if( base->getPriceMarket() ) { _resCost->setValue( i ,base->getPriceMarket()->getResourcePrice( i ) ); } _resBase->setValue( i ,base->getResourceList()->getValue( i ) ); } QString dest = IMAGE_PATH + "base/race_" + QString::number( _idBase ) + "/base.png"; _dispo->init( base, dest ); _buildingAction->init( base->getActionList() ); _inside->setBase( _idBase ); _inside->init(); } else { clear(); } } void SectionBase::clear() { _idBase = 0; _name->setValue( "" ); /*_population->setValue( 0 ); _growth->setValue( 0 ); _loss->setValue( 0 ); */ _inside->setBase( 0 ); _inside->clear(); } void SectionBase::selectFirst() { save(); if( _idBase > 0 ) { _idBase = 0; init(); } } void SectionBase::selectPrevious() { save(); if( _idBase > 0 ) { _idBase--; } init(); } void SectionBase::selectNext() { save(); if( _idBase < DataTheme.bases.count() - 1 ) { _idBase++; } init(); } void SectionBase::selectLast() { save(); _idBase = DataTheme.bases.count() - 1; init(); } void SectionBase::selectNew() { save(); _idBase = DataTheme.bases.count(); GenericBaseModel * base = new GenericBaseModel(); DataTheme.bases.append( base ); init(); } void SectionBase::selectDel() { clear(); delete DataTheme.bases.takeAt( _idBase ); _idBase = std::min( _idBase, DataTheme.bases.count() - 1 ); init(); } void SectionBase::save() { if( _idBase < DataTheme.bases.count() ) { int nbRes = DataTheme.resources.count(); GenericBaseModel * base = DataTheme.bases.at( _idBase ); base->setModelName( _name->getValue() ); /* base->setPopulation( _population->getValue() ); base->setPopulationGrowth( _growth->getValue() ); base->setPopulationLoss( _loss->getValue() ); */ base->clearActions(); QList alist; alist = _buildingAction->save(); Action * action; if( alist.count() ) { for( int i = 0; i < alist.count(); i++ ) { action = alist.at( i ); if( action ) { base->addAction( action ); } } } _inside->save(); for( int i = 0; i < nbRes; i++ ) { base->getPriceMarket()->setResourcePrice( i, _resCost->getValue( i ) ); base->getResourceList()->setValue( i, _resBase->getValue( i ) ); } } } // // ----- SectionInsideBuilding ----- // SectionInsideBuilding::SectionInsideBuilding( QWidget * parent, const char * /* name */ ) : QWidget( parent ) { _idBase = 0; _idBuild = 0; _select = new SelectionWidget( this ); _select->setTitle( tr( " Building " ) ); _name = new AskString( tr( "Name: " ), this ); _description = new AskString( tr( "Description: " ), this ); _x = new AskInt( "x: ", this ); _x->setMaxValue( 1000 ); _y = new AskInt( "y: ", this ); _y->setMaxValue( 1000 ); _cost = new AskCost( tr( "Cost: " ), this ); _maintCost = new AskCost( tr( "Maintenance cost: " ), this ); _comboInAct = new QComboBox( this ); _comboInAct->addItem( tr( "Not yet used" ) ); _comboInAct->addItem( tr( "Main Building" ) ); _comboInAct->addItem( tr( "Castle" ) ); _comboInAct->addItem( tr( "Prod Creature" ) ); _comboInAct->addItem( tr( "Market" ) ); _comboInAct->addItem( tr( "Tavern" ) ); FIXEDSIZE( _comboInAct ); _params = new AskIntList( this ); _params->setLabel( tr( "Params: " ) ); _requirements = new AskIntList( this ); _requirements->setLabel( tr( "Requirements" ) ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _select ); layout->addWidget( _name ); layout->addWidget( _description ); layout->addWidget( _x ); layout->addWidget( _y ); layout->addWidget( _cost ); layout->addWidget( _maintCost ); layout->addWidget( _comboInAct ); layout->addWidget( _params ); layout->addWidget( _requirements ); layout->addStretch( 1 ); layout->activate(); connect( _select, SIGNAL( sig_first() ), SLOT( selectFirst() ) ); connect( _select, SIGNAL( sig_previous() ), SLOT( selectPrevious() ) ); connect( _select, SIGNAL( sig_next() ), SLOT( selectNext() ) ); connect( _select, SIGNAL( sig_last() ), SLOT( selectLast() ) ); connect( _select, SIGNAL( sig_new() ), SLOT( selectNew() ) ); connect( _select, SIGNAL( sig_del() ), SLOT( selectDel() ) ); init(); } void SectionInsideBuilding::setBase( uint base ) { if( (int)base != _idBase ) { save(); clear(); _idBase = base; _idBuild = 0; init(); } } void SectionInsideBuilding::selectFirst() { save(); if( _idBuild > 0 ) { _idBuild = 0; init(); } } void SectionInsideBuilding::selectPrevious() { save(); if( _idBuild > 0 ) { _idBuild--; } init(); } void SectionInsideBuilding::selectNext() { save(); if( ( _idBase < DataTheme.bases.count() ) && ( _idBuild < (int)DataTheme.bases.at( _idBase )->getBuildingCount() - 1 ) ) { _idBuild++; } init(); } void SectionInsideBuilding::selectLast() { save(); if( _idBase < DataTheme.bases.count() ) { _idBuild = DataTheme.bases.at( _idBase )->getBuildingCount() - 1; } init(); } void SectionInsideBuilding::selectNew() { save(); if( _idBase < DataTheme.bases.count() ) { _idBuild = DataTheme.bases.at( _idBase )->getBuildingCount(); InsideBuildingModel * build = new InsideBuildingModel(); DataTheme.bases.at( _idBase )->addBuilding( build ); /// XXX: setRace/setLevel } init(); } void SectionInsideBuilding::selectDel() { clear(); if( _idBase < DataTheme.bases.count() ) { DataTheme.bases.at( _idBase )->removeBuilding( _idBuild ); _idBuild = std::min( _idBase, (int)DataTheme.bases.at( _idBase )->getBuildingCount() - 1 ); } init(); } void SectionInsideBuilding::save() { if( ( _idBase < DataTheme.bases.count() ) && ( _idBuild < (int)DataTheme.bases.at( _idBase )->getBuildingCount() ) ) { InsideBuildingModel * build = DataTheme.bases.at( _idBase )->getBuildingModel( _idBuild ); build->setName( _name->getValue() ); build->setDescription( _description->getValue() ); build->setX( _x->getValue() ); build->setY( _y->getValue() ); uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { build->setCost( i, _cost->getValue( i ) ); build->setMantCost( i, _maintCost->getValue( i ) ); } InsideAction * action = new InsideAction(); action->setType((uint) _comboInAct->currentIndex()); for( uint i = 0; i < _params->count(); i++ ) { action->addParam( _params->getValue(i) ); } build->setAction( action ); build->clearRequirements(); for( uint i = 0; i < _requirements->count(); i++ ) { build->addRequirement( _requirements->getValue( i ) - 1 ); } } } void SectionInsideBuilding::init() { if( ( _idBase < DataTheme.bases.count() ) && ( _idBuild < (int)DataTheme.bases.at( _idBase )->getBuildingCount() ) ) { QString text; text.sprintf( QString (tr( " Building : %1/%2" ).arg(_idBuild + 1).arg(DataTheme.bases.at( _idBase )->getBuildingCount())).toLatin1().constData() ); _select->setTitle( text ); InsideBuildingModel * build = DataTheme.bases.at( _idBase )->getBuildingModel( _idBuild ); _name->setValue( build->getName() ); _description->setValue( build->getDescription() ); _x->setValue( build->getX() ); _y->setValue( build->getY() ); _params->clear(); _requirements->clear(); InsideAction * action = build->getAction(); if( action ){ _comboInAct->setCurrentIndex((uint) action->getType()); for( uint i = 0; i < action->getParamNumber(); i++ ) { _params->addValue( action->getParam(i) ); } } else { _comboInAct->setCurrentIndex( 0 ); } uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { _cost->setValue( i, build->getCost( i ) ); _maintCost->setValue( i, build->getMantCost( i ) ); } for( int i = 0; i < build->getRequirementNumber(); i++ ) { _requirements->addValue( build->getRequirement( i ) + 1 ); } } } void SectionInsideBuilding::clear() { _idBuild = 0; _name->setValue( "" ); _description->setValue( "" ); _x->setValue( 0 ); _y->setValue( 0 ); uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { _cost->setValue( i, 0 ); _maintCost->setValue( i, 0 ); } _comboInAct->setCurrentIndex( 0 ); _params->clear(); _requirements->clear(); } attal-src-1.0-rc2/themeEditor/sectionBase.h0000644000175000017500000000601410740437744016350 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionBase.h ** section specifying bases ** ** Version : $Id: sectionBase.h,v 1.15 2008/01/07 15:06:12 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONBASE_H #define SECTIONBASE_H // generic include files // include files for QT #include #include // application specific include files #include "libClient/askCost.h" #include "themeEditor/sectionWidget.h" #include "themeEditor/buildingAction.h" class QComboBox; class MapDispositionEditor; class SectionInsideBuilding; /* ------------------------------ * SectionBase * ------------------------------ */ /** comment for the class */ class SectionBase : public GenericSection { Q_OBJECT public: /** Constructor */ SectionBase( QWidget * parent = 0, const char * name = 0 ); void updateData(); /** Selects the first item */ void selectFirst(); /** Selects the previous item */ void selectPrevious(); /** Selects the next item */ void selectNext(); /** Selects the last item */ void selectLast(); /** Creates a new item */ void selectNew(); /** Deletes the current item */ void selectDel(); /** Saves the data */ void save(); /** Inits the section */ void init(); void clear(); public slots: void slot_preview(); private: int _idBase; AskString * _name; AskInt * _population, * _growth, * _loss; AskCost * _resCost; AskCost * _resBase; BuildingAction * _buildingAction; MapDispositionEditor * _dispo; SectionInsideBuilding * _inside; }; class SectionInsideBuilding : public QWidget { Q_OBJECT public: SectionInsideBuilding( QWidget * parent = 0, const char * name = 0 ); void setBase( uint base ); /** Saves the data */ void save(); /** Inits the section */ void init(); void clear(); public slots: /** Selects the first item */ void selectFirst(); /** Selects the previous item */ void selectPrevious(); /** Selects the next item */ void selectNext(); /** Selects the last item */ void selectLast(); /** Creates a new item */ void selectNew(); /** Deletes the current item */ void selectDel(); protected: int _idBase, _idBuild; SelectionWidget * _select; AskString * _name, * _description; AskInt * _x, * _y ; AskCost * _maintCost,* _cost; AskIntList * _params; AskIntList * _requirements; QComboBox * _comboInAct; }; #endif // SECTIONBASE_H attal-src-1.0-rc2/themeEditor/sectionBuilding.cpp0000644000175000017500000001167710751372504017573 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionBuilding.cpp ** section specifying buildings ** ** Version : $Id: sectionBuilding.cpp,v 1.12 2008/02/03 17:09:24 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionBuilding.h" // generic include files #include // include files for QT #include #include // application specific include files #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libCommon/genericBuilding.h" #include "libClient/gui.h" #include "themeEditor/mapDispositionEditor.h" extern QString IMAGE_PATH; SectionBuilding::SectionBuilding( QWidget * parent, const char * name ) : GenericSection( parent, name ) { _num = 0; setTitle( tr( "Building" ) ); QVBoxLayout * layout = new QVBoxLayout( _mainWidget ); layout->setMargin( 5 ); layout->setSpacing( 5 ); _name = new AskString( tr( "Name: " ), _mainWidget ); layout->addWidget( _name ); _description = new AskString( tr( "Description: " ), _mainWidget ); layout->addWidget( _description ); _frame = new AskInt( tr( "Number Frames: " ), _mainWidget ); layout->addWidget( _frame ); _animFreq = new AskInt( tr( "Animation Freq.: " ), _mainWidget ); layout->addWidget( _animFreq ); _type = new AskInt( tr( "Type: " ), _mainWidget ); layout->addWidget( _type ); _resBuild = new AskCost( tr( "Res Build: " ), _mainWidget ); layout->addWidget( _resBuild ); _item = new AskPixmap( true, "", tr( "Picture: " ), _mainWidget ); layout->addWidget( _item ); _buildingAction = new BuildingAction( _mainWidget ); layout->addWidget( _buildingAction ); _dispo = new MapDispositionEditor( _mainWidget ); layout->addWidget( _dispo ); layout->addStretch( 1 ); layout->activate(); init(); } void SectionBuilding::init() { if( (int)DataTheme.buildings.count() > _num ) { GenericBuildingModel * building = DataTheme.buildings.at( _num ); _name->setValue( building->getName() ); _description->setValue( building->getDescription() ); _type->setValue( building->getType() ); _frame->setValue(building->getNbFrame()); _animFreq->setValue(building->getAnimFreq()); QString dest; dest = IMAGE_PATH + QString( "building/building_" ) + QString::number( _num ) + QString( "_0" ) + QString( ".png" ); _item->setDestination( dest ); _buildingAction->init( building->getActionList() ); _dispo->init( building, dest ); uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { _resBuild->setValue( i , building->getResourceList()->getValue( i ) ); } } } void SectionBuilding::clear() { _name->setValue( "" ); _description->setValue( "" ); _type->setValue( 0 ); _item->setValue( "" ); _frame->setValue( 1 ); _animFreq->setValue( 1 ); } void SectionBuilding::save() { if( (int)DataTheme.buildings.count() > _num ) { GenericBuildingModel * building = DataTheme.buildings.at( _num ); building->setName( _name->getValue() ); building->setDescription( _description->getValue() ); building->setType( _type->getValue() ); building->setNbFrame( _frame->getValue() ); building->setAnimFreq( _animFreq->getValue() ); _item->save(); building->clearActions(); QList alist; alist = _buildingAction->save(); Action * action; if( alist.count() ) { for( int i = 0; i < alist.count(); i++ ) { action = alist.at( i ); if( action ) { building->addAction( action ); } } } uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { building->getResourceList()->setValue( i, _resBuild->getValue( i ) ); } } } void SectionBuilding::selectFirst() { save(); _num = 0; init(); } void SectionBuilding::selectPrevious() { save(); _num = std::max( 0, _num - 1 ); init(); } void SectionBuilding::selectNext() { save(); _num = std::min( int(DataTheme.buildings.count() - 1), _num + 1 ); init(); } void SectionBuilding::selectLast() { save(); _num = DataTheme.buildings.count() - 1; init(); } void SectionBuilding::selectNew() { save(); GenericBuildingModel * building = new GenericBuildingModel(); _num = DataTheme.buildings.count(); DataTheme.buildings.append( building ); clear(); } void SectionBuilding::selectDel() { if( DataTheme.buildings.count() > 0 ) { delete DataTheme.buildings.takeAt( _num ); _num = std::min( _num, int(DataTheme.buildings.count() - 1) ); init(); } } attal-src-1.0-rc2/themeEditor/sectionBuilding.h0000644000175000017500000000413410751372504017226 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionBuilding.h ** section specifying buildings ** ** Version : $Id: sectionBuilding.h,v 1.7 2008/02/03 17:09:24 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONBUILDING_H #define SECTIONBUILDING_H // generic include files // include files for QT // application specific include files #include "sectionWidget.h" #include "libClient/askCost.h" #include "themeEditor/buildingAction.h" class MapDispositionEditor; /* ------------------------------ * SectionBuilding * ------------------------------ */ class SectionBuilding : public GenericSection { Q_OBJECT public: /** Constructor */ SectionBuilding( QWidget * parent = 0, const char * name = 0 ); /** Selects the first item */ void selectFirst(); /** Selects the previous item */ void selectPrevious(); /** Selects the next item */ void selectNext(); /** Selects the last item */ void selectLast(); /** Creates a new item */ void selectNew(); /** Deletes the current item */ void selectDel(); /** Inits the section */ void init(); /** Clears the section */ void clear(); /** Saves the section */ void save(); private: AskString * _name, * _description; AskInt * _type, *_action, *_coeff, *_frame,*_animFreq; AskPixmap * _item; AskCost * _resBuild; BuildingAction * _buildingAction; MapDispositionEditor * _dispo; int _num; }; #endif // SECTIONBUILDING_H attal-src-1.0-rc2/themeEditor/sectionCreature.cpp0000644000175000017500000002700410740437744017605 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionCreature.cpp ** section for specifying creatures ** ** Version : $Id: sectionCreature.cpp,v 1.23 2008/01/07 15:06:12 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionCreature.h" // generic include files #include // include files for QT #include #include #include // application specific include files #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libCommon/genericLord.h" #include "libCommon/unit.h" #include "libClient/askCost.h" extern QString IMAGE_PATH; SectionCreature::SectionCreature( QWidget * parent, const char * name ) : Section( parent, name ) { _race = 0; _creature = 0; QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); _selectRace = new SelectionWidget( this ); _selectRace->setTitle( tr( "Race" ) ); layout->addWidget( _selectRace ); _nameRace = new AskString( tr( "Name: " ), this ); layout->addWidget( _nameRace ); _selectCreature = new SelectionWidget( this ); _selectCreature->setTitle( tr( " Creature " ) ); layout->addWidget( _selectCreature ); _editCreature = new EditCreature( this ); layout->addWidget( _editCreature ); layout->addStretch( 1 ); layout->activate(); connect( _selectRace, SIGNAL( sig_first() ), SLOT( slot_firstRace() ) ); connect( _selectRace, SIGNAL( sig_previous() ), SLOT( slot_previousRace() ) ); connect( _selectRace, SIGNAL( sig_next() ), SLOT( slot_nextRace() ) ); connect( _selectRace, SIGNAL( sig_last() ), SLOT( slot_lastRace() ) ); connect( _selectRace, SIGNAL( sig_new() ), SLOT( slot_newRace() ) ); connect( _selectRace, SIGNAL( sig_del() ), SLOT( slot_delRace() ) ); connect( _selectCreature, SIGNAL( sig_first() ), SLOT( slot_firstCreature() ) ); connect( _selectCreature, SIGNAL( sig_previous() ), SLOT( slot_previousCreature() ) ); connect( _selectCreature, SIGNAL( sig_next() ), SLOT( slot_nextCreature() ) ); connect( _selectCreature, SIGNAL( sig_last() ), SLOT( slot_lastCreature() ) ); connect( _selectCreature, SIGNAL( sig_new() ), SLOT( slot_newCreature() ) ); connect( _selectCreature, SIGNAL( sig_del() ), SLOT( slot_delCreature() ) ); init(); } void SectionCreature::save() { DataTheme.creatures.getRace( _race )->setName( _nameRace->getValue() ); _editCreature->save( _race, _creature ); emit sig_changed(); } void SectionCreature::init() { QString text; text.sprintf( QString (tr(" Race : %1/%2").arg( _race + 1 ).arg(DataTheme.creatures.countRace() )).toLatin1().constData()); _selectRace->setTitle( text ); if( _race < DataTheme.creatures.countRace() ) { text.sprintf( QString (tr(" Creature : %1/%2").arg( _creature + 1 ).arg(DataTheme.creatures.getRace( _race )->count() )).toLatin1().constData()); } else { text.sprintf( QString (tr(" Creature : %1/??").arg( _creature + 1) ).toLatin1().constData()); } _selectCreature->setTitle( text ); _nameRace->setValue( DataTheme.creatures.getRace( _race )->getName() ); _editCreature->init( _race, _creature ); } void SectionCreature::slot_firstRace() { if( _race > 0 ) { save(); _race = 0; _creature = 0; init(); } } void SectionCreature::slot_previousRace() { if( _race > 0 ) { save(); _race--; _creature = 0; init(); } } void SectionCreature::slot_nextRace() { if( _race < DataTheme.creatures.countRace() - 1 ) { save(); _race++; _creature = 0; init(); } } void SectionCreature::slot_lastRace() { if( _race < DataTheme.creatures.countRace() - 1 ) { save(); _race = DataTheme.creatures.countRace() - 1; _creature = 0; init(); } } void SectionCreature::slot_newRace() { Race * race = new Race(); Creature * creature = new Creature(); race->append( creature ); DataTheme.creatures.QList::append( race ); slot_lastRace(); } void SectionCreature::slot_delRace() { if( DataTheme.creatures.countRace() > 1 ) { save(); removeRace(); _creature = 0; init(); } } void SectionCreature::removeRace() { delete DataTheme.creatures.takeAt( _race ); int newRace = std::min( _race, DataTheme.creatures.countRace() - 1 ); int newCreature = std::min( (int) _creature, DataTheme.creatures.getRace( newRace )->count() - 1 ); for( int i = 0; i < DataTheme.lords.count(); i++ ) { GenericLordModel * lord = DataTheme.lords.at( i ); for( uint j = 0; j < MAX_UNIT; j++ ) { GenericFightUnit * unit = lord->getUnit( j ); if( ( unit ) && ( unit->getRace() == _race ) ) { unit->setCreature( newRace, newCreature ); } } } _race = newRace; } void SectionCreature::slot_firstCreature() { save(); _creature = 0; init(); } void SectionCreature::slot_previousCreature() { save(); _creature = (uint)std::max( 0, (int)_creature-1 ); init(); } void SectionCreature::slot_nextCreature() { save(); _creature = std::min( DataTheme.creatures.getRace( _race )->count() - 1, (int)_creature + 1 ); init(); } void SectionCreature::slot_lastCreature() { save(); _creature = DataTheme.creatures.getRace( _race )->count() - 1; init(); } void SectionCreature::slot_newCreature() { Creature * creature = new Creature(); DataTheme.creatures.getRace( _race )->append( creature ); slot_lastCreature(); } void SectionCreature::slot_delCreature() { if( DataTheme.creatures.getRace( _race )->count() > 1 ) { save(); removeCreature(); init(); } } void SectionCreature::removeCreature() { delete DataTheme.creatures.getRace( _race )->takeAt( _creature ); int newCreature = std::min( (int)_creature, DataTheme.creatures.getRace( _race )->count() - 1 ); for( int i = 0; i < DataTheme.lords.count(); i++ ) { GenericLordModel * lord = DataTheme.lords.at( i ); for( uint j = 0; j < MAX_UNIT; j++ ) { GenericFightUnit * unit = lord->getUnit( j ); if( ( unit ) && ( unit->getLevel() == _creature ) ) { unit->setCreature( _race, newCreature ); } } } _creature = newCreature; } /*************************************************************************/ EditCreature::EditCreature( QWidget * parent, const char * /*name*/ ) : QWidget( parent ) { QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); _name = new AskString( tr( "Name: " ), this ); layout->addWidget( _name ); _ptAttack = new AskInt( tr( "Attack: " ), this ); _ptDefense = new AskInt( tr( "Defense: " ), this ); _maxHealth = new AskInt( tr( "Max Health: " ), this ); _maxMove = new AskInt( tr( "Max Move: " ), this ); _distAttack = new AskInt( tr( "Dist Attack: " ), this ); _minDamages = new AskInt( tr( "Min Damages: " ), this ); _maxDamages = new AskInt( tr( "Max Damages: " ), this ); _morale = new AskInt( tr( "Morale: " ), this ); _luck = new AskInt( tr( "Luck: " ), this ); _size = new AskInt( tr( "Size: " ), this ); QWidget * widg = new QWidget(this); QGridLayout * glayout = new QGridLayout( widg ); glayout->setColumnStretch( 0, 1 ); glayout->setColumnStretch( 1, 1 ); glayout->addWidget( _ptAttack, 0, 0,Qt::AlignLeft ); glayout->addWidget( _ptDefense, 0, 1 ,Qt::AlignLeft ); glayout->addWidget( _maxHealth, 1, 0 ,Qt::AlignLeft ); glayout->addWidget( _maxMove, 1, 1 ,Qt::AlignLeft ); glayout->addWidget( _distAttack, 2, 0 ,Qt::AlignLeft ); glayout->addWidget( _minDamages, 3, 0 ,Qt::AlignLeft ); glayout->addWidget( _maxDamages, 3, 1 ,Qt::AlignLeft ); glayout->addWidget( _morale, 4, 0 ,Qt::AlignLeft ); glayout->addWidget( _luck, 4, 1 ,Qt::AlignLeft ); glayout->addWidget( _size, 5, 0 ,Qt::AlignLeft ); glayout->setRowStretch( 6, 1 ); glayout->setMargin( 0 ); widg->setFixedWidth( 450 ); layout->addWidget( widg ); _cost = new AskCost( tr( "Cost: " ), this ); layout->addWidget( _cost ); _maintCost = new AskCost( tr( "Maintenance cost: " ), this ); layout->addWidget( _maintCost ); _XOffset = new AskInt( tr( "X Offset: " ), this ); _XOffset->setMinValue( -255 ); _XOffsetMirr = new AskInt( tr( "X Offset mirror: " ), this ); _XOffsetMirr->setMinValue( -255 ); _YOffset = new AskInt( tr( "Y Offset: " ), this ); _YOffset->setMinValue( -255 ); QWidget * widg2 = new QWidget(this); QGridLayout * glayout2 = new QGridLayout( widg2 ); glayout2->setColumnStretch( 0, 1 ); glayout2->setColumnStretch( 1, 1 ); glayout2->addWidget( _XOffset, 0, 0,Qt::AlignLeft ); glayout2->addWidget( _XOffsetMirr, 0, 1 ,Qt::AlignLeft ); glayout2->addWidget( _YOffset, 1, 0 ,Qt::AlignLeft ); glayout2->setRowStretch( 2, 1 ); glayout2->setMargin( 0 ); widg2->setFixedWidth( 450 ); layout->addWidget( widg2 ); _numFrames = new AskInt( tr( "Num. Frames: " ), this ); _numFrames ->setMinValue( 0 ); layout->addWidget( _numFrames ); _creatureAnimation = new CreatureAnimation( this ); layout->addWidget( _creatureAnimation ); _pix = new AskPixmap( true, "", tr( "Picture: " ), this ); layout->addWidget( _pix ); layout->addStretch( 1 ); layout->activate(); } void EditCreature::save( int race, int creature ) { Creature * unit = DataTheme.creatures.getRace( race )->at( creature ); unit->setName( _name->getValue() ); unit->setAttack( _ptAttack->getValue() ); unit->setDefense( _ptDefense->getValue() ); unit->setMaxHealth( _maxHealth->getValue() ); unit->setMaxMove( _maxMove->getValue() ); unit->setDistAttack( _distAttack->getValue() ); unit->setMinDamages( _minDamages->getValue() ); unit->setMaxDamages( _maxDamages->getValue() ); unit->setMorale( _morale->getValue() ); unit->setSize( _size->getValue() ); unit->setLuck( _luck->getValue() ); unit->setXOffset( _XOffset->getValue() ); unit->setXOffsetMirror( _XOffsetMirr->getValue() ); unit->setYOffset( _YOffset->getValue() ); unit->setNumFrames( _numFrames->getValue() ); uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { unit->setCost( i, _cost->getValue( i ) ); unit->setMantCost( i, _maintCost->getValue( i ) ); } _creatureAnimation->save(); _pix->save(); } void EditCreature::init( int race, int creature ) { Creature * unit = DataTheme.creatures.getRace( race )->at( creature ); _name->setValue( unit->getName() ); _ptAttack->setValue( unit->getAttack() ); _ptDefense->setValue( unit->getDefense() ); _maxHealth->setValue( unit->getMaxHealth() ); _maxMove->setValue( unit->getMaxMove() ); _distAttack->setValue( unit->getDistAttack() ); _minDamages->setValue( unit->getMinDamages() ); _maxDamages->setValue( unit->getMaxDamages() ); _morale->setValue( unit->getMorale() ); _size->setValue( unit->getSize() ); _luck->setValue( unit->getLuck() ); _XOffset->setValue(unit->getXOffset()); _XOffsetMirr->setValue(unit->getXOffsetMirror()); _YOffset->setValue(unit->getYOffset()); _numFrames->setValue(unit->getNumFrames()); _creatureAnimation->init( unit ); uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { _cost->setValue( i, unit->getCost( i ) ); _maintCost->setValue( i, unit->getMantCost( i ) ); } QString name; name = QString( IMAGE_PATH + "units/race_" + QString::number( race ) + "/level_" + QString::number( creature ) + "/creature.png" ); _pix->setDestination( name ); } attal-src-1.0-rc2/themeEditor/sectionCreature.h0000644000175000017500000000657310620345323017246 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionCreature.h ** section for specifying creatures ** ** Version : $Id: sectionCreature.h,v 1.10 2007/05/09 13:21:23 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONCREATURE_H #define SECTIONCREATURE_H // generic include files // include files for QT #include // application specific include files #include "themeEditor/sectionWidget.h" #include "themeEditor/creatureAnimation.h" class AskCost; class EditCreature; /* ------------------------------ * SectionCreature * ------------------------------ */ /** comment for the class */ class SectionCreature : public Section { Q_OBJECT public: /** Constructor */ SectionCreature( QWidget * parent = 0, const char * name = 0 ); /** Saves the data */ void save(); /** Inits the section */ void init(); public slots: /** Slot for selecting first race */ void slot_firstRace(); /** Slot for selecting previous race */ void slot_previousRace(); /** Slot for selecting next race */ void slot_nextRace(); /** Slot for selecting last race */ void slot_lastRace(); /** Slot for creating a new race */ void slot_newRace(); /** Slot for deleting the current race */ void slot_delRace(); /** slot for selecting first creature of the current race */ void slot_firstCreature(); /** slot for selecting previous creature of the current race */ void slot_previousCreature(); /** slot for selecting next creature of the current race */ void slot_nextCreature(); /** slot for selecting last creature of the current race */ void slot_lastCreature(); /** slot for creating a new creature in the current race */ void slot_newCreature(); /** slot for deleting the current creature of the current race */ void slot_delCreature(); signals: /** Signal when stg change */ void sig_changed(); private: void removeRace(); void removeCreature(); AskString * _nameRace; uint _race, _creature; SelectionWidget * _selectRace, * _selectCreature; EditCreature * _editCreature; }; /** Edition of a creature */ class EditCreature : public QWidget { Q_OBJECT public: /** Constructor */ EditCreature( QWidget * parent = 0, const char * name = 0 ); /** Saves the data */ void save( int race, int creature ); /** Init the widget */ void init( int race, int creature ); private: CreatureAnimation * _creatureAnimation; AskString * _name; AskInt * _ptAttack, * _ptDefense; AskInt * _maxHealth, * _maxMove; AskInt * _distAttack; AskInt * _XOffset, * _XOffsetMirr, * _YOffset; AskInt * _minDamages, * _maxDamages; AskInt * _morale, * _luck; AskInt * _size; AskInt * _numFrames; AskCost * _cost, * _maintCost; AskPixmap * _pix; }; #endif // SECTIONCREATURE_H attal-src-1.0-rc2/themeEditor/sectionDecoration.cpp0000644000175000017500000001311010532664271020107 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionDecoration.cpp ** section for specifying decorations ** ** Version : $Id: sectionDecoration.cpp,v 1.13 2006/11/27 22:37:45 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionDecoration.h" // generic include files #include // include files for QT #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/genericDecoration.h" #include "libCommon/log.h" #include "libClient/imageTheme.h" #include "themeEditor/decorationEffect.h" #include "themeEditor/mapDispositionEditor.h" extern QString IMAGE_PATH; // // ----- SectionDecoration ----- // SectionDecoration::SectionDecoration( QWidget * parent , const char * name ) : GenericSection( parent, name ) { _num = 1; _numItem = 0; setTitle( tr( "Decoration group" ) ); QVBoxLayout * layout = new QVBoxLayout( _mainWidget ); layout->setMargin( 5 ); layout->setSpacing( 5 ); _name = new AskString( tr( "Name: " ), _mainWidget ); layout->addWidget( _name ); _info = new AskString( tr( "Info: " ), _mainWidget ); layout->addWidget( _info ); _decorationEffect = new DecorationEffect( _mainWidget ); layout->addWidget( _decorationEffect ); _selectItem = new SelectionWidget( _mainWidget ); _selectItem->setTitle( tr( "Decoration item" ) ); layout->addWidget( _selectItem ); _image = new AskPixmap( true, "", tr( "Image: " ), _mainWidget ); layout->addWidget( _image ); _dispo = new MapDispositionEditor( _mainWidget ); layout->addWidget( _dispo ); layout->addStretch( 1 ); layout->activate(); connect( _selectItem, SIGNAL( sig_first() ), SLOT( slot_firstItem() ) ); connect( _selectItem, SIGNAL( sig_previous() ), SLOT( slot_previousItem() ) ); connect( _selectItem, SIGNAL( sig_next() ), SLOT( slot_nextItem() ) ); connect( _selectItem, SIGNAL( sig_last() ), SLOT( slot_lastItem() ) ); connect( _selectItem, SIGNAL( sig_new() ), SLOT( slot_newItem() ) ); connect( _selectItem, SIGNAL( sig_del() ), SLOT( slot_delItem() ) ); init(); } void SectionDecoration::clear() { _name->setValue( "" ); _info->setValue( "" ); } void SectionDecoration::init() { if( DataTheme.decorations.count() > 1 ) { DecorationGroup * group = DataTheme.decorations.at( _num ); _name->setValue( group->getName() ); _info->setValue( group->getInfo() ); _decorationEffect->init( group ); QString dest = IMAGE_PATH + QString( "decor/decoration_" ) + QString::number( _num ) + "_" + QString::number( _numItem ) + QString( ".png" ); _image->setDestination( dest ); _dispo->init( group->at( _numItem ), dest ); } } void SectionDecoration::save() { if( DataTheme.decorations.count() > 0 ) { DecorationGroup * group = DataTheme.decorations.at( _num ); group->setName( _name->getValue() ); group->setInfo( _info->getValue() ); _decorationEffect->save(); _image->save(); } } void SectionDecoration::selectFirst() { save(); if( _num != 1 ) { _num = 1; _numItem = 0; } init(); } void SectionDecoration::selectPrevious() { save(); if( _num != std::max( 1, _num - 1 ) ) { _num = std::max( 1, _num - 1 ); _numItem = 0; } init(); } void SectionDecoration::selectNext() { save(); if( _num != std::min( DataTheme.decorations.count() - 1, _num + 1 ) ) { _num = std::min( DataTheme.decorations.count() - 1, _num + 1 ); _numItem = 0; } init(); } void SectionDecoration::selectLast() { save(); if( _num != DataTheme.decorations.count() - 1 ) { _num = DataTheme.decorations.count() - 1; _numItem = 0; } init(); } void SectionDecoration::selectNew() { save(); DecorationGroup * group = new DecorationGroup(); _num = DataTheme.decorations.count(); _numItem = 0; DataTheme.decorations.append( group ); clear(); } void SectionDecoration::selectDel() { if( DataTheme.decorations.count() > 0 ) { delete DataTheme.decorations.takeAt( _num ); /// XXX: other things to do ? remove pixmaps ? _num = std::min( _num, DataTheme.decorations.count() - 1 ); _numItem = 0; init(); } } void SectionDecoration::slot_firstItem() { save(); _numItem = 0; init(); } void SectionDecoration::slot_previousItem() { save(); _numItem = std::max( 0, _numItem - 1 ); init(); } void SectionDecoration::slot_nextItem() { save(); _numItem = std::min( DataTheme.decorations.at( _num )->count() - 1, _numItem + 1 ); init(); } void SectionDecoration::slot_lastItem() { save(); _numItem = DataTheme.decorations.at( _num )->count() - 1; init(); } void SectionDecoration::slot_newItem() { save(); GenericDecoration * decor = new GenericDecoration(); _numItem = DataTheme.decorations.at( _num )->count(); DataTheme.decorations.at( _num )->append( decor ); clear(); } void SectionDecoration::slot_delItem() { if( DataTheme.decorations.at( _num )->count() > 0 ) { delete DataTheme.decorations.at( _num )->takeAt( _numItem ); /// XXX: other things to do ? remove/shift pixmaps ? _numItem = std::min( _numItem, DataTheme.decorations.at( _num )->count() - 1 ); init(); } } attal-src-1.0-rc2/themeEditor/sectionDecoration.h0000644000175000017500000000435310346554561017570 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionDecoration.h ** section for specifying decorations ** ** Version : $Id: sectionDecoration.h,v 1.8 2005/12/10 13:34:41 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONDECORATION_H #define SECTIONDECORATION_H // generic include files // include files for QT #include // application specific include files #include "sectionWidget.h" class DecorationEffect; class MapDispositionEditor; /* ------------------------------ * SectionDecoration * ------------------------------ */ class SectionDecoration : public GenericSection { Q_OBJECT public: /** Constructor */ SectionDecoration( QWidget * parent = 0, const char * name = 0 ); /** Selects the first item */ void selectFirst(); /** Selects the previous item */ void selectPrevious(); /** Selects the next item */ void selectNext(); /** Selects the last item */ void selectLast(); /** Creates new item */ void selectNew(); /** Deletes current item */ void selectDel(); /** Clears the section */ void clear(); /** Initialize the section */ void init(); /** Saves the data */ void save(); public slots: void slot_firstItem(); void slot_previousItem(); void slot_nextItem(); void slot_lastItem(); void slot_newItem(); void slot_delItem(); private: AskString * _name, * _info; AskCombo * _moveEffect, * _technicEffect; AskPixmap * _image; DecorationEffect * _decorationEffect; SelectionWidget * _selectItem; MapDispositionEditor * _dispo; int _num; int _numItem; }; #endif // SECTIONDECORATION_H attal-src-1.0-rc2/themeEditor/sectionExperience.cpp0000644000175000017500000000430610576524070020116 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionExperience.cpp ** section for setting levels of experience ** ** Version : $Id: sectionExperience.cpp,v 1.5 2007/03/16 14:22:48 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionExperience.h" // generic include files // include files for QT #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libClient/askWidget.h" #include "libClient/gui.h" SectionExperience::SectionExperience( QWidget * parent, const char * name ) : Section( parent, name ) { QLabel * labList = new QLabel( this ); labList->setText( tr( "List of required experience to gain for accessing the next level:" ) ); FIXEDSIZE( labList ); _list = new AskIntList( this ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( labList ); layout->addWidget( _list ); layout->addStretch( 1 ); layout->activate(); init(); } void SectionExperience::clear() { _list->clear(); } void SectionExperience::init() { uint nbLevels = DataTheme.lordExperience.getLevelNumber(); uint lastLevel = 0; for( uint i = 1; i < nbLevels; i++ ) { _list->addValue( DataTheme.lordExperience.getLevel( i ) - lastLevel ); lastLevel = DataTheme.lordExperience.getLevel( i ); } } void SectionExperience::save() { uint nbLevels = _list->count(); DataTheme.lordExperience.clear(); for( uint i = 0; i < nbLevels; i++ ) { DataTheme.lordExperience.appendLevelByDiff( _list->getValue( i ) ); } } attal-src-1.0-rc2/themeEditor/sectionExperience.h0000644000175000017500000000305210047163656017562 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionExperience.h ** section for setting levels of experience ** ** Version : $Id: sectionExperience.h,v 1.1 2004/05/08 13:59:10 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONEXPERIENCE_H #define SECTIONEXPERIENCE_H // generic include files // include files for QT // application specific include files #include "themeEditor/sectionWidget.h" class AskIntList; /* ------------------------------ * SectionExperience * ------------------------------ */ class SectionExperience : public Section { Q_OBJECT public: /** Constructor */ SectionExperience( QWidget * parent = 0, const char * name = 0 ); /** Clears the section */ void clear(); /** Initializes the section */ void init(); /** Saves the data */ void save(); protected: AskIntList * _list; }; #endif // SECTIONEXPERIENCE_H attal-src-1.0-rc2/themeEditor/sectionGeneral.cpp0000644000175000017500000001612410522705153017377 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionGeneral.cpp ** section with general info about theme ** ** Version : $Id: sectionGeneral.cpp,v 1.8 2006/11/03 18:28:59 fdarling Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionGeneral.h" // generic include files // include files for QT #include #include #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/generalOptions.h" #include "libCommon/log.h" #include "libClient/gui.h" extern QString IMAGE_PATH; SectionGeneral::SectionGeneral( QWidget * parent, const char * name ) : Section( parent, name ) { _dayN = 1; _weekN = 1; _monthN = 1; _vision = new AskCombo( tr( "Vision management: " ), this ); _vision->insertItem( GeneralOptions::getVisionManagementName( GeneralOptions::VISION_ONCE ) ); _vision->insertItem( GeneralOptions::getVisionManagementName( GeneralOptions::VISION_REAL ) ); _nbUnit = new AskInt( tr( "Number of unit/lord" ), this ); _nbUnit->setMinValue( 1 ); _nbUnit->setMaxValue( 10 ); _logo = new AskPixmap( false, IMAGE_PATH + QString( "misc/logo.png" ), tr( "Logo (200x180): " ), this ); _day = new SelectionDate( this ); _day->setTitle( tr( "Day " ) ); _dayName = new AskString( tr( "Name: " ), this ); _week = new SelectionDate( this ); _week->setTitle( tr( "Week " ) ); _weekName = new AskString( tr( "Name: " ), this ); _month = new SelectionDate( this ); _month->setTitle( tr( "Month" ) ); _monthName = new AskString( tr( "Name: " ), this ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _vision ); layout->addWidget( _nbUnit ); layout->addWidget( _logo ); layout->addWidget( _day ); layout->addWidget( _dayName ); layout->addWidget( _week ); layout->addWidget( _weekName ); layout->addWidget( _month ); layout->addWidget( _monthName ); layout->addStretch( 1 ); layout->activate(); connect( _day, SIGNAL( sig_first() ), SLOT( slot_firstDay() ) ); connect( _day, SIGNAL( sig_previous() ), SLOT( slot_previousDay() ) ); connect( _day, SIGNAL( sig_next() ), SLOT( slot_nextDay() ) ); connect( _day, SIGNAL( sig_last() ), SLOT( slot_lastDay() ) ); connect( _week, SIGNAL( sig_first() ), SLOT( slot_firstWeek() ) ); connect( _week, SIGNAL( sig_previous() ), SLOT( slot_previousWeek() ) ); connect( _week, SIGNAL( sig_next() ), SLOT( slot_nextWeek() ) ); connect( _week, SIGNAL( sig_last() ), SLOT( slot_lastWeek() ) ); connect( _month, SIGNAL( sig_first() ), SLOT( slot_firstMonth() ) ); connect( _month, SIGNAL( sig_previous() ), SLOT( slot_previousMonth() ) ); connect( _month, SIGNAL( sig_next() ), SLOT( slot_nextMonth() ) ); connect( _month, SIGNAL( sig_last() ), SLOT( slot_lastMonth() ) ); init(); } void SectionGeneral::init() { _vision->setCurrentItem( (uint)DataTheme.general.getVisionManagement() ); QString text; text.sprintf( QString (tr(" Day : %1/%2").arg(_dayN).arg(FIRST_LEVEL) ).toLatin1().constData()); _day->setTitle( text ); _dayName->setValue(DataTheme.general.getCalendar()->getLevelName( 0 , _dayN - 1)); text.sprintf( QString (tr(" Week : %1/%2").arg(_weekN).arg(SECOND_LEVEL) ).toLatin1().constData()); _week->setTitle( text ); _weekName->setValue(DataTheme.general.getCalendar()->getLevelName( 1 , _weekN - 1)); text.sprintf( QString (tr(" Month : %1/%2").arg(_monthN).arg(THIRD_LEVEL) ).toLatin1().constData()); _month->setTitle( text ); _monthName->setValue(DataTheme.general.getCalendar()->getLevelName( 2 , _monthN - 1)); } void SectionGeneral::save() { DataTheme.general.setVisionManagement( ( GeneralOptions::VISION_MANAGEMENT )_vision->currentItem() ); _logo->save(); DataTheme.general.getCalendar()->setLevelName( 0 , _dayN - 1, _dayName->getValue()); DataTheme.general.getCalendar()->setLevelName( 1 , _weekN - 1, _weekName->getValue()); DataTheme.general.getCalendar()->setLevelName( 2 , _monthN - 1, _monthName->getValue()); emit sig_changed(); } void SectionGeneral::slot_firstDay() { save(); _dayN = 1; init(); } void SectionGeneral::slot_previousDay() { save(); _dayN = (uint)std::max( 1, (int)_dayN-1 ); init(); } void SectionGeneral::slot_nextDay() { save(); _dayN = std::min( FIRST_LEVEL, (int)_dayN + 1 ); init(); } void SectionGeneral::slot_lastDay() { save(); _dayN = FIRST_LEVEL; init(); } void SectionGeneral::slot_firstWeek() { save(); _weekN = 1; init(); } void SectionGeneral::slot_previousWeek() { save(); _weekN = (uint)std::max( 1, (int)_weekN-1 ); init(); } void SectionGeneral::slot_nextWeek() { save(); _weekN = std::min( SECOND_LEVEL, (int)_weekN + 1 ); init(); } void SectionGeneral::slot_lastWeek() { save(); _weekN = SECOND_LEVEL; init(); } void SectionGeneral::slot_firstMonth() { save(); _monthN = 1; init(); } void SectionGeneral::slot_previousMonth() { save(); _monthN = (uint)std::max( 1, (int)_monthN-1 ); init(); } void SectionGeneral::slot_nextMonth() { save(); _monthN = std::min( THIRD_LEVEL, (int)_monthN + 1 ); init(); } void SectionGeneral::slot_lastMonth() { save(); _monthN = THIRD_LEVEL; init(); } SelectionDate::SelectionDate( QWidget * parent, const char * name ) : QFrame( parent ) { setWindowTitle( QString ( name )); QHBoxLayout * layout = new QHBoxLayout( this ); setFrameStyle( QFrame::Box | QFrame::Raised ); layout->addSpacing( 5 ); QPushButton * butFirst = new QPushButton( "|<", this ); FIXEDSIZE( butFirst ); layout->addWidget( butFirst ); QPushButton * butPrevious = new QPushButton( "<", this ); FIXEDSIZE( butPrevious ); layout->addWidget( butPrevious ); layout->addSpacing( 5 ); _labTitle = new QLabel( tr( "None" ), this ); FIXEDSIZE( _labTitle ); layout->addWidget( _labTitle ); layout->addSpacing( 5 ); QPushButton * butNext = new QPushButton( ">", this ); FIXEDSIZE( butNext ); layout->addWidget( butNext ); QPushButton * butLast = new QPushButton( ">|", this ); FIXEDSIZE( butLast ); layout->addWidget( butLast ); layout->addSpacing( 5 ); layout->addStretch( 1 ); layout->addSpacing( 5 ); layout->activate(); setMinimumHeight( 40 ); connect( butFirst, SIGNAL( clicked() ), SIGNAL( sig_first() ) ); connect( butPrevious, SIGNAL( clicked() ), SIGNAL( sig_previous() ) ); connect( butNext, SIGNAL( clicked() ), SIGNAL( sig_next() ) ); connect( butLast, SIGNAL( clicked() ), SIGNAL( sig_last() ) ); } void SelectionDate::setTitle( QString title ) { _labTitle->setText( title ); FIXEDSIZE( _labTitle ); } attal-src-1.0-rc2/themeEditor/sectionGeneral.h0000644000175000017500000000476210337204741017052 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionGeneral.h ** section with general info about theme ** ** Version : $Id: sectionGeneral.h,v 1.4 2005/11/17 22:53:21 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONGENERAL_H #define SECTIONGENERAL_H // generic include files // include files for QT #include #include // application specific include files #include "themeEditor/sectionWidget.h" /* ------------------------------ * SectionDate * ------------------------------ */ class SelectionDate : public QFrame { Q_OBJECT public: /** Constructor */ SelectionDate( QWidget * parent = 0, const char * name = 0 ); void setTitle( QString title ); signals: void sig_first(); void sig_previous(); void sig_next(); void sig_last(); private: QLabel * _labTitle; }; /* ------------------------------ * SectionGeneral * ------------------------------ */ /** comment for the class */ class SectionGeneral : public Section { Q_OBJECT public: /** Constructor */ SectionGeneral( QWidget * parent = 0, const char * name = 0 ); /** Saves the data */ void save(); /** inits the data */ void init(); signals: /** Signal when stg change */ void sig_changed(); public slots: void slot_firstDay(); void slot_previousDay(); void slot_nextDay(); void slot_lastDay(); void slot_firstWeek(); void slot_previousWeek(); void slot_nextWeek(); void slot_lastWeek(); void slot_firstMonth(); void slot_previousMonth(); void slot_nextMonth(); void slot_lastMonth(); private: AskCombo * _vision; SelectionDate * _day, * _week, * _month; AskInt * _nbUnit; AskPixmap * _logo; AskString * _weekName, * _monthName, * _dayName; uint _dayN, _weekN, _monthN; }; #endif // SECTIONGENERAL_H attal-src-1.0-rc2/themeEditor/sectionGround.cpp0000644000175000017500000000740310617214344017262 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionGround.cpp ** section for specifying grounds ** ** Version : $Id: sectionGround.cpp,v 1.11 2007/05/05 23:53:08 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionGround.h" // generic include files #include // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/genericCell.h" #include "libCommon/log.h" #include "libClient/imageTheme.h" #include "themeEditor/askDiversification.h" extern QString IMAGE_PATH; SectionGround::SectionGround( QWidget * parent, const char * name ) : GenericSection( parent, name ) { setTitle( tr( "Tiles" ) ); _width = new AskInt( tr( "Width: " ), _mainWidget ); _height = new AskInt( tr( "Height: " ), _mainWidget ); _name = new AskString( tr( "Name: " ), _mainWidget ); _coef = new AskInt( tr( "Coef: " ), _mainWidget ); _color = new AskColor( tr( "Color: " ), _mainWidget ); _diversification = new AskDiversificationList( _mainWidget ); QVBoxLayout * layout = new QVBoxLayout( _mainWidget ); _layH = new QHBoxLayout(); _layH->addWidget( _width ); _layH->addWidget( _height ); layout->addLayout( _layH ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _name ); layout->addWidget( _coef ); layout->addWidget( _color ); layout->addWidget( _diversification ); layout->addStretch( 1 ); layout->activate(); _num = 1; init(); } SectionGround::~SectionGround() { delete _layH; } void SectionGround::clear() { _name->setValue( QString( tr( "Tile " ) ) + QString::number( _num + 1 ) ); _coef->setValue( 0 ); _color->setValue( Qt::black ); _diversification->clear(); } void SectionGround::init() { _width->setValue( DataTheme.tiles.getWidth() ); _height->setValue( DataTheme.tiles.getHeight() ); if( DataTheme.tiles.count() > 0 ) { CellModel * cell = DataTheme.tiles.at( _num ); _name->setValue( cell->getName() ); _coef->setValue( cell->getCoeff() ); _color->setValue( cell->getColor() ); _diversification->setValue( cell ); } } void SectionGround::save() { DataTheme.tiles.setWidth( _width->getValue() ); DataTheme.tiles.setHeight(_height->getValue() ); if( DataTheme.tiles.count() > 0 ) { CellModel * cell = DataTheme.tiles.at( _num ); cell->setName( _name->getValue() ); cell->setCoeff( _coef->getValue() ); cell->setColor( _color->getValue() ); _diversification->save(); } } void SectionGround::selectFirst() { save(); _num = 1; init(); } void SectionGround::selectPrevious() { save(); _num = std::max( 1, _num - 1 ); init(); } void SectionGround::selectNext() { save(); _num = std::min( (int)DataTheme.tiles.count() - 1, _num + 1 ); init(); } void SectionGround::selectLast() { save(); _num = DataTheme.tiles.count() - 1; init(); } void SectionGround::selectNew() { save(); CellModel * cell = new CellModel(); _num = DataTheme.tiles.count(); DataTheme.tiles.append( cell ); clear(); } void SectionGround::selectDel() { if( DataTheme.tiles.count() > 1 ) { delete DataTheme.tiles.takeAt( _num ); _num = std::min( _num, (int)DataTheme.tiles.count() - 1 ); init(); } } attal-src-1.0-rc2/themeEditor/sectionGround.h0000644000175000017500000000406110617214344016724 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionGround.h ** section for specifying grounds ** ** Version : $Id: sectionGround.h,v 1.8 2007/05/05 23:53:08 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONGROUND_H #define SECTIONGROUND_H // generic include files // include files for QT #include #include // application specific include files #include "themeEditor/sectionWidget.h" class AskDiversificationList; /* ------------------------------ * SectionGround * ------------------------------ */ /** comment for the class */ class SectionGround : public GenericSection { Q_OBJECT public: /** Constructor */ SectionGround( QWidget * parent = 0, const char * name = 0 ); ~SectionGround(); /** Selects the first item */ void selectFirst(); /** Selects the previous item */ void selectPrevious(); /** Selects the next item */ void selectNext(); /** Selects the last item */ void selectLast(); /** Creates new item */ void selectNew(); /** Deletes current item */ void selectDel(); /** Clears the section */ void clear(); /** Initialize the section */ void init(); /** Saves the data */ void save(); protected: int _num; AskString * _name; AskInt * _coef, * _width, * _height; AskColor * _color; AskDiversificationList * _diversification; QHBoxLayout * _layH; }; #endif // SECTIONGROUND_H attal-src-1.0-rc2/themeEditor/sectionLord.cpp0000644000175000017500000002475310740437744016743 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionLord.cpp ** section for specifying lords ** ** Version : $Id: sectionLord.cpp,v 1.19 2008/01/07 15:06:12 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionLord.h" // generic include files #include // include files for QT #include #include #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/unit.h" #include "libCommon/log.h" #include "libClient/gui.h" #include "libClient/askCost.h" extern QString IMAGE_PATH; SectionLord::SectionLord( QWidget * parent, const char * name ) : GenericSection( parent, name ) { setTitle( tr( "Lord" ) ); QVBoxLayout * layout = new QVBoxLayout( _mainWidget ); layout->setMargin( 5 ); layout->setSpacing( 5 ); _bigPix = new AskPixmap( true, "", tr( "Photo: " ), _mainWidget ); layout->addWidget( _bigPix ); _smallPix = new AskPixmap( true, "", tr( "Icon: " ), _mainWidget ); layout->addWidget( _smallPix ); _name = new AskString( tr( "Name : " ), _mainWidget ); layout->addWidget( _name ); _category = new AskCombo( tr( "Category : " ), _mainWidget ); layout->addWidget( _category ); _attack = new AskInt( tr( "Attack : " ), _mainWidget ); _defense = new AskInt( tr( "Defense : " ), _mainWidget ); _power = new AskInt( tr( "Power : " ), _mainWidget ); _knowledge = new AskInt( tr( "Knowledge : " ), _mainWidget ); _charisma = new AskInt( tr( "Charisma : " ), _mainWidget ); _movemax = new AskInt( tr( "MaxMoves : " ), _mainWidget ); _movemax->setMaxValue( 9000 ); _vision = new AskInt( tr( "Vision : " ), _mainWidget ); QWidget * widg = new QWidget(this); QGridLayout * glayout = new QGridLayout( widg ); glayout->setColumnStretch( 0, 1 ); glayout->setColumnStretch( 1, 1 ); glayout->addWidget( _attack, 0, 0,Qt::AlignLeft ); glayout->addWidget( _defense, 0, 1 ,Qt::AlignLeft ); glayout->addWidget( _power, 1, 0 ,Qt::AlignLeft ); glayout->addWidget( _knowledge, 1, 1 ,Qt::AlignLeft ); glayout->addWidget( _charisma, 2, 0 ,Qt::AlignLeft ); glayout->addWidget( _movemax, 3, 0 ,Qt::AlignLeft ); glayout->addWidget( _vision, 3, 1 ,Qt::AlignLeft ); glayout->setRowStretch( 4, 1 ); glayout->setMargin( 0 ); widg->setFixedWidth( 450 ); layout->addWidget( widg ); _cost = new AskCost( tr( "Cost: " ), _mainWidget ); layout->addWidget( _cost ); _troops = new DisplayTroops( _mainWidget ); layout->addWidget( _troops ); layout->addStretch( 1 ); layout->activate(); if( DataTheme.lords.count() > 1 ) { _idLord = 1; } else { _idLord = 0; } updateData(); selectFirst(); } void SectionLord::updateData() { LordCategoryModel * category; QString str; _category->clear(); uint nbCategory = DataTheme.lordCategories.count(); for( uint i = 0; i < nbCategory; i++ ) { category = DataTheme.lordCategories.at( i ); str = tr( " (Race: " ) + DataTheme.creatures.getRace( category->getRace() )->getName() + ")"; _category->insertItem( category->getName() + str ); } _troops->updateData(); init(); } void SectionLord::clear() { _name->setValue( "" ); _category->setCurrentItem( 0 ); _attack->setValue( 1 ); _defense->setValue( 1 ); _power->setValue( 0 ); _knowledge->setValue( 0 ); _charisma->setValue( 1 ); _movemax->setValue( 16 ); _vision->setValue( 5 ); _troops->clear(); _bigPix->setValue( "" ); _smallPix->setValue( "" ); } void SectionLord::init() { GenericLordModel * lord = DataTheme.lords.at( _idLord ); if( _idLord > 0 ) { _name->setValue( lord->getName() ); _category->setCurrentItem( DataTheme.getLordCategory( lord->getCategory() ) ); _attack->setValue( lord->getBaseCharac( ATTACK ) ); _defense->setValue( lord->getBaseCharac( DEFENSE ) ); _power->setValue( lord->getBaseCharac( POWER ) ); _knowledge->setValue( lord->getBaseCharac( KNOWLEDGE ) ); _charisma->setValue( lord->getBaseCharac( CHARISMA ) ); _movemax->setValue( lord->getBaseCharac( MAXMOVE ) ); _vision->setValue( lord->getBaseCharac( VISION ) ); uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { _cost->setValue( i, lord->getCost( i ) ); } QString dest; dest.sprintf( "%slords/lord_%03d.png", IMAGE_PATH.toLatin1().constData(), _idLord ); _bigPix->setDestination( dest ); dest.sprintf( "%slords/smallLord_%03d.png", IMAGE_PATH.toLatin1().constData(), _idLord ); _smallPix->setDestination( dest ); _troops->init( lord ); } else { clear(); } } void SectionLord::selectFirst() { save(); if( DataTheme.lords.count() > 1 ) { _idLord = 1; init(); } else { _idLord = 0; } init(); } void SectionLord::selectPrevious() { save(); if( _idLord > 1 ) { _idLord--; } init(); } void SectionLord::selectNext() { save(); if( _idLord < DataTheme.lords.count() - 1 ) { _idLord++; } init(); } void SectionLord::selectLast() { save(); _idLord = DataTheme.lords.count() - 1; init(); } void SectionLord::selectNew() { uchar numLords = DataTheme.lords.count(); if( numLords < GenericLord::MAX_LORDS-1 ) { save(); _idLord = DataTheme.lords.count(); GenericLordModel * lord = new GenericLordModel(); DataTheme.lords.append( lord ); init(); } } void SectionLord::selectDel() { if( _idLord > 0 ) { clear(); delete DataTheme.lords.takeAt( _idLord ); _idLord = std::min( _idLord, DataTheme.lords.count() - 1 ); init(); } else { ///XXX: warning, can't delete lord (list empty) } } void SectionLord::save() { GenericLordModel * lord = DataTheme.lords.at( _idLord ); if( _idLord > 0 ) { lord->setName( _name->getValue() ); lord->setCategory( DataTheme.lordCategories.at( _category->currentItem() ) ); lord->setBaseCharac( ATTACK, _attack->getValue() ); lord->setBaseCharac( DEFENSE, _defense->getValue() ); lord->setBaseCharac( POWER, _power->getValue() ); lord->setBaseCharac( KNOWLEDGE, _knowledge->getValue() ); lord->setBaseCharac( CHARISMA, _charisma->getValue() ); lord->setBaseCharac( MAXMOVE, _movemax->getValue() ); lord->setBaseCharac( VISION, _vision->getValue() ); uint nbRes = DataTheme.resources.count(); for( uint i = 0; i < nbRes; i++ ) { lord->setCost( i, _cost->getValue( i ) ); } _bigPix->save(); _smallPix->save(); _troops->save( lord ); } } // // ----- DisplayTroops ----- // DisplayTroops::DisplayTroops( QWidget * parent, const char * /* name */ ) : QWidget( parent ) { int i; QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); QHBoxLayout * lay2 = new QHBoxLayout(); lay2->setMargin( 5 ); lay2->setSpacing( 5 ); for( i = 0; i < 4; i++ ) { _troop[i] = new EditTroop( i, this ); lay2->addWidget( _troop[i] ); } lay2->addStretch( 1 ); layout->addLayout( lay2 ); QHBoxLayout * lay3 = new QHBoxLayout(); lay3->setMargin( 5 ); lay3->setSpacing( 5 ); for( i = 4; i < MAX_UNIT; i++ ) { _troop[i] = new EditTroop( i, this ); lay3->addWidget( _troop[i] ); } lay3->addStretch( 1 ); layout->addLayout( lay3 ); layout->addStretch( 1 ); layout->activate(); } void DisplayTroops::clear() { for( int i = 0; i < MAX_UNIT; i++ ) { _troop[i]->clear(); } } void DisplayTroops::init( GenericLordModel * lord ) { if( lord ) { for( int i = 0; i < MAX_UNIT; i++ ) { _troop[i]->init( lord->getUnit( i ) ); } } else { clear(); } } void DisplayTroops::save( GenericLordModel * lord ) { for( int i = 0; i < MAX_UNIT; i++ ) { _troop[i]->save( i, lord ); } } void DisplayTroops::updateData() { for( int i = 0; i < MAX_UNIT; i++ ) { _troop[i]->updateData(); } } // // ----- EditTroop ----- // EditTroop::EditTroop( int num, QWidget * parent, const char * /* name*/ ) : QFrame( parent ) { _unit = 0; setFrameStyle( QFrame::Panel | QFrame::Raised ); QVBoxLayout * layout = new QVBoxLayout( this ); layout->setMargin( 5 ); layout->setSpacing( 5 ); QLabel * label = new QLabel( this ); label->setText( "Unit " + QString::number( num ) ); FIXEDSIZE( label ); layout->addWidget( label ); _race = new AskCombo( tr( "Race : " ), this ); _race->setCurrentItem( 0 ); layout->addWidget( _race ); _name = new AskCombo( tr( "Name : " ), this ); layout->addWidget( _name ); _number = new AskInt( tr( "Number : " ), this ); layout->addWidget( _number ); layout->addStretch( 1 ); layout->activate(); updateData(); connect( _race, SIGNAL( sig_activated( int ) ), SLOT( slot_raceChanged( int ) ) ); } void EditTroop::slot_raceChanged( int race ) { _name->clear(); for( int i = 0; i < DataTheme.creatures.getRace( race )->count(); i++ ) { _name->insertItem( DataTheme.creatures.getRace( race )->at( i )->getName() ); } } void EditTroop::updateData() { int race = _race->currentItem(); _race->clear(); for( uint i = 0; i < DataTheme.countRace(); i++ ) { _race->insertItem( DataTheme.creatures.getRace( i )->getName() ); } if( _unit ) { _race->setCurrentItem( _unit->getRace() ); } else { _race->setCurrentItem( race ); } _name->clear(); if(_race->currentItem() >= 0) { for( int i = 0; i < DataTheme.creatures.getRace( _race->currentItem() )->count(); i++ ) { _name->insertItem( DataTheme.creatures.getRace( _race->currentItem() )->at( i )->getName() ); } } } void EditTroop::clear() { _race->setCurrentItem( 0 ); _name->setCurrentItem( 0 ); _number->setValue( 0 ); } void EditTroop::init( GenericFightUnit * unit ) { _unit = unit; if( unit ) { _race->setCurrentItem( unit->getRace() ); slot_raceChanged( unit->getRace() ); _name->setCurrentItem( unit->getLevel() ); _number->setValue( unit->getNumber() ); } else { clear(); } } void EditTroop::save( int i, GenericLordModel * lord ) { GenericFightUnit * unit = lord->getUnit( i ); if( _number->getValue() > 0 ) { if( ! unit ) { unit = new GenericFightUnit(); } unit->setCreature( _race->currentItem(), _name->currentItem() ); unit->setNumber( _number->getValue() ); lord->setUnit( i, unit ); } else { if( unit ) { delete unit; } lord->setUnit( i, 0 ); } } attal-src-1.0-rc2/themeEditor/sectionLord.h0000644000175000017500000000633710511545110016365 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionLord.h ** section for specifying lords ** ** Version : $Id: sectionLord.h,v 1.7 2006/10/06 21:27:36 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONLORD_H #define SECTIONLORD_H // generic include files // include files for QT #include // application specific include files #include "themeEditor/sectionWidget.h" #include "libCommon/genericLord.h" class AskCost; class QComboBox; class DisplayTroops; class EditTroop; class GenericFightUnit; class GenericLord; /** ------------------------------ * SectionLord ** ------------------------------ */ class SectionLord : public GenericSection { Q_OBJECT public: /** Constructor */ SectionLord( QWidget * parent = 0, const char * name = 0 ); /** Clears the section */ void clear(); /** Initialize the section */ void init(); /** Updates data */ void updateData(); /** Selects the first item */ void selectFirst(); /** Selects the previous item */ void selectPrevious(); /** Selects the next item */ void selectNext(); /** Selects the last item */ void selectLast(); /** Creates new item */ void selectNew(); /** Deletes the current item */ void selectDel(); /** Saves the data */ void save(); private: AskString * _name; AskCombo * _category; AskCost * _cost; AskInt * _attack, * _defense; AskInt * _power, * _knowledge, * _movemax, * _charisma; AskInt * _vision; AskPixmap * _bigPix, * _smallPix; DisplayTroops * _troops; int _idLord; }; /** Widget displaying all troops of a lord */ class DisplayTroops : public QWidget { public: /** Constrcutor */ DisplayTroops( QWidget * parent = 0, const char * name = 0 ); /** Clears all the troops */ void clear(); /** Updates data */ void updateData(); /** Inits display */ void init( GenericLordModel * lord ); /** Saves the data */ void save( GenericLordModel * lord ); private: EditTroop * _troop[MAX_UNIT]; }; /** Widget for editing a troop of a lord */ class EditTroop : public QFrame { Q_OBJECT public: /** Constructor */ EditTroop( int num, QWidget * parent = 0, const char * name = 0 ); /** Clears the widget */ void clear(); /** Updates data */ void updateData(); /** Inits the widget with 'unit' */ void init( GenericFightUnit * unit ); /** Saves the data */ void save( int i, GenericLordModel * lord ); public slots: /** Slot if races have changed */ void slot_raceChanged( int race ); private: GenericFightUnit * _unit; AskCombo * _race, * _name; AskInt * _number; }; #endif // SECTIONLORD_H attal-src-1.0-rc2/themeEditor/sectionLordCategory.cpp0000644000175000017500000001104710522705153020417 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionLordCategory.cpp ** section for editing lord categories ** ** Version : $Id: sectionLordCategory.cpp,v 1.6 2006/11/03 18:28:59 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionLordCategory.h" // generic include files #include // include files for QT #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/log.h" #include "libClient/gui.h" SectionLordCategory::SectionLordCategory( QWidget * parent, const char * name ) : GenericSection( parent, name ) { setTitle( tr( "Lord Categories" ) ); _num = 0; _name = new AskString( tr( "Name: " ), _mainWidget ); _description = new AskString( tr( "Description: " ), _mainWidget ); _race = new AskCombo( tr( "Race: " ), _mainWidget ); _attack = new AskInt( tr( "Evolution of Attack skill (weight): " ), _mainWidget ); _defense = new AskInt( tr( "Evolution of Defense skill (weight): " ), _mainWidget ); _power = new AskInt( tr( "Evolution of Power skill (weight): " ), _mainWidget ); _knowledge = new AskInt( tr( "Evolution of Knowledge skill (weight): " ), _mainWidget ); QVBoxLayout * layout = new QVBoxLayout( _mainWidget ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _name ); layout->addWidget( _description ); layout->addWidget( _race ); layout->addWidget( _attack ); layout->addWidget( _defense ); layout->addWidget( _power ); layout->addWidget( _knowledge ); layout->addStretch( 1 ); layout->activate(); updateData(); selectFirst(); } void SectionLordCategory::updateData() { _race->clear(); uint nbRace = DataTheme.countRace(); for( uint i = 0; i < nbRace; i++ ) { _race->insertItem( DataTheme.creatures.getRace( i )->getName() ); } init(); } void SectionLordCategory::clear() { _name->setValue( QString::number( _num + 1 ) ); _description->setValue( "" ); _race->setCurrentItem( 0 ); _attack->setValue( 1 ); _defense->setValue( 1 ); _power->setValue( 1 ); _knowledge->setValue( 1 ); } void SectionLordCategory::init() { if( DataTheme.lordCategories.count() > 0 ) { LordCategoryModel * category = DataTheme.lordCategories.at( _num ); _name->setValue( category->getName() ); _description->setValue( category->getDescription() ); _race->setCurrentItem( category->getRace() ); _attack->setValue( category->getEvolution( ATTACK ) ); _defense->setValue( category->getEvolution( DEFENSE ) ); _power->setValue( category->getEvolution( POWER ) ); _knowledge->setValue( category->getEvolution( KNOWLEDGE ) ); } } void SectionLordCategory::save() { if( DataTheme.lordCategories.count() > 0 ) { LordCategoryModel * category = DataTheme.lordCategories.at( _num ); category->setName( _name->getValue() ); category->setDescription( _description->getValue() ); category->setRace( _race->currentItem() ); category->setEvolution( ATTACK, _attack->getValue() ); category->setEvolution( DEFENSE, _defense->getValue() ); category->setEvolution( POWER, _power->getValue() ); category->setEvolution( KNOWLEDGE, _knowledge->getValue() ); emit sig_changed(); } } void SectionLordCategory::selectFirst() { save(); _num = 0; init(); } void SectionLordCategory::selectPrevious() { save(); _num = std::max( 0, _num - 1 ); init(); } void SectionLordCategory::selectNext() { save(); _num = std::min( (int)DataTheme.lordCategories.count() - 1, _num + 1 ); init(); } void SectionLordCategory::selectLast() { save(); _num = DataTheme.lordCategories.count() - 1; init(); } void SectionLordCategory::selectNew() { save(); LordCategoryModel * category = new LordCategoryModel(); _num = DataTheme.lordCategories.count(); DataTheme.lordCategories.append( category ); clear(); } void SectionLordCategory::selectDel() { if( DataTheme.lordCategories.count() > 1 ) { DataTheme.lordCategories.remove( _num ); _num = std::min( _num, (int)DataTheme.lordCategories.count() - 1 ); init(); } } attal-src-1.0-rc2/themeEditor/sectionLordCategory.h0000644000175000017500000000405710047406376020076 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionLordCategory.h ** section for editing lord categories ** ** Version : $Id: sectionLordCategory.h,v 1.2 2004/05/09 10:50:38 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 08/05/2004 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONLORDCATEGORY_H #define SECTIONLORDCATEGORY_H // generic include files // include files for QT // application specific include files #include "themeEditor/sectionWidget.h" /* ------------------------------ * SectionLordCategory * ------------------------------ */ class SectionLordCategory: public GenericSection { Q_OBJECT public: /** Constructor */ SectionLordCategory( QWidget * parent = 0, const char * name = 0 ); /** Updates data */ void updateData(); /** Selects the first item */ void selectFirst(); /** Selects the previous item */ void selectPrevious(); /** Selects the next item */ void selectNext(); /** Selects the last item */ void selectLast(); /** Creates new item */ void selectNew(); /** Deletes current item */ void selectDel(); /** Clears the section */ void clear(); /** Initializes the section */ void init(); /** Saves the data */ void save(); signals: /** Signal when stg change */ void sig_changed(); protected: int _num; AskString * _name, * _description; AskCombo * _race; AskInt * _attack, * _defense, * _power, * _knowledge; }; #endif // SECTIONLORDCATEGORY_H attal-src-1.0-rc2/themeEditor/sectionMachine.cpp0000644000175000017500000000763210522705153017372 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionMachine.cpp ** section for specifying war machines ** ** Version : $Id: sectionMachine.cpp,v 1.8 2006/11/03 18:28:59 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 28/11/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionMachine.h" // generic include files #include // include files for QT #include // application specific include files #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libCommon/warMachine.h" #include "libClient/imageTheme.h" extern QString IMAGE_PATH; SectionMachine::SectionMachine( QWidget * parent, const char * name ) : GenericSection( parent, name ) { _num = 0; setTitle( tr( "War Machine" ) ); QVBoxLayout * layout = new QVBoxLayout( _mainWidget ); layout->setMargin( 5 ); layout->setSpacing( 5 ); _name = new AskString( tr( "Name: " ), _mainWidget ); layout->addWidget( _name ); _type = new AskInt( tr( "Type: " ), _mainWidget ); _type->setMinValue( 0 ); _type->setMaxValue( 3 ); layout->addWidget( _type ); _param1 = new AskInt( tr( "Param (1): " ), _mainWidget ); _param1->setMinValue( 0 ); _param1->setMaxValue( 3 ); layout->addWidget( _param1 ); _params = new AskIntList( _mainWidget ); _params->setLabel( tr( "Params: " ) ); //_params->setMinValue( 0 ); //_param1->setMaxValue( 3 ); layout->addWidget( _params ); _icon = new AskPixmap( true, "", tr( "Icon: " ), _mainWidget ); layout->addWidget( _icon ); _item = new AskPixmap( true, "", tr( "Item: " ), _mainWidget ); layout->addWidget( _item ); layout->addStretch( 1 ); layout->activate(); init(); } void SectionMachine::clear() { _name->setValue( "" ); _type->setValue( 0 ); _param1->setValue( 0 ); } void SectionMachine::init() { if( (int)DataTheme.machines.count() > _num ) { WarMachine * machine = DataTheme.machines.at( _num ); _name->setValue( machine->getName() ); _type->setValue( machine->getType() ); _param1->setValue( machine->getParam( 0 ) ); QString dest; dest = IMAGE_PATH + QString( "machines/machineIcon_" ) + QString::number( _num ) + QString( ".png" ); _icon->setDestination( dest ); dest = IMAGE_PATH + QString( "machines/machineItem_" ) + QString::number( _num ) + QString( ".png" ); _item->setDestination( dest ); } } void SectionMachine::save() { if( (int)DataTheme.machines.count() > _num ) { WarMachine * machine = DataTheme.machines.at( _num ); machine->setName( _name->getValue() ); machine->setType( (WarMachine::MachineType)_type->getValue() ); machine->addParam0( _param1->getValue() ); _icon->save(); _item->save(); } } void SectionMachine::selectFirst() { save(); _num = 0; init(); } void SectionMachine::selectPrevious() { save(); _num = std::max( 0, _num - 1 ); init(); } void SectionMachine::selectNext() { save(); _num = std::min( int(DataTheme.artefacts.count() - 1), _num + 1 ); init(); } void SectionMachine::selectLast() { save(); _num = DataTheme.artefacts.count() - 1; init(); } void SectionMachine::selectNew() { save(); WarMachine * machine = new WarMachine(); _num = DataTheme.machines.count(); DataTheme.machines.append( machine ); clear(); } void SectionMachine::selectDel() { if( DataTheme.machines.count() > 0 ) { delete DataTheme.machines.takeAt( _num ); _num = std::min( _num, DataTheme.machines.count() - 1 ); init(); } } attal-src-1.0-rc2/themeEditor/sectionMachine.h0000644000175000017500000000364507720664043017047 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionMachine.h ** section for specifying war machines ** ** Version : $Id: sectionMachine.h,v 1.2 2003/08/20 12:22:59 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 28/11/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONMACHINE_H #define SECTIONMACHINE_H // generic include files // include files for QT // application specific include files #include "sectionWidget.h" /* ------------------------------ * SectionArtefact * ------------------------------ */ /** comment for the class */ class SectionMachine : public GenericSection { Q_OBJECT public: /** Constructor */ SectionMachine( QWidget * parent = 0, const char * name = 0 ); /** Selects the first item */ void selectFirst(); /** Selects the previous item */ void selectPrevious(); /** Selects the nextt item */ void selectNext(); /** Selects the last item */ void selectLast(); /** Creates a new item */ void selectNew(); /** Deletes the current item */ void selectDel(); /** Clears the section */ void clear(); /** Inits the section */ void init(); /** Saves the section */ void save(); private: AskString * _name; AskInt * _type, * _param1; AskPixmap * _icon, * _item; AskIntList * _params; int _num; }; #endif // SECTIONARTEFACT_H attal-src-1.0-rc2/themeEditor/sectionRessource.cpp0000644000175000017500000001042510717366360020003 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionRessource.cpp ** section specifying resources ** ** Version : $Id: sectionRessource.cpp,v 1.14 2007/11/16 19:18:08 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 03/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionRessource.h" // generic include files // include files for QT #include #include #include #include #include // application specific include files #include "libCommon/dataTheme.h" #include "libCommon/log.h" #include "libClient/gui.h" extern QString IMAGE_PATH; SectionResource::SectionResource( QWidget * parent, const char * name ) : GenericSection( parent, name ) { _num = 0; setTitle( tr( "Resource" ) ); QVBoxLayout * layout = new QVBoxLayout( _mainWidget ); layout->setMargin( 5 ); layout->setSpacing( 5 ); _name = new AskString( tr( "Name: " ), _mainWidget ); layout->addWidget( _name ); _icon = new AskPixmap( true, "", tr( "Icon: " ), _mainWidget ); layout->addWidget( _icon ); _smallIcon = new AskPixmap( true, "", tr( "Small icon: " ), _mainWidget ); layout->addWidget( _smallIcon ); _comboInAct = new QComboBox( this ); _comboInAct->addItem( tr( "Local Preservable" ) ); _comboInAct->addItem( tr( "Local Not Preservable" ) ); _comboInAct->addItem( tr( "Global Preservable" ) ); _comboInAct->addItem( tr( "Global Not Preservable" ) ); FIXEDSIZE( _comboInAct ); layout->addWidget( _comboInAct ); layout->addStretch( 1 ); layout->activate(); init(); } void SectionResource::clear() { _name->setValue( "" ); _icon->setValue( "" ); _smallIcon->setValue( "" ); } void SectionResource::save() { if( DataTheme.resources.count() > _num ) { ResourceModel * ress = DataTheme.resources.at( _num ); ress->setResourceName( _name->getValue() ); ress->setType((ResourceModel::ResourceType) _comboInAct->currentIndex()); QString dest = _icon->getValue(); dest.remove( IMAGE_PATH ); ress->setFileName( dest ); _icon->setDestination( dest ); QString dest2 = _smallIcon->getValue(); dest2.remove( IMAGE_PATH ); ress->setSmallFileName( dest2 ); _smallIcon->setDestination( dest2 ); _icon->save(); _smallIcon->save(); DataTheme.resources.save(); } } void SectionResource::init() { if( DataTheme.resources.count() > _num ) { ResourceModel * ress = DataTheme.resources.at( _num ); QString es = ress->getResourceName(); _name->setValue( es ); _comboInAct->setCurrentIndex((uint) ress->getType()); QString dest = IMAGE_PATH + ress->getFileName(); TRACE("dest %s ", dest.toLatin1().constData() ); _icon->setDestination( dest ); dest = IMAGE_PATH + ress->getSmallFileName(); TRACE("dest2 %s ", dest.toLatin1().constData() ); _smallIcon->setDestination( dest ); } } void SectionResource::selectFirst() { save(); _num = 0; init(); } void SectionResource::selectPrevious() { save(); _num = std::max( 0, _num - 1 ); init(); } void SectionResource::selectNext() { save(); _num = std::min( DataTheme.resources.count() - 1, _num + 1 ); init(); } void SectionResource::selectLast() { save(); _num = DataTheme.resources.count() - 1; init(); } void SectionResource::selectNew() { save(); ResourceModel * resource = new ResourceModel(); _num = DataTheme.resources.count(); resource->setId( _num ); DataTheme.resources.append( resource ); clear(); } void SectionResource::selectDel() { if( DataTheme.resources.count() > 0 ) { TRACE(" _num %d", _num); delete DataTheme.resources.takeAt( _num ); _num = std::min( _num, DataTheme.resources.count() - 1 ); for( int i = 0; i < DataTheme.resources.count(); i++ ) { ResourceModel * ress = DataTheme.resources.at( i ); ress->setId( i ); } init(); } } attal-src-1.0-rc2/themeEditor/sectionRessource.h0000644000175000017500000000377510713710123017444 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionRessource.h ** section specifying ressources ** ** Version : $Id: sectionRessource.h,v 1.8 2007/11/05 21:51:15 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 03/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONRESSOURCE_H #define SECTIONRESSOURCE_H // generic include files // include files for QT #include #include // application specific include files #include "themeEditor/sectionWidget.h" class QPushButton; class RessourcePresentation; /* ------------------------------ * SectionRessource * ------------------------------ */ /** comment for the class */ class SectionResource : public GenericSection { Q_OBJECT public: /** Constructor */ SectionResource( QWidget * parent = 0, const char * name = 0 ); /** Selects the first item */ void selectFirst(); /** Selects the previous item */ void selectPrevious(); /** Selects the next item */ void selectNext(); /** Selects the last item */ void selectLast(); /** Creates new item */ void selectNew(); /** Deletes current item */ void selectDel(); /** Clears the section */ void clear(); /** Initialize the section */ void init(); /** Saves the data */ void save(); private: int _num; AskString * _name; AskPixmap * _icon, * _smallIcon; QComboBox * _comboInAct; }; #endif // SECTIONRESSOURCE_H attal-src-1.0-rc2/themeEditor/sectionSelector.cpp0000644000175000017500000001307010671020145017573 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionSelector.cpp ** main widget, allows modif in diff theme sections ** ** Version : $Id: sectionSelector.cpp,v 1.11 2007/09/09 16:33:41 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionSelector.h" // generic include files // include files for QT #include // application specific include files #include "sectionArtefact.h" #include "sectionBuilding.h" #include "sectionBase.h" #include "sectionCreature.h" #include "sectionDecoration.h" #include "sectionExperience.h" #include "sectionGeneral.h" #include "sectionGround.h" #include "sectionLord.h" #include "sectionLordCategory.h" #include "sectionMachine.h" #include "sectionRessource.h" #include "sectionTeam.h" class AttalScrollView : public QScrollArea { public: /** Constructor */ AttalScrollView( QWidget * parent = 0 ); void setSection( Section * section ); Section * getSection() { return _section; } protected: Section * _section; }; AttalScrollView::AttalScrollView( QWidget * parent ) : QScrollArea( parent ) { _section = 0; setWidgetResizable(true); } void AttalScrollView::setSection( Section * section ) { _section = section; //addChild( section ); setWidget( section ); } // // ----- SectionSelector // SectionSelector::SectionSelector( QWidget * parent, const char * name ) : QTabWidget( parent ) { setWindowTitle( QString ( name )); AttalScrollView * viewGeneral = new AttalScrollView( 0 ); _general = new SectionGeneral( 0, "general" ); viewGeneral->setSection( _general ); addTab( viewGeneral, tr( "General" ) ); AttalScrollView * viewArtefact = new AttalScrollView( 0 ); _artefact = new SectionArtefact( 0, "artefact" ); viewArtefact->setSection( _artefact ); addTab( viewArtefact, tr( "Artefacts" ) ); AttalScrollView * viewTeam = new AttalScrollView( 0 ); _team = new SectionTeam( 0, "team" ); viewTeam->setSection( _team ); addTab( viewTeam, tr( "Teams" ) ); AttalScrollView * viewBase = new AttalScrollView( 0 ); _base = new SectionBase( 0, "base" ); viewBase->setSection( _base ); addTab( viewBase, tr( "Bases" ) ); AttalScrollView * viewBuilding = new AttalScrollView( 0 ); _building = new SectionBuilding( 0, "building" ); viewBuilding->setSection( _building ); addTab( viewBuilding, tr( "Buildings" ) ); AttalScrollView * viewCreature = new AttalScrollView( 0 ); _creature = new SectionCreature( 0, "creatures" ); viewCreature->setSection( _creature ); addTab( viewCreature, tr( "Creatures" ) ); AttalScrollView * viewDecoration = new AttalScrollView( 0 ); _decoration = new SectionDecoration( 0, "decoration" ); viewDecoration->setSection( _decoration ); addTab( viewDecoration, tr( "Decorations" ) ); AttalScrollView * viewGround = new AttalScrollView( 0 ); _ground = new SectionGround( 0, "ground" ); viewGround->setSection( _ground ); addTab( viewGround, tr( "Grounds" ) ); AttalScrollView * viewLordCategory = new AttalScrollView( 0 ); _lordCategories = new SectionLordCategory( 0, "lord categories" ); viewLordCategory->setSection( _lordCategories ); addTab( viewLordCategory, tr( "Lord Categories" ) ); AttalScrollView * viewLord = new AttalScrollView( 0 ); _lord = new SectionLord( 0, "lords" ); viewLord->setSection( _lord ); addTab( viewLord, tr( "Lords" ) ); AttalScrollView * viewExperience = new AttalScrollView( 0 ); _experience = new SectionExperience( 0, "experience" ); viewExperience->setSection( _experience ); addTab( viewExperience, tr( "Levels" ) ); AttalScrollView * viewResource = new AttalScrollView( 0 ); _resource = new SectionResource( 0, "resources" ); viewResource->setSection( _resource ); addTab( viewResource, tr( "Resources" ) ); AttalScrollView * viewMachine = new AttalScrollView( 0 ); _machine = new SectionMachine( 0, "machines" ); viewMachine->setSection( _machine ); addTab( viewMachine, tr( "War Machines" ) ); connect( this, SIGNAL( currentChanged( int ) ), SLOT( slot_changed( int ) ) ); connect( _creature, SIGNAL( sig_changed() ), SLOT( slot_creaturesChanged() ) ); connect( _lordCategories, SIGNAL( sig_changed() ), SLOT( slot_lordCategoryChanged() ) ); connect( _general, SIGNAL( sig_changed() ), SLOT( slot_generalChanged() ) ); _current = _general; } void SectionSelector::save() { _current->save(); } void SectionSelector::saveAll() { _lordCategories->save(); _general->save(); _artefact->save(); _team->save(); _building->save(); _creature->save(); _decoration->save(); _ground->save(); _experience->save(); _resource->save(); _machine->save(); _base->save(); _lord->save(); } void SectionSelector::slot_changed( int index ) { QWidget * widg = widget( index ); _current->save(); _current = ((AttalScrollView *)widg)->getSection(); } void SectionSelector::slot_creaturesChanged() { _lordCategories->updateData(); _lord->updateData(); } void SectionSelector::slot_generalChanged() { _base->updateData(); } void SectionSelector::slot_lordCategoryChanged() { _lord->updateData(); } attal-src-1.0-rc2/themeEditor/sectionSelector.h0000644000175000017500000000472410671020145017246 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionSelector.h ** main widget, allows modif in diff theme sections ** ** Version : $Id: sectionSelector.h,v 1.7 2007/09/09 16:33:41 lusum Exp $ ** ** Author(s) : Pascal Audoux - Sardi Carlo ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONSELECTOR_H #define SECTIONSELECTOR_H // generic include files // include files for QT #include // application specific include files class Section; class SectionBase; class SectionLord; class SectionLordCategory; class SectionGeneral; class SectionArtefact; class SectionTeam; class SectionBuilding; class SectionCreature; class SectionDecoration; class SectionGround; class SectionExperience; class SectionResource; class SectionMachine; /** ------------------------------ * SectionSelector ** ------------------------------ */ class SectionSelector : public QTabWidget { Q_OBJECT public: /** Constructor */ SectionSelector( QWidget * parent = 0, const char * name = 0 ); /** Saves the sections */ void save(); /** Saves all the sections */ void saveAll(); public slots: /** Slot if something changed */ void slot_changed( int index ); /** Slot if creatures changed */ void slot_creaturesChanged(); /** Slot if general attributes changed */ void slot_generalChanged(); /** Slot if lord categories attributes changed */ void slot_lordCategoryChanged(); private: Section * _current; SectionLordCategory * _lordCategories; SectionGeneral * _general; SectionArtefact * _artefact; SectionTeam * _team; SectionBuilding * _building; SectionCreature * _creature; SectionDecoration * _decoration; SectionGround * _ground; SectionExperience * _experience; SectionResource * _resource; SectionMachine * _machine; SectionBase * _base; SectionLord * _lord; }; #endif // SECTIONSELECTOR_H attal-src-1.0-rc2/themeEditor/sectionTeam.cpp0000644000175000017500000000777210522705157016725 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionTeam.cpp ** section for specifying team (flag, color) ** ** Version : $Id: sectionTeam.cpp,v 1.9 2006/11/03 18:29:03 fdarling Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 26/08/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionTeam.h" // generic include files #include // include files for QT #include #include #include #include #include // application specific include files #include "libCommon/log.h" #include "libCommon/dataTheme.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" extern QString IMAGE_PATH; SectionTeam::SectionTeam( QWidget * parent , const char * name ) : GenericSection( parent, name ) { _num = 0; _red = 0; _green = 0; _blue = 0; setTitle( tr( "Team" ) ); _name = new AskString( tr( "Name: " ), _mainWidget ); _pbColor = new QPushButton( tr( "Color" ), _mainWidget ); FIXEDSIZE( _pbColor ); _flag = new AskPixmap( true, "", tr( "Flag: " ), _mainWidget ); QVBoxLayout * layout = new QVBoxLayout( _mainWidget ); layout->setMargin( 5 ); layout->setSpacing( 5 ); layout->addWidget( _name ); layout->addWidget( _pbColor, 0, Qt::AlignLeft ); layout->addWidget( _flag ); layout->addStretch( 1 ); layout->activate(); init(); connect( _pbColor, SIGNAL( clicked() ), SLOT( slot_color() ) ); } void SectionTeam::slot_color() { QColor col = QColorDialog::getColor( QColor( _red, _green, _blue ), this ); if( col.isValid() ) { _red = col.red(); _green = col.green(); _blue = col.blue(); QPalette p = _pbColor->palette(); p.setColor( QPalette::Button, col ); _pbColor->setPalette( p ); } } void SectionTeam::clear() { _name->setValue( QString( tr( "Team" ) ) + QString::number( _num + 1 ) ); _red = 0; _green = 0; _blue = 0; QPalette palette; palette.setColor(_pbColor->backgroundRole(), QColor( 0, 0, 0 )); _pbColor->setPalette(palette); _flag->setValue( "" ); } void SectionTeam::init() { if( DataTheme.decorations.count() > 0 ) { GenericTeam * team = DataTheme.teams.at( _num ); _name->setValue( team->getName() ); _red = team->getRed(); _green = team->getGreen(); _blue = team->getBlue(); QPalette palette; palette.setColor(_pbColor->backgroundRole(), QColor( _red, _green, _blue )); _pbColor->setPalette(palette); QString dest = IMAGE_PATH + QString( "players/flag_" ) + QString::number( _num ) + QString( ".png" ); _flag->setDestination( dest ); } } void SectionTeam::save() { if( DataTheme.teams.count() > 0 ) { GenericTeam * team = DataTheme.teams.at( _num ); team->setName( _name->getValue() ); team->setRed( _red ); team->setGreen( _green ); team->setBlue( _blue ); _flag->save(); } } void SectionTeam::selectFirst() { save(); _num = 0; init(); } void SectionTeam::selectPrevious() { save(); _num = std::max( 0, _num - 1 ); init(); } void SectionTeam::selectNext() { save(); _num = std::min( (int)DataTheme.teams.count() - 1, _num + 1 ); init(); } void SectionTeam::selectLast() { save(); _num = DataTheme.teams.count() - 1; init(); } void SectionTeam::selectNew() { save(); _num = DataTheme.teams.count(); GenericTeam * team = new GenericTeam( _num ); DataTheme.teams.append( team ); clear(); } void SectionTeam::selectDel() { if( DataTheme.teams.count() > 0 ) { delete DataTheme.teams.takeAt( _num ); _num = std::min( _num, DataTheme.teams.count() - 1 ); init(); } } attal-src-1.0-rc2/themeEditor/sectionTeam.h0000644000175000017500000000370107673141246016364 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionTeam.h ** section for specifying teams (flag, color) ** ** Version : $Id: sectionTeam.h,v 1.1.1.1 2003/06/15 19:01:58 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 26/08/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONTEAM_H #define SECTIONTEAM_H // generic include files // include files for QT // application specific include files #include "sectionWidget.h" /* ------------------------------ * SectionTeam * ------------------------------ */ /** comment for the class */ class SectionTeam : public GenericSection { Q_OBJECT public: /** Constructor */ SectionTeam( QWidget * parent = 0, const char * name = 0 ); /** Selects the first item */ void selectFirst(); /** Selects teh previous item */ void selectPrevious(); /** Selects the next item */ void selectNext(); /** Selects the last item */ void selectLast(); /** Creates new item */ void selectNew(); /** Deletes current item */ void selectDel(); /** Clears the section */ void clear(); /** Initialize the section */ void init(); /** Saves the data */ void save(); public slots: void slot_color(); private: int _num; AskString * _name; QPushButton * _pbColor; int _red, _green, _blue; AskPixmap * _flag; }; #endif // SECTIONDECORATION_H attal-src-1.0-rc2/themeEditor/sectionWidget.cpp0000644000175000017500000000753610523355716017263 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionWidget.cpp ** widgets for building sections ** ** Version : $Id: sectionWidget.cpp,v 1.8 2006/11/05 12:40:46 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "sectionWidget.h" // generic include files // include files for QT #include #include #include #include #include #include // application specific include files #include "libClient/gui.h" SelectionWidget::SelectionWidget( QWidget * parent, const char * /*name*/ ) : QFrame( parent ) { QHBoxLayout * layout = new QHBoxLayout( this ); setFrameStyle( QFrame::Box | QFrame::Raised ); layout->addSpacing( 5 ); QPushButton * butFirst = new QPushButton( "|<", this ); FIXEDSIZE( butFirst ); layout->addWidget( butFirst ); QPushButton * butPrevious = new QPushButton( "<", this ); FIXEDSIZE( butPrevious ); layout->addWidget( butPrevious ); layout->addSpacing( 5 ); _labTitle = new QLabel( tr( "None" ), this ); FIXEDSIZE( _labTitle ); layout->addWidget( _labTitle ); layout->addSpacing( 5 ); QPushButton * butNext = new QPushButton( ">", this ); FIXEDSIZE( butNext ); layout->addWidget( butNext ); QPushButton * butLast = new QPushButton( ">|", this ); FIXEDSIZE( butLast ); layout->addWidget( butLast ); layout->addSpacing( 5 ); layout->addStretch( 1 ); QPushButton * butNew = new QPushButton( "New" , this ); FIXEDSIZE( butNew ); layout->addWidget( butNew ); layout->addSpacing( 5 ); QPushButton * butDel = new QPushButton( "Del", this ); FIXEDSIZE( butDel ); layout->addWidget( butDel ); layout->addSpacing( 5 ); layout->activate(); setMinimumHeight( 40 ); connect( butFirst, SIGNAL( clicked() ), SIGNAL( sig_first() ) ); connect( butPrevious, SIGNAL( clicked() ), SIGNAL( sig_previous() ) ); connect( butNext, SIGNAL( clicked() ), SIGNAL( sig_next() ) ); connect( butLast, SIGNAL( clicked() ), SIGNAL( sig_last() ) ); connect( butNew, SIGNAL( clicked() ), SIGNAL( sig_new() ) ); connect( butDel, SIGNAL( clicked() ), SIGNAL( sig_del() ) ); } void SelectionWidget::setTitle( QString title ) { _labTitle->setText( title ); FIXEDSIZE( _labTitle ); } /************************************************************************/ Section::Section( QWidget * parent, const char * /* name*/ ) : QWidget( parent ) { } /************************************************************************/ GenericSection::GenericSection( QWidget * parent, const char * name ) : Section( parent, name ) { QVBoxLayout * layout = new QVBoxLayout( this ); _select = new SelectionWidget( this, "select" ); layout->addWidget( _select ); layout->addSpacing( 5 ); _mainWidget = new QWidget( this ); _mainWidget->setWindowTitle( "main widget" ); layout->addWidget( _mainWidget, 1 ); layout->addSpacing( 5 ); layout->activate(); connect( _select, SIGNAL( sig_first() ), SLOT( slot_first() ) ); connect( _select, SIGNAL( sig_previous() ), SLOT( slot_previous() ) ); connect( _select, SIGNAL( sig_next() ), SLOT( slot_next() ) ); connect( _select, SIGNAL( sig_last() ), SLOT( slot_last() ) ); connect( _select, SIGNAL( sig_new() ), SLOT( slot_new() ) ); connect( _select, SIGNAL( sig_del() ), SLOT( slot_del() ) ); } attal-src-1.0-rc2/themeEditor/sectionWidget.h0000644000175000017500000000625210331243516016711 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** sectionWidget.h ** widgets for building sections ** ** Version : $Id: sectionWidget.h,v 1.2 2005/10/30 22:21:02 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef SECTIONWIDGET_H #define SECTIONWIDGET_H // generic include files // include files for QT #include #include #include #include #include #include #include // application specific include files #include "libClient/askWidget.h" class QLabel; class QComboBox; class QPixmap; class QPushButton; /* ------------------------------ * SectionWidget * ------------------------------ */ class SelectionWidget : public QFrame { Q_OBJECT public: /** Constructor */ SelectionWidget( QWidget * parent = 0, const char * name = 0 ); void setTitle( QString title ); signals: void sig_first(); void sig_previous(); void sig_next(); void sig_last(); void sig_new(); void sig_del(); private: QLabel * _labTitle; }; /** Pure virtual class for sections */ class Section : public QWidget { public: Section( QWidget * parent = 0, const char * name = 0 ); virtual void save() = 0; }; /** Pure virtual class with usefull api for section */ class GenericSection : public Section { Q_OBJECT public: /** Constructor */ GenericSection( QWidget * parent = 0, const char * name = 0 ); /** Selects the first item */ virtual void selectFirst() = 0; /** Selects the previous item */ virtual void selectPrevious() = 0; /** Selects the next item */ virtual void selectNext() = 0; /** Selects the last item */ virtual void selectLast() = 0; /** Creates new item */ virtual void selectNew() = 0; /** Deletes current item */ virtual void selectDel() = 0; /** Saves the data */ virtual void save() = 0; /** Sets title to the section */ void setTitle( QString title ) { _select->setTitle( title ); } public slots: /** Slot when 'First' button is clicked */ void slot_first() { selectFirst(); } /** Slot when 'Previous' button is clicked */ void slot_previous() { selectPrevious(); } /** Slot when 'Next' button is clicked */ void slot_next() { selectNext(); } /** Slot when 'Last' button is clicked */ void slot_last() { selectLast(); } /** Slot when 'New' button is clicked */ void slot_new() { selectNew(); } /** Slot when 'Del' button is clicked */ void slot_del() { selectDel(); } protected: SelectionWidget * _select; QWidget * _mainWidget; }; #endif // SECTIONWIDGET_H attal-src-1.0-rc2/themeEditor/themeEditor.cpp0000644000175000017500000000453110630060445016703 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** themeEditor.cpp ** main file for the theme editor ** ** Version : $Id: themeEditor.cpp,v 1.20 2007/06/01 18:10:45 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ // include files for QT #include #include #include #include #include #include #include // application specific includes #include "conf.h" #include "libCommon/attalCommon.h" #include "libCommon/dataTheme.h" #include "libCommon/log.h" #include "libClient/gui.h" #include "themeEditor/themeInterface.h" extern QString IMAGE_PATH; extern QString THEME; extern QString THEME_PATH; int main( int argc, char **argv ) { QDir trfolder; trfolder = translationsDir(); QApplication app( argc, argv ); QTranslator translator( 0 ); translator.load( QString("theme_editor_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibcomm( 0 ); translatorlibcomm.load( QString("attal_libcommon_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); QTranslator translatorlibclient( 0 ); translatorlibclient.load( QString("attal_libclient_") + QLocale::system().name().section('_', 0,0 ), trfolder.absolutePath() ); app.installTranslator( &translator ); app.installTranslator( &translatorlibcomm ); app.installTranslator( &translatorlibclient ); if (parseArgs( argc, argv, AttalCommon::ATTALTHEMEEDITOR) ) { return 1; } useTheme(); app.setWindowIcon(QIcon( IMAGE_PATH + "misc/ico_attal-theme-editor.png")); if (app.windowIcon().isNull()) qDebug("Window icon is null!"); ThemeInterface edit; //app.setMainWidget( &edit ); edit.show(); return app.exec(); } attal-src-1.0-rc2/themeEditor/themeEditor.pro0000644000175000017500000000432410740437744016735 0ustar aaaaTEMPLATE = app include( ../config.pro ) INCLUDEPATH += .. LIBS += -L.. unix:LIBS += -lAttalClient unix:LIBS += -lAttalCommon win32:LIBS += -lAttalClient9 win32:LIBS += -lAttalCommon9 contains( DEFINES, WITH_SOUND ) { win32:INCLUDEPATH += "$$quote($${SDL_DIR})\include" contains( CONFIG, staticlib ) { LIBS += -lSDL LIBS += -lSDL_mixer } } SOURCES += artefactAction.cpp SOURCES += askDiversification.cpp SOURCES += buildingAction.cpp SOURCES += creatureAnimation.cpp SOURCES += decorationEffect.cpp SOURCES += editWidget.cpp SOURCES += mapDispositionEditor.cpp SOURCES += previewBaseDialog.cpp SOURCES += sectionArtefact.cpp SOURCES += sectionBase.cpp SOURCES += sectionBuilding.cpp SOURCES += sectionCreature.cpp SOURCES += sectionDecoration.cpp SOURCES += sectionExperience.cpp SOURCES += sectionGeneral.cpp SOURCES += sectionGround.cpp SOURCES += sectionLord.cpp SOURCES += sectionLordCategory.cpp SOURCES += sectionMachine.cpp SOURCES += sectionRessource.cpp SOURCES += sectionSelector.cpp SOURCES += sectionTeam.cpp SOURCES += sectionWidget.cpp SOURCES += themeEditor.cpp SOURCES += themeInterface.cpp HEADERS += artefactAction.h HEADERS += askDiversification.h HEADERS += buildingAction.h HEADERS += creatureAnimation.h HEADERS += decorationEffect.h HEADERS += editWidget.h HEADERS += mapDispositionEditor.h HEADERS += previewBaseDialog.h HEADERS += sectionArtefact.h HEADERS += sectionBase.h HEADERS += sectionBuilding.h HEADERS += sectionCreature.h HEADERS += sectionDecoration.h HEADERS += sectionExperience.h HEADERS += sectionGeneral.h HEADERS += sectionGround.h HEADERS += sectionLord.h HEADERS += sectionLordCategory.h HEADERS += sectionMachine.h HEADERS += sectionRessource.h HEADERS += sectionSelector.h HEADERS += sectionTeam.h HEADERS += sectionWidget.h HEADERS += themeInterface.h TRANSLATIONS += ../i18n/de/theme_editor_de.ts TRANSLATIONS += ../i18n/fr/theme_editor_fr.ts TRANSLATIONS += ../i18n/ru/theme_editor_ru.ts TRANSLATIONS += ../i18n/it/theme_editor_it.ts DESTDIR = .. OBJECTS_DIR=./obj MOC_DIR=./moc TARGET = attal-theme-editor unix:!macx { QMAKE_LFLAGS += -Wl,-rpath,. } unix { target.path = $${ATT_PREFIX}/bin/ INSTALLS += target } QT += xml win32 { contains( CONFIG, debug ) { CONFIG += console } } attal-src-1.0-rc2/themeEditor/themeInterface.cpp0000644000175000017500000001122010762316275017361 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** mapInterface.cpp ** Manages the editor ** ** Version : $Id: themeInterface.cpp,v 1.19 2008/03/01 18:13:17 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "themeInterface.h" // include files for QT #include #include #include #include #include #include #include #include // application specific include files #include "conf.h" #include "libCommon/dataTheme.h" #include "libClient/aboutDialog.h" #include "libClient/gui.h" #include "libClient/imageTheme.h" #include "themeEditor/sectionSelector.h" extern QString IMAGE_PATH; extern QString DATA_PATH; extern QString THEME; ThemeInterface::ThemeInterface() { _help =NULL; initActions(); initMenuBar(); initStatusBar(); if( DataTheme.init() && ImageTheme.init() ) { _selector = new SectionSelector( this ); setCentralWidget( _selector ); } else { /// XXX: we could manage this better (later :) ) QMessageBox::critical( this, tr( "Can't load theme" ), tr( "Theme " ) + THEME + tr( " has not been loaded successfully" ) ); } resize( 600, 600 ); } ThemeInterface::~ThemeInterface() { //free before ImageTheme, after DataTheme (clear of ImageTheme depend on DataTheme data) ImageTheme.clear(); DataTheme.clear(); } void ThemeInterface::changeEvent ( QEvent * e ) { //used to replace setCaption switch (e->type()){ case QEvent::WindowTitleChange: { setWindowTitle( tr( "Theme editor for 'Attal - Lords of Doom'" ) ); } break; default: QWidget::changeEvent ( e ); break; } } void ThemeInterface::initStatusBar() { statusBar()->showMessage( tr( "Status Bar" ), 0 ); } void ThemeInterface::addAction( const QString & text, const QString & key, MENU_ACTIONS num, QSignalMapper * sigmap ) { QAction * action = new QAction( text, this ); action->setShortcut( QKeySequence( key ) ); _actions.insert( num, action ); sigmap->setMapping( action, num ); connect( action, SIGNAL( triggered() ), sigmap, SLOT( map() ) ); } void ThemeInterface::initActions() { _actions.resize( NB_ACTIONS ); QSignalMapper * sigmap = new QSignalMapper( this ); addAction( tr( "&New theme" ), tr( "CTRL+N" ), ACTION_NEW, sigmap ); addAction( tr( "&Open theme" ), tr( "CTRL+O" ), ACTION_OPEN, sigmap ); addAction( tr( "&Save theme" ), tr( "CTRL+S" ), ACTION_SAVE, sigmap ); addAction( tr( "&Quit" ), tr( "CTRL+Q" ), ACTION_QUIT, sigmap ); addAction( tr( "&Help" ), tr( "F1" ), ACTION_HELP, sigmap ); addAction( tr( "&About" ), tr( "CTRL+A" ), ACTION_ABOUT, sigmap ); connect( sigmap, SIGNAL( mapped( int ) ), SLOT( slot_actions( int ) ) ); _actions[ ACTION_NEW ]->setEnabled( false ); _actions[ ACTION_OPEN ]->setEnabled( false ); } void ThemeInterface::initMenuBar() { QMenu * menuFile = menuBar()->addMenu( tr( "&File" ) ); QMenu * menuHelp = menuBar()->addMenu( tr( "&Help" ) ); menuFile->addAction( _actions[ ACTION_NEW ] ); menuFile->addAction( _actions[ ACTION_OPEN ] ); menuFile->addAction( _actions[ ACTION_SAVE ] ); menuFile->addSeparator(); menuFile->addAction( _actions[ ACTION_QUIT ] ); menuHelp->addAction( _actions[ ACTION_HELP ] ); menuHelp->addAction( _actions[ ACTION_ABOUT ] ); } void ThemeInterface::slot_actions( int num ) { switch( num ) { case ACTION_NEW: _actions[ ACTION_SAVE ]->setEnabled( true ); break; case ACTION_OPEN: { QString filename; filename = QFileDialog::getOpenFileName( this, tr( "Open theme" ), "", "*.scn" ); if (!filename.isNull()) { } _actions[ ACTION_SAVE ]->setEnabled( true ); break; } case ACTION_SAVE: { _selector->saveAll(); DataTheme.save(); break; } case ACTION_QUIT: qApp->quit(); break; case ACTION_HELP: actionHelp(); break; case ACTION_ABOUT: { AboutDialog dialog( this ); dialog.exec(); } break; } } void ThemeInterface::actionHelp() { if( ! _help ) { _help = new DisplayHelp( this ); } _help->resize( 800, 600 ); _help->show(); } void ThemeInterface::slot_status( QString text ) { statusBar()->showMessage( text, 0 ); } attal-src-1.0-rc2/themeEditor/themeInterface.h0000644000175000017500000000420610762316300017021 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** themeInterface.h ** Manages the theme editor ** ** Version : $Id: themeInterface.h,v 1.8 2008/03/01 18:13:20 lusum Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 02/06/2001 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef THEMEINTERFACE_H #define THEMEINTERFACE_H // include files for QT #include #include #include // application specific include #include "libCommon/displayHelp.h" class QAction; class QSignalMapper; class SectionSelector; /* ------------------------------ * ThemeInterface * ------------------------------ */ class ThemeInterface : public QMainWindow { Q_OBJECT public: /** Constructor */ ThemeInterface(); /** Destructor */ ~ThemeInterface(); protected: virtual void changeEvent ( QEvent * e ); private: enum MENU_ACTIONS { ACTION_NEW, ACTION_OPEN, ACTION_SAVE, ACTION_QUIT, ACTION_HELP, ACTION_ABOUT, NB_ACTIONS }; /** Defines actions */ void initActions(); /** Defines menus */ void initMenuBar(); /** Defines statusBar */ void initStatusBar(); void actionHelp(); /** Add new action */ void addAction( const QString & text, const QString & key, MENU_ACTIONS num, QSignalMapper * sigmap ); public slots: /** Slot managing actions */ void slot_actions( int num ); /** Slot managing the status bar */ void slot_status( QString text ); private: SectionSelector * _selector; DisplayHelp * _help; QVector _actions; }; #endif // THEMEINTERFACE_H attal-src-1.0-rc2/.cvsignore0000644000175000017500000000027410111474571013460 0ustar aaaathemes *.opt *.plg *.scn *.so *.so.* *.qm Makefile attal-client attal-server theme-editor scenario-editor attal-campaign-editor attal-scenario-editor attal-theme-editor attal-ai devel.pro attal-src-1.0-rc2/AUTHORS0000644000175000017500000000122010605547376012534 0ustar aaaaAuthors and contributors to project Pascal Audoux : Developper - Specs Cyrille Verrier: Developper Gilles Oppeneau : Webmaster - Graphist - Specs Alexandre Lherault: Graphist (Cyberpunk) Marc Leyral : Medieval Theme - Graphist - Specs Morgan: Medieval Theme - Graphist - Specs Quentin Dusoulier: Developper Carlo Sardi: Mantainer, Developper, Alpha-tester Nickolay Semenov : Developper (from may 2003) Raphael Goulais : Debian packages Al Louzaouenn band: Music Forest Darling: Patches Tim Felgentreff: Graphist attal-src-1.0-rc2/COPYING0000644000175000017500000004312707674122724012531 0ustar aaaa GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. attal-src-1.0-rc2/HOWTOPLAY0000644000175000017500000001421510612703762012774 0ustar aaaa IMPORTANT: this file is obsolete, use HOWTOPLAY.html instead The goal of this file is to explain how to play with Attal! Summary I - Getting Started 1) Installation 2) Launching the game 3) Connecting players 4) Choose a scenario II - Playing 1) Generalities 2) Turn by turn game 3) Managing lords 4) Managing bases 4.1)Inside a base 5) Economic 6) Fight mode 7) End of game ******************************* ***** I - Getting Started ***** ******************************* 1) Installation First, install the game (read INSTALL for any question) 2) Launching the game Start the executables: You can launch : - the client: $ ./attal-client & - the server: $ ./attal-server & - the ia-client: $ ./attal-ai & IMPORTANT NOTE: all the executables need to find the theme (medieval theme for the moment) and so the folder 'themes', which have to contain the 'medieval' theme must be present in the current directory (where there are the binaries). If you have some problems to find libraries set the environment variable LD_LIBRARY_PATH to local directory like this: export LD_LIBRARY_PATH=. For the moment, if you want to play a scenario alone against one AI, you have to start attal-client, attal-server and attal-ai (you have to launch as many attal-ai as you need of AI players). Now is present the possibility to start the server from client (Fast Server action in menu file in attal-client) and to fill the others players of scenario with ai (action Fill with Ai in menu Game in attal-server). 3) Connecting players Connect your clients and AI to the server: attal-ai and attal-client have a menu with a 'connect' item (or use CTRL+C as shortcut). It requests you to set the IP adress of the server (if you are playing in local, you don't have to change anything). Each player connected is shown on the server interface. 4) Choose a scenario Choose a scenario in the server: By default, you have 2 demo scenarii directly available from the server interface but you can choose another one (the demo scenarii are not really exciting!). Default scenarii are available in /themes/medieval/scenarii You could find some new scenarii on our website (www.attal-thegame.org in the section 'd/l scenarii'). Of course, you can edit your own scenarii with the scenario editor provided with Attal Now click on 'Start' button in the server to launch the game. Each player has to play at his turn. ************************ ***** II - Playing ***** ************************ 1) Generalities In adventure mode, you manage your lords and bases. The interface is composed by: -menus, for global actions: quit, connect/disconnect, hide/show some elements of the interface -main view, which displays the map (adventure mode) -chat window, for talking with other players and also see some message from server -Mini-map where you can see the whole map (click on it for centering the main view where you want) -Tab window where you can have general information, see the list of your lords and see the list of your bases 2) Turn-by-turn game Attal is a turn by turn game, so you play only when it is your turn to. There is no time limitation for the moment... When it is not your turn to play, you can only chat with other player or, if you are attacked by another player, defend yourself (in fight mode) 3) Managing lords You can select a lord through the list of lords or on clicking on it in the main view Then you can make it move in clicking elsewhere on the map (you will see first a path on the ground and if you click again the lord will move). If you click twice on a lord (on the map or in the list), you can see the characteristics of the lord (and change its artefacts, its units...) If two 'friend' lords encounter, you can do some exchange between them (units, artefacts...) If they are opponent, they fight! (see (5 - Fight mode)) 4) Managing bases You can select a base through the list of bases or on clicking on it in the main view If you click twice on a base (on the map or in the list), you can see the inside of the base and act inside (add new buildings, buy units, trade in the market...) When a lord enter in a base, you automatically see the inside of the base. 4.1)Inside a base: Inside a base you have a market, where you can trade your resources, some building where you can buy some units, every week (but the time will customizable) and a building where you can build some other buildings (and sell it) When you buy an unit , it will be placed on the unit window (click on lord face (or no lord face) to activate this window) 5) Economic The economic part in Attal is quite complex: you have to manage bases , buildings , lord and units. All internals buildings and units can have a mantainment cost that is payed every week. The external building can produce a fixed number of resource or one random number between two ranges (RANDRESSOURCE), between zero and the coeff of resource, also the external buildings can give other bonus. Every base have a population: this population growth every week by a rate that depend on type of base. Every base loss population by a percentage value fixed by race every time the base change owner. The money (gold) give by a base is equal to his population, so take care to defend the most populated bases. Every base can have a market and these prices depend on type of base, so differents players have different strategies about resources. The prices of resources depend on type of base you own: you pay the best prices for resources if you onw bases of different races. All these proprieties are theme-dependant, so you can see that in theme-editor. 6) Fight mode When two opponent lords encounter, or if a lord attacks a creature stack on the map, the game enter in fight mode. It is a turn-by-turn fight, where you can move each lord's units on the ground. A current unit is automatically selected and has to be played. When the player who owns it has finished (make it move, or fight a neighbour unit...) the next unit is selected and so on... The fight is finished when a lord has lost all its units or when he flees. Then, the winner gain some experience and the game returns in adventure mode, normally. 7) End of the game If a player lost all its lords and bases, he has lost the game. attal-src-1.0-rc2/HOWTOPLAY.html0000644000175000017500000003744011015363146013740 0ustar aaaa

The goal of this file is to explain how to play with Attal!

Summary

I - Getting Started

  1. Installation

  2. Launching the game

  3. Start a game

  4. Connecting players (multiplayer)

  5. Choose a scenario

II - Playing

  1. Generalities

  2. Turn by turn game

  3. Managing lords

  4. Managing bases

  5. Economic

  6. Fight mode

  7. End of game

III - Editors

  1. Scenario Editor

  2. Theme Editor

IV - Server




I - Getting Started

1) Installation

First, install the game (read INSTALL for any question) You can use the installer in windows or use the binary data package on linux. Some distributions like ubuntu have an attal package available.

2) Launching the game

Start the executables:
You can launch :

  • Start simply the client:
    Linux:

    $ ./attal-client &

    Windows:

    attal-client

    If you want to start a multiplayer server game, start the server, the ai-client is started only for debugging purposes

  • the server:

    $ ./attal-server &
  • the ai-client:

    $ ./attal-ai &

IMPORTANT NOTE: all the executables need to find the theme (medieval theme for the moment) and so the folder 'themes', which have to contain the 'medieval' theme, is found if is:

  • present in the current directory (where there are the binaries) only if you play in local directory

  • can be set with --themepath switch at command line

  • can be set with environment variable ATTAL_THEME_PATH
    Using make install these steps are not necessary if the game is installed ( make install ).

3) Start a game

For linux only:
If you have some problems to find libraries set the environment variable LD_LIBRARY_PATH to local directory like this:

export LD_LIBRARY_PATH=.

If you want to play a scenario press startGame on file menu in client.
It appear the Start Game widget.

  • To start a new game, simply press Start Scenario and choose a predefined scenario.

  • To start a saved game, press Load Scenario

  • To start a campaign press Start Campaign

  • To load a campaign press Load Campaign
    It is also possible to start the server from client (Fast Server action in menu file in attal-client) and to fill the others players of scenario with ai (action Fill with Ai in menu Game in attal-server), this old behavior is present for debugging purposes.
    An internal Ai now autostart to fill lacking players at the start of game.

4) Connecting players (multiplayer)

Connect your clients to the server: attal-client have a menu with a 'connect' item (or use CTRL+C as shortcut).
It requests you to set the IP address of the server (if you are playing in local, you don't have to change anything).

Each player connected is shown on the server interface.

5) Choose a scenario (multiplayer)

Choose a scenario in the server:
By default, you have 2 demo scenarios directly available from the server interface but you can choose another one (the demo scenarios are not really exciting!).
Default scenarii are available in /themes/medieval/scenarii
You could find some new scenarii on our website (www.attal-thegame.org in the section 'd/l scenarii'). Of course, you can edit your own scenarii with the scenario editor provided with Attal.

Now click on 'Start' button in the server to launch the game. Each player has to play at his turn.

II - Playing

1) Menus

In adventure mode, you manage your lords and bases. The interface is composed by:

  • menus, for global actions:

    • File menu:

      • Start Game: start the game

      • Save Game: save game (only if is a local game)

      • End Game: end the game ( only if is a local game )

      • Connect to Server: connect to a remote server: you can choose the IP of server and the game that will appear in chat. Note: the name that you choose to connect will be saved for future connections.

      • Fast Server: old feature, is a method to start a multiplayer game in a faster way, starting the server interface from client.

      • Disconnect: disconnect to server

      • Quit: quit the game

    • Game menu:

      • Minimap: hide/show minimap

      • Fullscreen: hide/show chat, minimap e some info to make space for map.

      • Enable music: enable/disable music

      • Enable sound: enable/disable sound

      • Scenario Informations: show scenario objectives

  • Screen menu:

      • Force some game resolutions: free size, 800x600 , 1024x768, 1280x1024

    • Help menu:

      • Help: this document

      • About: some informations about the game

  • main view, which displays the map (adventure mode)

  • chat window, for talking with other players and also see some message from server

  • Mini-map where you can see the whole map (click on it for centering the main view where you want)

To move the lord on map you have to select lord in the list at the right and press the destination cell: if a cell is marked with a green X the cell is reachable in one turn, otherwise you have to pass turn and wait.

  • Pressing on bonus ( resource miniatures ) give you some help.

  • Pressing on creature can be dangerous: they have different behavior: they can fight or offer to join you.

  • Pressing on buildings you own the building that will add more resource or population.

  • Pressing on bases :

    • if you own the base, you simply enter

    • if is not owned by you enter in the base and add the base to your reign

    • if is owned by an enemy and an enemy lord is present, you will have to fight and win before enter.

2) Turn-by-turn game

Attal is a turn by turn game, so you play only when it is your turn to. There is no time limitation for the moment. Only some scenario could require it. When it is not your turn to play, you can only chat with other player or, if you are attacked by another player, defend yourself (in fight mode).

3) Managing lords

You can select a lord through the list of lords or on clicking on it in the main view. Then you can make it move in clicking elsewhere on the map (you will see first a path on the ground and if you click again the lord will move).
If you click twice on a lord (on the map or in the list), you can see the characteristics of the lord (and change his artefacts, his units...).
If two 'friend' lords encounter, you can do some exchange between them (units, artefacts...) but if they are opponent, they fight! (see (6 - Fight mode))

4) Managing bases

You can select a base through the list of bases or on clicking on it in the main view. If you click twice on a base (on the map or in the list), you can see the inside of the base and act inside (add new buildings, buy units, trade in the market).

You have some different building actions implemented:

  • Main building: you can buy other buildings

  • Market: where you can trade your resources

  • Tavern: buy lords

  • Castle: a complete list of all units available

  • Various building where you can buy units



New units are produced every monday (but it will be customizable), replacing old units available.
When you buy an unit, it will be placed on the unit window (click on lord face (or no lord face) to activate this window).

They are two lord status in a base: visitor and garrison: it is possible to have two lords in a base, one garrison and another visitor: it is possible to defend a base only if a garrison lord is present, otherwise all units produced are lost.

To set a lord garrison is necessary to place lord face on the base name in unit window.

5) Economic

The economic part in Attal is quite complex: you have to manage bases, buildings, lord and units. All internals buildings and units can have a maintenance cost that is paid every week.
The external building can produce a fixed number of resource or one random number between two ranges, zero and the coeff of ressource.

The external buildings can give other bonus or increment your population.
Every base have a population: the population growth every week by a ratio that based on base type. Every base lose population every time the base change owner by a percentage value based on base type.
The money (gold) give by to you is equal to your total population plus the money earned by some particular buildings like gold mines, so take care to defend the most populated bases. Every base can have a market and these prices depend on type of base, so different players have different strategies about resources.
The prices of resources depend on type of base you own: you pay the best prices for resources if you own bases of different races.
All these proprieties are theme-dependant, so you can see that in theme-editor.

6) Fight mode

When two opponent lords encounter, or if a lord attacks a creature stack on the map, the game enter in fight mode. It is a turn-by-turn fight, where you can move each lord's units on the ground.

To hit a unit you have to click on enemy unit ( not enemy cell ) and it appear a cursor with an hand-form. A forbidden cursor mean that is not possible to perform an action on this cell.
A current unit is automatically selected and has to be played. When the player who owns it has finished (make it move, or fight a neighbor unit...) the next unit is selected and so on.. The fight have an end when a lord lose all his units or when he flees. Then, the winner gain some experience and the game returns in adventure mode, as usual.

In fight mode they are some buttons on bottom left of interface: the feature currently implemented are flee ( the lord lose the fight ), wait ( pass unit turn ) and option.

In option dialog you can set three params: see/hide cells, animation active/not active, animations speed.

7) End of the game

If a player complete a quest or defeat all enemies he win. If a player don't complete the quest ( ex: time exhausted ) or lose all its lords and bases, he has lost the game.

III - Editors

1) Scenario Editor

ScenarioEditor is used to write or edit maps: you can create a map based on various elements.

You can load a map ( a scenario .scn extension or a saved map .gam extension ) and modify the map, the resources, the lords, etc.

( TODO)

2) Theme Editor

Attal is a themeable game: you can customize most part of the game: you can change parameters and even properties of single building.

ThemeEditor also allow you to write new themes: now the default theme is the medieval one.

This editor allow you to have a panoramic view on all the characteristics of themes.

(TODO)

IV – Server

Server can be managed in client chat window

Server commands:

/gameinfo : informations about the game

/gamelist : list players of a game

/list : list players connected to a server

/kick <player> : kick a player

/version : show server version



attal-src-1.0-rc2/INSTALL0000644000175000017500000000753310765065055012526 0ustar aaaaBinaries: Just make sure, that your enviroment variables are set as it said in HOWTOPLAY file and themes directory (or symbolic link to it) is set to the current directory, from you want to start Attal Sources: We are now using qmake for building Attal. For using qmake you must be sure that the environment variables QMAKESPEC and QTDIR are correctly sets. For more information, read the documentation given with qt about qmake. The sintax is: export QTDIR=path to qt Note that you will need to have (at least) qt 4.2.0 installed (lib and include files). Attal is tested with various gcc compilers, from gcc 3.2.2 to gcc 4 Note that for compile themes directory need to be placed in src2 directory If you have some problems to find libraries set the environment variable LD_LIBRARY_PATH to local directory like this: export LD_LIBRARY_PATH=. Now, do the following steps: $ qmake -o Makefile Makefile.pro $ make $ make install (as root) Or, better under unix, after setting QTDIR , do the following steps: $ ./autogen.sh $ make $ make install (as root) $ /sbin/ldconfig (as root) Well, everything should be ok now. You can launch : - the client: $ attal-client & - the server: $ attal-server & - the ia-client: $ attal-ai & - the scenario editor: $ attal-scenario-editor & - the theme editor: $ attal-theme-editor & - the campaign editor: $ attal-campaign-editor & IMPORTANT NOTE: all the executables need to find the theme (medieval theme for the moment) and so the folder 'themes', which have to contain the 'medieval' theme, is found if is: * present in the current directory (where there are the binaries) only if you play in local directory * can be set with --themepath switch at command line * can be set with environment variable ATTAL_THEME_PATH Using make install these steps are not necessary if the game is installed ( make install ). NOTE: to uninstall the game use: $ make uninstall (as root) You can edit config.pro for setting some global options (for example compiling in static if you got problem with dynamic libs). If you have some problems for compiling it, you can read INSTALL.Debian which relates a user experience for compiling it on Debian... If you have some problems for compiling it on MacosX, that seem not manage well dynamic libs try to compile with staticlib, uncommenting #CONFIG += staticlib in config.pro If you want to debug some part of code, please try to compile with debug option, uncommenting #CONFIG += debug as above Sound in compilation from source code is enabled , if you want to disable this, commenting like this #DEFINES += WITH_SOUND For different options of compilation, read comments in config.pro If you want to make an attal package you have various environment variable to set to help your work all these commands are to do before launch autogen.sh export ATT_PREFIX=your path Choose a different installation directory export ATT_LIB_PREFIX=your path Choose a different libs installation directory export ATT_DOCS_PREFIX=your path Choose a different documentation installation directory export ATT_THEMES_PREFIX=your path Set the default path where attal will search themes export ATT_TRANSL_PREFIX=your path Set the default path where attal will search translations export ATT_TEMP_THEMES_PREFIX=your path Set the place where place themes ( that could be different from theme_prefix ( useful for packages ) export ATT_TEMP_TRANSL_PREFIX=your path Set the place where place translations ( that could be different from transl_prefix ( useful for packages ) export ATT_QMAKE=qmake_bin Set a different qmake export ATT_LUPDATE=lupdate_bin Set a different lupdate export ATT_LRELEASE=lrelease_bin Set a different lrelease export ATT_CROSS_COMPILE=true Activate some cross compilation fixes export ATT_VERSION=your version Set a different version export ATT_DEBUG=true Enable debug export ATT_GPROF=true Enable profiling attal-src-1.0-rc2/INSTALL.Debian0000644000175000017500000000423007717673730013706 0ustar aaaaI spent like three hours working to get the 0.7 src compiled, so I want to share my problems and how I solved them. Perhaps one of the developpers reads it and some things will be easier in the future. I am not very experienced in Linux, so some things might seem strange to you, but - it's working... I will give some NOTEs to the developpers, marked with NOTE. Because I'm using Debian 3.0, some things might work on other distros that didn't work in Debian 3.0. First of: You need: libqt3, libqt3-dev. Then you have to add a unstable host in your /etc/apt/sources.list, for example: "deb ftp://128.101.80.131/debian unstable main contrib non-free" Now update your apt and install the package libstdc++5. This will install a couple of programs and libraries, but nothing will be removed. (NOTE: please say somewhere that we need libstdc++5, Debian 3.0 stable has libstdc++3!) Download the sources and unpack, cd into the unpacked directory(I will refer to that dir as "top"). Type: export QTDIR=/usr/share/qt Type: export QMAKESPEC=/usr/share/qt/mkspecs/linux-g++/qmake.conf Then run in top: qmake -o Makefile Makefile.pro Get into every subdir and run: qmake -o Makefile Makefile.pro (NOTE: please mention that in the INSTALL file!) Because Debian installs some qt libraries in /usr/lib/qt3/plugins/styles, you have to type(as superuser): cd /usr/lib ln qt3/plugins/styles/libqwindowsstyle.so -s ln libqwindowsstyle.so libqwindowsstyle.so.1 -s (I really don't know why attal needs libqwindowsstyle.so for compiling, but libqwindowsstyle.so.1 for running) exit superuser Then edit every Makefile in every subdir and add at the end of the line beginning with "LIBS =": -lqwindowsstyle Now... compile. Type make. (finally) Uh no, not starting the program yet. It has NO idea where to look for its libraries. Log in as root again, type: cd /usr/lib ln top/libCommon.so.1 -s ln top/libClient.so.0 ln top/libFight.so.1 ln top/libServer.so.1 Ok it should start now. (NOTE: Developpers: the bins should really look into the top directory for the libs...) Have fun. Oh, and good luck - most probably you have to change something else on your system. --Prophyle attal-src-1.0-rc2/Makefile.pro0000644000175000017500000000050310774016512013714 0ustar aaaaTEMPLATE = subdirs SUBDIRS += libCommon SUBDIRS += libServer SUBDIRS += libAi SUBDIRS += libClient SUBDIRS += libFight SUBDIRS += ai SUBDIRS += client SUBDIRS += server SUBDIRS += scenarioEditor SUBDIRS += campaignEditor SUBDIRS += themeEditor SUBDIRS += themes SUBDIRS += i18n !isEmpty( ATT_DEBUG ) { SUBDIRS += test } attal-src-1.0-rc2/NEWS0000644000175000017500000002231511010170657012154 0ustar aaaa**************************** ** ** ** Attal: Lords of Doom ** ** ** **************************** Release 1.0-rc2 - No more necessity of LD_LIBRARY_PATH on linux - Resource management rewrite, added local resources - Population is another resource - Levels implemented - Possibility to steal resources to creatures - Remote server control added - Speed improvement and refactoring of code - Improvements in fight interface - Allow 'chat' in fight mode and base display - ThemeEditor improved - Added actions to bases - Add popup help - Better debian package - Bug fixing - Medieval theme: - Resources changed, now only: Money, Wood, Iron, Food, Diamond, Population - 'Mines' buildings in adventure mode smaller - Units smaller - Water transitions - New flags Release 1.0-rc1 - Graphical engine improved - Porting to new qt graphic engine - New graphics ( bases and units ) - Client interface partially rewrite to optimize space - Ai rewrite - New scenarii - Drop all Qt3Support - Server and ai are integrated in client so for local game, no need of other program that attal-client - Better handling of fight animations - Sound management - Sound management improved - Enable/disable sound and music in client during the game - Ai is also integrated in server (no need of external ai client (except for debug)) - Player management in server - kick player - control of client attal version - Better handling of installation - Minimap improved - Improved search and management of themes (command line args , environment var, local directory, hardcoded path) - Implemented autosave and save every turn - Implemented fight with garrison lord - Implemented animation speed control in fight - Implemented split unit - Managed dependencies between buildings inside base - Managed more kind of animations for creatures (dead, dying, attack high, attack low, shoot high, shoot low...) - Added management for small bases pixmap in client - Initial separation between server and engine - New saved data in scenarii: - game version - turn - start date - production of creatures - Calendar: - Improved api - Quests: -Implemented date-based quests - Require at least Qt 4.2.0 - A lot of bug fixing - Medieval theme: - New graphics for bases - New graphics for internal buildings - New external building : village - New creatures : Magician creatures and Necromancer creatures - New scenarii : TheIsland, TheLabyrint, Villages - Added faces for mercenary units - New lord faces Release 0.10.1 - Better fight management - Partial drop of Qt3Support - Minimap improved - Dependecies between buildings implemented - Village implemented - Bug fixing Release 0.10 - Porting to Qt4 - Windows port - New displayLord Interface - Start game management improved - Grid implemented in scenarioEditor - Fight: - Usability improvements - Add active unit animation - Better handling of cursors for fight - New end game dialog - Various bug fixing - Music management improvements - Calendar: - Save of calendar implemented - Handling of calendar in scenarioEditor - Handling of calendar in themeEditor - Improved api - Campaign: - Update campaign management in server - Improved saving - Campaign editor bug fix - Usability improvements - Bug fixing - Medieval theme: First Campaign : How Ol'Bar become famous Release 0.9.4 - Teams management (server,client,ai,scenario editor) - Tavern implemented - Usability improvements - Save of campaigns implemented - Handling of animations in themeEditor - Added make install (and uninstall) for unix - Bug fixing - Medieval theme: Animations for the 'druidic' creatures Release 0.9.3 - Highlight lord when selected - Better start game management (autoFill with AI, hide AI (experimental), better campaign management) - Improved fight mode (client, server, bug fix) - Improved scenarioEditor ( disposition management, better placement management) - Disposition for decoration now used for pathfinding - Add command line help - Is possible to disable sound at command line (for hardware problems) - Management of different screen resolutions - Management of log level at command line - Management of player vision on savefiles - Usability improvements - highlight internals buildings - more info - better buy building interface - castle improved - market improved - Improve AI - AI can use market - Better management of internals buildings - New scenarios - Bug fixing Release 0.9.2 - Castle implemented - Better connection management - Destroy unit implemented - Manage 'behaviour' of map creatures (flee/join/mercenary/attack) - Manage growth of map creatures - RandomResource rewrite - Usability improvements (more info, better buy interface, autoscrolling) - Exchange units partially rewrite - Add "groups" for decorations - Autodraw paths and other small improvement in scenarioEditor - Improved themeEditor - Fix/improve AI - AI can explore - Priorities for targets - Tuning AI based on enemy power - Various fix. - Bug fixing Release 0.9.1 - New calendar api - Fast connection (client start server and connect to it) - Auto fill scenarii with ai - New display of inside base - Update documentation - Add pixmaps for Mercenary base - Flag management for bases - Bug fixing Release 0.9 - Sets flags for lords on map - Manage sounds effects - More user-frendly informations on game (turn, resources, etc...) - Management of 'far' cells in path - Improve townhall inside building (for buying other buildings) - Improved AI - Save Game implemented - Population management - Clean-up of code - Management of experience in game - Very basic campaign management - Bug fixing Release 0.8.1 - Improve management of events on map (chests, resources...) and in editor - Some coding of quests (basic management) - Market implemented - Minimap in scenario editor - Levels of experience management (in theme editor) - Added docs - Management of buildings (external and internal) in editors - Bug fixing Release 0.8 - Animation of creatures in fight mode (moves only) - Management of tiles diversification in editors - New Client Interface - Some artefact management - Improved connections management - Sell of internal buildings - Bug fixing Release 0.7.2 - Management of bonus and chest - Fix/improve AI - Better mini-map - Music management - Better fight mode - Tiles diversification Release 0.7.1 - Improve scenarii editor - Improve theme editor - Add lots of graphics for decorations (roads, trees...) - Manage decoration effects (roads cost less move points...) - Fix bugs in fog of war - Improve fight mode Release 0.7 - Fog of war (buggy ?) - Bugs in scenarii editor - Improve scenarii editor (properties of lords, creatures, bases...) - Add features in theme editor (preview of base...) - New architecture of sources. Use of qmake - Medieval theme: Pictures of resources - Medieval theme: Pictures of new bases (necromancer, barbarian and atlantis) Release 0.6.2 - IA rewrite and improved. - Major bug fixing (minimap crash, huge computing time when fighting, ...). - Fight against creatures on map. Release 0.6.1 - The AI can play also in adventure mode - More graphics for decorations - Cleaning of the code (comments, api, ...) - Bug fixing Release 0.6 - The AI can fight (but still don't move in adventure mode) - We handle buildings in bases (can build creatures, other buildings...) - Friend lords can exchange some units - Management of some buildings on map (mines...) - Graphics for the 'druidic' race (buildings and creatures) - Begin of management of creatures on map Release 0.5.1 - Scenario Editor can now load and save maps used by Attal - Server controls if a player has some lords left and warns if a player has lost - Move points (of lords) are handled - Data files of theme medieval are updated Release 0.5 - Rewrite 'network layer' (AttalSocket) - Lots of new or better graphics (transitions, buildings, bases (inside), units) - Theme Editor and Scenario Editor are up-to-date - Switch between fight mode and adventure mode - Lot of small bugs removes and features improved Release 0.4 - Lot of graphics (lords, creatures, decorations, transitions) - Data in medieval theme (for humans) - Some add to the theme editor - Better management of transitions - Inside base dispayed (begin of management) Release 0.3 - A theme editor has been added (for units, races, ressources) - Fight mode begin (move, hit, display) - More things are managed by the server - More and better graphisms - Transitions on ground managed - Decoration on the map are added Release 0.2 - Add network : there is now a client and a server. Data are exchanged by them. Turns are managed. - Add an ia 'fake' (can be connected to the server but doesn't really play (just ends turns)) - More data are managed through themes (for units, lords, ressources...) - The editor can edit scenario instead of maps. - Graphics improve (add lords, bases, buildings) - Some Lord management - Some Base management - Paths are displayed on map Release 0.1 -Initial release -Display map -You can move lords on map -Beginning of theme management -Map editor attal-src-1.0-rc2/README0000644000175000017500000000010307674122724012341 0ustar aaaaReadme file for Attal. For installation, please read INSTALL file attal-src-1.0-rc2/TODO0000644000175000017500000000216211010171316012134 0ustar aaaaThings to do... =============== C: Code G: Graphic M: Music S: Scenario T: Theme O: Other 04) [M] Add a music game (when no game has been started) 05) [G] Add introduction video when game is starting 06) [C] Choose player's team in server [COMPLICATED] 08) [S] Use new pixmaps of tree in scenarii 12) [C] Allow activation or not of some rules for 'tuning' difficulty level [WHICH RULES ?] 13) [C] Manage charisma [QUESTION HOW MANY ...?] ##14) [C] Display resource price in market [CODED, but preferred this one interface] 15) [G] Add some specific mouse cursor in game 22) [T/C] Some move arrows are twice in the theme data... 27) [C] Manage many creature animations for a kind of action, to choose randomly 29) [G] Pixmap for highlighted lord (when activated) [PART. DONE] 32) [C] Manage some params of AI in a file for a better tuning (and some different AI) 49) [C] Better management of Buildings 50) [C,G] Management of Skills 51) [C] Better management of Artefacts 52) [C,G] Management of Technics 53) [C,G] Animation (for lords, ...) 54) [C] Water management 55) [C] Don't use MAX_UNIT const 60) [O] Add developer documentation attal-src-1.0-rc2/autogen.sh0000755000175000017500000000530410776155627013477 0ustar aaaaecho "Building Makefile..." if [ -z "$QTDIR" ] then echo "You have to set the qt4 libs directory : export QTDIR= " exit fi if [ -n "$ATT_PREFIX" ] then pref="ATT_PREFIX=$ATT_PREFIX" fi if [ -n "$ATT_LIB_PREFIX" ] then lib="ATT_LIB_PREFIX=$ATT_LIB_PREFIX" fi if [ -n "$ATT_THEMES_PREFIX" ] then par2="ATT_THEMES_PREFIX=$ATT_THEMES_PREFIX" fi if [ -n "$ATT_TRANSL_PREFIX" ] then par3="ATT_TRANSL_PREFIX=$ATT_TRANSL_PREFIX" fi if [ -n "$ATT_DOCS_PREFIX" ] then attdocs="ATT_DOCS_PREFIX=$ATT_DOCS_PREFIX" fi if [ -n "$ATT_TEMP_THEMES_PREFIX" ] then par5="ATT_TEMP_THEMES_PREFIX=$ATT_TEMP_THEMES_PREFIX" fi if [ -n "$ATT_TEMP_TRANSL_PREFIX" ] then par6="ATT_TEMP_TRANSL_PREFIX=$ATT_TEMP_TRANSL_PREFIX" fi if [ -z "$ATT_QMAKE" ] then ATT_QMAKE=$QTDIR/bin/qmake fi if [ -z "$ATT_LUPDATE" ] then ATT_LUPDATE=$QTDIR/bin/lupdate fi if [ -z "$ATT_LRELEASE" ] then ATT_LRELEASE=$QTDIR/bin/lrelease fi if [ -n "$ATT_CROSS_COMPILE" ] then unset par1 unset par2 unset par3 cross="ATT_CROSS_COMPILE=$ATT_CROSS_COMPILE" fi if [ -n "$ATT_GPROF" ] then gprof="ATT_GPROF=$ATT_GPROF" fi if [ -n "$ATT_GCOV" ] then gcov="ATT_GCOV=$ATT_GCOV" fi if [ -n "$ATT_DEBUG" ] then debug="ATT_DEBUG=$ATT_DEBUG" fi echo "$ATT_QMAKE $pref $lib $par2 $par3 $par5 $par6 $attdocs $cross $gprof $gcov $debug -o Makefile Makefile.pro" $ATT_QMAKE $pref $lib $par2 $par3 $par5 $par6 $attdocs $cross $gprof $gcov $debug -o Makefile Makefile.pro echo "Done" echo "Creating national language files in i18n..." $ATT_LUPDATE -noobsolete -silent server/server.pro 2>/dev/null $ATT_LUPDATE -noobsolete -silent client/client.pro 2>/dev/null $ATT_LUPDATE -noobsolete -silent ai/ai.pro 2>/dev/null $ATT_LUPDATE -noobsolete -silent scenarioEditor/scenarioEditor.pro 2>/dev/null $ATT_LUPDATE -noobsolete -silent themeEditor/themeEditor.pro 2>/dev/null $ATT_LUPDATE -noobsolete -silent campaingEditor/campaignEditor.pro 2>/dev/null $ATT_LUPDATE -noobsolete -silent libServer/libServer.pro 2>/dev/null $ATT_LUPDATE -noobsolete -silent libClient/libClient.pro 2>/dev/null $ATT_LUPDATE -noobsolete -silent libCommon/libCommon.pro 2>/dev/null $ATT_LUPDATE -noobsolete -silent libAi/libAi.pro 2>/dev/null $ATT_LUPDATE -noobsolete -silent libFight/libFight.pro 2>/dev/null $ATT_LUPDATE -noobsolete -silent themes/themes.pro 2>/dev/null echo "Done" echo "Compiling existing translations..." $ATT_LRELEASE -silent i18n/??/attal_*_??.ts $ATT_LRELEASE -silent i18n/??/attal_*_??.ts $ATT_LRELEASE -silent i18n/??/attal_*_??.ts $ATT_LRELEASE -silent i18n/??/attal_*_??.ts $ATT_LRELEASE -silent i18n/??/campaign_*_??.ts $ATT_LRELEASE -silent i18n/??/theme_*_??.ts $ATT_LRELEASE -silent i18n/??/scenario_*_??.ts echo "Done" echo "You may now 'make && make install'" attal-src-1.0-rc2/conf.h0000644000175000017500000000331410770500504012551 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** conf.h ** this file contains all generic datas ** ** Version : $Id: conf.h,v 1.12 2008/03/20 15:22:44 lusum Exp $ ** ** Author(s) : Pascal Audoux - Cyrille Verrier ** ** Date : 02/08/2000 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CONF_H #define CONF_H #include #define ATTAL_PORT 1717 const QString IMAGE_DEFAULT_PATH( "images/" ); const QString MUSIC_DEFAULT_PATH( "musics/" ); const QString SOUND_DEFAULT_PATH( "sounds/" ); const QString DATA_DEFAULT_PATH( "data/" ); const QString CAMPAIGN_DEFAULT_PATH( "campaigns/" ); const QString SCENARIO_DEFAULT_PATH( "scenarii/" ); const QString TRANSLATIONS_DEFAULT_PATH( "translations/" ); const QString THEME_DEFAULT( "medieval" ); #ifdef WIN32 const QString CONFIG_DEFAULT_PATH( "attal/" ); #else const QString CONFIG_DEFAULT_PATH( ".attal/" ); #endif enum CanvasHeight { CAN_GROUND, CAN_TRANS, CAN_DECO, CAN_ARTEFACT, CAN_BUILDING, CAN_CREATURE, CAN_ARROW=1000, CAN_NUM_ARROW, CAN_LORD=10000 }; enum CanvasFightHeight { CAN_F_UNIT_DEAD, CAN_F_GROUND, CAN_F_OBSTACLE, CAN_F_UNIT }; #endif // CONF_H attal-src-1.0-rc2/config.pro0000644000175000017500000000523411001141713013434 0ustar aaaa# # config.pro # File included by any Makefile.pro # # if you are a developper (using cvs), don't change this file but # create a devel.pro file with your options. # # Otherwise: # # Uncomment 'CONFIG += staticlib' if you want static libs and static link # Uncomment 'CONFIG += debug' if you do want debugging symbols to be added (may be add next line "CONFIG += debug") # define ATT_CROSS_COMPILE if you do a cross compilation from unix to win32) # Comment 'DEFINES += WITH_SOUND' if you want to disable sound support (sound need SDL and SDL_mixer installed ) # If you are using a version of qt with windows-style as plugin, you may # try to add these 2 lines 'DEFINES += QT_PLUGIN' and 'LIBS += -lqwindowsstyle' (maybe it is not enough, I do not know exists( devel.pro ) { include( devel.pro ) } else { CONFIG += qt CONFIG += warn_on CONFIG -= debug #CONFIG += staticlib !isEmpty( ATT_CROSS_COMPILE ) { CONFIG += crosslinwin } !isEmpty( ATT_DEBUG ) { CONFIG += debug } isEmpty( ATT_GPROF ) { isEmpty( ATT_GCOV ) { QMAKE_CFLAGS+=-O2 QMAKE_CXXFLAGS+=-O2 } } !isEmpty( ATT_GPROF ) { CONFIG += staticlib QMAKE_CFLAGS+=-pg QMAKE_CXXFLAGS+=-pg QMAKE_LFLAGS+=-pg } !isEmpty( ATT_GCOV ) { QMAKE_CFLAGS+=-fprofile-arcs -ftest-coverage QMAKE_CXXFLAGS+=-fprofile-arcs -ftest-coverage QMAKE_LFLAGS+=-fprofile-arcs -lgcov } isEmpty( ATTAL_VERSION ) { ATTAL_VERSION=1.0-rc2 } DEFINES += ATTAL_VERSION=\\\"$$ATTAL_VERSION\\\" DEFINES += WITH_SOUND unix:!macx { isEmpty( ATT_PREFIX ) { ATT_PREFIX = /usr/local } isEmpty( ATT_LIB_PREFIX ) { ATT_LIB_PREFIX = $${ATT_PREFIX}/lib/ } isEmpty( ATT_THEMES_PREFIX ) { ATT_THEMES_PREFIX = $${ATT_PREFIX}/share/games/attal/themes/ #Themes final directory } isEmpty( ATT_TRANSL_PREFIX ) { ATT_TRANSL_PREFIX = $${ATT_PREFIX}/share/games/attal/translations/ #Traslations final directory } isEmpty( ATT_DOCS_PREFIX ) { ATT_DOCS_PREFIX = $${ATT_PREFIX}/share/doc/attal/ #Docs final directory } isEmpty( ATT_TEMP_THEMES_PREFIX ) { ATT_TEMP_THEMES_PREFIX = $${ATT_THEMES_PREFIX} #Change it if themes final directory is different from installation dir } isEmpty( ATT_TEMP_TRANSL_PREFIX ) { ATT_TEMP_TRANSL_PREFIX = $${ATT_TRANSL_PREFIX} #Change it if translations final directory is different from installation dir } } DEFINES += ATT_THEMES_DIR=\\\"$$ATT_THEMES_PREFIX\\\" DEFINES += ATT_TRANSL_DIR=\\\"$$ATT_TRANSL_PREFIX\\\" DEFINES += ATT_DOCS_DIR=\\\"$$ATT_DOCS_PREFIX\\\" # For sound under windows, enter here the path to SDL root dir and uncomment line #win32:SDL_DIR = # For compilers different from gcc and mingw, uncomment line (not tested) #DEFINES +=WIN32VC6 } attal-src-1.0-rc2/doxyfile0000644000175000017500000011436207674122724013244 0ustar aaaa# Doxyfile 1.2.18 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = Attal # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = 0.7 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = doc # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, # Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en # (Japanese with english messages), Korean, Norwegian, Polish, Portuguese, # Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish and Ukrainian. OUTPUT_LANGUAGE = English # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these class will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited # members of a class in the documentation of that class as if those members were # ordinary class members. Constructors, destructors and assignment operators of # the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. It is allowed to use relative paths in the argument list. STRIP_FROM_PATH = # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower case letters. If set to YES upper case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # users are adviced to set this option to NO. CASE_SENSE_NAMES = YES # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explict @brief command for a brief description. JAVADOC_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # reimplements. INHERIT_DOCS = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consist of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. # For instance some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources # only. Doxygen will then generate output that is more tailored for Java. # For instance namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = . # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp # *.h++ *.idl *.odl FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = themes data editor doc # The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories # that are symbolic links (a Unix filesystem feature) are excluded from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. EXCLUDE_PATTERNS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. INPUT_FILTER = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output dir. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non empty doxygen will try to run # the html help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the Html help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript and frames is required (for instance Mozilla, Netscape 4.0+, # or Internet explorer 4.0+). Note that for large projects the tree generation # can take a very long time. In such cases it is better to disable this feature. # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimised for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assigments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_XML = NO # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_PREDEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse the # parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::addtions related to external references #--------------------------------------------------------------------------- # The TAGFILES tag can be used to specify one or more tagfiles. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or # super classes. Setting the tag to NO turns the diagrams off. Note that this # option is superceded by the HAVE_DOT option below. This is only a fallback. It is # recommended to install and use dot, since it yield more powerful graphs. CLASS_DIAGRAMS = YES # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found on the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_WIDTH = 1024 # The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height # (in pixels) of the graphs generated by dot. If a graph becomes larger than # this value, doxygen will try to truncate the graph, so that it fits within # the specified constraint. Beware that most browsers cannot cope with very # large images. MAX_DOT_GRAPH_HEIGHT = 1024 # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermedate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::addtions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO # The CGI_NAME tag should be the name of the CGI script that # starts the search engine (doxysearch) with the correct parameters. # A script with this name will be generated by doxygen. CGI_NAME = search.cgi # The CGI_URL tag should be the absolute URL to the directory where the # cgi binaries are located. See the documentation of your http daemon for # details. CGI_URL = # The DOC_URL tag should be the absolute URL to the directory where the # documentation is located. If left blank the absolute path to the # documentation, with file:// prepended to it, will be used. DOC_URL = # The DOC_ABSPATH tag should be the absolute path to the directory where the # documentation is located. If left blank the directory on the local machine # will be used. DOC_ABSPATH = # The BIN_ABSPATH tag must point to the directory where the doxysearch binary # is installed. BIN_ABSPATH = /usr/local/bin/ # The EXT_DOC_PATHS tag can be used to specify one or more paths to # documentation generated for other projects. This allows doxysearch to search # the documentation for these projects as well. EXT_DOC_PATHS = attal-src-1.0-rc2/qmake.dsp0000644000175000017500000001324007734125247013275 0ustar aaaa# Microsoft Developer Studio Project File - Name="qmake" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Generic Project" 0x010a CFG=qmake - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "qmake.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "qmake.mak" CFG="qmake - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "qmake - Win32 Release" (based on "Win32 (x86) Generic Project") !MESSAGE "qmake - Win32 Debug" (based on "Win32 (x86) Generic Project") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" MTL=midl.exe !IF "$(CFG)" == "qmake - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" !ELSEIF "$(CFG)" == "qmake - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" !ENDIF # Begin Target # Name "qmake - Win32 Release" # Name "qmake - Win32 Debug" # Begin Group "libCommon" # PROP Default_Filter "" # Begin Source File SOURCE=.\libCommon\Makefile.pro !IF "$(CFG)" == "qmake - Win32 Release" !ELSEIF "$(CFG)" == "qmake - Win32 Debug" # Begin Custom Build - qmake 'libCommon' InputPath=.\libCommon\Makefile.pro "Common.dsp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" cd libCommon qmake -t vclib Makefile.pro # End Custom Build !ENDIF # End Source File # End Group # Begin Group "libClient" # PROP Default_Filter "" # Begin Source File SOURCE=.\libClient\Makefile.pro !IF "$(CFG)" == "qmake - Win32 Release" !ELSEIF "$(CFG)" == "qmake - Win32 Debug" # Begin Custom Build - qmake 'libClient' InputPath=.\libClient\Makefile.pro "Client.dsp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" cd libClient qmake -t vclib Makefile.pro # End Custom Build !ENDIF # End Source File # End Group # Begin Group "libServer" # PROP Default_Filter "" # Begin Source File SOURCE=.\libServer\Makefile.pro !IF "$(CFG)" == "qmake - Win32 Release" !ELSEIF "$(CFG)" == "qmake - Win32 Debug" # Begin Custom Build - qmake 'libServer' InputPath=.\libServer\Makefile.pro "Server.dsp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" cd libServer qmake -t vclib Makefile.pro # End Custom Build !ENDIF # End Source File # End Group # Begin Group "libFight" # PROP Default_Filter "" # Begin Source File SOURCE=.\libFight\Makefile.pro !IF "$(CFG)" == "qmake - Win32 Release" !ELSEIF "$(CFG)" == "qmake - Win32 Debug" # Begin Custom Build - qmake 'libFight' InputPath=.\libFight\Makefile.pro "Fight.dsp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" cd libFight qmake -t vclib Makefile.pro # End Custom Build !ENDIF # End Source File # End Group # Begin Group "client" # PROP Default_Filter "" # Begin Source File SOURCE=.\client\Makefile.pro !IF "$(CFG)" == "qmake - Win32 Release" !ELSEIF "$(CFG)" == "qmake - Win32 Debug" # Begin Custom Build - qmake 'client' InputPath=.\client\Makefile.pro "attal_client.dsp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" cd client qmake -t vcapp Makefile.pro # End Custom Build !ENDIF # End Source File # End Group # Begin Group "server" # PROP Default_Filter "" # Begin Source File SOURCE=.\server\Makefile.pro !IF "$(CFG)" == "qmake - Win32 Release" !ELSEIF "$(CFG)" == "qmake - Win32 Debug" # Begin Custom Build - qmake 'server' InputPath=.\server\Makefile.pro "attal_server.dsp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" cd server qmake -t vcapp Makefile.pro # End Custom Build !ENDIF # End Source File # End Group # Begin Group "ai" # PROP Default_Filter "" # Begin Source File SOURCE=.\ai\Makefile.pro !IF "$(CFG)" == "qmake - Win32 Release" !ELSEIF "$(CFG)" == "qmake - Win32 Debug" # Begin Custom Build - qmake 'ai' InputPath=.\ai\Makefile.pro "attal_ai.dsp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" cd ai qmake -t vcapp Makefile.pro # End Custom Build !ENDIF # End Source File # End Group # Begin Group "scenarioEditor" # PROP Default_Filter "" # Begin Source File SOURCE=.\scenarioEditor\Makefile.pro !IF "$(CFG)" == "qmake - Win32 Release" !ELSEIF "$(CFG)" == "qmake - Win32 Debug" # Begin Custom Build - qmake scenarioEditor InputPath=.\scenarioEditor\Makefile.pro "scenario_editor.dsp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" cd scenarioEditor qmake -t vcapp Makefile.pro # End Custom Build !ENDIF # End Source File # End Group # Begin Group "themeEditor" # PROP Default_Filter "" # Begin Source File SOURCE=.\themeEditor\Makefile.pro !IF "$(CFG)" == "qmake - Win32 Release" !ELSEIF "$(CFG)" == "qmake - Win32 Debug" # Begin Custom Build - qmake themeEditor InputPath=.\themeEditor\Makefile.pro "theme_editor.dsp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" cd themeEditor qmake -t vcapp Makefile.pro # End Custom Build !ENDIF # End Source File # End Group # End Target # End Project attal-src-1.0-rc2/qmake.dsw0000644000175000017500000000450207725453563013312 0ustar aaaaMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "Client"=".\libClient\Client.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "Common"=".\libCommon\Common.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "Fight"=".\libFight\Fight.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "Server"=".\libServer\Server.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "attalai"=".\ai\attal_ai.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "attalclient"=".\client\attal_client.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "attalserver"=".\server\attal_server.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "qmake"=".\qmake.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "scenarioeditor"=".\scenarioEditor\scenario_editor.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Project: "themeeditor"=".\themeEditor\theme_editor.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### attal-src-1.0-rc2/template.cpp0000644000175000017500000000204707674125461014012 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** template.cpp ** this is a template for all .cpp files ** ** Version : $Id: template.cpp,v 1.1 2003/06/18 18:10:57 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #include "template.h" // generic include files // include files for QT // application specific include files /** add comments here */ ClassName::ClassName() { // internal comments } attal-src-1.0-rc2/template.h0000644000175000017500000000235607674125460013461 0ustar aaaa/**************************************************************** ** ** Attal : Lords of Doom ** ** template.h ** this is a template for all .h files ** ** Version : $Id: template.h,v 1.1 2003/06/18 18:10:56 audoux Exp $ ** ** Author(s) : Pascal Audoux ** ** Date : 05/01/2002 ** ** Licence : ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ****************************************************************/ #ifndef CLASSNAME_H #define CLASSNAME_H // generic include files // include files for QT // application specific include files /* ------------------------------ * ClassName * ------------------------------ */ /** comment for the class */ class ClassName { public: /** Constructor */ ClassName(); }; #endif // CLASSNAME_H