Skip to content

Commit

Permalink
modified: OpenRA.Game/Widgets/SliderWidget.cs
Browse files Browse the repository at this point in the history
	modified:   OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs
	modified:   mods/ra/chrome/settings.yaml
  • Loading branch information
earthpig committed Apr 29, 2012
1 parent ea7056a commit c817b10
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 14 deletions.
13 changes: 12 additions & 1 deletion OpenRA.Game/Widgets/SliderWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class SliderWidget : Widget
{
public Func<bool> IsDisabled = () => false;
public event Action<float> OnChange = _ => {};
public event Action<int> OnChangeInt = _ => {};
public int Ticks = 0;
public int TrackHeight = 5;

Expand All @@ -33,6 +34,7 @@ public SliderWidget(SliderWidget other)
: base(other)
{
OnChange = other.OnChange;
OnChangeInt = other.OnChangeInt;
Ticks = other.Ticks;
MinimumValue = other.MinimumValue;
MaximumValue = other.MaximumValue;
Expand All @@ -45,6 +47,12 @@ void UpdateValue(float newValue)
Value = newValue.Clamp(MinimumValue, MaximumValue);
OnChange(Value);
}

void UpdateValue(int newValue)
{
Value = (int)newValue.Clamp(MinimumValue, MaximumValue);
OnChangeInt((int)Value);
}

public override bool HandleMouseInput(MouseInput mi)
{
Expand Down Expand Up @@ -78,7 +86,10 @@ public override bool HandleMouseInput(MouseInput mi)

float ValueFromPx(int x) { return MinimumValue + (MaximumValue - MinimumValue) * (1f * x / RenderBounds.Width); }
int PxFromValue(float x) { return (int)(RenderBounds.Width * (x - MinimumValue) / (MaximumValue - MinimumValue)); }


int ValueFromPxInt(int y) { return (int)(MinimumValue + (MaximumValue - MinimumValue) * (1f * y / RenderBounds.Width)); }
int PxFromValueInt(int y) { return (int)(RenderBounds.Width * (y - MinimumValue) / (MaximumValue - MinimumValue)); }

public override Widget Clone() { return new SliderWidget(this); }

Rectangle ThumbRect
Expand Down
4 changes: 3 additions & 1 deletion OpenRA.Mods.RA/AI/HackyAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ void AssignRolesToIdleUnits(Actor self)

/* Create an attack force when we have enough units around our base. */
// (don't bother leaving any behind for defense.)
int randomizedSquadSize = random.Next(Info.SquadSize/3, Info.SquadSize*3);

int randomizedSquadSize = Info.SquadSize - 4 + random.Next(200);

if (unitsHangingAroundTheBase.Count >= randomizedSquadSize)
{
BotDebug("Launch an attack.");
Expand Down
6 changes: 5 additions & 1 deletion OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ public SettingsMenuLogic()
var edgeScrollSlider = general.GetWidget<SliderWidget>("EDGE_SCROLL_AMOUNT");
edgeScrollSlider.Value = Game.Settings.Game.ViewportEdgeScrollStep;
edgeScrollSlider.OnChange += x => Game.Settings.Game.ViewportEdgeScrollStep = x;


var timeStepSlider = general.GetWidget<SliderWidget>("GAME_SPEED_AMOUNT");
timeStepSlider.Value = Game.Settings.Game.Timestep;
timeStepSlider.OnChangeInt += y => Game.Settings.Game.Timestep = y;

var inversescroll = general.GetWidget<CheckboxWidget>("INVERSE_SCROLL");
inversescroll.IsChecked = () => Game.Settings.Game.MouseScroll == MouseScrollType.Inverted;
inversescroll.OnClick = () => Game.Settings.Game.MouseScroll = (Game.Settings.Game.MouseScroll == MouseScrollType.Inverted) ? MouseScrollType.Standard : MouseScrollType.Inverted;
Expand Down
40 changes: 40 additions & 0 deletions mods/cnc/rules/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,46 @@ Player:
jeep: 0%
mtnk: 0%
arty: 0%
HackyAI@psydev:
Name:PsydevAI
BuildingFractions:
proc: 20%
nuke: 9%
pyle: 5%
hand: 5%
hq: 4%
nuk2: 9%
weap: 9%
afld: 9%
gtwr: 5%
gun: 5%
atwr: 9%
obli: 7%
sam: 7%
eye: 1%
tmpl: 1%
silo: 4%
fix: 1%
hpad: 2%
UnitsToBuild:
e1: 14%
e3: 7%
e2: 10%
e4: 7%
e5: 5%
harv: 1%
bggy: 5%
bike: 40%
ltnk: 25%
ftnk: 10%
arty: 60%
stnk: 40%
jeep: 5%
mtnk: 20%
msam: 40%
htnk: 50%
heli: 5%
orca: 5%
PlayerColorPalette:
BasePalette: terrain
PaletteFormat: cnc
Expand Down
20 changes: 17 additions & 3 deletions mods/ra/chrome/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,38 @@ Background@SETTINGS_MENU:
Ticks:5
MinimumValue: 10
MaximumValue: 50
Label@GAME_SPEED_AMOUNT_LABEL:
Id:EDGE_SCROLL_AMOUNT_LABEL
X:0
Y:100
Text: Game Speed
Slider@GAME_SPEED_AMOUNT:
Id:GAME_SPEED_AMOUNT
X:130
Y:90
Width:250
Height:20
Ticks:5
MinimumValue: 1
MaximumValue: 80
Checkbox@INVERSE_SCROLL:
Id:INVERSE_SCROLL
X:0
Y:90
Y:120
Width:200
Height:20
Text: Invert Mouse Drag Scrolling
Checkbox@TEAMCHAT_TOGGLE:
Id:TEAMCHAT_TOGGLE
X:0
Y:120
Y:145
Width:200
Height:20
Text: Shift-Enter Toggles Team Chat
Checkbox@SHOW_SHELLMAP:
Id:SHOW_SHELLMAP
X:0
Y:150
Y:170
Width:200
Height:20
Text: Show Shellmap
Expand Down
12 changes: 4 additions & 8 deletions mods/ra/rules/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,17 @@ Player:
3tnk: 50%
SquadSize: 10
HackyAI@epAI:
#If you make any changes to this, please rename your
# custom bot to something else to avoid confusion
# in viewing replays, sharing information, etc.
Name:epAI 120421
Name:epAI 120428
BuildingFractions:
proc: 25%
proc: 30%
powr: 35%
tent: 1%
barr: 1%
weap: 5%
pbox: 7%
gun: 10%
ftur: 5%
tsla: 15%
tsla: 14%
fix: 1%
dome: 3%
agun: 10%
Expand All @@ -153,7 +150,6 @@ Player:
stek: 1%
UnitsToBuild:
e1: 14%
e2: 7%
e3: 10%
harv: 20%
apc: 5%
Expand All @@ -164,7 +160,7 @@ Player:
3tnk: 60%
v2rl: 25%
arty: 25%
SquadSize: 10
SquadSize: 7

PlayerColorPalette:
BasePalette: terrain
Expand Down
2 changes: 2 additions & 0 deletions mods/ra/rules/vehicles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ ARTY:
PrimaryWeapon: 155mm
RenderUnit:
Explodes:
Weapon: UnitExplode
Chance: 75
AutoTarget:

HARV:
Expand Down

0 comments on commit c817b10

Please sign in to comment.