KEBEditor.cpp 8.7 KB

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