Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AttachmentsChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# attachments.lua ChangeLog

### Version 0.85
- Added option to control angles and offsets using the mouse.

### Version 0.84
- Added handling of Particle attachments to props via the attachments.txt database.
- Added Particle example to example attachments.txt database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
<Label text="Attachments Configuration"/>
</Panel>
<Panel hittest="false" id="AttachmentsBody">

<Panel class="ButtonRow">

<ToggleButton class="CheckBox" checked="checked" style="align: center center; margin-left:10px;" id="AttachCheckbox" text="Attach?" onactivate="AttachCheckbox();" />
<Button id="Freeze" class="SplashButton SButton" onactivate="Freeze()">
<Label text="Freeze"/>
Expand All @@ -41,6 +43,16 @@
</DropDown>
</Panel>
</Panel>

<Panel class="ButtonRow">
<ToggleButton class="CheckBox" checked="checked" style="align: center center; margin-left:5px;" id="MouseAngleCheckbox" text="Mouse angles?" onactivate="MouseControlAngles();" />
<ToggleButton class="CheckBox" checked="checked" style="align: center center; margin-right:5px;" id="MouseOffsetCheckbox" text="Mouse offsets?" onactivate="MouseControlOffsets();" />
<Label style="align: center center; font-size: 14px; margin-right:5px;" text="Updates per second:"/>
<DropDown id="MouseUpdateScale" style="align:center center; width: 80px; margin-right:5px;" oninputsubmit="MouseUpdateScale()"> </DropDown>
<Panel class="InfoIcon" tabindex="auto" onmouseover="ShowMouseHelpTooltip()"
onmouseout="HideMouseHelpTooltip()"/>
</Panel>

<Label class="LineLabel" text="Attach Point"/>
<TextEntry id="Attach" class="LineEntry" tabindex="auto" ontabbackward="SetInputFocus(Roll)" placeholder="attach_something" onblur="UpdateAttachment();" oninputsubmit="UpdateAttachment()"/>
<Label class="LineLabel" text="Model"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ function GetAttachmentTable()
table['XPos'] = parseFloat($('#XPos').text) || 0.0;
table['YPos'] = parseFloat($('#YPos').text) || 0.0;
table['ZPos'] = parseFloat($('#ZPos').text) || 0.0;
$.Msg(table);
if(!IsMouseControlledOffsets && !IsMouseControlledAngles)
$.Msg(table);

return table;
}
Expand Down Expand Up @@ -288,9 +289,133 @@ function ActivateAttachmentConfiguration(msg)
showing = true;
}
}


var IsMouseControlledAngles = false;
var IsMouseControlledOffsets = false;
var lastMousePos;
var mouseUpdateInterval = 2.0;
function MouseControlAngles()
{
if(IsMouseControlledAngles == false) {
IsMouseControlledAngles = true;
MouseControlAnglesLoop();
}
else {
IsMouseControlledAngles = false;
}
}

function MouseControlOffsets()
{
if(IsMouseControlledOffsets == false) {
IsMouseControlledOffsets = true;
MouseControlOffsetsLoop();
}
else {
IsMouseControlledOffsets = false;
}
}

function MouseControlAnglesLoop()
{
var mousePos = GameUI.GetCursorPosition();
var difX = lastMousePos[0] - mousePos[0];
var difY = lastMousePos[1] - mousePos[1];

if(GameUI.IsMouseDown(0) == false) {
var yaw = MouseCalc($('#Yaw'), difX, pmscale/8);
var pitch = MouseCalc($('#Pitch'), difY, pmscale/8);
var roll = MouseCalc($("#Roll"), g_MouseYaw, pmscale*10);

$("#Yaw").text = yaw;
$("#Pitch").text = pitch;
$("#Roll").text = roll;
UpdateAttachment();
}

g_MouseYaw = 0;
lastMousePos = mousePos;
if(IsMouseControlledAngles == true) {
$.Schedule(1.0/mouseUpdateInterval, MouseControlAnglesLoop);
}
}

function MouseCalc(panel, dif, scale)
{
var num = parseFloat(panel.text);
if(isNaN(num)) {
panel.text = num.toString();
num = 0;
}
var angle = num + (scale * dif);
angle = Math.round(angle * 100) / 100;
return angle.toString();
}

function MouseControlOffsetsLoop()
{
var mousePos = GameUI.GetCursorPosition();
var difX = lastMousePos[0] - mousePos[0];
var difY = lastMousePos[1] - mousePos[1];

if(GameUI.IsMouseDown(0) == false) {
var x = MouseCalc($('#XPos'), difX, pmscale/8);
var y = MouseCalc($('#YPos'), difY, pmscale/8);
var z = MouseCalc($("#ZPos"), g_MouseYaw, pmscale*10);

$('#XPos').text = x.toString();
$('#YPos').text = y.toString();
$('#ZPos').text = z.toString();

if(IsMouseControlledAngles == false)
{
UpdateAttachment();
}
}

if(IsMouseControlledAngles == false) {
lastMousePos = mousePos;
g_MouseYaw = 0;
}
if(IsMouseControlledOffsets == true)
{
$.Schedule(1.0/mouseUpdateInterval, MouseControlOffsetsLoop);
}
}

function MouseUpdateScale()
{
var dropdown = $("#MouseUpdateScale");
mouseUpdateInterval = parseFloat(dropdown.GetSelected().text);
}

function ShowMouseHelpTooltip()
{
$.DispatchEvent("DOTAShowTextTooltip", "Holding the left mouse button down disables updating. Scale affects the rate at which items are oriented or moved. Vertical mouse movement affects the Y offset and pitch. Horizontal mouse movement affects the X offset and yaw. Mouse wheel movement affects the Z offset and roll.");
}

function HideMouseHelpTooltip()
{
$.DispatchEvent("DOTAHideTextTooltip");
}

var g_MouseYaw = 0;

function HandleMouseEvent(eventName, arg)
{
if ( eventName === "wheeled" ) {
g_MouseYaw += arg * pmscale;
if(IsMouseControlledAngles == true || IsMouseControlledOffsets == true) {
return true;
}
}
return false;
}

(function()
{
lastMousePos = GameUI.GetCursorPosition();

var panel = $("#AttachmentsPanel");
$("#AttachmentsHeader").toDragId = "AttachmentsPanel";
$("#CosmeticsHeader").toDragId = "CosmeticsPanel";
Expand All @@ -313,6 +438,15 @@ function ActivateAttachmentConfiguration(msg)
dropdown.AddOption(label);
}

options = [2, 5, 10, 15, 20, 25, 30];
dropdown = $("#MouseUpdateScale");
for (var i=0; i<options.length; i++){
var label = $.CreatePanel('Label', dropdown, 'mDD' + i);
label.text = Math.ceil(options[i] * 100) / 100;
dropdown.AddOption(label);
}
GameUI.SetMouseCallback(HandleMouseEvent);

dropdown.SetSelected("DD2");

$.RegisterEventHandler( 'DragStart', $('#AttachmentsHeader'), OnDragStart );
Expand Down
Binary file modified game/dota_addons/barebones/panorama_debugger.cfg
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ATTACHMENTS_VERSION = "0.84"
ATTACHMENTS_VERSION = "0.85"

--[[
Lua-controlled Frankenstein Attachments Library by BMD
Expand Down