Search in sources :

Example 1 with GuiConfig

use of net.minecraftforge.fml.client.config.GuiConfig in project DynamicSurroundings by OreCruncher.

the class GuiConfigBase method actionPerformed.

/**
 * Called by the controls from the buttonList when activated. (Mouse pressed for
 * buttons)
 */
@Override
protected void actionPerformed(GuiButton button) {
    if (button.id == 2000) {
        boolean flag = true;
        try {
            if ((this.configID != null || this.parentScreen == null || !(this.parentScreen instanceof GuiConfig)) && (this.entryList.hasChangedEntry(true))) {
                final boolean requiresMcRestart = this.entryList.saveConfigElements();
                // My hook for massaging the results
                doFixups();
                if (Loader.isModLoaded(this.modID)) {
                    final ConfigChangedEvent event = new OnConfigChangedEvent(this.modID, this.configID, this.isWorldRunning, requiresMcRestart);
                    MinecraftForge.EVENT_BUS.post(event);
                    if (!event.getResult().equals(Result.DENY))
                        MinecraftForge.EVENT_BUS.post(new PostConfigChangedEvent(this.modID, this.configID, this.isWorldRunning, requiresMcRestart));
                    if (requiresMcRestart) {
                        flag = false;
                        this.mc.displayGuiScreen(new GuiMessageDialog(this.parentScreen, "fml.configgui.gameRestartTitle", new TextComponentString(I18n.format("fml.configgui.gameRestartRequired")), "fml.configgui.confirmRestartMessage"));
                    }
                    if (this.parentScreen instanceof GuiConfig)
                        ((GuiConfig) this.parentScreen).needsRefresh = true;
                }
            }
        } catch (final Throwable e) {
            FMLLog.log.error("Error performing GuiConfig action:", e);
        }
        if (flag)
            this.mc.displayGuiScreen(this.parentScreen);
    } else if (button.id == 2001) {
        this.entryList.setAllToDefault(this.chkApplyGlobally.isChecked());
    } else if (button.id == 2002) {
        this.entryList.undoAllChanges(this.chkApplyGlobally.isChecked());
    }
}
Also used : PostConfigChangedEvent(net.minecraftforge.fml.client.event.ConfigChangedEvent.PostConfigChangedEvent) OnConfigChangedEvent(net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent) GuiConfig(net.minecraftforge.fml.client.config.GuiConfig) GuiMessageDialog(net.minecraftforge.fml.client.config.GuiMessageDialog) ConfigChangedEvent(net.minecraftforge.fml.client.event.ConfigChangedEvent) PostConfigChangedEvent(net.minecraftforge.fml.client.event.ConfigChangedEvent.PostConfigChangedEvent) OnConfigChangedEvent(net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 2 with GuiConfig

use of net.minecraftforge.fml.client.config.GuiConfig in project DynamicSurroundings by OreCruncher.

the class PresetsConfigGui method onGuiClosed.

@Override
public void onGuiClosed() {
    super.onGuiClosed();
    if (this.parentScreen instanceof GuiConfig) {
        final GuiConfig parentGuiConfig = (GuiConfig) this.parentScreen;
        parentGuiConfig.needsRefresh = true;
        parentGuiConfig.initGui();
    }
}
Also used : GuiConfig(net.minecraftforge.fml.client.config.GuiConfig)

Aggregations

GuiConfig (net.minecraftforge.fml.client.config.GuiConfig)2 TextComponentString (net.minecraft.util.text.TextComponentString)1 GuiMessageDialog (net.minecraftforge.fml.client.config.GuiMessageDialog)1 ConfigChangedEvent (net.minecraftforge.fml.client.event.ConfigChangedEvent)1 OnConfigChangedEvent (net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent)1 PostConfigChangedEvent (net.minecraftforge.fml.client.event.ConfigChangedEvent.PostConfigChangedEvent)1