Skip to content

Commit

Permalink
Update patches
Browse files Browse the repository at this point in the history
  • Loading branch information
SEVA77 committed Nov 4, 2024
1 parent c6a786e commit 5165612
Show file tree
Hide file tree
Showing 8 changed files with 723 additions and 60 deletions.
535 changes: 486 additions & 49 deletions patches/CirSim.patch

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions patches/EditDialog.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- /dev/null
+++ src/main/java/com/lushprojects/circuitjs1/client/EditDialog.java
@@ -162,6 +162,10 @@
if (ei.text == null) {
ei.textf.setText(unitString(ei));
}
+ if (ei.isColor){
+ ei.textf.getElement().setAttribute("type", "color");
+ ei.textf.getElement().setAttribute("style", "width:178px;padding:0");
+ }
}
if (vp.getWidgetCount() > 15) {
// start a new column
@@ -272,6 +276,8 @@
adj.setSliderValue(ei.value);
}
}
+ cframe.unsavedChanges = true;
+ cframe.changeWindowTitle(true);
cframe.needAnalyze();
}

10 changes: 10 additions & 0 deletions patches/EditInfo.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- /dev/null
+++ src/main/java/com/lushprojects/circuitjs1/client/EditInfo.java
@@ -77,6 +77,7 @@
boolean dimensionless;
boolean noSliders;
double minVal, maxVal;
+ boolean isColor = false;

// for slider dialog
TextBox minBox, maxBox, labelBox;
49 changes: 49 additions & 0 deletions patches/EditOptions.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
--- /dev/null
+++ src/main/java/com/lushprojects/circuitjs1/client/EditOptions.java
@@ -55,16 +55,36 @@
return ei;
}

