MWEdit

Home Forums Projects MWEdit

Viewing 20 posts - 61 through 80 (of 323 total)
  • Author
    Posts
  • #3853

    There’s a chance the program doesn’t work well with Unicode paths. I forget how I fixed it in BOSS but I’ll see if I can track things down if it turns out the paths have issues. This mostly affected languages that weren’t based on the Latin character set, so Russian and several Asian languages for example.

    #3855
    DeVaultSetter
    Keymaster

      Ooh, the language will be a thing – are there libraries for them?

      Tab doesn’t work properly in pages with a tab control

      It’s a bit cryptic, typically one transfers the focus of one control to another control on a form with CTRL-TAB. A tab form or page is itself also a control, thus the user may not expect the change in focus. And, depending on the tab order, the focus could switch to another tab, or a control in another tab, so you’ll want code for the tab to be activated with the contained controls shown, along with the one with the focus. Here’s a little V1 AHK script where CTRL-TAB selects the next tab:

      WS_CLIPSIBLINGS := 0x4000000
      DetectHiddenWindows, On
      Gui, +LastFound -MaximizeBox -MinimizeBox +OwnDialogs HWNDguihWnd
      thisguiW := floor(A_ScreenWidth/2)
      thisguiH := floor(A_ScreenHeight/6)

      Gui, Add, Text, vText Center x0 y0, Tab1
      GuiControl, Move, Text, % “x” thisguiW/3 “y” thisguiH/3

      Gui, Add, Tab2, x0 y0 w%thisguiW% h%thisguiH% vTestTab gTestTab HWNDtestTabhWnd, Tab1|Tab2|Tab3

      Gui, Show, w%thisguiW% h%thisguiH% Hide

      ; Calling GetNonClientDim with testTabhWnd is useless
      tabguiH := thisguiH – GetNonClientDim(guihWnd)
      tabguiW := thisguiW – A_LastError

      tmp := A_ScriptDir . “\” . “logo.png”
      urlDownloadToFile(“https://stearnvault.com/wp-content/uploads/2025/04/logo.png”, tmp, “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36 OPR/87.0.4390.45”)

      sleep 120

      loop, 3
      {
      Gui, Tab, %A_Index%
      picH := LoadPicture(tmp, GDI+ w%tabguiW% h%tabguiH%)
      if (picH)
      {
      Gui, Add, Picture, x0 y0 w%tabguiW% h%tabguiH% glogo %WS_CLIPSIBLINGS%, % “HBITMAP:*” picH
      gosub logo
      }
      }

      ControlGetPos,,, w, h, Static2, , % “HBITMAP:*” picH

      msgbox % “Pic width ” w ” Pic height ” h “nthisgui width " thisguiW " thisgui height " thisguiH "ntabgui width ” tabguiW ” tabgui height ” tabguiH

      Gui, Show, w%thisguiW% h%thisguiH%, Test

      return
      TestTab:
      GuiControlGet, tmp, , TestTab
      GuiControl, , Text, %tmp%
      Return
      logo:
      GuiControl, Move, % “HBITMAP:*” picH, % “x” 0 “y” (thisguiH – tabguiH) “w” tabguiW “h” tabguiH
      Return
      Esc::
      GuiClose:
      filerecycle %tmp%
      ExitApp

      GetNonClientDim(Hwnd)
      {
      If WinExist(“ahk_id ” Hwnd)
      {
      VarSetCapacity(rect, 16, 0)
      DllCall(“GetWindowRect”, “Ptr”, Hwnd, “Ptr”, &rect)
      W := NumGet(rect, 8, “int”) – NumGet(rect, 0, “int”)
      H := NumGet(rect, 12, “int”) – NumGet(rect, 4, “int”)
      VarSetCapacity(rect, 16, 0)
      DllCall(“GetClientRect”, “Ptr”, Hwnd, “Ptr”, &rect)
      W := W – NumGet(rect, 8, “int”)
      DllCall(“SetLastError”, “UInt”, W)
      Return H – NumGet(rect, 12, “int”)
      }
      else
      msgbox Problem with Tab!
      }
      /* Written by Masonjar13

      Downloads a file from a URL to a local file.

      Parameters:
      —————
      url: url to download from

      fileDest (optonal): local path to save to (defaults to script
      folder with name of file from the url)

      userAgent (optional): a valid useragent string to be used during
      the http request

      return: caught error message
      —————

      Example:
      ————
      urlDownloadToFile(“https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png”)
      ————

      */

      urlDownloadToFile(url,fileDest:=””,userAgent:=””){
      if (!fileDest) {
      splitPath,url,fileDest
      fileDest:=a_scriptDir “\” fileDest
      }
      if (!regExMatch(url,”i)https?://”))
      url:=”https://” url
      try {
      hObject:=ComObjCreate(“WinHttp.WinHttpRequest.5.1”)
      ;hObject:=ComObjCreate(“Msxml2.XMLHTTP”) not reliable
      hObject.Option(9) := 0X0800
      ;Msxml2.XMLHTTP
      ;hObject.AddRequestHeaders($hRequest, “Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9”)
      ;hObject.SetRequestHeader(“Pragma”, “no-cache”)
      ;hObject.SetRequestHeader(“Cache-Control”, “no-cache, no-store”)
      ;hObject.SetRequestHeader(“If-Modified-Since”, “Sat, 1 Jan 2000 00:00:00 GMT”)
      hObject.SetTimeouts(0,30000,30000,120000)
      hObject.open(“GET”,url)
      if (userAgent)
      hObject.setRequestHeader(“User-Agent”,userAgent)
      hObject.send()

      uBytes:=hObject.responseBody,cLen:=uBytes.maxIndex()
      fileHandle:=fileOpen(fileDest,”w”)
      varSetCapacity(f,cLen,0)
      loop % cLen+1
      numPut(uBytes[a_index-1],f,a_index-1,”UChar”)
      err:=fileHandle.rawWrite(f,cLen+1)
      } catch e
      return % e.message
      }

      The AHK logo is now stored here, ever since a rather stricter regime of Cloudflare settings has taken hold over there. πŸ™
      Ehm, anyway, back to C++. πŸ˜›

      #3857

      Pretty sure I was able to fix it using the standard features. I vaguely recall that I may have simply switched over to the wide string type (simply wstring compared to string) from the normal one but it’ll need verification. It would increase memory a tad since it has to allocate more storage per character but the effect should be negligible

      Most GUI libraries let you change the tab order so we’ll want to make sure the sequence is correct in whatever GUI library we go with. GUI programming is something I don’t have much experience with outside of VB 6 so we’ll see how it goes πŸ˜›

      Do I understand correctly or is there more to it than that?

      I found an old VB 6 disc lying around somewhere when I was cleaning up a few years ago. Really need to see if it still works!

      #3858
      DeVaultSetter
      Keymaster

        It can be changed with WS_TABSTOP, see here, implementation may not be straight forward. The comments in How can I set the control’s tab index? explain things a little better.
        Have you got a portable DVD player? If any issues with that, just copy setup files to HDD, else try transfer to flash drive instead πŸ™‚

        #3859

        Great, thanks. Will keep it in mind. Looks like GTK mostly handles that internally so it may go away when the switch is made:)

        Found the path stuff: https://github.com/boss-developers/boss/commit/bee3deb160258054165908b7104815a783a69afd

        Not sure if the version in the standard has the same behavior or if wide paths are needed but we’ll find out!

        Things are settling down so I’m planning to continue to work on those last few files in Common tomorrow before moving the investigation to the main code πŸ™‚

        Edit:

        Looking at the Unicode sample here: https://en.cppreference.com/w/cpp/filesystem/path/string

        It looks like those changes were merged into the standard but C++ used to have weird Unicode handling. Looks like it may have improved in recent years. Which would be nice as it used to be very cludgy.

        I don’t understand why they mix C and C++ file handling, though. Going to worry about it when we get there

        #3865

        Common is done. Now I can start reviewing the main code. πŸ™‚

        #3878

        Another note!

        Until the switch to GTK takes place, we’ll need to consider compiler support for the Windows GUI library. I know that, in the past, MinGW’s version of the Windows API had limited support for the Windows GUI library. It’s something that needs to be looked at again and kept in mind.

        Edit:

        Looks like MinGW-w64 has gotten a lot more GUI support in the years since I last used it

        #3883

        Tried again to hunt down the main function or WinMain but still couldn’t find it. I wouldn’t be surprised if it was done as a macro somewhere. I’ll keep an eye out as I go and will take a close look at the VS project files when I get there.

        Going through the esm folder and the code is really hard to understand without proper includes and namespace prefixes (there are very few comments to explain things) so those will definitely need to be added. Some of the class names are also on the docket for being changed as they’re not very descriptive, consisting of things such as item1 and item2. Lot of stuff to decipher before it starts making sense

        Edit:

        We also will need to extract the layout in the resource file and convert it into GTK’s cross-platform XML.

        #3890

        Class members are going to need to be rearranged. They’ve got separate sections for members and methods which makes it hard to see everything at a glace so the sections are probably going to be combined. The order is also inconsistent so that’s going on the list as well

        Additionally, I’m identifying various if-statements that could use optimizing. πŸ™‚

        #3891

        I’m currently working on the several arrays in esm/EsmBase.cpp, reformatting them so they’re a lot more readable (they’re large so it’s taking a bit: the file is going to be close to 3,000 lines of code once the arrays are reformatted), and they’re going to need some comments to describe what each field is for once we figure that out. The first field is obvious: it’s the text description but the next ones are unclear. For the animation array, for instance, it’s just a bunch of hex without any comments to tell us what the addresses are for. Each animation record has two hex fields associated with it and they’re often different so inference isn’t helping much.

        It’s also possible that some of these arrays would do better as maps or sets since they’re key-value pairs but we can look into that once we have a better handle on how they’re used.

        #3897

        Haven’t gotten to the usage yet but those arrays are arrays of structs using the names as the keys. Additionally, it uses accessor functions to convert the index to the string and back again. Based on this, there’s a very good chance that they’d be better off as a map of structs with the names as the keys. I’m a big fan of using data types that semantically make sense as they greatly help with understanding πŸ™‚

        #3907

        Took a quick look at .gitignore and it may need some additions, such as *.o to ignore object files. Will get it taken care of at some point πŸ™‚

        Also, proper destructors need to be used. It uses a mixture of destructors and a custom Destroy function. In some cases, the latter simply calls the former. In other cases, the former is commented out in favor of the latter.

        Also renamed the features.md file to FEATURES.md to follow standard naming conventions and fixed its line endings. Forgot that git had a mv command so the commit log is a bit messy. Hey, it’s been close to ten years! πŸ˜›

        It’s in the queue for the next push when I finish the esm folder πŸ™‚

        I may add some stuff to .gitattributes to ensure consistent line endings. Looking at it now….

        #3916

        There’s another typo in a file name: ESMSubBase.h should be EsmSubBase.h to match the convention used with the other files. Will add it to the list to adjust later just in case the includes also need to be fixed. Not an issue on Windows as the file system isn’t case system but still good practice to line everything up. That and we hope to get it working on other systems πŸ™‚

        Additionally, it’s possible a lot of the macros can be changed to enums. Not yet sure as I’m still pretty rusty so that’ll be looked at much later.

        Additionally, the scope of many variables can be reduced due to changes in the standard since the code was originally written. This will help with behind the scenes stuff and will get it added to the list.

        #3929

        There are some casts that can be removed. As an example:

        if (pEffectData->HasDuration() && pEffectData->HasMagnitude()) {
        	Cost = (float)(BaseCost / 10.0 + BaseCost * Duration * Magnitude / 5.0);
        } else if (pEffectData->HasDuration()) {
        	Cost = (float)(BaseCost / 10.0 + BaseCost * Duration / 5.0);
        } else if (pEffectData->HasMagnitude()) {
        	Cost = (float)(BaseCost / 10.0 + BaseCost * Magnitude / 5.0);
        } else {
        	Cost = (float)(BaseCost / 10.0 + BaseCost / 5.0);
        }

        Cost and BaseCost are defined as floats a few lines earlier so the result will automatically be float without concerns in the modern standard. Another option would be to set the float specifier on the numeric literals so they’d be, say, 5.0f instead but I’m pretty sure that’s unnecessary with the current implicit conversion rules in the language. Removing the casts in these cases will greatly improve readability so will add it to the list of things to do after the initial reformat πŸ™‚

        #3930
        DeVaultSetter
        Keymaster

          Vector might be a viable alternative to array of structs, even better, just an array of key/value pairs.
          Fine, just watch for certain add/subtract operations in floats, there’s a cautionary note here.

          #3931

          Yep, we also have the old joke, “Two plus two equals five for large values of two.”

          cppreference has a section on it here under “Floating–integral conversions”. Interestingly, the code mixes the double and floating point types in some places. The only difference between the two types as far as C++ is concerned is memory related so we may be able to simply combine most of those instances and reduce them to a single type.

          #3933
          DeVaultSetter
          Keymaster

            Is it possible to refactor code to run from custom operators? So define operators f+ as float plus, d+ as float double, f- as float minus, d- as double minus etc.. This obeys the usual arithmetical precedence rules in converting the surrounding operands to the type specified by the operator. Bound to be messy and slow in large expressions of mixed types so two operands per statement is best. Non numerical operators must then be represented in their numerical forms by conversion functions if necessary.
            An idea for the backburner, less one chooses to take on the challenge of crunching a bit bucket load of numbers in Pacman fashion for that extra edge in Morrowind modding power. πŸ˜›

            #3937

            Sorry, my dog’s been sick this week so it’s been a bit hard to get much done when I’ve had to get her out every hour or so. She seems to be doing better now, though

            Yep, operator overloading is definitely doable. Generally, it’s recommended to use the feature sparingly to help keep things from getting too confusing. BOSS, for example, uses operator overloading to simply define a template for its log file. It does so by overloading the stream operator << and replacing it with << template to make things cleaner.

            We can also overload the ( and ) to change the order of operations if we want. That’s a bit of a more esoteric change but it can definitely be done. Why we’d do so is anyone’s guess πŸ˜›

            If we were to overload things, how would we use them?

            Edit:

            Found the lines that create the arrays (I think, will need to verify later):

            /* Static array for creating the record's subrecords */
            #define DECLARE_SUBRECCREATE() private: \
            	static const esmsubreccreate_t s_SubRecCreate[]; \
            	virtual const esmsubreccreate_t* GetSubRecCreate (void) const { return (s_SubRecCreate); }

            They’re in esm/EsmRecord.h

            Going to leave it alone for now but it definitely could use some sweeping.

            So that macro is used to insert those lines into certain classes. Two better options would be to add it to the base class so they’re inherited or simply copy them into the child classes. It’s important not to do it via a macro so that we understand what’s going on in each class.

            #3940

            We’re probably going to want to generate a class diagram to help sort through things. I’ll see what options are available when I get the opportunity

            Edit:

            Google since again useless. It gives me results for UML when my search term was “linux generate class diagram”. /Sigh

            Just tried it in Bing and I actually get programs to generate class diagrams…Followed by UML…. Search engines are useless these days…

            Edit 2:

            Not seeing much in the community posts so I’ll check the package manager when I’m back on a computer.

            #3945

            In order to get the program to build using other compilers (assuming VS works), it’ll be necessary to add WinMain() as it currently doesn’t exist with a call to Run() from the main window (that class is already set up properly so it may be easy) and it’ll also be necessary to sort out the image library. The image library is set up to use an embedded DLL and will need to be changed to be handled at build time since DLLs are compiler specific. Haven’t gotten to the IL directory yet, though.

            We’ll also probably need to get a build script together, which I always find pretty difficult. Will get there!

          Viewing 20 posts - 61 through 80 (of 323 total)
          • You must be logged in to reply to this topic.

          Home Forums Projects MWEdit