Live Constant Tweaker

Live Constant Tweaker provides a GUI to tweak public static constants on the fly.

License

License

GroupId

GroupId

me.lachlanap.lct
ArtifactId

ArtifactId

lct
Last Version

Last Version

1.1
Release Date

Release Date

Type

Type

jar
Description

Description

Live Constant Tweaker
Live Constant Tweaker provides a GUI to tweak public static constants on the fly.
Project URL

Project URL

http://github.com/ThorinII/lct
Source Code Management

Source Code Management

http://github.com/ThorinII/lct

Download lct

How to add to project

<!-- https://jarcasting.com/artifacts/me.lachlanap.lct/lct/ -->
<dependency>
    <groupId>me.lachlanap.lct</groupId>
    <artifactId>lct</artifactId>
    <version>1.1</version>
</dependency>
// https://jarcasting.com/artifacts/me.lachlanap.lct/lct/
implementation 'me.lachlanap.lct:lct:1.1'
// https://jarcasting.com/artifacts/me.lachlanap.lct/lct/
implementation ("me.lachlanap.lct:lct:1.1")
'me.lachlanap.lct:lct:jar:1.1'
<dependency org="me.lachlanap.lct" name="lct" rev="1.1">
  <artifact name="lct" type="jar" />
</dependency>
@Grapes(
@Grab(group='me.lachlanap.lct', module='lct', version='1.1')
)
libraryDependencies += "me.lachlanap.lct" % "lct" % "1.1"
[me.lachlanap.lct/lct "1.1"]

Dependencies

test (2)

Group / Artifact Type Version
junit : junit jar 4.10
org.mockito : mockito-core jar 1.9.5

Project Modules

There are no modules declared in this project.

lct - The Live Constant Tweaker

The Live Constant Tweaker is designed for use in game developement, to help get your numbers (eg physics constants, timers) just right. It is Java based.

This is still a work in progress - as such it shouldn't really be used for 'real' projects.

Build Status

Using Live Constant Tweaker

Add this to your Maven pom:

<dependency>
    <groupId>me.lachlanap.lct</groupId>
    <artifactId>lct</artifactId>
    <version>1.1</version>
</dependency>

or translate it into the correct format for your build system.

Expected Use

Defining constants

Define your constants as public static fields (not final - that would defeat the purpose of tweaking), and annotate them with the Constant annotation:

public static class PhysicsConstants {
  @Constant(name = "Gravity", constraints = "1,100")
  public static float GRAVITY = 9.81f;
  
  @Constant(name = "Substeps in Frame", constraints = "1,")
  public static int NUMBER_OF_SUBSTEPS = 3;
  
  @Constant(name = "Coefficient of Friction")
  public static double FRICTION_COEFFICIENT = 0.3;
}

Note there is just one Constant annotation. Currently, you specify constraints like a limited range using a String - the exact format depends on the type of the field, but for number constants use it like this: "min,max", where either min or max can be omitted. Note the constraints parameter is optional.

Using the system

Just create an instance of the me.lachlanap.lct.LCTManager class:

LCTManager lct = new LCTManager();

Then register all your constant classes:

lct.register(PhysicsConstants.class);
// more if needed...

Load any saved settings (the idea is that you tweak settings, then save them):

String file = "game-constants.properties";
try {
  lct.loadSettings(file);
} catch (IOException ioe) {
  // handle file reading errors...
}

When you want to show the settings tweaker, either create an LCTEditor and install it in a Swing GUI, or just create an LCTFrame:

// Using an LCTEditor
LCTEditor editor = new LCTEditor(lct);
// add it to a panel...

// Using an LCTFrame
LCTFrame frame = new LCTFrame(lct);
frame.setVisible(true);

When all the tweaking is done, save the settings:

String file = "game-constants.properties";
try {
  lct.saveSettings(file);
} catch (IOException ioe) {
  // handle file writing errors...
}

Versions

Version
1.1
1.0