- if (n == 3)
- return new EditInfo("Positive Color", CircuitElm.positiveColor.getHexValue());
- if (n == 4)
- return new EditInfo("Negative Color", CircuitElm.negativeColor.getHexValue());
- if (n == 5)
- return new EditInfo("Neutral Color", CircuitElm.neutralColor.getHexValue());
- if (n == 6)
- return new EditInfo("Selection Color", CircuitElm.selectColor.getHexValue());
- if (n == 7)
- return new EditInfo("Current Color", CircuitElm.currentColor.getHexValue());
+ if (n == 3){
+ EditInfo ei = new EditInfo("Positive Color", CircuitElm.positiveColor.getHexValue());
+ ei.isColor = true;
+ return ei;
+ }
+
+ if (n == 4){
+ EditInfo ei = new EditInfo("Negative Color", CircuitElm.negativeColor.getHexValue());
+ ei.isColor = true;
+ return ei;
+ }
+
+ if (n == 5){
+ EditInfo ei = new EditInfo("Neutral Color", CircuitElm.neutralColor.getHexValue());
+ ei.isColor = true;
+ return ei;
+ }
+
+ if (n == 6){
+ EditInfo ei = new EditInfo("Selection Color", CircuitElm.selectColor.getHexValue());
+ ei.isColor = true;
+ return ei;
+ }
+
+ if (n == 7){
+ EditInfo ei = new EditInfo("Current Color", CircuitElm.currentColor.getHexValue());
+ ei.isColor = true;
+ return ei;
+ }
+
if (n == 8)
return new EditInfo("# of Decimal Digits (short format)", CircuitElm.shortDecimalDigits);
if (n == 9)
2 changes: 1 addition & 1 deletion patches/HelpDialog.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- /dev/null
+++ src/main/java/com/lushprojects/circuitjs1/client/HelpDialog.java
@@ -0,0 +1,90 @@
@@ -0,0 +1,104 @@
+/*
+ Copyright (C) Paul Falstad, Iain Sharp and Usevalad Khatkevich
+
Expand Down
28 changes: 28 additions & 0 deletions patches/LoadFile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--- /dev/null
+++ src/main/java/com/lushprojects/circuitjs1/client/LoadFile.java
@@ -37,7 +37,7 @@
sim.readCircuit(s);
sim.createNewLoadFile();
sim.setCircuitTitle(t);
- ExportAsLocalFileDialog.setLastFileName(t);
+ sim.setLastFileName(t);
sim.unsavedChanges = false;
}

@@ -57,6 +57,16 @@
}


+ public native String getPath()
+ /*-{
+ return $doc.getElementById("LoadFileElement").value;
+ }-*/;
+
+ public native String getFileName()
+ /*-{
+ return $doc.getElementById("LoadFileElement").files[0].name;
+ }-*/;
+
public final native void click()
/*-{
$doc.getElementById("LoadFileElement").click();
129 changes: 122 additions & 7 deletions patches/ModDialog.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- /dev/null
+++ src/main/java/com/lushprojects/circuitjs1/client/ModDialog.java
@@ -0,0 +1,372 @@
@@ -0,0 +1,487 @@
+/*
+ Copyright (C) Paul Falstad and Usevalad Khatkevich
+
Expand All @@ -24,6 +24,10 @@
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.event.dom.client.KeyPressHandler;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ChangeHandler;
+import com.google.gwt.user.client.ui.DialogBox;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.HTML;
Expand All @@ -34,6 +38,10 @@
+import com.google.gwt.user.client.ui.HasVerticalAlignment;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.storage.client.Storage;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.ValueBoxBase.TextAlignment;
+
+public class ModDialog extends DialogBox {
+
Expand Down Expand Up @@ -78,10 +86,23 @@
+ native boolean CirSimIsRunning()/*-{
+ return $wnd.CircuitJS1.isRunning();
+ }-*/;
+
+ //for "Other:"
+ CheckBox setShowSidebaronStartup;
+ CheckBox setOverlayingSidebar;
+
+ HorizontalPanel SBAnimationSettings;
+ TextBox DurationSB;
+ CheckBox setAnimSidebar;
+ ListBox SpeedCurveSB;
+
+ int getSpeedCurveSBIndex(String val){
+ for (int i=0;i<=SpeedCurveSB.getItemCount();i++){
+ if (SpeedCurveSB.getValue(i)==val)
+ return i;
+ }
+ return 1;
+ }
+
+ CheckBox setPauseWhenWinUnfocused;
+
+ Button closeButton;
+
Expand Down Expand Up @@ -233,7 +254,7 @@
+ vp2.add(setStopIcon = new CheckBox("Stop"));
+ vp2.add(setPauseIcon = new CheckBox("Pause"));
+
+ vp3.add(hideSRBtns = new CheckBox("HIDE BUTTONS!"));
+ vp3.add(hideSRBtns = new CheckBox("HIDE BUTTONS"));
+
+ if (CirSim.absResetBtn.getElement().hasClassName("modDefaultResetBtn"))
+ setDefaultSRBtns.setValue(true);
Expand All @@ -246,7 +267,7 @@
+ if (lstor.getItem("MOD_absBtnIcon")=="stop") setStopIcon.setValue(true);
+ else setPauseIcon.setValue(true);
+
+ if (!CirSim.absRunStopBtn.isVisible()) hideSRBtns.setValue(true);
+ if (lstor.getItem("MOD_hideAbsBtns")=="true") hideSRBtns.setValue(true);
+
+ setDefaultSRBtns.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
Expand Down Expand Up @@ -342,9 +363,91 @@
+ }
+ });
+
+ vp.add(new HTML("<hr><big><b>Other:</b></big>"));
+ vp.add(new HTML("<hr><big><b>Sidebar:</b></big>"));
+ vp.add(setOverlayingSidebar = new CheckBox("Sidebar is overlaying"));
+ vp.setCellVerticalAlignment(setOverlayingSidebar, HasVerticalAlignment.ALIGN_TOP);
+ //vp.setCellHorizontalAlignment(setOverlayingSidebar, HasHorizontalAlignment.ALIGN_CENTER);
+
+ vp.add(SBAnimationSettings = new HorizontalPanel());
+ SBAnimationSettings.setWidth("100%");
+ SBAnimationSettings.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
+ SBAnimationSettings.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ SBAnimationSettings.add(setAnimSidebar = new CheckBox("Animation:"));
+ SBAnimationSettings.setCellHorizontalAlignment(setAnimSidebar, HasHorizontalAlignment.ALIGN_LEFT);
+ SBAnimationSettings.add(new Label("duration is"));
+ SBAnimationSettings.add(DurationSB = new TextBox());
+ DurationSB.setMaxLength(3);DurationSB.setVisibleLength(1);
+ DurationSB.setHeight("0.6em");
+ DurationSB.setAlignment(TextAlignment.CENTER);
+ SBAnimationSettings.add(new Label("ms,"));
+ SBAnimationSettings.add(new Label("speed curve is"));
+ SBAnimationSettings.add(SpeedCurveSB = new ListBox());
+ SpeedCurveSB.getElement().setAttribute("style","appearance:none;padding:1px;");
+ SpeedCurveSB.addItem("ease");
+ SpeedCurveSB.addItem("linear");
+ SpeedCurveSB.addItem("ease-in");
+ SpeedCurveSB.addItem("ease-out");
+ SpeedCurveSB.addItem("ease-in-out");
+
+ vp.add(setShowSidebaronStartup = new CheckBox("Show sidebar on startup"));
+ vp.setCellHorizontalAlignment(setShowSidebaronStartup, HasHorizontalAlignment.ALIGN_CENTER);
+ //vp.setCellHorizontalAlignment(setShowSidebaronStartup, HasHorizontalAlignment.ALIGN_CENTER);
+
+ if (lstor.getItem("MOD_overlayingSidebar")=="true") setOverlayingSidebar.setValue(true);
+ else setAnimSidebar.setEnabled(false);
+ if (lstor.getItem("MOD_overlayingSBAnimation")=="true") setAnimSidebar.setValue(true);
+
+ DurationSB.setValue(lstor.getItem("MOD_SBAnim_duration"));
+ SpeedCurveSB.setItemSelected(getSpeedCurveSBIndex(lstor.getItem("MOD_SBAnim_SpeedCurve")),true);
+
+ DurationSB.addKeyPressHandler(new KeyPressHandler() {
+ public void onKeyPress(KeyPressEvent event) {
+ if (!Character.isDigit(event.getCharCode()) || DurationSB.getValue()=="0") {
+ ((TextBox) event.getSource()).cancelKey();
+ }
+ }
+ });
+
+ DurationSB.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ lstor.setItem("MOD_SBAnim_duration", DurationSB.getValue());
+ if (setOverlayingSidebar.getValue()) CirSim.setSidebarAnimation(DurationSB.getValue(),SpeedCurveSB.getSelectedItemText());
+ }
+ });
+
+ SpeedCurveSB.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ lstor.setItem("MOD_SBAnim_SpeedCurve", SpeedCurveSB.getSelectedItemText());
+ if (setOverlayingSidebar.getValue())
+ CirSim.setSidebarAnimation(DurationSB.getValue(),SpeedCurveSB.getSelectedItemText());
+ }
+ });
+
+ setOverlayingSidebar.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ if (setOverlayingSidebar.getValue()){
+ lstor.setItem("MOD_overlayingSidebar", "true");
+ setAnimSidebar.setEnabled(true);
+ if (setAnimSidebar.getValue()) CirSim.setSidebarAnimation(DurationSB.getValue(),SpeedCurveSB.getSelectedItemText());
+ } else {
+ lstor.setItem("MOD_overlayingSidebar", "false");
+ setAnimSidebar.setEnabled(false);
+ CirSim.setSidebarAnimation("none","");
+ }
+ }
+ });
+ setAnimSidebar.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ if (setAnimSidebar.getValue()){
+ lstor.setItem("MOD_overlayingSBAnimation", "true");
+ if (setOverlayingSidebar.getValue())
+ CirSim.setSidebarAnimation(DurationSB.getValue(),SpeedCurveSB.getSelectedItemText());
+ } else {
+ lstor.setItem("MOD_overlayingSBAnimation", "false");
+ CirSim.setSidebarAnimation("none","");
+ }
+ }
+ });
+
+ if (lstor.getItem("MOD_showSidebaronStartup")=="true") setShowSidebaronStartup.setValue(true);
+ setShowSidebaronStartup.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
Expand All @@ -353,6 +456,18 @@
+ } else {lstor.setItem("MOD_showSidebaronStartup", "false");}
+ }
+ });
+
+ vp.add(new HTML("<hr><big><b>Other:</b></big>"));
+ vp.add(setPauseWhenWinUnfocused = new CheckBox("Pause simulation when window loses focus<br>(recommended for optimal performance)",true));
+ vp.setCellHorizontalAlignment(setPauseWhenWinUnfocused, HasHorizontalAlignment.ALIGN_CENTER);
+ if (lstor.getItem("MOD_setPauseWhenWinUnfocused")=="true") setPauseWhenWinUnfocused.setValue(true);
+ setPauseWhenWinUnfocused.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ if (setPauseWhenWinUnfocused.getValue()){
+ lstor.setItem("MOD_setPauseWhenWinUnfocused", "true");
+ } else {lstor.setItem("MOD_setPauseWhenWinUnfocused", "false");}
+ }
+ });
+ vp.add(new HTML("<br>"));
+
+ vp.add(closeButton = new Button("<b>Close</b>",
Expand Down
8 changes: 5 additions & 3 deletions patches/style.css.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- /dev/null
+++ src/main/java/com/lushprojects/circuitjs1/public/style.css
@@ -1,123 +1,92 @@
@@ -1,123 +1,94 @@
@charset "UTF-8";

-/*Hide all mobile elements when in desktop usage*/
Expand Down Expand Up @@ -45,6 +45,7 @@
- }
+.triggerLabel {
+ display: initial;
+ border: 1px solid #bbb;
+ border-radius: 10px 0px 0px 10px;
+ background: #e3e8f3 url(images/hborder.png) repeat-x 0px -2003px;
+ width: 25px;
Expand All @@ -53,7 +54,7 @@
+ top: 50px;
+ right: 0;
+ z-index: 1;
+ transition: right 1s;
+ /*transition: right 1s;*/
+ cursor: pointer;
+}
+.triggerLabel:before {
Expand Down Expand Up @@ -122,7 +123,8 @@
+ width: 0 !important;
+ background: white;
+ z-index: 1;
+ transition: width 1s;
+ /*transition: width 1s;*/
+ border-left: 1px solid #bbb;
+}
+.trigger:checked+.triggerLabel+div {
+ width: 166px !important;
Expand Down

0 comments on commit 5165612

Please sign in to comment.