|
1 | 1 | --- /dev/null |
2 | 2 | +++ src/main/java/com/lushprojects/circuitjs1/client/ModDialog.java |
3 | | -@@ -0,0 +1,372 @@ |
| 3 | +@@ -0,0 +1,487 @@ |
4 | 4 | +/* |
5 | 5 | + Copyright (C) Paul Falstad and Usevalad Khatkevich |
6 | 6 | + |
|
24 | 24 | + |
25 | 25 | +import com.google.gwt.event.dom.client.ClickEvent; |
26 | 26 | +import com.google.gwt.event.dom.client.ClickHandler; |
| 27 | ++import com.google.gwt.event.dom.client.KeyPressEvent; |
| 28 | ++import com.google.gwt.event.dom.client.KeyPressHandler; |
| 29 | ++import com.google.gwt.event.dom.client.ChangeEvent; |
| 30 | ++import com.google.gwt.event.dom.client.ChangeHandler; |
27 | 31 | +import com.google.gwt.user.client.ui.DialogBox; |
28 | 32 | +import com.google.gwt.user.client.ui.VerticalPanel; |
29 | 33 | +import com.google.gwt.user.client.ui.HTML; |
|
34 | 38 | +import com.google.gwt.user.client.ui.HasVerticalAlignment; |
35 | 39 | +import com.google.gwt.user.client.ui.CheckBox; |
36 | 40 | +import com.google.gwt.storage.client.Storage; |
| 41 | ++import com.google.gwt.user.client.ui.Label; |
| 42 | ++import com.google.gwt.user.client.ui.TextBox; |
| 43 | ++import com.google.gwt.user.client.ui.ListBox; |
| 44 | ++import com.google.gwt.user.client.ui.ValueBoxBase.TextAlignment; |
37 | 45 | + |
38 | 46 | +public class ModDialog extends DialogBox { |
39 | 47 | + |
|
78 | 86 | + native boolean CirSimIsRunning()/*-{ |
79 | 87 | + return $wnd.CircuitJS1.isRunning(); |
80 | 88 | + }-*/; |
81 | | -+ |
82 | | -+ //for "Other:" |
83 | 89 | + CheckBox setShowSidebaronStartup; |
| 90 | ++ CheckBox setOverlayingSidebar; |
| 91 | ++ |
| 92 | ++ HorizontalPanel SBAnimationSettings; |
| 93 | ++ TextBox DurationSB; |
| 94 | ++ CheckBox setAnimSidebar; |
| 95 | ++ ListBox SpeedCurveSB; |
| 96 | ++ |
| 97 | ++ int getSpeedCurveSBIndex(String val){ |
| 98 | ++ for (int i=0;i<=SpeedCurveSB.getItemCount();i++){ |
| 99 | ++ if (SpeedCurveSB.getValue(i)==val) |
| 100 | ++ return i; |
| 101 | ++ } |
| 102 | ++ return 1; |
| 103 | ++ } |
84 | 104 | + |
| 105 | ++ CheckBox setPauseWhenWinUnfocused; |
85 | 106 | + |
86 | 107 | + Button closeButton; |
87 | 108 | + |
|
233 | 254 | + vp2.add(setStopIcon = new CheckBox("Stop")); |
234 | 255 | + vp2.add(setPauseIcon = new CheckBox("Pause")); |
235 | 256 | + |
236 | | -+ vp3.add(hideSRBtns = new CheckBox("HIDE BUTTONS!")); |
| 257 | ++ vp3.add(hideSRBtns = new CheckBox("HIDE BUTTONS")); |
237 | 258 | + |
238 | 259 | + if (CirSim.absResetBtn.getElement().hasClassName("modDefaultResetBtn")) |
239 | 260 | + setDefaultSRBtns.setValue(true); |
|
246 | 267 | + if (lstor.getItem("MOD_absBtnIcon")=="stop") setStopIcon.setValue(true); |
247 | 268 | + else setPauseIcon.setValue(true); |
248 | 269 | + |
249 | | -+ if (!CirSim.absRunStopBtn.isVisible()) hideSRBtns.setValue(true); |
| 270 | ++ if (lstor.getItem("MOD_hideAbsBtns")=="true") hideSRBtns.setValue(true); |
250 | 271 | + |
251 | 272 | + setDefaultSRBtns.addClickHandler(new ClickHandler() { |
252 | 273 | + public void onClick(ClickEvent event) { |
|
342 | 363 | + } |
343 | 364 | + }); |
344 | 365 | + |
345 | | -+ vp.add(new HTML("<hr><big><b>Other:</b></big>")); |
| 366 | ++ vp.add(new HTML("<hr><big><b>Sidebar:</b></big>")); |
| 367 | ++ vp.add(setOverlayingSidebar = new CheckBox("Sidebar is overlaying")); |
| 368 | ++ vp.setCellVerticalAlignment(setOverlayingSidebar, HasVerticalAlignment.ALIGN_TOP); |
| 369 | ++ //vp.setCellHorizontalAlignment(setOverlayingSidebar, HasHorizontalAlignment.ALIGN_CENTER); |
| 370 | ++ |
| 371 | ++ vp.add(SBAnimationSettings = new HorizontalPanel()); |
| 372 | ++ SBAnimationSettings.setWidth("100%"); |
| 373 | ++ SBAnimationSettings.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); |
| 374 | ++ SBAnimationSettings.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); |
| 375 | ++ SBAnimationSettings.add(setAnimSidebar = new CheckBox("Animation:")); |
| 376 | ++ SBAnimationSettings.setCellHorizontalAlignment(setAnimSidebar, HasHorizontalAlignment.ALIGN_LEFT); |
| 377 | ++ SBAnimationSettings.add(new Label("duration is")); |
| 378 | ++ SBAnimationSettings.add(DurationSB = new TextBox()); |
| 379 | ++ DurationSB.setMaxLength(3);DurationSB.setVisibleLength(1); |
| 380 | ++ DurationSB.setHeight("0.6em"); |
| 381 | ++ DurationSB.setAlignment(TextAlignment.CENTER); |
| 382 | ++ SBAnimationSettings.add(new Label("ms,")); |
| 383 | ++ SBAnimationSettings.add(new Label("speed curve is")); |
| 384 | ++ SBAnimationSettings.add(SpeedCurveSB = new ListBox()); |
| 385 | ++ SpeedCurveSB.getElement().setAttribute("style","appearance:none;padding:1px;"); |
| 386 | ++ SpeedCurveSB.addItem("ease"); |
| 387 | ++ SpeedCurveSB.addItem("linear"); |
| 388 | ++ SpeedCurveSB.addItem("ease-in"); |
| 389 | ++ SpeedCurveSB.addItem("ease-out"); |
| 390 | ++ SpeedCurveSB.addItem("ease-in-out"); |
| 391 | ++ |
346 | 392 | + vp.add(setShowSidebaronStartup = new CheckBox("Show sidebar on startup")); |
347 | | -+ vp.setCellHorizontalAlignment(setShowSidebaronStartup, HasHorizontalAlignment.ALIGN_CENTER); |
| 393 | ++ //vp.setCellHorizontalAlignment(setShowSidebaronStartup, HasHorizontalAlignment.ALIGN_CENTER); |
| 394 | ++ |
| 395 | ++ if (lstor.getItem("MOD_overlayingSidebar")=="true") setOverlayingSidebar.setValue(true); |
| 396 | ++ else setAnimSidebar.setEnabled(false); |
| 397 | ++ if (lstor.getItem("MOD_overlayingSBAnimation")=="true") setAnimSidebar.setValue(true); |
| 398 | ++ |
| 399 | ++ DurationSB.setValue(lstor.getItem("MOD_SBAnim_duration")); |
| 400 | ++ SpeedCurveSB.setItemSelected(getSpeedCurveSBIndex(lstor.getItem("MOD_SBAnim_SpeedCurve")),true); |
| 401 | ++ |
| 402 | ++ DurationSB.addKeyPressHandler(new KeyPressHandler() { |
| 403 | ++ public void onKeyPress(KeyPressEvent event) { |
| 404 | ++ if (!Character.isDigit(event.getCharCode()) || DurationSB.getValue()=="0") { |
| 405 | ++ ((TextBox) event.getSource()).cancelKey(); |
| 406 | ++ } |
| 407 | ++ } |
| 408 | ++ }); |
| 409 | ++ |
| 410 | ++ DurationSB.addChangeHandler(new ChangeHandler() { |
| 411 | ++ public void onChange(ChangeEvent event) { |
| 412 | ++ lstor.setItem("MOD_SBAnim_duration", DurationSB.getValue()); |
| 413 | ++ if (setOverlayingSidebar.getValue()) CirSim.setSidebarAnimation(DurationSB.getValue(),SpeedCurveSB.getSelectedItemText()); |
| 414 | ++ } |
| 415 | ++ }); |
| 416 | ++ |
| 417 | ++ SpeedCurveSB.addChangeHandler(new ChangeHandler() { |
| 418 | ++ public void onChange(ChangeEvent event) { |
| 419 | ++ lstor.setItem("MOD_SBAnim_SpeedCurve", SpeedCurveSB.getSelectedItemText()); |
| 420 | ++ if (setOverlayingSidebar.getValue()) |
| 421 | ++ CirSim.setSidebarAnimation(DurationSB.getValue(),SpeedCurveSB.getSelectedItemText()); |
| 422 | ++ } |
| 423 | ++ }); |
| 424 | ++ |
| 425 | ++ setOverlayingSidebar.addClickHandler(new ClickHandler() { |
| 426 | ++ public void onClick(ClickEvent event) { |
| 427 | ++ if (setOverlayingSidebar.getValue()){ |
| 428 | ++ lstor.setItem("MOD_overlayingSidebar", "true"); |
| 429 | ++ setAnimSidebar.setEnabled(true); |
| 430 | ++ if (setAnimSidebar.getValue()) CirSim.setSidebarAnimation(DurationSB.getValue(),SpeedCurveSB.getSelectedItemText()); |
| 431 | ++ } else { |
| 432 | ++ lstor.setItem("MOD_overlayingSidebar", "false"); |
| 433 | ++ setAnimSidebar.setEnabled(false); |
| 434 | ++ CirSim.setSidebarAnimation("none",""); |
| 435 | ++ } |
| 436 | ++ } |
| 437 | ++ }); |
| 438 | ++ setAnimSidebar.addClickHandler(new ClickHandler() { |
| 439 | ++ public void onClick(ClickEvent event) { |
| 440 | ++ if (setAnimSidebar.getValue()){ |
| 441 | ++ lstor.setItem("MOD_overlayingSBAnimation", "true"); |
| 442 | ++ if (setOverlayingSidebar.getValue()) |
| 443 | ++ CirSim.setSidebarAnimation(DurationSB.getValue(),SpeedCurveSB.getSelectedItemText()); |
| 444 | ++ } else { |
| 445 | ++ lstor.setItem("MOD_overlayingSBAnimation", "false"); |
| 446 | ++ CirSim.setSidebarAnimation("none",""); |
| 447 | ++ } |
| 448 | ++ } |
| 449 | ++ }); |
| 450 | ++ |
348 | 451 | + if (lstor.getItem("MOD_showSidebaronStartup")=="true") setShowSidebaronStartup.setValue(true); |
349 | 452 | + setShowSidebaronStartup.addClickHandler(new ClickHandler() { |
350 | 453 | + public void onClick(ClickEvent event) { |
|
353 | 456 | + } else {lstor.setItem("MOD_showSidebaronStartup", "false");} |
354 | 457 | + } |
355 | 458 | + }); |
| 459 | ++ |
| 460 | ++ vp.add(new HTML("<hr><big><b>Other:</b></big>")); |
| 461 | ++ vp.add(setPauseWhenWinUnfocused = new CheckBox("Pause simulation when window loses focus<br>(recommended for optimal performance)",true)); |
| 462 | ++ vp.setCellHorizontalAlignment(setPauseWhenWinUnfocused, HasHorizontalAlignment.ALIGN_CENTER); |
| 463 | ++ if (lstor.getItem("MOD_setPauseWhenWinUnfocused")=="true") setPauseWhenWinUnfocused.setValue(true); |
| 464 | ++ setPauseWhenWinUnfocused.addClickHandler(new ClickHandler() { |
| 465 | ++ public void onClick(ClickEvent event) { |
| 466 | ++ if (setPauseWhenWinUnfocused.getValue()){ |
| 467 | ++ lstor.setItem("MOD_setPauseWhenWinUnfocused", "true"); |
| 468 | ++ } else {lstor.setItem("MOD_setPauseWhenWinUnfocused", "false");} |
| 469 | ++ } |
| 470 | ++ }); |
356 | 471 | + vp.add(new HTML("<br>")); |
357 | 472 | + |
358 | 473 | + vp.add(closeButton = new Button("<b>Close</b>", |
|
0 commit comments