Skip to content

Commit

Permalink
xrEProps: NumericVector seems to be ported. Needs testing
Browse files Browse the repository at this point in the history
Add C++Builder-specific code ShaderFunction (just as a template)
  • Loading branch information
Xottab-DUTY committed Feb 26, 2018
1 parent b186ebf commit f23abf1
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 16 deletions.
29 changes: 28 additions & 1 deletion src/editors/xrECore/Props/NumericVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ bool NumericVector::Run(pcstr title, Fvector* data, int decimal, Fvector* resetV
this->Text = str;
Value = data;
ResetValue = resetValue;
buttonReset->Enabled = !!resetValue;

numX->DecimalPlaces = decimal;
numY->DecimalPlaces = decimal;
numZ->DecimalPlaces = decimal;

numX->Value = (Decimal)data->x;
numY->Value = (Decimal)data->y;
numZ->Value = (Decimal)data->z;

if (min)
{
Expand Down Expand Up @@ -42,7 +51,25 @@ bool NumericVector::Run(pcstr title, Fvector* data, int decimal, Fvector* resetV

}

buttonReset_Click(nullptr, nullptr);
if (!X || !Y)
{
POINT pt;
GetCursorPos(&pt);
int w = GetSystemMetrics(SM_CXSCREEN);
int h = GetSystemMetrics(SM_CYSCREEN);
Left = pt.x - (Width * 0.5f);
Top = pt.y;
if (((Left + Width * 0.5f) > w) || ((Top + Height) > h))
{
Left = w * 0.5f - Width * 0.5f;
Top = h * 0.5f;
}
}
else
{
Left = *X - (Width * 0.5f);
Top = *Y;
}

numX->ValueChanged += gcnew EventHandler(this, &NumericVector::OnValueChanged);

Expand Down
32 changes: 17 additions & 15 deletions src/editors/xrECore/Props/NumericVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ namespace XRay
{
namespace ECore
{
namespace Props
{
ref class NumericVector;
}
}
}

template <class T>
struct _vector3;
Expand Down Expand Up @@ -44,23 +47,30 @@ public ref class NumericVector : public System::Windows::Forms::Form
}
}

private: System::Void buttonApply_Click(System::Object^ sender, System::EventArgs^ e);
private: System::Void buttonOk_Click(System::Object^ sender, System::EventArgs^ e);
private: System::Void buttonCancel_Click(System::Object^ sender, System::EventArgs^ e);
private: System::Void buttonReset_Click(System::Object^ sender, System::EventArgs^ e);
private: System::Void buttonImmediate_Click(System::Object^ sender, System::EventArgs^ e);
private: System::Void NumericVector_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e);

private: System::Void OnValueChanged(System::Object^ sender, System::EventArgs^ e);


private: Fvector* Value;
private: Fvector* ResetValue;
private: System::Windows::Forms::Button^ buttonOk;
private: System::Windows::Forms::Button^ buttonCancel;
private: System::Windows::Forms::Button^ buttonReset;
private: System::Windows::Forms::Button^ buttonReset;
private: System::Windows::Forms::Button^ buttonApply;
private: System::Windows::Forms::Button^ buttonImmediate;
private: System::Windows::Forms::CheckBox^ checkImmediate;
private: XRay::SdkControls::NumericSpinner^ numX;
private: XRay::SdkControls::NumericSpinner^ numY;
private: XRay::SdkControls::NumericSpinner^ numZ;
private: System::Windows::Forms::Label^ labelX;
private: System::Windows::Forms::Label^ labelY;
private: System::Windows::Forms::Label^ labelZ;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::CheckBox^ checkImmediate;

private: System::Windows::Forms::Button^ buttonApply;
private: System::Windows::Forms::Button^ buttonImmediate;

private:
System::ComponentModel::Container^ components;
Expand Down Expand Up @@ -199,14 +209,6 @@ private: System::Windows::Forms::Button^ buttonImmediate;

}
#pragma endregion
private: System::Void buttonApply_Click(System::Object^ sender, System::EventArgs^ e);
private: System::Void buttonOk_Click(System::Object^ sender, System::EventArgs^ e);
private: System::Void buttonCancel_Click(System::Object^ sender, System::EventArgs^ e);
private: System::Void buttonReset_Click(System::Object^ sender, System::EventArgs^ e);
private: System::Void buttonImmediate_Click(System::Object^ sender, System::EventArgs^ e);
private: System::Void NumericVector_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e);

private: System::Void OnValueChanged(System::Object^ sender, System::EventArgs^ e);
};
} // namespace Props
} // namespace ECore
Expand Down
50 changes: 50 additions & 0 deletions src/editors/xrECore/Props/ShaderFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,56 @@ void ShaderFunction::DrawGraph()

// XXX: Draw
//System::Windows::Controls::Canvas canvas;

#if 0 // Taken from xrEProps/ShaderFunction.cpp
int w = imDraw->Width - 4;
int h = imDraw->Height - 4;

TRect r;
r.Left = 0;
r.Top = 0;
r.Right = w + 4;
r.Bottom = h + 4;
TCanvas* C = imDraw->Canvas;
C->Brush->Color = clBlack;
C->FillRect(r);
C->Pen->Color = TColor(0x00006600);
// draw center
C->Pen->Color = clLime;
C->Pen->Style = psDot;
C->MoveTo(2, h / 2 + 2);
C->LineTo(w + 2, h / 2 + 2);
// draw rect
C->Pen->Color = TColor(0x00006600);
C->Pen->Style = psSolid;
C->MoveTo(0, 0);
C->LineTo(w + 3, 0);
C->LineTo(w + 3, h + 3);
C->LineTo(0, h + 3);
C->LineTo(0, 0);
// draw graph
C->Pen->Color = clYellow;

float t_cost = 1.f / w;
float tm = 0;
float y = m_CurFunc->Calculate(tm) - m_CurFunc->arg[0];
float delta = m_CurFunc->arg[1] * 2;
delta = delta ? (h / delta) : 0;
float yy = h - (delta * y + h / 2);
C->MoveTo(2, yy + 2);
for (int t = 1; t < w; t++)
{
tm = seScale->Value * t * t_cost / (fis_zero(m_CurFunc->arg[3]) ? 1.f : m_CurFunc->arg[3]);
y = m_CurFunc->Calculate(tm) - m_CurFunc->arg[0];
yy = h - (delta * y + h / 2);
C->LineTo(t + 2, yy + 2);
}
// draw X-axis
C->Pen->Color = clGreen;
float AxisX = h - (delta * (-m_CurFunc->arg[0]) + h / 2);
C->MoveTo(2, AxisX + 2);
C->LineTo(w + 2, AxisX + 2);
#endif
}
} // namespace Props
} // namespace ECore
Expand Down
3 changes: 3 additions & 0 deletions src/editors/xrECore/Props/ShaderFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ namespace XRay
{
namespace ECore
{
namespace Props
{
ref class ShaderFunction;
}
}
}

struct WaveForm;
struct xr_token;
Expand Down

0 comments on commit f23abf1

Please sign in to comment.