Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Devtool) change compile and install VS AI mode #374

Open
wants to merge 93 commits into
base: master
Choose a base branch
from

Conversation

jzy-chitong56
Copy link
Contributor

@jzy-chitong56 jzy-chitong56 commented Sep 20, 2024

  • Place the console and script in the same directory -- ForwardsCompat support handling all console
  • Simultaneously compile VS AI console -- so no need to copy console anymore
  • The installation script now supports installing consoles in new directories, but still defaults to installing non VS AI mode -- Including the new installer script, but I suggest you add an option to choose to install VS AI, which I really cannot complete
  • Compile , installed and uninstall add environment detection. When Perl is not installed, an error will occur and prompt for download
  • Compile automatically closes the command line window when it passes normally (for double clicking with the mouse to run) -- Only pause once during simultaneous compilation
  • Removed VS AI compilation files
  • rename Optimize compiled all files
  • Optimization compilation will now proceed with a regular compilation to avoid having no files to optimize - I know this doesn't align with your idea
  • Optimization compilation can optimize VS AI
  • Removed temp files
  • compatibility can installation VSAI
  • new installer should compatibility installation VSAI
  • add new bat install -- InstallAppointVERToMap.bat

#353
#322
#401
#390
#382

@jzy-chitong56
Copy link
Contributor Author

jzy-chitong56 commented Sep 24, 2024

InstallToDir.pl
InstallVERToMap.bat

compatibility installation VSAI
But I really don't know the wording of the document

@jzy-chitong56 jzy-chitong56 changed the title Devtool Devtool - done Sep 24, 2024
@jzy-chitong56
Copy link
Contributor Author

jzy-chitong56 commented Oct 22, 2024

add new bat install -- InstallAppointVERToMap.bat
Semi visual operation, install any specified version and console
But I really don't know how to replace the language with BAT
and...I'm not very good at writing this description in readme

1.2 The new installer is still under research and I may not be able to handle it. When I removed the installation menu(Because I believe that with a graphical interface, there is no need to use menus anymore), the language menu was also removed, causing some text to be unable to be translated. Unfortunately, there are many issues with Chinese translation. I should have submitted a new version earlier

image
image
image

@jzy-chitong56
Copy link
Contributor Author

Different language length restrictions may need to be addressed, and some language button texts may overflow
image

@jzy-chitong56
Copy link
Contributor Author

jzy-chitong56 commented Oct 25, 2024

[1] won't trigger the [2] main.ts works, but the translation method '@ngx-translate/core' seems to be built-in and cannot be edited, which is a bit troublesome -- can not see console.log('eee 1');
The subsequent steps are even more difficult to test

I believe at least I got the process right
1[√]>>2.1[X]>>2.2[?]>>3[?]

[1]

      label: translations['PAGES.MENU.ENGLISH'],
      type: 'radio',
      checked: this.translate.currentLang == 'en',
      click: () => {
        this.translate.use('en')
        this.electronService.ipcRenderer.send('setlang-English');
        console.log('setlang-English');
      }

---------------------------------------------------------------------------------------

[2.1]
  ipcMain && ipcMain.on('setlang-English', async () => {
    console.log('eee 1');
    setLang(signal, "English");
  });

----------------------------------------------------------------------------------------

[2.2]
const setLang = async (signal, lang: String = "English") => {
  const controller = new AbortController();
  const response = [];
  const newlang = `"${lang}"`;
  const isMap: boolean = false;
  const ver: String = "REFORGED";
  let child;
  // passing reference to external call back
  signal = controller.signal;
  console.log('${lang}  -newlang');
  let currentExecDir = `./AMAI-release/`,
    currentScriptDir = './AMAI-release/';

  if(!isDev()) {
    currentExecDir = `./AMAI/`;
    currentScriptDir = path.join(
      __dirname,
      `../${currentExecDir}`
    );
  }
  response[0] = currentScriptDir;
  win.webContents.send('setlanguage', <InstallModel>{
    response: response[0],
    newlang,
    isMap
  });

  try {
    console.log('try  0');
    process.chdir(currentScriptDir);
  } catch(err) {

  }

  // init set language proccess
  try {
    child = cp.fork(
      require.resolve(
        path.join(
          __dirname,
          `../${currentExecDir}install.js`
        )
      ),
      [ response[0], newlang, ver ],
      { signal },
      (err) => {
        win.webContents.send('on-setlanguage-error', err);
      }
    );
    console.log('try 1');
    // send messages to modal on front
    child.on('message', (message) => {
      win.webContents.send('on-setlanguage-message', message);
    });

    // close modal on process finishes
    child.on('exit', () => {
      win.webContents.send('on-setlanguage-exit');
    });
  } catch(err) {
    win.webContents.send('on-setlanguage-error', err.message);
  }
}

----------------------------------------------------------------------------

[3]
  if (args[1] !== '1' && args[1] !== '2' && args[1] !== '0') {
    process.send(`#### AMAI set Scripts Languages ####`);
    const searchFor = /string language = "([^"]*)"/g;
    const replaceWith = `string language = ${args[1]}`;
    process.send(`s ${searchFor}`)
    process.send(`r ${replaceWith}`)
    const filePath = ``;
    const updatedData = ``;

    if (fs.existsSync(`Scripts\\REFORGED\\common.ai`)) {
      filePath = path.join(__dirname, `Scripts\\REFORGED\\common.ai`);
      fs.readFile(filePath, 'utf8', (err, data) => {
       updatedData = data.replace(new RegExp(searchFor, 'g'), replaceWith);
        fs.writeFile(filePath, updatedData, 'utf8', (err) => {
          if (err) {
            process.send(`ERROR: Cannot Set REFORGED common.ai language`)
          }
        });
      });
    }
   ......

@jzy-chitong56
Copy link
Contributor Author

jzy-chitong56 commented Oct 25, 2024

Now can review

  • New installer synchronized to 1.2.0 -- install VS AI Commander
  • Fixed menu translation field mismatch and installation menu TFT input error
  • The installation menu also supports writing VS AI Commander, but you will find that I disabled the installation menu......
  • Some menu buttons that I think are useless have also been disabled
  • Corrected Chinese translation errors
  • Added some translation text, which is reserved for installing JS, but I don't know how this standalone script retrieves translations from the packaged file unless the pushed text itself is translated -- this loses the meaning of external plugins
  • Reserved the function of modifying the language while also modifying the default language of the script, but disabled it. The reason I mentioned above may be resolved in the future...Sorry, the attempt failed
    -- In-scripts language configurable from installer #390 This question may be about wanting to display different local languages in real-time based on the player's name in the game - I'm not sure if the translation correctly expresses their original meaning..@Slayer95 , but it's not scientific. Even if each character can be recognized as a language, it doesn't affect usage. I can't understand English, but it doesn't affect my ability to use English as a name, which would distort it..

@jzy-chitong56
Copy link
Contributor Author

The code should be correct now, but it seems that some computers cannot replace the language. I only ran it successfully on my own machine

SMUnlimited added a commit that referenced this pull request Nov 8, 2024
Part one of pulling in PR #374 with additional tweaks and fixes, this is unfinished still under review.

Also added different handling for optimise although no simple way to install via installer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant