KEBEditor.cpp 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. #include "KEBeschreibung.h"
  2. #include <TextFeld.h>
  3. #include <Text.h>
  4. #include <MausEreignis.h>
  5. #include "../../../../Global/Initialisierung.h"
  6. #include "../../../../Global/Variablen.h"
  7. #include <DateiSystem.h>
  8. bool KEBKnopfPressME( void *p, void *obj, MausEreignis me );
  9. // Inhalt der KEBEditor Klasse aus KEBEditor.h
  10. // Konstruktor
  11. KEBEditor::KEBEditor( Schrift *zSchrift, KEBeschreibung *zKeb )
  12. {
  13. beschreibung = initKnopf( 10, 10, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Beschreibung" );
  14. initToolTip( beschreibung, "Beschreibung bei der Kartenauswahl", zSchrift->getThis(), hauptScreen );
  15. beschreibung->setMausEreignisParameter( zKeb );
  16. beschreibung->setMausEreignis( KEBKnopfPressME );
  17. titelBild = initKnopf( 10, 40, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Titel Bild" );
  18. initToolTip( titelBild, "Titelbild während der Kartenauswahl (200x100)", zSchrift->getThis(), hauptScreen );
  19. titelBild->setMausEreignisParameter( zKeb );
  20. titelBild->setMausEreignis( KEBKnopfPressME );
  21. mapBild = initKnopf( 10, 70, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Minimap Bild" );
  22. initToolTip( mapBild, "Kartenvorschau Bild währed des erstellens einer Gruppe (348x348)", zSchrift->getThis(), hauptScreen );
  23. mapBild->setMausEreignisParameter( zKeb );
  24. mapBild->setMausEreignis( KEBKnopfPressME );
  25. ladenBild = initKnopf( 10, 100, 100, 20, zSchrift, Knopf::Style::Sichtbar, "Laden Bild" );
  26. initToolTip( ladenBild, "Hintergrundbild beim Laden der Karte", zSchrift->getThis(), hauptScreen );
  27. ladenBild->setMausEreignisParameter( zKeb );
  28. ladenBild->setMausEreignis( KEBKnopfPressME );
  29. bild = initBildZ( 120, 10, 750, 510, ( BildZ::Style::normal | BildZ::Style::Alpha ) & ~BildZ::Style::Sichtbar, 0 );
  30. LTDSDatei *sd = new LTDSDatei();
  31. sd->setPfad( new Text( "data/schriften/ksgs.ltds" ) );
  32. sd->leseDaten();
  33. Schrift *ksgsS = sd->ladeSchrift();
  34. sd->release();
  35. ksgs = dllDateien->ladeDLL( "KSGScript.dll", "data/bin/KSGScript.dll" );
  36. if( ksgs )
  37. {
  38. KSGSGetEditor getKSGScriptEditor = (KSGSGetEditor)GetProcAddress( ksgs, KSGS_EDITOR_FUNKTION );
  39. if( getKSGScriptEditor )
  40. {
  41. text = getKSGScriptEditor();
  42. text->setSchriftZ( ( ksgsS ? ksgsS : zSchrift )->getThis() );
  43. text->setSize( 750, 510 );
  44. text->setPosition( 120, 10 );
  45. text->setStyle( ZeichnungHintergrund::Style::HScroll | ZeichnungHintergrund::Style::VScroll | ZeichnungHintergrund::Style::Erlaubt | ZeichnungHintergrund::Style::Rahmen | ZeichnungHintergrund::Style::Hintergrund );
  46. text->setLinienRahmenBreite( 1 );
  47. text->setLinienRahmenFarbe( 0xFF00FF00 );
  48. text->setHorizontalScrollPos( 0 );
  49. text->setVertikalScrollPos( 0 );
  50. text->setMausEreignis( _ret1ME );
  51. text->setTastaturEreignis( _ret1TE );
  52. text->setText( new Text( "" ) );
  53. }
  54. else
  55. {
  56. text = 0;
  57. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ),
  58. new Text( "Der Einstiegspunkt '" KSGS_EDITOR_FUNKTION "' in der DLL-Datei "
  59. "'data/bin/KSGScript.dll' konnte nicht gefunden werden." ),
  60. new Text( "Ok" ), 0, NachrichtType::nachricht, 0 );
  61. }
  62. }
  63. else
  64. {
  65. text = 0;
  66. nachLogin->zNachrichtenListe()->addNachricht( new Text( "Fehler" ),
  67. new Text( "Die DLL-Datei 'data/bin/KSGScript.dll' konnte nicht geladen werden." ),
  68. new Text( "Ok" ), 0, NachrichtType::nachricht, 0 );
  69. }
  70. if( ksgsS )
  71. ksgsS->release();
  72. speichern = initKnopf( 10, 500, 100, 20, zSchrift, 0, "Speichern" );
  73. initToolTip( speichern, "Beschreibung speichern", zSchrift->getThis(), hauptScreen );
  74. speichern->setMausEreignisParameter( zKeb );
  75. speichern->setMausEreignis( KEBKnopfPressME );
  76. importieren = initKnopf( 10, 500, 100, 20, zSchrift, 0, "Importieren" );
  77. initToolTip( importieren, "Bild von Festplatte hochladen", zSchrift->getThis(), hauptScreen );
  78. importieren->setMausEreignisParameter( zKeb );
  79. importieren->setMausEreignis( KEBKnopfPressME );
  80. vorschau = initKnopf( 10, 470, 100, 20, zSchrift, 0, "Script Testen" );
  81. initToolTip( vorschau, "Die Beschreibung auf Scriptfehler testen", zSchrift->getThis(), hauptScreen );
  82. vorschau->setMausEreignisParameter( zKeb );
  83. vorschau->setMausEreignis( KEBKnopfPressME );
  84. jetzt = 0;
  85. sichtbar = 0;
  86. alpha = 0;
  87. tickVal = 0;
  88. ref = 1;
  89. }
  90. // Destruktor
  91. KEBEditor::~KEBEditor()
  92. {
  93. beschreibung->release();
  94. titelBild->release();
  95. mapBild->release();
  96. ladenBild->release();
  97. bild->release();
  98. text->release();
  99. speichern->release();
  100. importieren->release();
  101. vorschau->release();
  102. if( ksgs )
  103. dllDateien->releaseDLL( "KSGScript.dll" );
  104. }
  105. // nicht constant
  106. void KEBEditor::setSichtbar( bool s )
  107. {
  108. sichtbar = s;
  109. }
  110. void KEBEditor::setText( Text *zText )
  111. {
  112. text->setText( new Text( zText->getText() ) );
  113. bild->removeStyle( BildZ::Style::Sichtbar );
  114. text->addStyle( ZeichnungHintergrund::Style::Sichtbar );
  115. importieren->removeStyle( Knopf::Style::Sichtbar );
  116. speichern->addStyle( Knopf::Style::Sichtbar );
  117. vorschau->addStyle( Knopf::Style::Sichtbar );
  118. }
  119. void KEBEditor::setBild( Bild *zBild )
  120. {
  121. bild->setBildZ( zBild->getThis() );
  122. text->removeStyle( ZeichnungHintergrund::Style::Sichtbar );
  123. bild->addStyle( BildZ::Style::Sichtbar );
  124. speichern->removeStyle( Knopf::Style::Sichtbar );
  125. importieren->addStyle( Knopf::Style::Sichtbar );
  126. vorschau->removeStyle( Knopf::Style::Sichtbar );
  127. }
  128. bool KEBEditor::tick( double tv )
  129. {
  130. bool ret = beschreibung->tick( tv );
  131. ret |= titelBild->tick( tv );
  132. ret |= mapBild->tick( tv );
  133. ret |= ladenBild->tick( tv );
  134. ret |= bild->tick( tv );
  135. ret |= text->tick( tv );
  136. ret |= speichern->tick( tv );
  137. ret |= importieren->tick( tv );
  138. ret |= vorschau->tick( tv );
  139. tickVal += tv * 150;
  140. int val = 0;
  141. if( tickVal > 1 )
  142. val = (int)tickVal;
  143. else
  144. return ret;
  145. if( sichtbar && alpha != 255 )
  146. {
  147. if( alpha + val > 255 )
  148. alpha = 255;
  149. else
  150. alpha += val;
  151. ret = 1;
  152. }
  153. if( !sichtbar && alpha != 0 )
  154. {
  155. if( alpha - val < 0 )
  156. alpha = 0;
  157. else
  158. alpha -= val;
  159. ret = 1;
  160. }
  161. return ret;
  162. }
  163. void KEBEditor::doMausEreignis( MausEreignis &me )
  164. {
  165. if( !sichtbar )
  166. return;
  167. beschreibung->setAlphaFeldFarbe( 0x5500FF00 );
  168. titelBild->setAlphaFeldFarbe( 0x5500FF00 );
  169. mapBild->setAlphaFeldFarbe( 0x5500FF00 );
  170. ladenBild->setAlphaFeldFarbe( 0x5500FF00 );
  171. bool mv = me.verarbeitet;
  172. beschreibung->doMausEreignis( me );
  173. if( !mv && me.verarbeitet && me.id == ME_RLinks )
  174. jetzt = 1;
  175. mv = me.verarbeitet;
  176. titelBild->doMausEreignis( me );
  177. if( !mv && me.verarbeitet && me.id == ME_RLinks )
  178. jetzt = 2;
  179. mv = me.verarbeitet;
  180. mapBild->doMausEreignis( me );
  181. if( !mv && me.verarbeitet && me.id == ME_RLinks )
  182. jetzt = 3;
  183. mv = me.verarbeitet;
  184. ladenBild->doMausEreignis( me );
  185. if( !mv && me.verarbeitet && me.id == ME_RLinks )
  186. jetzt = 4;
  187. if( jetzt == 1 )
  188. beschreibung->setAlphaFeldFarbe( 0x0000FF00 );
  189. if( jetzt == 2 )
  190. titelBild->setAlphaFeldFarbe( 0x0000FF00 );
  191. if( jetzt == 3 )
  192. mapBild->setAlphaFeldFarbe( 0x0000FF00 );
  193. if( jetzt == 4 )
  194. ladenBild->setAlphaFeldFarbe( 0x0000FF00 );
  195. bild->doMausEreignis( me );
  196. text->doMausEreignis( me );
  197. speichern->doMausEreignis( me );
  198. importieren->doMausEreignis( me );
  199. vorschau->doMausEreignis( me );
  200. }
  201. void KEBEditor::doTastaturEreignis( TastaturEreignis &te )
  202. {
  203. if( !sichtbar )
  204. return;
  205. text->doTastaturEreignis( te );
  206. }
  207. void KEBEditor::render( Bild &zRObj )
  208. {
  209. if( !alpha )
  210. return;
  211. zRObj.setAlpha( alpha );
  212. beschreibung->render( zRObj );
  213. titelBild->render( zRObj );
  214. mapBild->render( zRObj );
  215. ladenBild->render( zRObj );
  216. text->render( zRObj );
  217. bild->render( zRObj );
  218. speichern->render( zRObj );
  219. importieren->render( zRObj );
  220. vorschau->render( zRObj );
  221. zRObj.releaseAlpha();
  222. }
  223. // constant
  224. int KEBEditor::getKNum( Knopf *zK ) const
  225. {
  226. if( zK == beschreibung )
  227. return 1;
  228. if( zK == titelBild )
  229. return 2;
  230. if( zK == mapBild )
  231. return 3;
  232. if( zK == ladenBild )
  233. return 4;
  234. if( zK == speichern )
  235. return -1;
  236. if( zK == importieren )
  237. return -2;
  238. if( zK == vorschau )
  239. return -3;
  240. return 0;
  241. }
  242. Text *KEBEditor::zBeschreibung() const
  243. {
  244. return text->zText();
  245. }
  246. int KEBEditor::getJetzt() const
  247. {
  248. return jetzt;
  249. }
  250. bool KEBEditor::istSichtbar() const
  251. {
  252. return sichtbar;
  253. }
  254. // Reference Counting
  255. KEBEditor *KEBEditor::getThis()
  256. {
  257. ref++;
  258. return this;
  259. }
  260. KEBEditor *KEBEditor::release()
  261. {
  262. ref--;
  263. if( !ref )
  264. delete this;
  265. return 0;
  266. }