Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 42

Thread: SvPascal

  1. #21
    Thanks for the example.

    One more thing. I tried writing:

    Code:
    SV.Utils.DottedFilePath(path, 8);
    Result was that the program closed without any errors or similar.

    The problems was solved by using a larger value in stead of 8.
    I can imagine various reasons why 8 is too small a number, but I would recommend to give some better error feedback than just closing the program with no warning. The log wouldn't even reveal the problem.
    Last edited by pstudio; 12-07-2011 at 07:55 PM.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  2. #22
    simvector
    Guest
    Hi... hmm.. interesting. I will have a look at this routine. It could be a bug in the routine and/or something going on with the call. But I will check it out. It does make a call the a Win32 API routine to do the work. Thanks for reporting.

  3. #23
    One last question (or two) related to file browsing I swear

    1. Is there an easy way in SvEngine or SvPascal to go up a directory when I have a path value? For instance if path := 'c:\foo\bar\' then I want path = 'c:\foo\'.
    2. Is there a way to check if a path leads to a folder or file? I thought I could use TSvUtils.MatchStrings like this "SV.Utils.MatchStrings(path, '.mp3')" to see if path lead to a mp3 file but it dodn't work.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  4. #24
    simvector
    Guest
    Haha... no worries. Your feedback is help me find and fix bugs so thank you.

    1) At the moment there is nothing. You can use the Pos routine to search for '\' which you can then use to find the last occurrence then back up to the previous.
    2) You can use FileExists, but DirectoryExists is not currently available. Note to self... "be sure to bind DirectoryExist command."
    3) MatchStrings... I think I added this to do some pattern matching for a string. So no, that will not help in this case.
    4) if you call TSvDirList.ReadFile(path, '*.mp3') will pick up all the files in this path or ReadAll to get everything including sub folders, then you can walk the list and use FileExists to see if the file is actually there.

  5. #25
    Thanks,
    FileExists worked fine for my purpose and I quickly made my own function to get the parent directory.

    Now a completely different kind of question. How do I register when my window loses focus? I've noticed that the window stops rendering and that's fine. However I'm playing music through the Bass library and music will continue to play when the app loses focus. So I need to know when the app loses and gains focus so I can manually pause and play music.

    If it makes a difference I'm inheriting from TSvPrototypeGame.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  6. #26
    simvector
    Guest
    1) no prob... glad to hear you got it all working. Coolness.

    2) You can override the TSvPrototypeGame.OnAppEvent event handler. There you can check SV.Minimized and SV.Active to test the application state.

    3) If you want the application window to continue rendering when it looses the focus, set RenderOnLostFocus to TRUE and if you ever need to control the audio playback of the default audio engine, set GlobalFocus property to TRUE and audio will continue playing when the focus is lost.
    Last edited by simvector; 13-07-2011 at 11:40 PM.

  7. #27
    Ok, I was actually looking at OnAppEvent but I was missing some input on what event was triggered. Apparently that is placed in SV. Thanks.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  8. #28
    I can't seem to make it work. It doesn't appear that OnAppEvent is called :?

    Code:
    type
      TShooterGame = class(TSvPrototypeGame)
      public  
        procedure OnAppEvent; override;
      end;
    
    procedure TShooterGame.OnAppEvent;
    begin
      inherited;
    
      WriteLn('AppEvent');
      WriteLn(SV.Active);
      WriteLn(SV.Minimized);
      if not SV.Active or SV.Minimized then
        StopSong(Music)
      else
        PlaySong(Music, False);
    end;
    Nothing is written in the console window when the window loses focus or is minimized.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  9. #29
    simvector
    Guest
    Ahh your right, it's not working. Sigh. In investigating this I discovered it does not like Assigning the event handler which I'm sure is the source of this problem. If I try to manually assign it, I'm getting an incompatible type. I have to dig into it a bit more. Thanks for reporting. The SvEngine equivalent works as expected.

  10. #30
    How can I disable that Escape quits the game. And how can I make sure that 'Alt' won't make the window loose focus so I can actually use that button in a game?
    I've tried to overwrite UpdateInput(a: Single) without calling inherited but that doesn't change anything.
    Last edited by pstudio; 16-07-2011 at 05:38 PM.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

Page 3 of 5 FirstFirst 12345 LastLast

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
  •