Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
rendertarget.c
Go to the documentation of this file.
1 #ifdef GAME_TEMPLATE
2 
3 [EditorAttribute("box", "GameLib/Scripted", "Render target", "-0.25 -0.25 -0.25", "0.25 0.25 0.25", "255 0 0 255")]
4 class RenderTargetClass
5 {
6 
7 }
8 
9 RenderTargetClass RenderTargetSource;
10 
11 class RenderTarget: GenericEntity
12 {
13  [Attribute("0", "slider", "Camera index", "0 31 1")]
14  int CameraIndex;
15  [Attribute("0", "editbox", "Position X <0, 1>")]
16  float X;
17  [Attribute("0", "editbox", "Position Y <0, 1>")]
18  float Y;
19  [Attribute("1", "editbox", "Render target width <0, 1>")]
20  float Width;
21  [Attribute("1", "editbox", "Render target height <0, 1>")]
22  float Height;
23  [Attribute("-1", "editbox", "Sort index (the lesser the more important)")]
24  int Sort;
25  [Attribute("0", "combobox", "Autoinit", "", { ParamEnum("No", "0"), ParamEnum("Yes", "1") } )]
26  int AutoInit;
27  [Attribute("0", "combobox", "Forcing creation of render target for camera #0 in Workbench", "", { ParamEnum("No", "0"), ParamEnum("Yes", "1") } )]
28  bool ForceCreation;
29  bool m_Show = true; // when autoinit, wait with showing the render target after all entities are created (EOnInit)
30  ref RenderTargetWidget m_RenderWidget;
31 
32  void RenderTarget(IEntitySource src, IEntity parent)
33  {
34  SetFlags(EntityFlags.ACTIVE, false);
35 
36  if (AutoInit)
37  {
38  m_Show = false;
39  SetEventMask(EntityEvent.INIT);
40  Init();
41  }
42  }
43 
44  void ~RenderTarget()
45  {
46  delete m_RenderWidget;
47  }
48 
49  void Init()
50  {
51  #ifdef WORKBENCH // Workbench is using its own renderer for main camera, it is not using render target widget.
52  if (!ForceCreation && CameraIndex == 0)
53  return;
54  #endif
55 
56  int screenW, screenH;
57  GetScreenSize(screenW, screenH);
58 
59  int posX = (float)(screenW * X);
60  int posY = (float)(screenH * Y);
61  int widthPix = (float)(screenW * Width);
62  int heightPix = (float)(screenH * Height);
63  if (Class.CastTo(m_RenderWidget, GetGame().GetWorkspace().CreateWidget(RenderTargetWidgetTypeID, posX, posY, widthPix, heightPix, WidgetFlags.VISIBLE | WidgetFlags.HEXACTSIZE | WidgetFlags.VEXACTSIZE | WidgetFlags.HEXACTPOS | WidgetFlags.VEXACTPOS, 0xffffffff, Sort)))
64  {
65  m_RenderWidget.Show(m_Show);
66  SetWidgetWorld(m_RenderWidget, GetGame().GetWorldEntity(), CameraIndex);
67  }
68  }
69  override void EOnInit(IEntity other, int extra)
70  {
71  if (m_RenderWidget)
72  {
73  m_Show = true;
74  m_RenderWidget.Show(m_Show);
75  }
76  }
77 }
78 
79 #endif
GetGame
proto native CGame GetGame()
IEntitySource
Definition: enentity.c:15
EntityFlags
EntityFlags
Entity flags.
Definition: enentity.c:114
Sort
proto void Sort(void param_array[], int num)
Sorts static array of integers(ascendically) / floats(ascendically) / strings(alphabetically)
GetScreenSize
proto void GetScreenSize(out int x, out int y)
X
@ X
Definition: ensystem.c:315
Y
@ Y
Definition: ensystem.c:316
EOnInit
protected override void EOnInit(IEntity other, int extra)
Definition: testframework.c:235
IEntity
Definition: enentity.c:164
Init
class InventoryGridController extends ScriptedWidgetEventHandler Init
Definition: uihintpanel.c:46
Attribute
Definition: enentity.c:823
EditorAttribute
void EditorAttribute(string style, string category, string description, vector sizeMin, vector sizeMax, string color, string color2="0 0 0 0", bool visible=true, bool insertable=true, bool dynamicBox=false)
Definition: enentity.c:854
SetFlags
proto native void SetFlags(ShapeFlags flags)
SetWidgetWorld
proto native void SetWidgetWorld(RenderTargetWidget w, IEntity wrldEntity, int camera)
ParamEnum
void ParamEnum(string key, string value, string desc="")
Definition: enentity.c:8
WidgetFlags
WidgetFlags
Definition: enwidgets.c:57
EntityEvent
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition: enentity.c:44
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
float
Definition: enconvert.c:96