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

199
LINES

< > BotCompany Repo | #1033509 // Standalone Gazelle V [previous head]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 1663K of libraries. Click here for Pure Java version (27870L/153K).

1  
/*       WELCOME!! This is THE PROGRAM YOU ARE LOOKING FOR.
2  
3  
There is a SLIGHT COMPILE ISSUE which we are RESOLVING RIGHT NOW.
4  
-Stefan Reich, 2021/10/29 05:34:21 UTC
5  
*/
6  
7  
!7
8  
9  
sS windowTitle = "Gazelle V 2020-10-28 .09";
10  
sS downloadURL = "https://botcompany.de/jar/1033411?withLibs=1&noCompiler=1";
11  
sS trayIconImageID = #1103047;
12  
static int borderSize = 5;
13  
static Color color1 = awtColor("ADD8E6");
14  
static Color color2 = awtColor("EEEEEE");
15  
static Color color3 = awtColor("A3C0AA");
16  
17  
lib 1400521 // FlatLAF
18  
19  
set flag PingV3.
20  
set flag NotifyingPrintLog.
21  
22  
static IF0<PingSource> ping_v3_pingSourceMaker() { ret () -> new PingSource; }
23  
24  
sclass Stem {
25  
  JFrame window;
26  
  
27  
  Rect getFrameRect() {
28  
    ret toRect(getBounds(window));
29  
  }
30  
}
31  
32  
static Stem stem;
33  
static GazelleV gazelle;
34  
static TrayIcon trayIcon;
35  
static JFrame mainWindow;
36  
static Set<S> argsSet;
37  
38  
svoid trayIconLeftClick {
39  
  activateFrame_v3(mainWindow);
40  
}
41  
42  
svoid makeTrayIcon {
43  
  pcall-short {
44  
    trayIcon_imageAutoSize = false;
45  
    trayIcon = installTrayIcon(trayIconImageID, windowTitle,
46  
      r trayIconLeftClick,
47  
      "Show Gazelle", r { activateFrame(mainWindow) },
48  
      "Exit Gazelle", r cleanExit
49  
    );
50  
  }
51  
}
52  
53  
p {
54  
  __javax = x30.class;
55  
  loadableUtils.utils.__setJavaX(x30.class);
56  
  vm_generalMap_put(stefansOS := mc());
57  
  __javax = x30.class;
58  
  x30.__javax = x30.class; // for hotwire
59  
  x30_pkg.x30_util.__setJavaX(x30.class);
60  
  x30.cleanKillMsg = "";
61  
  callOnLoadMethods(mc());
62  
  
63  
  argsSet = asSet(args);
64  
  
65  
  if (!argsSet.contains("noflatlaf"))
66  
    com.formdev.flatlaf.FlatLightLaf.setup();
67  
  
68  
  if (contains(args, "profile"))
69  
    profileToConsole(() -> actualMain(args));
70  
  else
71  
    actualMain(args);
72  
    
73  
  if (argsSet.contains("brexit")) System.exit(0);
74  
  
75  
  temp gazelle.enter();
76  
  gazelle.start();
77  
}
78  
79  
svoid actualMain(S... args) {
80  
  // Do the JavaX init
81  
  
82  
  System.out.println(hmsWithColonsAndMS() + ": Init");
83  
  //x30.coreInit();
84  
  
85  
  // Ready to roll
86  
  
87  
  if (containsOneOf(argsSet, "upgrade", "update"))
88  
    ret with upgradeGazelle();
89  
90  
  makeTrayIcon();
91  
  
92  
  printWithMS("new GazelleV");
93  
  gazelle = new GazelleV;
94  
  stem = new Stem;
95  
  gazelle._host = stem;
96  
  copyLocalLog(gazelle, mc());
97  
98  
  temp gazelle.enter();
99  
  printWithMS("Visualize");
100  
  var vis = swing(() -> gazelle.visualize());
101  
  
102  
  vis = makeWindowBorderAndTitle(vis, windowTitle);
103  
  printWithMS("Show frame");
104  
  //stem.window = showMainFrame("Gazella", vis);
105  
  JFrame frame = makeUndecoratedFrame(windowTitle, vis);
106  
  setFrameIcon(frame, trayIconImageID);
107  
  stem.window = mainWindow = frame;
108  
  onWindowClosing(stem.window, r cleanExit);
109  
  showWindow(stem.window);
110  
  printWithMS("Dudadoneski");
111  
}
112  
113  
svoid minimize {
114  
  if (trayIcon == null)
115  
    minimizeWindow(mainWindow);
116  
  else
117  
    hideWindow(mainWindow);
118  
}  
119  
120  
static JComponent makeWindowBorderAndTitle(JComponent contents, S title) {
121  
  //ret jCenteredSection_fontSizePlus(10, title, vis);
122  
  
123  
  var icons = jline();
124  
  icons.add(jbutton("Minimize", r minimize));
125  
  icons.add(jbutton("Close", r { disposeWindow(icons) }));
126  
  icons.add(jPopDownButton_noText(
127  
    "Update Gazelle", rThread upgradeGazelle,
128  
    "Dump threads", rThread { showText("User threads", renderUserThreadsWithStackTraces()); },
129  
  ));
130  
  
131  
  var actualTitle = fontSizePlus(7, jCenteredLabel(title));
132  
  var spacer = gazelle_wavySpacer();
133  
  var titleBarMain = setOpaqueBackground(color1,
134  
    westCenterAndEastWithMargin(
135  
      jImage_scaledToHeight(24, trayIconImageID),
136  
      actualTitle,
137  
      setOpaqueBackground(color2, spacer));
138  
  
139  
  installWindowDragger(actualTitle);
140  
  installWindowDragger(spacer);
141  
  
142  
  var titleBar = setBackground(color2, centerAndEast(
143  
    titleBarMain,
144  
    icons));
145  
  
146  
  var border =
147  
    // createBevelBorder();
148  
    BorderFactory.createLineBorder(color1, borderSize);
149  
    
150  
  var outerPanel = withBorder(border,
151  
    northAndCenter(titleBar, contents));
152  
    
153  
  installWindowResizeDraggerOnBorder(outerPanel);
154  
  ret outerPanel;
155  
}
156  
157  
sO dm_getStem(O moduleOrID) {
158  
  ret stem;
159  
}
160  
161  
sO resolveModule(O moduleOrID) { ret moduleOrID == stem ? gazelle : moduleOrID; }
162  
163  
svoid cleanExit {
164  
  System.exit(0);
165  
}
166  
167  
svoid upgradeGazelle {
168  
  File myJar = getBytecodePathForClass(mc());
169  
  print(+myJar);
170  
  
171  
  S javaCmd = or2(currentProcessCommand(), "java");
172  
  S date = ymdMinusHMS();
173  
  File f = javaxCodeDir("Downloaded Updates/" + "gazelle-" + date + ".jar");
174  
  infoBox("Downloading Update...");
175  
  loadBinaryPageToFile(downloadURL, f);
176  
  printFileInfo(f);
177  
  if (!isNonEmptySingleZip_byMagicHeader(f))
178  
    ret with  infoBox("Bad file downloaded... :(");
179  
    
180  
  bool replaced;
181  
  if (isFile(myJar)) {
182  
    print("Loaded " + nClasses(loadAllClassesInByteCodePath(myJar)));
183  
    print("Replacing with new version: " + myJar);
184  
    renameFile(myJar, appendToBaseName(myJar, ".bak." + date));
185  
    copyFile(f, myJar);
186  
    printFileInfo(myJar);
187  
    set replaced;
188  
  }
189  
    
190  
  infoBox(replaced
191  
    ? "Installed update, replaced " + f2s(myJar) + " - now starting"
192  
    : "Starting update, but could not replace originally downloaded jar");
193  
  S cmd = pqO(javaCmd) + " -jar " + pqO(replaced ? myJar : f);
194  
  print(cmd);
195  
  nohup(cmd);
196  
  cleanExit();
197  
}
198  
199  
!include early #1033309 // GazelleV

Author comment

Began life as a copy of #1033411

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): bhatertpkbcr, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033509
Snippet name: Standalone Gazelle V [previous head]
Eternal ID of this version: #1033509/5
Text MD5: 480f923a1bd9adf5d0e6fb3ff7e4d48c
Transpilation MD5: 4805576a848aca038d52b2d4de6a46e6
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-29 08:11:50
Source code size: 5329 bytes / 199 lines
Pitched / IR pitched: No / No
Views / Downloads: 193 / 719
Version history: 4 change(s)
Referenced in: [show references]