This commit is contained in:
VegaZ
2018-11-27 19:51:00 +01:00
parent fa8f77f80a
commit d8ce039f71
4 changed files with 7 additions and 225 deletions

View File

@@ -3,7 +3,7 @@
body { body {
width: 50%; width: 50%;
position: center; position: center;
margin: 0 auto; margin: 5% auto auto 25%;
} }
.inventory-table { .inventory-table {
@@ -52,4 +52,5 @@ body {
margin: 0 auto; margin: 0 auto;
text-align: center; text-align: center;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
pointer-events: visible;
} }

View File

@@ -58,6 +58,7 @@
</div> </div>
<div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot9"> <div class="inventory-cell" ondrop="drop(event)" ondragover="allowDrop(event)" id="slot9">
<div class="inventory-slot">10</div> <div class="inventory-slot">10</div>
<div class="inventory-item" draggable="true" ondragstart="drag(event)" id="item3" style="background-color:green;">Chickenburger</div>
</div> </div>
</div> </div>
<div class="inventory-row"> <div class="inventory-row">
@@ -95,221 +96,5 @@
</div> </div>
</div> </div>
</div> </div>
<script>
"use strict";
jQuery.fn.extend({
addRemoveItems: function (targetCount) {
return this.each(function () {
var $children = $(this).children();
var rowCountDifference = targetCount - $children.length;
//console.log('row count diff: ' + rowCountDifference);
if (rowCountDifference > 0) {
// Add items
for (var i = 0; i < rowCountDifference; i++) {
//console.log($rows.first());
$children.last().clone().appendTo(this);
}
}
else if (rowCountDifference < 0) {
// remove items
$children.slice(rowCountDifference).remove();
}
});
},
// Modified and Updated by MLM
// Origin: Davy8 (http://stackoverflow.com/a/5212193/796832)
parentToAnimate: function (newParent, duration) {
duration = duration || 'slow';
var $element = $(this);
//console.log($element);
if ($element.length > 0) {
newParent = $(newParent); // Allow passing in either a JQuery object or selector
var oldOffset = $element.offset();
$(this).appendTo(newParent);
var newOffset = $element.offset();
var temp = $element.clone().appendTo('body');
temp.css({
'position': 'absolute',
'left': oldOffset.left,
'top': oldOffset.top,
'zIndex': 1000
});
$element.hide();
temp.animate({
'top': newOffset.top,
'left': newOffset.left
}, duration, function () {
$element.show();
temp.remove();
});
//console.log("parentTo Animate done");
}
}
});
$('#row-count').on('input propertychange change', function () {
var targetRowCount = $(this).val();
//console.log('target count: ' + targetRowCount);
$('label[for="' + $(this).attr('id') + '"]').html(targetRowCount);
$('#personal-inventory.inventory-table').addRemoveItems(targetRowCount);
refreshSortableInventoryList();
}).trigger('change');
$('#column-count').on('input propertychange change', function () {
var targetColumnCount = $(this).val();
//console.log('target count: ' + targetColumnCount);
$('label[for="' + $(this).attr('id') + '"]').html(targetColumnCount);
$('#personal-inventory.inventory-table .inventory-row').addRemoveItems(targetColumnCount);
refreshSortableInventoryList();
}).trigger('change');
// Sorting, dragging, dropping, etc
refreshSortableInventoryList();
function refreshSortableInventoryList() {
$('.inventory-cell').sortable({
connectWith: '.inventory-cell',
placeholder: 'inventory-item-sortable-placeholder',
receive: function (event, ui) {
var attrWhitelist = $(this).closest('.inventory-table').attr('data-item-filter-whitelist');
var attrBlackList = $(this).closest('.inventory-table').attr('data-item-filter-blacklist');
var itemFilterWhitelistArray = attrWhitelist ? attrWhitelist.split(/\s+/) : [];
var itemFilterBlacklistArray = attrBlackList ? attrBlackList.split(/\s+/) : [];
//console.log(itemFilterWhitelistArray);
//console.log(itemFilterBlacklistArray);
var attrTypeList = $(ui.item).attr('data-item-type');
var itemTypeListArray = attrTypeList ? attrTypeList.split(/\s+/) : [];
//console.log(itemTypeListArray);
var canMoveIntoSlot = verifyWithWhiteBlackLists(itemTypeListArray, itemFilterWhitelistArray, itemFilterBlacklistArray)
if (!canMoveIntoSlot) {
console.log("Can't move to this slot");
//$(ui.sender).sortable('cancel');
$(ui.item).parentToAnimate($(ui.sender), 200);
}
else {
// Swap places of items if dragging on top of another
// Add the items in this list to the list the new item was from
$(this).children().not(ui.item).parentToAnimate($(ui.sender), 200);
// $(this) is the list the item is being moved into
// $(ui.sender) is the list the item came from
// Don't forget the move swap items as well
// $(this).attr('data-slot-position-x');
// $(this).attr('data-slot-position-y');
// $(ui.sender).attr('data-slot-position-x');
// $(ui.sender).attr('data-slot-position-y');
//console.log("Moving to: (" + $(this).attr('data-slot-position-x') + ", " + $(this).attr('data-slot-position-y') + ") - From: (" + $(ui.sender).attr('data-slot-position-x') + ", " + $(ui.sender).attr('data-slot-position-y') + ")");
}
}
}).each(function () {
// Setup some nice attributes for everything
// Makes it easier to update the backend
$(this).attr('data-slot-position-x', $(this).prevAll('.inventory-cell').length);
$(this).attr('data-slot-position-y', $(this).closest('.inventory-row').prevAll('.inventory-row').length);
}).disableSelection();
}
function verifyWithWhiteBlackLists(itemList, whiteList, blackList) {
// itemList should contain tags
// whiteList and blackList can contain tags and tag queries
// If we have a matching tags to some tag query in the whiteList but not in the blackList, then return true
// Else return false
console.group("Lists");
console.log(itemList);
console.log(whiteList);
console.log(blackList);
console.groupEnd();
// If white and black lists are empty, return true
// Save the calculations, no filtering
if (whiteList.length == 0 && blackList.length == 0)
return true;
// Check if the itemList has an item in the blackList
var inBlackList = false;
$.each(blackList, function (index, value) {
var itemBlack = value;
var itemBlackAndArray = itemBlack.split(/\+/);
console.log(itemBlackAndArray);
var andedResult = true;
for (var i = 0; i < itemBlackAndArray.length; i++) {
if (blackList.length > 0 && $.inArray(itemBlackAndArray[i], itemList) !== -1) {
andedResult = andedResult && true;
}
else {
andedResult = andedResult && false;
}
}
if (andedResult)
inBlackList = true;
});
inBlackList = blackList.length > 0 ? inBlackList : false;
// Check if the itemList has an item in the whiteList
var inWhiteList = false;
$.each(whiteList, function (index, value) {
var itemWhite = value;
var itemWhiteAndArray = itemWhite.split(/\+/);
//console.log(itemWhiteAndArray);
var andedResult = true;
for (var i = 0; i < itemWhiteAndArray.length; i++) {
if (whiteList.length > 0 && $.inArray(itemWhiteAndArray[i], itemList) !== -1) {
andedResult = andedResult && true;
}
else {
andedResult = andedResult && false;
}
}
//console.log("andedResult: " + andedResult);
if (andedResult)
inWhiteList = true;
});
inWhiteList = whiteList.length > 0 ? inWhiteList : false;
console.log("inWhite: " + inWhiteList + " - inBlack: " + inBlackList);
if ((whiteList.length == 0 || inWhiteList) && !inBlackList)
return true;
return false;
}
</script>
</body> </body>
</html> </html>

View File

@@ -7,11 +7,8 @@
//https://docs.microsoft.com/de-de/windows/desktop/inputdev/virtual-key-codes //https://docs.microsoft.com/de-de/windows/desktop/inputdev/virtual-key-codes
var chat = false; var chat = false;
<<<<<<< HEAD
var showInventory = false; var showInventory = false;
=======
var showGui = true; var showGui = true;
>>>>>>> develop
//ENTER //ENTER
mp.keys.bind(0x0D, false, function () { mp.keys.bind(0x0D, false, function () {
@@ -53,7 +50,6 @@ mp.keys.bind(0x49, false, function () {
} }
}); });
<<<<<<< HEAD
//J //J
mp.keys.bind(0x4A, false, function () { mp.keys.bind(0x4A, false, function () {
if (showInventory === false) { if (showInventory === false) {
@@ -65,8 +61,6 @@ mp.keys.bind(0x4A, false, function () {
} }
}); });
//N
=======
//K //Dienstkleidung //K //Dienstkleidung
mp.keys.bind(0x4B, false, function () { mp.keys.bind(0x4B, false, function () {
if (!chat) { if (!chat) {
@@ -82,7 +76,6 @@ mp.keys.bind(0x4C, false, function () {
}); });
//N //Motor Starten //N //Motor Starten
>>>>>>> develop
mp.keys.bind(0x4E, false, function () { mp.keys.bind(0x4E, false, function () {
if (!chat) { if (!chat) {
mp.events.callRemote("keyPress:N"); mp.events.callRemote("keyPress:N");

View File

@@ -22,6 +22,9 @@
<HintPath>..\Bootstrapper.dll</HintPath> <HintPath>..\Bootstrapper.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' == 'Debug'"> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(ConfigurationName)' == 'Debug'">
<Exec Command="del &quot;..\..\client_packages\*&quot; /Q /S&#xD;&#xA;xcopy &quot;$(OutDir)*&quot; &quot;..\..\bridge\resources\reallife-gamemode&quot; /Y /Q&#xD;&#xA;del &quot;..\..\client_packages\*.*&quot; /Q&#xD;&#xA;xcopy &quot;..\..\reallife-gamemode\reallife-gamemode\Client\*&quot; &quot;..\..\client_packages\&quot; /S /Q /Y&#xD;&#xA;" /> <Exec Command="del &quot;..\..\client_packages\*&quot; /Q /S&#xD;&#xA;xcopy &quot;$(OutDir)*&quot; &quot;..\..\bridge\resources\reallife-gamemode&quot; /Y /Q&#xD;&#xA;del &quot;..\..\client_packages\*.*&quot; /Q&#xD;&#xA;xcopy &quot;..\..\reallife-gamemode\reallife-gamemode\Client\*&quot; &quot;..\..\client_packages\&quot; /S /Q /Y&#xD;&#xA;" />
</Target> </Target>