Results 1 to 10 of 11

Thread: dRezEngine

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Currently working in an IMGUI system. It very much WIP but coming along well.

    MEDIA


    CODE
    Code:
      TdeGuiSliderEvent = procedure(aSender: Pointer; aId: Integer; aValue: Single; aMinValue: Single; aMaxValue: Single);
      TdeGuiButtonEvent = procedure(aSender: Pointer; aId: Integer);
    
    { --- TdeIMGUI -------------------------------------------------------------- }
      TdeIMGUI = class(TdeBaseObject)
      protected
        FStyle: array[DEFAULT_BACKGROUND_COLOR..LISTVIEW_TEXT_COLOR_DISA  BLED] of Integer;
        FGuiState: TdeGuiControlState;
        FGuiAlpha: Single;
        FCursorTimer: Single;
        FCursorBlink: Boolean;
        function VALIGN_OFFSET(aHeight: Integer): Integer; inline;
        function GetColor(aValue: Cardinal): TColor;
        function Fade(aColor: TColor; aAlpha: Single): TColor;
        function CheckCollisionPointRec(aX: Integer; aY: Integer; aBounds: TRect): Boolean;
        function IsMouseButtonDown(aButton: Integer): Boolean;
        function IsMouseButtonReleased(aButton: Integer): Boolean;
        function IsMouseButtonUp(aButton: Integer): Boolean;
        function GetKeyPressed: Integer;
        function IsKeyPressed(aKey: Integer): Boolean;
        function IsKeyDown(aKey: Integer): Boolean;
        procedure DrawRectangleLines(aBounds: TRect;  aThick: Integer; aColor: TColor);
        procedure DrawRectangle(aX: Integer; aY: Integer; aWidth: Integer; aHeight: Integer; aColor: TColor);
        procedure DrawRectangleRec(aRec: TRect; aColor: TColor);
        function MeasureText(aText: string; aFontSize: Integer): Integer;
        procedure DrawText(aText: string; aX: Integer; aY: Integer; aFontSize: Integer; aColor: TColor);
        procedure SetGuiFade(aValue: Single);
      public
        property GuiAlpha: Single read FGuiAlpha write SetGuiFade;
        constructor Create; override;
        destructor Destroy; override;
        procedure SetProperty(aProperty: TdeGuiProperty; aValue: Cardinal);
        function GetProperty(aProperty: TdeGuiProperty): Cardinal;
        procedure Enable;
        procedure Disable;
        procedure &Label(aBounds: TRect; aText: string);
        function LabelButton(aBounds: TRect; aText: string): Boolean;
        function Button(aBounds: TRect; aText: string; aSender: Pointer=nil; aId: Integer=-1; aEventHandler: TdeGuiButtonEvent=nil): Boolean;
        function TextBox(aBounds: TRect; var aText: string; aTextSize: Integer; aEditMode: Boolean): Boolean;
        function CheckBox(aBounds: TRect; var aChecked: Boolean): Boolean;
        function CheckBoxExt(aBounds: TRect; var aChecked: Boolean; aText: string): Boolean;
        function Slider(aBounds: TRect; var aValue: Single; aMinValue: Single; aMaxValue: Single; aSender: Pointer=nil; aId: Integer=-1; aEventHandler: TdeGuiSliderEvent=nil): Single;
    
        procedure UseDefaultLightStyle;
        procedure UseDefaultDarkStyle;
      end;
    DEMO
    Code:
    program gui_test;
    
    {$APPTYPE CONSOLE}
    
    {$R *.res}
    
    uses
      System.SysUtils,
      dRez.Engine.IMGUI in '..\..\libs\dRez.Engine.IMGUI.pas',
      dRez.Engine in '..\..\libs\dRez.Engine.pas';
    
    const
      cWindowWidth        = 480;
      cWindowHeight       = 600;
      cFullscreen         = False;
    
    var
      Starfield: TStarfield;
      Gui: TdeIMGUI;
      name: string = 'Jarrod';
      check1: boolean = True;
      check2: Boolean = False;
      check3: Boolean = False;
      enable_disable: array[false .. true] of string = ('disabled', 'enabled');
      volume: Single = 1;
      music: TMusic;
      button_status: array[0 .. 1] of string;
    
      procedure UpdateMusicVolume(aSender: Pointer; aId: Integer; aValue: Single; aMinValue: Single; aMaxValue: Single);
      begin
        Music_SetVolume(aValue);
      end;
    
      procedure ButtonClicked(aSender: Pointer; aId: Integer);
      var
        s: string;
      begin
        s := '';
        case aId of
          0:
          begin
            button_status[0] :='Button 1 clicked';
            button_status[1] :='';
          end;
          1:
          begin
            button_status[0] :='';
            button_status[1] :='Button 2 clicked';
          end;
        end;
    
      end;
    
    begin
    
      // open app window
      Window_Open('dRez Engine - Basic GUI Demo', cWindowWidth, cWindowHeight, cFullscreen, False);
    
      music := Music_Load(nil, 'arc/music/opus.mp3');
      Music_Play(music, volume, -1);
    
      Starfield := Starfield_Create;
    
      gui := TdeIMGUI.Create;
      //gui.SetProperty(SLIDER_SLIDER_WIDTH, 5);
    
      // LGL game loop - until app has terminated
      while not Terminated do
      begin
        // process events (kbd, mouse, window, etc)
        ProcessEvents;
    
        // check if app window is ready (has focus, not minimized)
        if not Window_Ready then
        begin
          // delay for 1 millisecond (allow background tasks to run)
          Delay(1);
    
          // continue to process events
          continue;
        end;
    
        // terminate on ESC
        if Keyboard_Pressed(KEY_ESCAPE) then
          Terminate(True);
    
        // toggle fullscreen on F11
        if Keyboard_Pressed(KEY_F11) then
          Window_ToggleFullscreen;
    
        // screenshot on F12
        if Keyboard_Pressed(KEY_F12) then
          Screenshot_Take;
    
        if Keyboard_Pressed(KEY_1) then
          gui.GuiAlpha := 0.1;
    
        if Keyboard_Pressed(KEY_2) then
          gui.GuiAlpha := 1.0;
    
    
        Starfield_Update(Starfield, DeltaTime);
    
        // clear background to a color
        Renderer_ClearFrame(BLACK);
    
        Starfield_Render(Starfield);
    
        // display hud
        Font_DrawFPS(ConsoleFont, 3, 3, GREEN, 12);
        Font_DrawText(ConsoleFont, 3, 15, GREEN, 12, 'ESC - Quit');
        Font_DrawText(ConsoleFont, 3, 30, GREEN, 12, 'F11 - Toggle Fullscreen');
        Font_DrawText(ConsoleFont, 3, 45, GREEN, 12, 'F12 - Screenshot');
        //Font_DrawText(ConsoleFont, 3, 60, GREEN, 12, PChar('hex - ' + gui.Test));
    
    
        gui.&Label(TRect.Create(3, 100, 50, 15), 'A LABEL');
    
        gui.Button(TRect.Create(3, 120, 70, 30), 'BUTTON 1', nil, 0, ButtonClicked);
        gui.&Label(TRect.Create(80, 128, 50, 15), button_status[0]);
    
    
        gui.Button(TRect.Create(3, 160, 70, 30), 'BUTTON 2', nil, 1, ButtonClicked);
        gui.&Label(TRect.Create(80, 168, 50, 15), button_status[1]);
    
        gui.TextBox(TRect.Create(3, 200, 70, 30), name, 30, true);
        gui.CheckBox(TRect.Create(3, 240, 20, 20), check1);
    
        if gui.LabelButton(TRect.Create(3, 270, 70, 30), 'LABEL BUTTON') then WarningDlg('Label Button');
    
        gui.CheckBoxExt(TRect.Create(3, 300, 10, 10), check2, 'Item 1 (' + enable_disable[check2] + ')' );
        gui.CheckBoxExt(TRect.Create(3, 320, 10, 10), check3, 'Item 2 (' + enable_disable[check3] + ')');
    
        gui.Slider(TRect.Create(10, 340, 50, 10), volume, 0, 1, nil, 0, UpdateMusicVolume);
        gui.&Label(TRect.Create(70, 340, 50, 15), 'Music Volume');
    
    
        // show frame buffer
        Renderer_ShowFrame;
    
      end;
    
      gui.Free;
    
      Starfield_Destroy(Starfield);
    
      Music_Destroy(music);
    
      // close app window
      Window_Close;
    
    end.

  2. #2
    Added more controls, enough now I think for use in an upcoming project.


  3. #3
    At this point (I hope) I got all the features needed for current project. I got the IMGUI system finished off. You can now save/load styles with a few styles available (dark, light, candy and cherry). In addition you can do in app purchase via Stripe.com and even tweet directly to a twitter account. Below is an example of the TdeMenu class. It's a basic text based menu system that's very flexible (lots of event handlers so you can control/customize many features).


  4. #4
    Glad to see you are still working on this project mate

    Have you used yet another name for your company? It is hard to keep track I must admit

    Keep up all the hard work bro!!
    Looking good

    cheers,
    Paul

  5. #5
    Quote Originally Posted by paul_nicholls View Post
    Glad to see you are still working on this project mate

    Have you used yet another name for your company? It is hard to keep track I must admit

    Keep up all the hard work bro!!
    Looking good

    cheers,
    Paul
    Paul, sup man. How have you been my friend? Hope all is well. Yea, finally got old code base modernized and all the features that I wanted to get in. Just wanted everything to be in place to do my projects. You know, I tried to contact you a time or two. The last time I made contact was GMS humble bundle sale (I think). Later, I emailed you the changes in direction I was making and seeing if you could give me some feedback on some things I was working on. No response. Any old emails you would have at the time would have still redirected back to me. But any way, glad to hear from you. How goes your gamedev projects? I think I tried to contact via your syntax error software domain. It was/is down. Do you still have this anywhere? At the time, the email I had of yours, it was getting flagged and my emails returning. The IPs I had at the time for my server, apparently was abused by a previous user so it had gotten on some spam blocking sites that I had to spend so much time to get clean. What a PITA that was. (Note, if you ever get a server, make sure you request clean IPs). I have not been back to PGD in about 6-8 months maybe? Forgot to try to PM you from PGD, oh well, haha.

  6. #6
    Rounding out the feature set is a light-weight IDE. Great for prototyping and MOD'ing.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •