File: Controls.c

package info (click to toggle)
openclonk 8.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 169,656 kB
  • sloc: cpp: 180,484; ansic: 108,988; xml: 31,371; python: 1,223; php: 767; makefile: 148; sh: 101; javascript: 34
file content (89 lines) | stat: -rw-r--r-- 2,130 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
	Controls.c
	Helper functions to find out if a Control fits into a certain category. (Throwing, using, interacting,...).
		
	@author boni
*/

// Control tells the clonk to move.
global func IsMovementControl(int ctrl)
{
	return ctrl == CON_Up || ctrl == CON_Down || ctrl == CON_Left || ctrl == CON_Right;
}

// Control throws selected item.
global func IsThrowControl(int ctrl)
{
	return ctrl == CON_Throw;
}

// Control drops items from inventory (hotkey or selected items).
global func IsDropControl(int ctrl)
{
	// selected items
	if (ctrl == CON_Drop
	// hotkeys
	|| ctrl == CON_DropHotkey0
	|| ctrl == CON_DropHotkey1
	|| ctrl == CON_DropHotkey2
	|| ctrl == CON_DropHotkey3
	|| ctrl == CON_DropHotkey4
	|| ctrl == CON_DropHotkey5
	|| ctrl == CON_DropHotkey6
	|| ctrl == CON_DropHotkey7
	|| ctrl == CON_DropHotkey8
	|| ctrl == CON_DropHotkey9)
		return true;
	
	return false;
}

// Control has the goal of interacting with some other object (Interaction, Grabbing, Entering,...).
global func IsInteractionControl(int ctrl)
{
	// Interaction itself
	if (ctrl == CON_Interact
	// hotkeys
	|| ctrl == CON_InteractionHotkey0
	|| ctrl == CON_InteractionHotkey1
	|| ctrl == CON_InteractionHotkey2
	|| ctrl == CON_InteractionHotkey3
	|| ctrl == CON_InteractionHotkey4
	|| ctrl == CON_InteractionHotkey5
	|| ctrl == CON_InteractionHotkey6
	|| ctrl == CON_InteractionHotkey7
	|| ctrl == CON_InteractionHotkey8
	|| ctrl == CON_InteractionHotkey9)
		return true;
	
	return false;
}

// Control has the goal of switching the currently selected crewmember.
global func IsCrewControl(int ctrl)
{
	// next/previous
	if (ctrl == CON_NextCrew
	|| ctrl == CON_PreviousCrew
	// hotkeys
	|| ctrl == CON_PlayerHotkey0
	|| ctrl == CON_PlayerHotkey1
	|| ctrl == CON_PlayerHotkey2
	|| ctrl == CON_PlayerHotkey3
	|| ctrl == CON_PlayerHotkey4
	|| ctrl == CON_PlayerHotkey5
	|| ctrl == CON_PlayerHotkey6
	|| ctrl == CON_PlayerHotkey7
	|| ctrl == CON_PlayerHotkey8
	|| ctrl == CON_PlayerHotkey9
	)
		return true;
	
	return false;
}

// Control uses selected item.
global func IsUseControl(int ctrl)
{
	return ctrl == CON_Use || ctrl == CON_UseAlt;
}