-
Notifications
You must be signed in to change notification settings - Fork 43
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
Showing
15 changed files
with
305 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
# Done to increase the memory available to gradle. | ||
org.gradle.jvmargs=-Xmx1G | ||
org.gradle.jvmargs = -Xmx1G | ||
|
||
# Fabric Properties | ||
# check these on https://modmuss50.me/fabric.html | ||
minecraft_version=1.16.2 | ||
yarn_mappings=1.16.2+build.10 | ||
loader_version=0.9.1+build.205 | ||
fabric_version=0.18.0+build.397-1.16 | ||
# check these on https://modmuss50.me/fabric.html | ||
minecraft_version = 1.16.2 | ||
yarn_mappings = 1.16.2+build.10 | ||
loader_version = 0.9.1+build.205 | ||
fabric_version = 0.18.0+build.397-1.16 | ||
|
||
# Mod Properties | ||
mod_version = 1.2.1 | ||
maven_group = juliand665 | ||
archives_base_name = dynamic-fps | ||
mod_version = 1.3.0 | ||
maven_group = juliand665 | ||
archives_base_name = dynamic-fps | ||
|
||
# Dependencies | ||
#developer_mode_version=1.0.15 | ||
#mod_menu_version = 1.8.5+build.23 | ||
databreaker_version = 0.2.6 | ||
findbugs_version = 3.0.2 | ||
#developer_mode_version=1.0.15 | ||
|
||
findbugs_version = 3.0.2 | ||
databreaker_version = 0.2.6 | ||
modmenu_version = 1.14.6+build.31 | ||
cloth_version = 4.8.3 | ||
toml4j_version = 0.7.2 |
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,48 @@ | ||
package dynamicfps; | ||
|
||
import com.moandjiezana.toml.Toml; | ||
import com.moandjiezana.toml.TomlWriter; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public final class DynamicFPSConfig { | ||
private transient File file; | ||
/// Whether to disable or enable the frame rate drop when unfocused | ||
public boolean reduceFPSWhenUnfocused = true; | ||
/// The frame rate to target when unfocused (only applies if `enableUnfocusedFPS` is true) | ||
public int unfocusedFPS = 1; | ||
/// Whether or not to uncap FPS when hovered, even if it would otherwise be reduced | ||
public boolean restoreFPSWhenHovered = true; | ||
|
||
private DynamicFPSConfig() {} | ||
|
||
public static DynamicFPSConfig load() { | ||
File file = new File( | ||
FabricLoader.getInstance().getConfigDir().toString(), | ||
DynamicFPSMod.MOD_ID + ".toml" | ||
); | ||
|
||
DynamicFPSConfig config; | ||
if (file.exists()) { | ||
Toml configTOML = new Toml().read(file); | ||
config = configTOML.to(DynamicFPSConfig.class); | ||
config.file = file; | ||
} else { | ||
config = new DynamicFPSConfig(); | ||
config.file = file; | ||
config.save(); | ||
} | ||
return config; | ||
} | ||
|
||
public void save() { | ||
TomlWriter writer = new TomlWriter(); | ||
try { | ||
writer.write(this, file); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package dynamicfps; | ||
|
||
import io.github.prospector.modmenu.api.ConfigScreenFactory; | ||
import io.github.prospector.modmenu.api.ModMenuApi; | ||
import me.shedaniel.clothconfig2.api.ConfigBuilder; | ||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; | ||
import net.minecraft.client.gui.screen.Screen; | ||
|
||
import static dynamicfps.util.Localization.localized; | ||
|
||
public class DynamicFPSModMenu implements ModMenuApi { | ||
@Override | ||
public ConfigScreenFactory<?> getModConfigScreenFactory() { | ||
return DynamicFPSModMenu::genConfig; | ||
} | ||
|
||
private static Screen genConfig(Screen parent) { | ||
ConfigBuilder builder = ConfigBuilder.create() | ||
.setParentScreen(parent) | ||
.setTitle(localized("config", "title")) | ||
.setSavingRunnable(DynamicFPSMod.config::save); | ||
ConfigEntryBuilder entryBuilder = builder.entryBuilder(); | ||
|
||
// general | ||
builder.getOrCreateCategory(localized("config", "category.general")) | ||
.addEntry(entryBuilder | ||
.startBooleanToggle( | ||
localized("config", "reduce_when_unfocused"), | ||
DynamicFPSMod.config.reduceFPSWhenUnfocused | ||
) | ||
.setSaveConsumer(value -> DynamicFPSMod.config.reduceFPSWhenUnfocused = value) | ||
.build() | ||
) | ||
.addEntry(entryBuilder | ||
.startIntSlider( | ||
localized("config", "unfocused_fps"), | ||
DynamicFPSMod.config.unfocusedFPS, | ||
0, 60 | ||
) | ||
.setSaveConsumer(value -> DynamicFPSMod.config.unfocusedFPS = value) | ||
.build() | ||
) | ||
.addEntry(entryBuilder | ||
.startBooleanToggle( | ||
localized("config", "restore_when_hovered"), | ||
DynamicFPSMod.config.restoreFPSWhenHovered | ||
) | ||
.setSaveConsumer(value -> DynamicFPSMod.config.restoreFPSWhenHovered = value) | ||
.build() | ||
); | ||
|
||
return builder.build(); | ||
} | ||
} |
Oops, something went wrong.