Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

200
LINES

< > BotCompany Repo | #1033411 // Standalone Gazelle V [HEAD]

JavaX source code (desktop) [tags: jar-with-libs no-compiler standalone use-pretranspiled]

Download Jar. Uses 2032K of libraries. Click here for Pure Java version (11053L/60K).

/*       WELCOME!! This is THE PROGRAM YOU ARE LOOKING FOR.

COMPILE ISSUE is RESOLVED! Program can be run.

-Stefan Reich, 2021/10/29 08:40:03 UTC
*/

!7

sS windowTitle = "Gazelle V 2020-10-28 .10";
sS downloadURL = "https://botcompany.de/jar/1033411?withLibs=1&noCompiler=1";
sS trayIconImageID = #1103047;
static int borderSize = 5;
static Color color1 = awtColor("ADD8E6");
static Color color2 = awtColor("EEEEEE");
static Color color3 = awtColor("A3C0AA");

lib 1400521 // FlatLAF

set flag PingV3.
set flag NotifyingPrintLog.

static IF0<PingSource> ping_v3_pingSourceMaker() { ret () -> new PingSource; }

sclass Stem {
  JFrame window;
  
  Rect getFrameRect() {
    ret toRect(getBounds(window));
  }
}

static Stem stem;
static GazelleV gazelle;
static TrayIcon trayIcon;
static JFrame mainWindow;
static Set<S> argsSet;

svoid trayIconLeftClick {
  activateFrame_v3(mainWindow);
}

svoid makeTrayIcon {
  pcall-short {
    trayIcon_imageAutoSize = false;
    trayIcon = installTrayIcon(trayIconImageID, windowTitle,
      r trayIconLeftClick,
      "Show Gazelle", r { activateFrame(mainWindow) },
      "Exit Gazelle", r cleanExit
    );
  }
}

p {
  __javax = x30.class;
  loadableUtils.utils.__setJavaX(x30.class);
  vm_generalMap_put(stefansOS := mc());
  __javax = x30.class;
  x30.__javax = x30.class; // for hotwire
  x30_pkg.x30_util.__setJavaX(x30.class);
  x30.cleanKillMsg = "";
  callOnLoadMethods(mc());
  
  argsSet = asSet(args);
  
  if (!argsSet.contains("noflatlaf"))
    com.formdev.flatlaf.FlatLightLaf.setup();
  
  if (contains(args, "profile"))
    profileToConsole(() -> actualMain(args));
  else
    actualMain(args);
    
  if (argsSet.contains("brexit")) System.exit(0);
  
  temp gazelle.enter();
  gazelle.start();
}

svoid actualMain(S... args) {
  // Do the JavaX init
  
  System.out.println(hmsWithColonsAndMS() + ": Init");
  //x30.coreInit();
  
  // Ready to roll
  
  if (containsOneOf(argsSet, "upgrade", "update"))
    ret with upgradeGazelle();

  makeTrayIcon();
  
  printWithMS("new GazelleV");
  gazelle = new GazelleV;
  stem = new Stem;
  gazelle._host = stem;
  copyLocalLog(gazelle, mc());

  temp gazelle.enter();
  printWithMS("Visualize");
  var vis = swing(() -> gazelle.visualize());
  
  vis = makeWindowBorderAndTitle(vis, windowTitle);
  printWithMS("Show frame");
  //stem.window = showMainFrame("Gazella", vis);
  JFrame frame = makeUndecoratedFrame(windowTitle, vis);
  setFrameIcon(frame, trayIconImageID);
  stem.window = mainWindow = frame;
  onWindowClosing(stem.window, r cleanExit);
  showWindow(stem.window);
  printWithMS("Dudadoneski");
}

svoid minimize {
  if (trayIcon == null)
    minimizeWindow(mainWindow);
  else
    hideWindow(mainWindow);
}  

static JComponent makeWindowBorderAndTitle(JComponent contents, S title) {
  //ret jCenteredSection_fontSizePlus(10, title, vis);
  
  var icons = jline();
  icons.add(jbutton("Minimize", r minimize));
  icons.add(jbutton("Close", r { disposeWindow(icons) }));
  icons.add(jPopDownButton_noText(
    "Update Gazelle", rThread upgradeGazelle,
    "Dump threads", rThread { showText("User threads", renderUserThreadsWithStackTraces()); },
  ));
  
  var actualTitle = fontSizePlus(7, jCenteredLabel(title));
  var spacer = gazelle_wavySpacer();
  var titleBarMain = setOpaqueBackground(color1,
    westCenterAndEastWithMargin(
      jImage_scaledToHeight(24, trayIconImageID),
      actualTitle,
      setOpaqueBackground(color2, spacer));
  
  installWindowDragger(actualTitle);
  installWindowDragger(spacer);
  
  var titleBar = setBackground(color2, centerAndEast(
    titleBarMain,
    icons));
  
  var border =
    // createBevelBorder();
    BorderFactory.createLineBorder(color1, borderSize);
    
  var outerPanel = withBorder(border,
    northAndCenter(titleBar, contents));
    
  installWindowResizeDraggerOnBorder(outerPanel);
  ret outerPanel;
}

sO dm_getStem(O moduleOrID) {
  ret stem;
}

sO resolveModule(O moduleOrID) { ret moduleOrID == stem ? gazelle : moduleOrID; }

svoid cleanExit {
  System.exit(0);
}

svoid upgradeGazelle {
  File myJar = getBytecodePathForClass(mc());
  print(+myJar);
  
  S javaCmd = or2(currentProcessCommand(), "java");
  S date = ymdMinusHMS();
  File f = javaxCodeDir("Downloaded Updates/" + "gazelle-" + date + ".jar");
  infoBox("Downloading Update...");
  loadBinaryPageToFile(downloadURL, f);
  printFileInfo(f);
  if (!isNonEmptySingleZip_byMagicHeader(f))
    ret with  infoBox("Bad file downloaded... :(");
    
  bool replaced;
  if (isFile(myJar)) {
    print("Loaded " + nClasses(loadAllClassesInByteCodePath(myJar)));
    print("Replacing with new version: " + myJar);
    renameFile(myJar, appendToBaseName(myJar, ".bak." + date));
    copyFile(f, myJar);
    printFileInfo(myJar);
    set replaced;
  }
    
  infoBox(replaced
    ? "Installed update, replaced " + f2s(myJar) + " - now starting"
    : "Starting update, but could not replace originally downloaded jar");
  S cmd = pqO(javaCmd) + " -jar " + pqO(replaced ? myJar : f);
  print(cmd);
  nohup(cmd);
  cleanExit();
}

!include early #1033508 // GazelleV

Author comment

Began life as a copy of #1033309

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033411
Snippet name: Standalone Gazelle V [HEAD]
Eternal ID of this version: #1033411/144
Text MD5: 02a6be6768e6dd844336684208d36070
Transpilation MD5: 1e2341d2fa707b3c457db45469e8e026
Author: stefan
Category: javax / screen recognition
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-30 14:57:51
Source code size: 5312 bytes / 200 lines
Pitched / IR pitched: No / No
Views / Downloads: 824 / 2466
Version history: 143 change(s)
Referenced in: [show references]