Support | News | Classic | F.A.Q. | Discord | Discussions | Wiki | Roadmap

Button Modding

Parts can have user interface (UI) buttons which can change the workings of a part. There are technically two types of UI buttons based on the difference on how they are engaged. There is also a type of list button.

UI button

A custom button has to be added to vanilla's

  • Cosmoteer 0.9.13 to 0.13.9: game gui.txt
  • Cosmoteer 0.14.0: part_toggles.txt or part_triggers.txt

which is done via the mod.txt
A UI button can offer many operational options or modes, here, also referred to as a state. Each state can be represented by a different looking button sprite representing the state, hence, has to be declared.

	{
		Action = Add
		AddTo = "<Gui/game gui.txt>/PartToggles"
		Name = "TractorBeamPush"
		ToAdd
		{
			ToggleID = "tractorbeam_push"
			Style = CycledButton
			Choices
			[
				// tractor beam pushing off
				{
					ChoiceID = "fire_mode_push_off" // 0.14.5+
					ButtonToolTipKey = "PartToggles/FireMode_Push_off"
					ButtonSprite
					{
						Texture = "Gui/tractor_beam_push_off.png"
					}
				}

			// tractor beam pushing on
			{
				ChoiceID = "fire_mode_push_on" // 0.14.5+
				ButtonToolTipKey = "PartToggles/FireMode_Push_on"
				ButtonSprite
				{
					Texture = "Gui/tractor_beam_push_on.png"
				}
			}
		]
	}
}

or more advanced

	{
		Action = AddMany
		AddTo = "<gui/game/parts/part_toggles.txt>/PartToggles"
		ManyToAdd = &<gui/part_toggles.txt>/PartToggles
	}

Do the same for PartTriggers buttons.

Then the Input and actual tooltip has to be set in en.txt. Each state must be setup separately for each of the two sections!

Inputs
{
	PartToggles
	{
		tractorbeam_push = "Toggle tractor beam push on/off"
	}
}
PartToggles
{
	FireMode_Push_off = "<b>Tractor Beam Direction: <bad>Push</bad></b> <btn id='PartToggles.tractorbeam_push'/>"
	FireMode_Push_on = "<b>Tractor Beam Direction: <good>Push</good></b> <btn id='PartToggles.tractorbeam_push'/>"
}

Do the same for PartTriggers buttons.
Text styles can be used with some limitation compared to the rest in en.txt. Each section has different text styling features available. Note: If the button uses a sprite the reference to the button must be added.

For a part to use the button it has to include the component for it.

		MyUIButton
		{
			Type = UIToggle
			ToggleID = "tractorbeam_push"
			DefaultToggleValue = 0
			ToggledOnChoices = [1]
		}

List button

Since Cosmoteer 0.14.0 it's possible to have a sort of list buttons to select for example different ammo. This is done by giving the button Popout as its style.

	// Missile type
	{
		ToggleID = "missile_type"
		Style = Popout
		ShowInEditor = true
		Choices
		[
			// High-Explosive.
			{
				ChoiceID = "missile_type_he"
				ButtonToolTipKey = "PartToggles/MissileType_HE"
				ButtonSprite
				{
					Texture
					{
						File = "missile_type_he.png"
						MipLevels = 2
						SampleMode = Linear
					}
				}
			}
			// EMP.
			{
				ChoiceID = "missile_type_emp"
				ButtonToolTipKey = "PartToggles/MissileType_EMP"
				ButtonSprite
				{
					Texture
					{
						File = "missile_type_emp.png"
						MipLevels = 2
						SampleMode = Linear
					}
				}
			}
		]
	}

Instead of a sprite for a button it could be just a text.

			{
				ChoiceID = "sequence_firing_mode_single"
				ButtonTextKey = "PartToggles/Rocket_FiringMode_Single_"
				ButtonToolTipKey = "PartToggles/Rocket_FiringMode_Single"
			}

The text has to be set in en.txt

Write a Reply...