EDGAR.CPP 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*******************************************************************************
  2. FILE: EDGAR.CPP
  3. DESCRIPTION: GUI Editor
  4. AUTHOR: Peter M. Freese
  5. CREATED: 06-30-95
  6. COPYRIGHT: Copyright (c) 1995 Q Studios Corporation
  7. *******************************************************************************/
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include <helix.h>
  11. #include <string.h>
  12. #include <io.h>
  13. #include <fcntl.h>
  14. #include "typedefs.h"
  15. #include "engine.h"
  16. #include "key.h"
  17. #include "misc.h"
  18. #include "gameutil.h"
  19. #include "gfx.h"
  20. #include "globals.h"
  21. #include "debug4g.h"
  22. #include "error.h"
  23. #include "gui.h"
  24. #include "screen.h"
  25. #include "textio.h"
  26. #include "inifile.h"
  27. #include "options.h"
  28. #include "timer.h"
  29. #include "edgar.h"
  30. #include "mouse.h"
  31. #include <memcheck.h>
  32. #define kAttrTitle (kColorGreen * 16 + kColorYellow)
  33. char buffer[256];
  34. EHF prevErrorHandler;
  35. void faketimerhandler( void )
  36. { }
  37. virtual void EButton::HandleEvent( GEVENT *event )
  38. {
  39. if ( event->type & evMouse )
  40. {
  41. if (event->mouse.button == 1)
  42. {
  43. switch (event->type)
  44. {
  45. case evMouseDrag:
  46. left = ClipRange((event->mouse.x - width / 2) & ~3, 0, owner->width - width);
  47. top = ClipRange((event->mouse.y - height / 2) & ~3, 0, owner->height - height);
  48. break;
  49. case evMouseUp:
  50. dprintf("Button dropped at %i, %i\n", left, top);
  51. break;
  52. }
  53. return;
  54. }
  55. }
  56. TextButton::HandleEvent(event);
  57. }
  58. /***********************************************************************
  59. * EditorErrorHandler()
  60. *
  61. * Terminate from error condition, displaying a message in text mode.
  62. *
  63. **********************************************************************/
  64. ErrorResult EditorErrorHandler( const Error& error )
  65. {
  66. uninitengine();
  67. keyRemove();
  68. setvmode(gOldDisplayMode);
  69. // chain to the default error handler
  70. return prevErrorHandler(error);
  71. };
  72. void main( void )
  73. {
  74. char title[256];
  75. gOldDisplayMode = getvmode();
  76. sprintf(title, "Edgar [%s] -- DO NOT DISTRIBUTE", gBuildDate);
  77. tioInit();
  78. tioCenterString(0, 0, tioScreenCols - 1, title, kAttrTitle);
  79. tioCenterString(tioScreenRows - 1, 0, tioScreenCols - 1,
  80. "Copyright (c) 1994, 1995 Q Studios Corporation", kAttrTitle);
  81. tioWindow(1, 0, tioScreenRows - 2, tioScreenCols);
  82. if ( _grow_handles(kRequiredFiles) < kRequiredFiles )
  83. ThrowError("Not enough file handles available", ES_ERROR);
  84. tioPrint("Initializing heap and resource system");
  85. Resource::heap = new QHeap(dpmiDetermineMaxRealAlloc());
  86. tioPrint("Initializing resource archive");
  87. gSysRes.Init("BLOOD.RFF", "*.*");
  88. gGuiRes.Init("GUI.RFF", NULL);
  89. tioPrint("Initializing mouse");
  90. if ( !initmouse() )
  91. tioPrint("Mouse not detected");
  92. // install our error handler
  93. prevErrorHandler = errSetHandler(EditorErrorHandler);
  94. InitEngine();
  95. Mouse::SetRange(xdim, ydim);
  96. tioPrint("Initializing screen");
  97. scrInit();
  98. tioPrint("Installing keyboard handler");
  99. keyInstall();
  100. scrCreateStdColors();
  101. tioPrint("Installing timer");
  102. timerRegisterClient(ClockStrobe, kTimerRate);
  103. timerInstall();
  104. tioPrint("Engaging graphics subsystem...");
  105. scrSetGameMode();
  106. scrSetGamma(gGamma);
  107. scrSetDac(0);
  108. clearview(0);
  109. scrNextPage();
  110. // create the dialog
  111. Window dialog(0, 0, 240, 80, "Edgar");
  112. dialog.Insert(new EButton( 4, 4, 80, 20, "&Button", mrNone));
  113. dialog.Insert(new ScrollBar(120, 4, 50, 0, 100, 0));
  114. // pressed esape
  115. ShowModal(&dialog);
  116. setvmode(gOldDisplayMode);
  117. dprintf("Removing timer\n");
  118. timerRemove();
  119. dprintf("uninitengine()\n");
  120. uninitengine();
  121. dprintf("All subsystems shut down. Processing exit functions\n");
  122. errSetHandler(prevErrorHandler);
  123. }