|
1 | | -using System; |
| 1 | +using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Drawing; |
4 | 4 | using System.Linq; |
@@ -373,6 +373,9 @@ private List<MenuItem> VisibleMenuItems |
373 | 373 |
|
374 | 374 | public bool EnableInstructionalButtons { get; set; } = true; |
375 | 375 |
|
| 376 | + public float[] WeaponStats { get; private set; } = new float[4] { 0.5f, 0.5f, 0.5f, 0.5f }; |
| 377 | + public bool ShowWeaponStatsPanel { get; set; } = false; |
| 378 | + |
376 | 379 | private bool filterActive = false; |
377 | 380 |
|
378 | 381 | public Dictionary<Control, string> InstructionalButtons = new Dictionary<Control, string>() { { Control.FrontendAccept, GetLabelText("HUD_INPUT28") }, { Control.FrontendCancel, GetLabelText("HUD_INPUT53") } }; |
@@ -858,6 +861,11 @@ public void ResetFilter() |
858 | 861 | FilterItems.Clear(); |
859 | 862 | } |
860 | 863 |
|
| 864 | + public void SetWeaponStats(float damage, float fireRate, float accuracy, float range) |
| 865 | + { |
| 866 | + WeaponStats = new float[4] { MathUtil.Clamp(damage, 0f, 1f), MathUtil.Clamp(fireRate, 0f, 1f), MathUtil.Clamp(accuracy, 0f, 1f), MathUtil.Clamp(range, 0f, 1f) }; |
| 867 | + } |
| 868 | + |
861 | 869 | #endregion |
862 | 870 |
|
863 | 871 | #region internal task functions |
@@ -1272,6 +1280,178 @@ internal async void Draw() |
1272 | 1280 |
|
1273 | 1281 | #endregion |
1274 | 1282 |
|
| 1283 | + #region Draw Weapon Stats |
| 1284 | + { |
| 1285 | + if (Size > 0) |
| 1286 | + { |
| 1287 | + var currentItem = filterActive ? FilterItems[CurrentIndex] : MenuItems[CurrentIndex]; |
| 1288 | + if (currentItem is MenuListItem listItem) |
| 1289 | + { |
| 1290 | + if (listItem.ShowColorPanel || listItem.ShowOpacityPanel) |
| 1291 | + { |
| 1292 | + goto SKIP_WEAPON_STATS; |
| 1293 | + } |
| 1294 | + } |
| 1295 | + } |
| 1296 | + |
| 1297 | + if (ShowWeaponStatsPanel) |
| 1298 | + { |
| 1299 | + float textSize = (14f * 27f) / MenuController.ScreenHeight; |
| 1300 | + float width = Width / MenuController.ScreenWidth; |
| 1301 | + float height = (140f) / MenuController.ScreenHeight; |
| 1302 | + float x = ((Width / 2f) / MenuController.ScreenWidth); |
| 1303 | + float y = descriptionYOffset + (height / 2f) + (8f / MenuController.ScreenHeight); |
| 1304 | + if (Size > MaxItemsOnScreen) |
| 1305 | + { |
| 1306 | + y -= (30f / MenuController.ScreenHeight); |
| 1307 | + } |
| 1308 | + |
| 1309 | + |
| 1310 | + #region background |
| 1311 | + SetScriptGfxAlign(LeftAligned ? 76 : 82, 84); |
| 1312 | + SetScriptGfxAlignParams(0f, 0f, 0f, 0f); |
| 1313 | + DrawRect(x, y, width, height, 0, 0, 0, 180); |
| 1314 | + ResetScriptGfxAlign(); |
| 1315 | + #endregion |
| 1316 | + |
| 1317 | + float bgStatBarWidth = (Width / 2f) / MenuController.ScreenWidth; |
| 1318 | + float bgStatBarX = x + (bgStatBarWidth / 2f) - (10f / MenuController.ScreenWidth); |
| 1319 | + |
| 1320 | + if (!LeftAligned) |
| 1321 | + { |
| 1322 | + bgStatBarX = x - (bgStatBarWidth / 2f) - (10f / MenuController.ScreenWidth); |
| 1323 | + } |
| 1324 | + float barWidth; |
| 1325 | + float barY = y - (height / 2f) + (25f / MenuController.ScreenHeight); |
| 1326 | + float bgStatBarHeight = 10f / MenuController.ScreenHeight; |
| 1327 | + float barX; |
| 1328 | + #region damage bar |
| 1329 | + barWidth = bgStatBarWidth * WeaponStats[0]; |
| 1330 | + if (LeftAligned) |
| 1331 | + { |
| 1332 | + barX = bgStatBarX - (bgStatBarWidth / 2f) + (barWidth / 2f); |
| 1333 | + } |
| 1334 | + else |
| 1335 | + { |
| 1336 | + barX = (barWidth * 1.5f) - bgStatBarWidth - (10f / MenuController.ScreenWidth); |
| 1337 | + } |
| 1338 | + SetScriptGfxAlign(LeftAligned ? 76 : 82, 84); |
| 1339 | + SetScriptGfxAlignParams(0f, 0f, 0f, 0f); |
| 1340 | + // bar bg |
| 1341 | + DrawRect(bgStatBarX, barY, bgStatBarWidth, bgStatBarHeight, 100, 100, 100, 180); |
| 1342 | + // real bar |
| 1343 | + DrawRect(barX, barY, barWidth, bgStatBarHeight, 255, 255, 255, 255); |
| 1344 | + ResetScriptGfxAlign(); |
| 1345 | + #endregion |
| 1346 | + |
| 1347 | + #region fire rate bar |
| 1348 | + barWidth = bgStatBarWidth * WeaponStats[1]; |
| 1349 | + barY += 30f / MenuController.ScreenHeight; |
| 1350 | + if (LeftAligned) |
| 1351 | + { |
| 1352 | + barX = bgStatBarX - (bgStatBarWidth / 2f) + (barWidth / 2f); |
| 1353 | + } |
| 1354 | + else |
| 1355 | + { |
| 1356 | + barX = (barWidth * 1.5f) - bgStatBarWidth - (10f / MenuController.ScreenWidth); |
| 1357 | + } |
| 1358 | + SetScriptGfxAlign(LeftAligned ? 76 : 82, 84); |
| 1359 | + SetScriptGfxAlignParams(0f, 0f, 0f, 0f); |
| 1360 | + // bar bg |
| 1361 | + DrawRect(bgStatBarX, barY, bgStatBarWidth, bgStatBarHeight, 100, 100, 100, 180); |
| 1362 | + // real bar |
| 1363 | + DrawRect(barX, barY, barWidth, bgStatBarHeight, 255, 255, 255, 255); |
| 1364 | + ResetScriptGfxAlign(); |
| 1365 | + #endregion |
| 1366 | + |
| 1367 | + #region accuracy bar |
| 1368 | + barWidth = bgStatBarWidth * WeaponStats[2]; |
| 1369 | + barY += 30f / MenuController.ScreenHeight; |
| 1370 | + if (LeftAligned) |
| 1371 | + { |
| 1372 | + barX = bgStatBarX - (bgStatBarWidth / 2f) + (barWidth / 2f); |
| 1373 | + } |
| 1374 | + else |
| 1375 | + { |
| 1376 | + barX = (barWidth * 1.5f) - bgStatBarWidth - (10f / MenuController.ScreenWidth); |
| 1377 | + } |
| 1378 | + SetScriptGfxAlign(LeftAligned ? 76 : 82, 84); |
| 1379 | + SetScriptGfxAlignParams(0f, 0f, 0f, 0f); |
| 1380 | + // bar bg |
| 1381 | + DrawRect(bgStatBarX, barY, bgStatBarWidth, bgStatBarHeight, 100, 100, 100, 180); |
| 1382 | + // real bar |
| 1383 | + DrawRect(barX, barY, barWidth, bgStatBarHeight, 255, 255, 255, 255); |
| 1384 | + ResetScriptGfxAlign(); |
| 1385 | + #endregion |
| 1386 | + |
| 1387 | + #region range bar |
| 1388 | + barWidth = bgStatBarWidth * WeaponStats[3]; |
| 1389 | + barY += 30f / MenuController.ScreenHeight; |
| 1390 | + if (LeftAligned) |
| 1391 | + { |
| 1392 | + barX = bgStatBarX - (bgStatBarWidth / 2f) + (barWidth / 2f); |
| 1393 | + } |
| 1394 | + else |
| 1395 | + { |
| 1396 | + barX = (barWidth * 1.5f) - bgStatBarWidth - (10f / MenuController.ScreenWidth); |
| 1397 | + } |
| 1398 | + SetScriptGfxAlign(LeftAligned ? 76 : 82, 84); |
| 1399 | + SetScriptGfxAlignParams(0f, 0f, 0f, 0f); |
| 1400 | + // bar bg |
| 1401 | + DrawRect(bgStatBarX, barY, bgStatBarWidth, bgStatBarHeight, 100, 100, 100, 180); |
| 1402 | + // real bar |
| 1403 | + DrawRect(barX, barY, barWidth, bgStatBarHeight, 255, 255, 255, 255); |
| 1404 | + ResetScriptGfxAlign(); |
| 1405 | + #endregion |
| 1406 | + |
| 1407 | + #region weapon stats text |
| 1408 | + float textX = LeftAligned ? x - (width / 2f) + (10f / MenuController.ScreenWidth) : GetSafeZoneSize() - ((Width - 10f) / MenuController.ScreenWidth); |
| 1409 | + float textY = y - (height / 2f) + (10f / MenuController.ScreenHeight); |
| 1410 | + |
| 1411 | + SetScriptGfxAlign(76, 84); |
| 1412 | + SetScriptGfxAlignParams(0f, 0f, 0f, 0f); |
| 1413 | + BeginTextCommandDisplayText("PM_DAMAGE"); |
| 1414 | + SetTextJustification(1); |
| 1415 | + SetTextScale(textSize, textSize); |
| 1416 | + |
| 1417 | + EndTextCommandDisplayText(textX, textY); |
| 1418 | + ResetScriptGfxAlign(); |
| 1419 | + |
| 1420 | + SetScriptGfxAlign(76, 84); |
| 1421 | + SetScriptGfxAlignParams(0f, 0f, 0f, 0f); |
| 1422 | + BeginTextCommandDisplayText("PM_FIRERATE"); |
| 1423 | + SetTextJustification(1); |
| 1424 | + SetTextScale(textSize, textSize); |
| 1425 | + textY += 30f / MenuController.ScreenHeight; |
| 1426 | + EndTextCommandDisplayText(textX, textY); |
| 1427 | + ResetScriptGfxAlign(); |
| 1428 | + |
| 1429 | + SetScriptGfxAlign(76, 84); |
| 1430 | + SetScriptGfxAlignParams(0f, 0f, 0f, 0f); |
| 1431 | + BeginTextCommandDisplayText("PM_ACCURACY"); |
| 1432 | + SetTextJustification(1); |
| 1433 | + SetTextScale(textSize, textSize); |
| 1434 | + textY += 30f / MenuController.ScreenHeight; |
| 1435 | + EndTextCommandDisplayText(textX, textY); |
| 1436 | + ResetScriptGfxAlign(); |
| 1437 | + |
| 1438 | + SetScriptGfxAlign(76, 84); |
| 1439 | + SetScriptGfxAlignParams(0f, 0f, 0f, 0f); |
| 1440 | + BeginTextCommandDisplayText("PM_RANGE"); |
| 1441 | + SetTextJustification(1); |
| 1442 | + SetTextScale(textSize, textSize); |
| 1443 | + textY += 30f / MenuController.ScreenHeight; |
| 1444 | + EndTextCommandDisplayText(textX, textY); |
| 1445 | + ResetScriptGfxAlign(); |
| 1446 | + #endregion |
| 1447 | + |
| 1448 | + } |
| 1449 | + } |
| 1450 | + |
| 1451 | + |
| 1452 | + SKIP_WEAPON_STATS: |
| 1453 | + #endregion |
| 1454 | + |
1275 | 1455 | #region Draw Color and opacity palletes |
1276 | 1456 | if (Size > 0) |
1277 | 1457 | { |
|
0 commit comments