Migration from closed source version.

Issue #1 resolved
Rilly Najuana created an issue

Hi, I have legacy code from your old gw2lib that mainly works besides the DbgOut and NewThread methods. They are in the header file but I get an external method resolution error when building.

Comments (3)

  1. rafzi repo owner

    As a result from porting the code to hacklib, the Main class and the DbgOut, ResetConsole and NewThread functions are now obsolete. I will remove them from the header to avoid confusion.


    You have probably noticed from the example, that the Main class is not used anymore. Instead the user should now define the gw2lib_main function to provide his entry point in Gw2lib.


    NewThread did not really provide any useful functionality. You can easily define it as:

    namespace GW2LIB
    {
        template <typename F>
        void NewThread(F function)
        {
            std::thread th(function);
            th.detach();
        }
    }
    

    DbgOut and ResetConsole were provided in the closed source version, because the user did not have direct access to ConsoleEx. Now that the project is open source, it does not make sense to lock the user to a specific type of logging.

    An example to get your old code working as it was before:

    #include "hacklib/Main.h"
    #include "hacklib/ConsoleEx.h"
    
    std::unique_ptr<hl::ConsoleEx> pCon;
    
    void inputCbFunction(std::string input)
    {
        pCon->printf("echo: %s\n", input.c_str());
    }
    
    namespace GW2LIB
    {
        void ResetConsole(int cellsX, int cellsY)
        {
            auto pNewCon = std::make_unique<hl::ConsoleEx>(hl::GetCurrentModule());
            pNewCon->registerInputCallback(inputCbFunction);
            hl::CONSOLEEX_PARAMETERS consoleParams = hl::ConsoleEx::GetDefaultParameters();
            consoleParams.cellsYBuffer = 5000;
            consoleParams.cellsYVisible = cellsY;
            consoleParams.cellsX = cellsX;
            consoleParams.closemenu = true;
            pNewCon->create("Gw2Lib Output Console", &consoleParams);
    
            pCon.swap(pNewCon);
    
            pCon->printf("=== Gw2Lib %s by rafi - www.gamerevision.com ===\n", "[Open Source Version]");
        }
    
        void DbgOut(std::string format, ...)
        {
            va_list vl;
            va_start(vl, format);
    
            pCon->vprintf(format.c_str(), vl);
    
            va_end(vl);
        }
    }
    
  2. rafzi repo owner

    Some APIs are now obsolete. Occurences in the header will be removed. See description for code migration.

  3. Log in to comment