Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "base/internal/ui/reflexcore"
- local function checkDefaults(defaults, target)
- for k, v in pairs(defaults) do
- if(type(v) == 'table') then checkDefaults(v, target);
- CheckSetDefaultValue(target, k, type(v), v);
- end
- end
- end
- CrosshairWeapons = {
- canPosition = false;
- defaultData = {crosshairs = {
- [1] = {style = 1; size = 16; color = Color(255,255,255);};
- [2] = {style = 10; size = 16; color = Color(255,255,255);};
- [3] = {style = 4; size = 16; color = Color(255,255,255);};
- [4] = {style = 10; size = 16; color = Color(255,255,255);};
- [5] = {style = 1; size = 16; color = Color(255,255,255);};
- [6] = {style = 10; size = 64; color = Color(255,255,255);};
- [7] = {style = 1; size = 16; color = Color(255,255,255);};
- [8] = {style = 4; size = 16; color = Color(255,255,255);};
- };
- };
- crosshairWidget = nil;
- userData = nil;
- optionHeight = 0;
- ------------------------------------------------------------------
- -- INITIALIZE!
- ------------------------------------------------------------------
- initialize = function(self)
- self.crosshairWidgetName = "Crosshairs";
- -- Load userData
- self.userData = loadUserData();
- CheckSetDefaultValue(self, "userData", 'table', {});
- checkDefaults(self.defaultData, self.userData);
- --get Crosshair widget data.
- self.crosshairWidget = _G[self.crosshairWidgetName];
- end;
- ------------------------------------------------------------------
- -- DRAW!
- ------------------------------------------------------------------
- draw = function(self)
- local crosshairData = self.crosshairWidget.userData;
- -- Early out if HUD shouldn't be shown.
- if not shouldShowHUD() then return end;
- local player = getPlayer();
- for k,v in pairs(self.userData.crosshairs) do
- if(self.userData.crosshairs[player.weaponIndexSelected]) then
- -- set crosshair type.
- consolePerformCommand("ui_" .. self.crosshairWidgetName .. "_type " .. self.userData.crosshairs[player.weaponIndexSelected].style);
- -- set crosshair size.
- crosshairData.crosshairSize = self.userData.crosshairs[player.weaponIndexSelected].size;
- -- set crosshair color.
- consolePerformCommand("ui_" .. self.crosshairWidgetName .. "_r " .. self.userData.crosshairs[player.weaponIndexSelected].color.r);
- consolePerformCommand("ui_" .. self.crosshairWidgetName .. "_g " .. self.userData.crosshairs[player.weaponIndexSelected].color.g);
- consolePerformCommand("ui_" .. self.crosshairWidgetName .. "_b " .. self.userData.crosshairs[player.weaponIndexSelected].color.b);
- end
- end
- end;
- ------------------------------------------------------------------
- -- DRAW OPTIONS!
- ------------------------------------------------------------------
- drawOptions = function(self, x, y)
- local sliderWidth = 100;
- local p = getPlayer() or getLocalPlayer();
- uiLabel("Type", x + sliderWidth + 10, y);
- uiLabel("Size", x + sliderWidth + 10 + 80, y);
- uiLabel("R", x + sliderWidth + 10 + 80 * 2, y);
- uiLabel("G", x + sliderWidth + 10 + 80 * 3, y);
- uiLabel("B", x + sliderWidth + 10 + 80 * 4, y);
- y = y + 40;
- -- Draw Options for each weapon
- for k = 1, #self.userData.crosshairs do -- i dont recommend using # to count tables. this case it doesnt matter though.
- uiLabel( p.weapons[k].name .. ":", x, y);
- y = y + 25;
- self.userData.crosshairs[k].style = round(uiSlider(x , y, sliderWidth, 1, 16, self.userData.crosshairs[k].style, k));
- self.userData.crosshairs[k].style = round(uiEditBox(self.userData.crosshairs[k].style, x + sliderWidth + 10, y, 60, k));
- self.userData.crosshairs[k].size = round(uiEditBox(self.userData.crosshairs[k].size, x + sliderWidth + 10 + 80, y, 60, k));
- self.userData.crosshairs[k].color.r = round(uiEditBox(self.userData.crosshairs[k].color.r, x + sliderWidth + 10 + 80 * 2, y, 60, k));
- self.userData.crosshairs[k].color.g = round(uiEditBox(self.userData.crosshairs[k].color.g, x + sliderWidth + 10 + 80 * 3, y, 60, k));
- self.userData.crosshairs[k].color.b = round(uiEditBox(self.userData.crosshairs[k].color.b, x + sliderWidth + 10 + 80 * 4, y, 60, k));
- y = y + 40;
- end
- self.optionHeight = y;
- saveUserData(self.userData);
- end;
- ------------------------------------------------------------------
- -- Get Height For Options ScrollBox.
- ------------------------------------------------------------------
- getOptionsHeight = function(self)
- return self.optionHeight; -- debug with: ui_optionsmenu_show_properties_height 1
- end;
- }
- registerWidget("CrosshairWeapons");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement