added contents

This commit is contained in:
Mark Minas
2024-09-18 17:04:31 +02:00
parent d28b17eba5
commit 71a4ac8d12
176 changed files with 51198 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
////////////////////////////////////////
// Programming project code
// UniBw M, 2022, 2023, 2024
// www.unibw.de/inf2
// (c) Mark Minas (mark.minas@unibw.de)
////////////////////////////////////////
package pp.dialog;
import com.jme3.app.Application;
import com.jme3.app.state.AppState;
import com.simsilica.lemur.DefaultCheckboxModel;
/**
* A checkbox model for enabling and disabling app states.
* This model links a checkbox with an AppState, so that checking
* or unchecking the box enables or disables the state, respectively.
*/
public class StateCheckboxModel extends DefaultCheckboxModel {
private final AppState state;
/**
* Constructs a StateCheckboxModel for the specified app state class.
*
* @param app the application containing the state manager
* @param stateClass the class of the app state to be controlled
*/
public StateCheckboxModel(Application app, Class<? extends AppState> stateClass) {
this(app.getStateManager().getState(stateClass));
}
/**
* Constructs a StateCheckboxModel for the specified app state.
*
* @param state the app state to be controlled
*/
public StateCheckboxModel(AppState state) {
this.state = state;
setChecked(state.isEnabled());
}
/**
* Sets the checked state of the checkbox and enables or disables
* the associated app state accordingly.
*
* @param checked true to check the box and enable the state, false to uncheck the box and disable the state
*/
@Override
public void setChecked(boolean checked) {
super.setChecked(checked);
state.setEnabled(checked);
}
}