Ticket #3870: textinputfix.patch

File textinputfix.patch, 4.3 KB (added by echotangoecho, 7 years ago)

Seems to work for linux, can't test for windows (probably doesn't work).

  • source/ps/GameSetup/GameSetup.cpp

     
    487487
    488488    const size_t cacheSize = ChooseCacheSize();
    489489    g_VFS = CreateVfs(cacheSize);
    490    
     490
    491491    const OsPath readonlyConfig = paths.RData()/"config"/"";
    492492    g_VFS->Mount(L"config/", readonlyConfig);
    493493
     
    576576    in_add_handler(gui_handler);
    577577
    578578    in_add_handler(touch_input_handler);
    579    
     579
    580580    in_add_handler(cinema_manager_handler);
    581581
    582582    // must be registered after (called before) the GUI which relies on these globals
     
    589589    SAFE_DELETE(g_GUI);
    590590
    591591    UnloadHotkeys();
    592    
     592
    593593    // disable the special Windows cursor, or free textures for OGL cursors
    594594    cursor_draw(g_VFS, 0, g_mouse_x, g_yres-g_mouse_y, false);
    595595}
     
    625625    g_ConfigDB.SetValueBool(CFG_SYSTEM, "waterrefraction", g_WaterRefraction);
    626626    g_Renderer.SetOptionBool(CRenderer::OPT_SHADOWSONWATER, g_WaterShadows);
    627627    g_ConfigDB.SetValueBool(CFG_SYSTEM, "watershadows", g_WaterShadows);
    628    
     628
    629629    g_Renderer.SetRenderPath(CRenderer::GetRenderPathByName(g_RenderPath));
    630630    g_Renderer.SetOptionBool(CRenderer::OPT_SHADOWPCF, g_ShadowPCF);
    631631    g_ConfigDB.SetValueBool(CFG_SYSTEM, "shadowpcf", g_ShadowPCF);
     
    684684    }
    685685    atexit(SDL_Quit);
    686686
     687    // Text input is active by default, disable it until it is actually needed.
     688    SDL_StopTextInput();
     689
    687690#if OS_MACOSX
    688691    // Some Mac mice only have one button, so they can't right-click
    689692    // but SDL2 can emulate that with Ctrl+Click
     
    932935
    933936    // g_ConfigDB, command line args, globals
    934937    CONFIG_Init(args);
    935    
    936     // Using a global object for the runtime is a workaround until Simulation and AI use 
     938
     939    // Using a global object for the runtime is a workaround until Simulation and AI use
    937940    // their own threads and also their own runtimes.
    938941    const int runtimeSize = 384 * 1024 * 1024;
    939942    const int heapGrowthBytesGCTrigger = 20 * 1024 * 1024;
     
    12081211 * Examples:
    12091212 * 1) "Bob" will host a 2 player game on the Arcadia map:
    12101213 * -autostart="scenarios/Arcadia 02" -autostart-host -autostart-host-players=2 -autostart-playername="Bob"
    1211  * 
     1214 *
    12121215 * 2) Load Alpine Lakes random map with random seed, 2 players (Athens and Britons), and player 2 is PetraBot:
    12131216 * -autostart="random/alpine_lakes" -autostart-seed=-1 -autostart-players=2 -autostart-civ=1:athen -autostart-civ=2:brit -autostart-ai=2:petra
    12141217*/
     
    12551258            else
    12561259                seed = seedArg.ToULong();
    12571260        }
    1258        
     1261
    12591262        // Random map definition will be loaded from JSON file, so we need to parse it
    12601263        std::wstring scriptPath = L"maps/" + autoStartName.FromUTF8() + L".json";
    12611264        JS::RootedValue scriptData(cx);
     
    13131316        // partially configured
    13141317        CStr8 mapSettingsJSON = LoadSettingsOfScenarioMap("maps/" + autoStartName + ".xml");
    13151318        scriptInterface.ParseJSON(mapSettingsJSON, &settings);
    1316        
     1319
    13171320        // Initialize the playerData array being modified by autostart
    13181321        // with the real map data, so sensible values are present:
    13191322        scriptInterface.GetProperty(settings, "PlayerData", &playerData);
     
    13581361        std::vector<CStr> civArgs = args.GetMultiple("autostart-team");
    13591362        for (size_t i = 0; i < civArgs.size(); ++i)
    13601363        {
    1361             int playerID = civArgs[i].BeforeFirst(":").ToInt();     
     1364            int playerID = civArgs[i].BeforeFirst(":").ToInt();
    13621365
    13631366            // Instead of overwriting existing player data, modify the array
    13641367            JS::RootedValue player(cx);
     
    14261429                scriptInterface.Eval("({})", &player);
    14271430            }
    14281431
    1429             int difficulty = civArgs[i].AfterFirst(":").ToInt();           
     1432            int difficulty = civArgs[i].AfterFirst(":").ToInt();
    14301433            scriptInterface.SetProperty(player, "AIDiff", difficulty);
    14311434            scriptInterface.SetPropertyInt(playerData, playerID-offset, player);
    14321435        }
     
    14531456                    }
    14541457                    scriptInterface.Eval("({})", &player);
    14551458                }
    1456            
     1459
    14571460                CStr name = civArgs[i].AfterFirst(":");
    14581461                scriptInterface.SetProperty(player, "Civ", std::string(name));
    14591462                scriptInterface.SetPropertyInt(playerData, playerID-offset, player);
     
    15541557    shared_ptr<ScriptInterface> pScriptInterface = g_GUI->GetActiveGUI()->GetScriptInterface();
    15551558    JSContext* cx = pScriptInterface->GetContext();
    15561559    JSAutoRequest rq(cx);
    1557    
     1560
    15581561    JS::RootedValue global(cx, pScriptInterface->GetGlobalObject());
    15591562    // Cancel loader
    15601563    LDR_Cancel();