Skip to content
Merged
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
39 changes: 38 additions & 1 deletion addons/source-python/packages/source-python/messages/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'UserMessageData',
'UserMessageImpl',
'SayText2Impl',
'ShowMenuImpl',
'VGUIMenuImpl',
'implemented_usermessages',
'get_user_message_impl',
Expand Down Expand Up @@ -171,6 +172,40 @@ def write_bitbuffer(buffer, data):
buffer.write_string(data.param4)


class ShowMenuImpl(UserMessageImpl):
"""ShowMenu implementation."""

@staticmethod
def read_protobuf(buffer):
return UserMessageData(
valid_slots=buffer.get_int32('bits_valid_slots'),
display_time=buffer.get_int32('display_time'),
menu_string=buffer.get_string('menu_string')
)

@staticmethod
def write_protobuf(buffer, data):
buffer.set_int32('bits_valid_slots', data.valid_slots)
buffer.set_int32('display_time', data.display_time)
buffer.set_string('menu_string', data.menu_string)

@staticmethod
def read_bitbuffer(buffer):
return UserMessageData(
valid_slots=buffer.read_word(),
display_time=buffer.read_char(),
chunked=buffer.read_byte(),
menu_string=buffer.read_string()
)

@staticmethod
def write_bitbuffer(buffer, data):
buffer.write_word(data.valid_slots)
buffer.write_char(data.display_time)
buffer.write_byte(data.chunked)
buffer.write_string(data.menu_string)


class VGUIMenuImpl(UserMessageImpl):
"""VGUIMenu implementation."""

Expand Down Expand Up @@ -226,9 +261,11 @@ def write_bitbuffer(buffer, data):
#: A dictionary that contains all implemented user messages.
implemented_usermessages = {
get_message_index('SayText2'): SayText2Impl,
get_message_index('VGUIMenu'): VGUIMenuImpl,
get_message_index('ShowMenu'): ShowMenuImpl,
get_message_index('VGUIMenu'): VGUIMenuImpl
}


def get_user_message_impl(msg_index):
"""Return the user message implementation for the given message index.

Expand Down