-
Notifications
You must be signed in to change notification settings - Fork 10
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
1455c42
commit b106a8d
Showing
26 changed files
with
453 additions
and
13 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
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
77 changes: 77 additions & 0 deletions
77
common/src/main/java/moe/caramel/chat/PlatformProvider.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,77 @@ | ||
package moe.caramel.chat; | ||
|
||
import moe.caramel.chat.util.ModLogger; | ||
|
||
/** | ||
* Platform Provider Interface | ||
*/ | ||
public abstract class PlatformProvider { | ||
|
||
/** | ||
* Mod id. | ||
*/ | ||
public static final String MOD_ID = "caramelchat"; | ||
|
||
/** | ||
* Default Provider. | ||
*/ | ||
public static final PlatformProvider DEFAULT = new PlatformProvider() { | ||
@Override | ||
public String getVersion() { | ||
return "UNKNOWN"; | ||
} | ||
|
||
@Override | ||
public String getPlatformName() { | ||
return "UNKNOWN"; | ||
} | ||
}; | ||
|
||
// ================================ | ||
|
||
private static PlatformProvider provider = PlatformProvider.DEFAULT; | ||
|
||
/** | ||
* Gets the Platform provider. | ||
* | ||
* @return provider | ||
*/ | ||
public static PlatformProvider getProvider() { | ||
return provider; | ||
} | ||
|
||
/** | ||
* Sets the Platform provider. | ||
* | ||
* @param provider provider | ||
*/ | ||
public static void setProvider(final PlatformProvider provider) { | ||
if (PlatformProvider.provider == PlatformProvider.DEFAULT) { | ||
PlatformProvider.provider = provider; | ||
ModLogger.log("The platform provider has been loaded: {}", provider); | ||
} else { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} | ||
|
||
// ================================ | ||
|
||
/** | ||
* Gets the current mod version. | ||
* | ||
* @return mod version | ||
*/ | ||
public abstract String getVersion(); | ||
|
||
/** | ||
* Gets the current platform name. | ||
* | ||
* @return platform name | ||
*/ | ||
public abstract String getPlatformName(); | ||
|
||
@Override | ||
public String toString() { | ||
return "(" + getPlatformName() + " / " + getVersion() + ")"; | ||
} | ||
} |
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
54 changes: 54 additions & 0 deletions
54
common/src/main/java/moe/caramel/chat/driver/KeyboardStatus.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,54 @@ | ||
package moe.caramel.chat.driver; | ||
|
||
/** | ||
* Gets the current keyboard status. | ||
* | ||
* @param language current ime language | ||
* @param useNative whether to using the native language | ||
*/ | ||
public record KeyboardStatus(Language language, boolean useNative) { | ||
|
||
@Override | ||
public Language language() { | ||
return useNative() ? language : Language.ENGLISH; | ||
} | ||
|
||
/** | ||
* Gets the display to use for language change notifications. | ||
* | ||
* @return display | ||
*/ | ||
public String display() { | ||
return language().display; | ||
} | ||
|
||
/** | ||
* Gets the indicator X offset. | ||
* | ||
* @return X offset | ||
*/ | ||
public float offset() { | ||
return language().offset; | ||
} | ||
|
||
/** | ||
* Display List | ||
*/ | ||
public enum Language { | ||
|
||
ENGLISH("ENG", 0.5f), | ||
KOREAN("한", 0.0f), | ||
JAPANESE("あ", 0.5f), | ||
CHINESE_SIMPLIFIED("中", 0.5f), | ||
CHINESE_TRADITIONAL("中", 0.5f), | ||
OTHER("Native", 0.5f); | ||
|
||
private final String display; | ||
private final float offset; | ||
|
||
Language(final String display, final float offset) { | ||
this.display = display; | ||
this.offset = offset; | ||
} | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
common/src/main/java/moe/caramel/chat/driver/arch/unknown/UnknownOperator.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
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
Oops, something went wrong.