-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65f3707
commit 20cdab1
Showing
7 changed files
with
182 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
1.7.10/src/main/java/city/windmill/ingameime/IMEventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package city.windmill.ingameime; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public interface IMEventHandler { | ||
IMStates onScreenClose(); | ||
|
||
IMStates onControlFocus(@Nonnull Object control, boolean focused); | ||
|
||
IMStates onScreenOpen(@Nullable Object screen); | ||
|
||
IMStates onToggleKey(); | ||
|
||
IMStates onMouseMove(); | ||
} |
98 changes: 98 additions & 0 deletions
98
1.7.10/src/main/java/city/windmill/ingameime/IMStates.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package city.windmill.ingameime; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public enum IMStates implements IMEventHandler { | ||
Disabled { | ||
@Override | ||
public IMStates onControlFocus(@Nonnull Object control, boolean focused) { | ||
if (focused) { | ||
ActiveControl = control; | ||
IngameIME_Forge.LOG.info("Opened by control focus: {}", ActiveControl.getClass()); | ||
Internal.setActivated(true); | ||
return OpenedAuto; | ||
} else { | ||
return this; | ||
} | ||
} | ||
|
||
@Override | ||
public IMStates onToggleKey() { | ||
IngameIME_Forge.LOG.info("Turned on by toggle key"); | ||
Internal.setActivated(true); | ||
return OpenedManual; | ||
} | ||
|
||
}, | ||
OpenedManual { | ||
@Override | ||
public IMStates onControlFocus(@Nonnull Object control, boolean focused) { | ||
// Ignore all focus event | ||
return this; | ||
} | ||
|
||
@Override | ||
public IMStates onMouseMove() { | ||
if (!Config.TurnOffOnMouseMove.getBoolean()) return this; | ||
IngameIME_Forge.LOG.info("Turned off by mouse move"); | ||
Internal.setActivated(false); | ||
return Disabled; | ||
} | ||
}, | ||
OpenedAuto { | ||
@Override | ||
public IMStates onControlFocus(@Nonnull Object control, boolean focused) { | ||
// Ignore not active focus one | ||
if (!focused && control != ActiveControl) return this; | ||
|
||
if (!focused) { | ||
IngameIME_Forge.LOG.info("Turned off by losing control focus: {}", ActiveControl.getClass()); | ||
Internal.setActivated(false); | ||
return Disabled; | ||
} | ||
|
||
// Update active focused control | ||
if (ActiveControl != control) { | ||
ActiveControl = control; | ||
IngameIME_Forge.LOG.info("Opened by control focus: {}", ActiveControl.getClass()); | ||
Internal.setActivated(true); | ||
ClientProxy.Screen.WInputMode.setActive(true); | ||
} | ||
return this; | ||
} | ||
}; | ||
|
||
@Nullable | ||
public static Object ActiveScreen = null; | ||
@Nullable | ||
public static Object ActiveControl = null; | ||
|
||
@Override | ||
public IMStates onScreenClose() { | ||
if (ActiveScreen != null) IngameIME_Forge.LOG.info("Screen closed: {}", ActiveScreen.getClass()); | ||
Internal.setActivated(false); | ||
ActiveScreen = null; | ||
return Disabled; | ||
} | ||
|
||
@Override | ||
public IMStates onScreenOpen(Object screen) { | ||
if (ActiveScreen == screen) return this; | ||
ActiveScreen = screen; | ||
if (ActiveScreen != null) IngameIME_Forge.LOG.info("Screen Opened: {}", ActiveScreen.getClass()); | ||
return this; | ||
} | ||
|
||
@Override | ||
public IMStates onMouseMove() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public IMStates onToggleKey() { | ||
IngameIME_Forge.LOG.info("Turned off by toggle key"); | ||
Internal.setActivated(false); | ||
return Disabled; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters