mirror of https://github.com/FWGS/hlsdk-xash3d
Merge branch 'master' into gravgun
This commit is contained in:
commit
4cafc73d79
|
@ -0,0 +1,112 @@
|
|||
name: build
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
cc: gcc
|
||||
cxx: g++
|
||||
- os: ubuntu-latest
|
||||
cc: clang
|
||||
cxx: clang++
|
||||
- os: windows-2019
|
||||
cc: cl
|
||||
cxx: cl
|
||||
env:
|
||||
CC: ${{ matrix.cc }}
|
||||
CXX: ${{ matrix.cxx }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Checkout steam-runtime
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ValveSoftware/steam-runtime
|
||||
path: steam-runtime
|
||||
- name: Cache steam-runtime
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
id: cache-steam-runtime
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz
|
||||
key: ${{ runner.os }}-steam-runtime
|
||||
- name: Download steam-runtime
|
||||
if: startsWith(matrix.os, 'ubuntu') && steps.cache-steam-runtime.outputs.cache-hit != 'true'
|
||||
run: wget --no-verbose https://repo.steampowered.com/steamrt-images-scout/snapshots/0.20210610.0/com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz
|
||||
- name: Install steam runtime
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
run: |
|
||||
sudo apt update
|
||||
./steam-runtime/setup_chroot.sh --i386 --tarball ./com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz
|
||||
sudo sed -i 's/groups=sudo/groups=adm/g' /etc/schroot/chroot.d/steamrt_scout_i386.conf
|
||||
|
||||
- name: Build on Linux
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
run: |
|
||||
schroot --chroot steamrt_scout_i386 -- cmake -B build -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DCMAKE_INSTALL_PREFIX="$PWD/dist"
|
||||
schroot --chroot steamrt_scout_i386 -- cmake --build build --target all
|
||||
schroot --chroot steamrt_scout_i386 -- cmake --build build --target install
|
||||
- name: Build on Linux with vgui
|
||||
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.cc, 'gcc')
|
||||
run: |
|
||||
schroot --chroot steamrt_scout_i386 -- cmake -B build-vgui -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VGUI=ON -DCMAKE_INSTALL_PREFIX="$PWD/dist-vgui"
|
||||
cp vgui_support/vgui-dev/lib/vgui.so build-vgui/cl_dll
|
||||
schroot --chroot steamrt_scout_i386 -- cmake --build build-vgui --target all
|
||||
schroot --chroot steamrt_scout_i386 -- cmake --build build-vgui --target install
|
||||
|
||||
- name: Add msbuild to PATH
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: Build on Windows
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
run: |
|
||||
cmake -G "Visual Studio 16 2019" -A Win32 -B build -DCMAKE_INSTALL_PREFIX="dist"
|
||||
msbuild -verbosity:normal /property:Configuration=Release build/INSTALL.vcxproj
|
||||
- name: Build on Windows with vgui
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
run: |
|
||||
cmake -G "Visual Studio 16 2019" -A Win32 -B build -DUSE_VGUI=ON -DCMAKE_INSTALL_PREFIX="dist-vgui"
|
||||
msbuild -verbosity:normal /property:Configuration=Release build/INSTALL.vcxproj
|
||||
|
||||
- name: Extract branch name
|
||||
shell: bash
|
||||
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')" >> $GITHUB_OUTPUT
|
||||
id: extract_branch
|
||||
- name: Extract gamedir
|
||||
shell: bash
|
||||
run: echo "gamedir=$(grep build/CMakeCache.txt -Ee 'GAMEDIR:STRING=[a-z]+' | cut -d '=' -f 2)" >> $GITHUB_OUTPUT
|
||||
id: extract_gamedir
|
||||
- name: Upload linux artifact
|
||||
if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'gcc'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux
|
||||
path: dist/${{ steps.extract_gamedir.outputs.gamedir }}
|
||||
- name: Upload linux artifact with vgui
|
||||
if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'gcc'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux-vgui
|
||||
path: dist-vgui/${{ steps.extract_gamedir.outputs.gamedir }}
|
||||
- name: Upload windows artifact
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows
|
||||
path: dist/${{ steps.extract_gamedir.outputs.gamedir }}
|
||||
- name: Upload windows artifact with vgui
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows-vgui
|
||||
path: dist-vgui/${{ steps.extract_gamedir.outputs.gamedir }}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
name: manual build
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
buildtype:
|
||||
type: choice
|
||||
description: Build Type
|
||||
options:
|
||||
- Release
|
||||
- Debug
|
||||
usevgui:
|
||||
type: choice
|
||||
description: Use VGUI
|
||||
options:
|
||||
- 'OFF'
|
||||
- 'ON'
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
cc: gcc
|
||||
cxx: g++
|
||||
- os: windows-2019
|
||||
cc: cl
|
||||
cxx: cl
|
||||
env:
|
||||
CC: ${{ matrix.cc }}
|
||||
CXX: ${{ matrix.cxx }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Checkout steam-runtime
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: ValveSoftware/steam-runtime
|
||||
path: steam-runtime
|
||||
- name: Cache steam-runtime
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
id: cache-steam-runtime
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz
|
||||
key: ${{ runner.os }}-steam-runtime
|
||||
- name: Download steam-runtime
|
||||
if: startsWith(matrix.os, 'ubuntu') && steps.cache-steam-runtime.outputs.cache-hit != 'true'
|
||||
run: wget --no-verbose https://repo.steampowered.com/steamrt-images-scout/snapshots/0.20210610.0/com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz
|
||||
- name: Install steam runtime
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
run: |
|
||||
sudo apt update
|
||||
./steam-runtime/setup_chroot.sh --i386 --tarball ./com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz
|
||||
sudo sed -i 's/groups=sudo/groups=adm/g' /etc/schroot/chroot.d/steamrt_scout_i386.conf
|
||||
|
||||
- name: Copy vgui.so
|
||||
if: ${{ startsWith(matrix.os, 'ubuntu') && github.event.inputs.usevgui == 'ON' }}
|
||||
run: |
|
||||
mkdir -p build/cl_dll
|
||||
cp vgui_support/vgui-dev/lib/vgui.so build/cl_dll
|
||||
- name: Build on Linux
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
run: |
|
||||
schroot --chroot steamrt_scout_i386 -- cmake -B build -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DCMAKE_BUILD_TYPE=${{ github.event.inputs.buildtype }} -DCMAKE_INSTALL_PREFIX="$PWD/dist" -DUSE_VGUI=${{ github.event.inputs.usevgui }}
|
||||
schroot --chroot steamrt_scout_i386 -- cmake --build build --target all
|
||||
schroot --chroot steamrt_scout_i386 -- cmake --build build --target install
|
||||
|
||||
- name: Add msbuild to PATH
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
uses: microsoft/setup-msbuild@v1.1
|
||||
- name: Build on Windows
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
run: |
|
||||
cmake -G "Visual Studio 16 2019" -A Win32 -B build -DCMAKE_INSTALL_PREFIX="dist" -DUSE_VGUI=${{ github.event.inputs.usevgui }}
|
||||
msbuild -verbosity:normal /property:Configuration=${{ github.event.inputs.buildtype }} build/INSTALL.vcxproj
|
||||
|
||||
- name: Extract branch name
|
||||
shell: bash
|
||||
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')" >> $GITHUB_OUTPUT
|
||||
id: extract_branch
|
||||
- name: Extract gamedir
|
||||
shell: bash
|
||||
run: echo "gamedir=$(grep build/CMakeCache.txt -Ee 'GAMEDIR:STRING=[a-z]+' | cut -d '=' -f 2)" >> $GITHUB_OUTPUT
|
||||
id: extract_gamedir
|
||||
- name: Copy pdbs to dist dir
|
||||
if: ${{ startsWith(matrix.os, 'windows') && github.event.inputs.buildtype == 'Debug' }}
|
||||
run: |
|
||||
copy build/cl_dll/Debug/client.pdb dist/${{ steps.extract_gamedir.outputs.gamedir }}/cl_dlls/
|
||||
copy build/dlls/Debug/hl.pdb dist/${{ steps.extract_gamedir.outputs.gamedir }}/dlls/
|
||||
- name: Delete .lib files from dist
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
run: |
|
||||
Remove-Item -Force -Path dist/${{ steps.extract_gamedir.outputs.gamedir }}/cl_dlls/client.lib
|
||||
Remove-Item -Force -Path dist/${{ steps.extract_gamedir.outputs.gamedir }}/dlls/hl.lib
|
||||
- name: Upload linux artifact
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux
|
||||
path: dist/${{ steps.extract_gamedir.outputs.gamedir }}
|
||||
- name: Upload windows artifact
|
||||
if: startsWith(matrix.os, 'windows')
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows
|
||||
path: dist/${{ steps.extract_gamedir.outputs.gamedir }}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
*.dll
|
||||
*.pdb
|
||||
build/
|
||||
CMakeLists.txt.user
|
||||
CMakeLists.txt.*
|
||||
cmake_install.cmake
|
||||
*.orig
|
||||
*.cbp
|
||||
|
@ -18,5 +18,14 @@ cmake_install.cmake
|
|||
*.vsproj
|
||||
*.sln
|
||||
.waf-*
|
||||
waf-*
|
||||
.waf3-*
|
||||
waf3-*
|
||||
.lock*
|
||||
*.pyc
|
||||
.vscode/
|
||||
.vs/
|
||||
CMakeSettings.json
|
||||
CMakeFiles
|
||||
CMakeCache.txt
|
||||
Makefile
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "vgui_support"]
|
||||
path = vgui_support
|
||||
url = https://github.com/FWGS/vgui_support
|
141
CMakeLists.txt
141
CMakeLists.txt
|
@ -20,42 +20,76 @@
|
|||
# SOFTWARE.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 2.6.0)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.15.0")
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
endif()
|
||||
|
||||
# Install custom module path
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
|
||||
|
||||
include(CheckIncludeFile)
|
||||
include(CheckCSourceCompiles)
|
||||
include(VSForceXPToolchain) # Force XP toolchain for Visual Studio
|
||||
|
||||
project (HLSDK-XASH3D)
|
||||
project (HLSDK-PORTABLE)
|
||||
|
||||
#--------------
|
||||
# USER DEFINES \
|
||||
################\
|
||||
option(USE_VGUI "Enable VGUI1. UNDONE" OFF)
|
||||
option(USE_VGUI "Enable VGUI1." OFF)
|
||||
option(USE_VGUI2 "Enable VGUI2. UNDONE" OFF)
|
||||
option(USE_NOVGUI_MOTD "Prefer non-VGUI MOTD when USE_VGUI is enabled" OFF)
|
||||
option(USE_NOVGUI_SCOREBOARD "Prefer non-VGUI Scoreboard when USE_VGUI is enabled" OFF)
|
||||
option(USE_VOICEMGR "Enable VOICE MANAGER." OFF)
|
||||
option(BUILD_CLIENT "Build client dll" ON)
|
||||
option(BUILD_SERVER "Build server dll" ON)
|
||||
option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF)
|
||||
option(64BIT "Disable auto -m32 appending to compiler flags" OFF)
|
||||
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 4 OR
|
||||
((WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "x64"
|
||||
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"
|
||||
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")))
|
||||
option(64BIT "Disable auto -m32 appending to compiler flags" OFF)
|
||||
option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" ON)
|
||||
else()
|
||||
option(64BIT "Disable auto -m32 appending to compiler flags" ON)
|
||||
option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF)
|
||||
endif()
|
||||
|
||||
option(BARNACLE_FIX_VISIBILITY "Enable barnacle tongue length fix" OFF)
|
||||
option(CLIENT_WEAPONS "Enable client local weapons prediction" ON)
|
||||
option(CROWBAR_IDLE_ANIM "Enable crowbar idle animation" OFF)
|
||||
option(CROWBAR_DELAY_FIX "Enable crowbar attack delay fix" OFF)
|
||||
option(CROWBAR_FIX_RAPID_CROWBAR "Enable rapid crowbar fix" OFF)
|
||||
option(GAUSS_OVERCHARGE_FIX "Enable gauss overcharge fix" OFF)
|
||||
option(TRIPMINE_BEAM_DUPLICATION_FIX "Enable fix of tripmine beam duplication on level transition" OFF)
|
||||
option(HANDGRENADE_DEPLOY_FIX "Enable handgrenade deploy animation fix after finishing a throw" OFF)
|
||||
option(WEAPONS_ANIMATION_TIMES_FIX "Enable animation times fix for some weapons" OFF)
|
||||
option(OEM_BUILD "Enable OEM Build" OFF)
|
||||
option(HLDEMO_BUILD "Enable Demo Build" OFF)
|
||||
|
||||
set(GAMEDIR "valve" CACHE STRING "Gamedir path")
|
||||
set(SERVER_INSTALL_DIR "dlls" CACHE STRING "Where put server dll")
|
||||
set(CLIENT_INSTALL_DIR "cl_dlls" CACHE STRING "Where put client dll")
|
||||
set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for Linux/MacOS/Windows")
|
||||
set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for PC platforms")
|
||||
message(STATUS "Half-Life")
|
||||
|
||||
#-----------------
|
||||
# MAIN BUILD CODE \
|
||||
###################\
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
|
||||
if(HLDEMO_BUILD AND OEM_BUILD)
|
||||
message(FATAL_ERROR "Don't mix Demo and OEM builds!")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT)
|
||||
if(MSVC)
|
||||
error("UNDONE: set 32 build flags")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
|
||||
endif()
|
||||
set(CMAKE_SIZEOF_VOID_P 4)
|
||||
|
@ -65,12 +99,71 @@ if(64BIT AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|||
message(FATAL_ERROR "You enabled XASH_64BIT, but compiler can't create 64 bit code!")
|
||||
endif()
|
||||
|
||||
if(64BIT)
|
||||
# Xash3D FWGS Library Naming Scheme compliance
|
||||
# see documentation: https://github.com/FWGS/xash3d-fwgs/blob/master/Documentation/extensions/library-naming.md
|
||||
include(LibraryNaming)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
message(STATUS "Building for 64 Bit")
|
||||
else()
|
||||
message(STATUS "Building for 32 Bit")
|
||||
endif()
|
||||
|
||||
if(CLIENT_WEAPONS)
|
||||
message(STATUS "Client weapons enabled.")
|
||||
add_definitions(-DCLIENT_WEAPONS)
|
||||
endif()
|
||||
|
||||
if(BARNACLE_FIX_VISIBILITY)
|
||||
message(STATUS "Barnacle tongue fix enabled")
|
||||
add_definitions(-DBARNACLE_FIX_VISIBILITY)
|
||||
endif()
|
||||
|
||||
if(CROWBAR_IDLE_ANIM)
|
||||
message(STATUS "Crowbar idle animation enabled")
|
||||
add_definitions(-DCROWBAR_IDLE_ANIM)
|
||||
endif()
|
||||
|
||||
if(CROWBAR_DELAY_FIX)
|
||||
message(STATUS "Crowbar attack delay fix enabled")
|
||||
add_definitions(-DCROWBAR_DELAY_FIX)
|
||||
endif()
|
||||
|
||||
if(CROWBAR_FIX_RAPID_CROWBAR)
|
||||
message(STATUS "Rapid crowbar fix enabled")
|
||||
add_definitions(-DCROWBAR_FIX_RAPID_CROWBAR)
|
||||
endif()
|
||||
|
||||
if(GAUSS_OVERCHARGE_FIX)
|
||||
message(STATUS "Gauss overcharge fix enabled")
|
||||
add_definitions(-DGAUSS_OVERCHARGE_FIX)
|
||||
endif()
|
||||
|
||||
if(TRIPMINE_BEAM_DUPLICATION_FIX)
|
||||
message(STATUS "Tripmine beam duplication fix enabled")
|
||||
add_definitions(-DTRIPMINE_BEAM_DUPLICATION_FIX)
|
||||
endif()
|
||||
|
||||
if(HANDGRENADE_DEPLOY_FIX)
|
||||
message(STATUS "Handgrenade deploy animation fix enabled")
|
||||
add_definitions(-DHANDGRENADE_DEPLOY_FIX)
|
||||
endif()
|
||||
|
||||
if(WEAPONS_ANIMATION_TIMES_FIX)
|
||||
message(STATUS "Weapons animation times fix enabled")
|
||||
add_definitions(-DWEAPONS_ANIMATION_TIMES_FIX)
|
||||
endif()
|
||||
|
||||
if(OEM_BUILD)
|
||||
message(STATUS "OEM build enabled")
|
||||
add_definitions(-DOEM_BUILD)
|
||||
endif()
|
||||
|
||||
if(HLDEMO_BUILD)
|
||||
message(STATUS "Demo build enabled")
|
||||
add_definitions(-DHLDEMO_BUILD)
|
||||
endif()
|
||||
|
||||
if (MINGW)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--add-stdcall-alias")
|
||||
|
@ -86,14 +179,40 @@ if(${CMAKE_VERSION} VERSION_LESS "3.0.2")
|
|||
endmacro()
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
#add_compile_options(-Wempty-body) # GCC/Clang flag
|
||||
add_compile_options(-Wreturn-type) # GCC/Clang flag
|
||||
else()
|
||||
add_definitions(-D_CRT_SILENCE_NONCONFORMING_TGMATH_H)
|
||||
endif()
|
||||
|
||||
if(VITA)
|
||||
add_compile_options(-fno-use-cxa-atexit)
|
||||
endif()
|
||||
|
||||
check_include_file("tgmath.h" HAVE_TGMATH_H)
|
||||
if(HAVE_TGMATH_H)
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_REQUIRED_LIBRARIES "m")
|
||||
endif()
|
||||
check_c_source_compiles("#include <tgmath.h>
|
||||
const float val = 2, val2 = 3;
|
||||
int main(){ return (int)(-asin(val) + cos(val2)); }" HAVE_VALID_TGMATH_H )
|
||||
if(${HAVE_VALID_TGMATH_H})
|
||||
add_definitions(-DHAVE_TGMATH_H)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BUILD_CLIENT)
|
||||
message(STATUS "Building client enabled")
|
||||
add_subdirectory(cl_dll)
|
||||
endif()
|
||||
|
||||
if(BUILD_SERVER)
|
||||
message(STATUS "Building server enabled")
|
||||
add_subdirectory(dlls)
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SERVER AND NOT BUILD_CLIENT)
|
||||
error("Nothing to build")
|
||||
message(FATAL_ERROR "Nothing to build")
|
||||
endif()
|
||||
|
|
357
README.md
357
README.md
|
@ -1,149 +1,336 @@
|
|||
# Half-Life SDK for Xash3D [![Build Status](https://travis-ci.org/FWGS/hlsdk-xash3d.svg)](https://travis-ci.org/FWGS/hlsdk-xash3d) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/FWGS/hlsdk-xash3d?svg=true)](https://ci.appveyor.com/project/a1batross/hlsdk-xash3d)
|
||||
# Half-Life SDK for GoldSource and Xash3D [![Build Status](https://github.com/FWGS/hlsdk-portable/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/FWGS/hlsdk-portable/actions/workflows/build.yml) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/FWGS/hlsdk-portable?svg=true)](https://ci.appveyor.com/project/a1batross/hlsdk-portable)
|
||||
|
||||
Half-Life SDK for Xash3D & GoldSource with some fixes.
|
||||
Half-Life SDK for GoldSource & Xash3D with some bugfixes.
|
||||
|
||||
## How to build
|
||||
<details><summary>Changelog</summary>
|
||||
<p>
|
||||
|
||||
### CMake as most universal way
|
||||
- Fixed an occasional bug when houndeyes stuck unable to do anything. Technical detail: now monster's `Activity` is set before the call to `SetYawSpeed`. [Patch](https://github.com/FWGS/hlsdk-portable/commit/467899b99aa225a95d90222137f18c141c929c86)
|
||||
- Monsters now play idle sounds as it's supposed by the code. Technical detail: the problem was a check for a wrong variable. [Patch](https://github.com/FWGS/hlsdk-portable/commit/9fc712da019a1ca646171e912209a993e7c43976)
|
||||
- Fixed a bug that caused talk monsters (scientists and security guards) to face a wrong direction during scripted sequence sometimes. [Patch](https://github.com/FWGS/hlsdk-portable/commit/3e2808de62e479e83068c075cb88b4f177f9acc7)
|
||||
- Fixed squad member removal. This bug affected houndeye attacks as their attack depends on percieved number of squad members. [Patch](https://github.com/FWGS/hlsdk-portable/commit/b4502f71336a08f3f2c72b7b061b2838a149a11b)
|
||||
- Scientists now react to smells. [Patch](https://github.com/FWGS/hlsdk-portable/commit/2de4e7ab003d5b1674d12525f5aefb1e57a49fa3)
|
||||
- Tau-cannon (gauss) plays idle animations.
|
||||
- Tau-cannon (gauss) beam color depends on the charge as it was before the prediction code was introduced in Half-Life. [Patch](https://github.com/FWGS/hlsdk-portable/commit/0a29ec49c8183ebb8da22a6d2ef395eae9c3dffe)
|
||||
- Brought back gluon flare in singleplayer. [Patch](https://github.com/FWGS/hlsdk-portable/commit/9d7ab6acf46a8b71ef119d9c252767865522d21d)
|
||||
- Hand grenades don't stay primed after holster, preventing detonation after weapon switch. [Patch](https://github.com/FWGS/hlsdk-portable/commit/6e1059026faa90c5bfe5e3b3f4f58fde398d4524)
|
||||
- Fixed flashlight battery appearing as depleted on restore.
|
||||
- Fixed a potential overflow when reading sentences.txt. [Patch](https://github.com/FWGS/hlsdk-xash3d/commit/cb51d2aa179f1eb622e08c1c07b053ccd49e40a5)
|
||||
- Fixed beam attachment invalidated on restore (that led to visual bugs). [Patch](https://github.com/FWGS/hlsdk-xash3d/commit/74b5543c83c5cdcb88e9254bacab08bc63c4c896)
|
||||
- Fixed alien controllers facing wrong direction in non-combat state. [Patch](https://github.com/FWGS/hlsdk-portable/commit/e51878c45b618f9b3920b46357545cbb47befeda)
|
||||
- Fixed weapon deploy animations not playing sometimes on fast switching between weapons. [Patch](https://github.com/FWGS/hlsdk-portable/commit/ed676a5413c2d26b2982e5b014e0731f0eda6a0d) [Patch2](https://github.com/FWGS/hlsdk-portable/commit/4053dca7a9cf999391cbd77224144da207e4540b)
|
||||
- Fixed tripmine sometimes having wrong body on pickup [Patch](https://github.com/FWGS/hlsdk-portable/commit/abf08e4520e3b6cd12a40f269f4a256cf8496227)
|
||||
|
||||
mkdir build && cd build
|
||||
cmake ../
|
||||
make
|
||||
Bugfix-related macros that can be enabled during the compilation:
|
||||
|
||||
Crosscompiling using mingw:
|
||||
- **CROWBAR_DELAY_FIX** fixes a bug when crowbar has a longer delay after the first hit.
|
||||
- **CROWBAR_FIX_RAPID_CROWBAR** fixes a "rapid crowbar" bug when hitting corpses of killed monsters.
|
||||
- **GAUSS_OVERCHARGE_FIX** fixes tau-cannon (gauss) charge sound not stopping after the overcharge.
|
||||
- **CROWBAR_IDLE_ANIM** makes crowbar play idle animations.
|
||||
- **TRIPMINE_BEAM_DUPLICATION_FIX** fixes tripmine's beam duplication on level transition.
|
||||
- **HANDGRENADE_DEPLOY_FIX** makes handgrenade play draw animation after finishing a throw.
|
||||
- **WEAPONS_ANIMATION_TIMES_FIX** fixes deploy and idle animation times of some weapons.
|
||||
|
||||
mkdir build-mingw && cd build-mingw
|
||||
TOOLCHAIN_PREFIX=i686-w64-mingw32 # check up the actual mingw prefix of your mingw installation
|
||||
cmake ../ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER="$TOOLCHAIN_PREFIX-gcc" -DCMAKE_CXX_COMPILER="$TOOLCHAIN_PREFIX-g++"
|
||||
Bugfix-related server cvars:
|
||||
|
||||
You may enable or disable some build options by -Dkey=value. All available build options are defined in CMakeLists.txt at root directory.
|
||||
See below if you want to build the GoldSource compatible libraries.
|
||||
- **satchelfix**: if set to 1, doors won't get blocked by satchels. Fixes an infamous exploit on `crossfire` map.
|
||||
- **explosionfix**: if set to 1, explosion damage won't propagate through thin bruses.
|
||||
- **selfgauss**: if set to 0, players won't hurt themselves with secondary attack when shooting thick brushes.
|
||||
|
||||
See below, if CMake is not suitable for you:
|
||||
*Note*: the macros and cvars were adjusted in [hlfixed](https://github.com/FWGS/hlsdk-portable/tree/hlfixed) branch (for further information read [this](https://github.com/FWGS/hlsdk-portable/wiki/HL-Fixed)). The bugfix macros are kept turned off in `master` branch to maintain the compatibility with vanilla servers and clients.
|
||||
|
||||
### Windows
|
||||
Other server cvars:
|
||||
|
||||
#### Using msvc
|
||||
- **mp_bhopcap**: if set to 1, enable bunny-hop.
|
||||
- **chargerfix**: if set to 1, wall-mounted health and battery chargers will play reject sounds if player has the full health or armor.
|
||||
- **corpsephysics**: if set to 1, corpses of killed monsters will fly a bit from an impact. It's a cut feature from Half-Life.
|
||||
|
||||
We use compilers provided with Microsoft Visual Studio 6. There're `compile.bat` scripts in both `cl_dll` and `dlls` directories.
|
||||
Before running any of those files you must define `MSVCDir` variable which is the path to your msvc installation.
|
||||
</p>
|
||||
</details>
|
||||
|
||||
set MSVCDir=C:\Program Files\Microsoft Visual Studio
|
||||
compile.bat
|
||||
<details><summary>Support for mods</summary>
|
||||
<p>
|
||||
|
||||
These scripts also can be ran via wine:
|
||||
This repository contains (re-)implementations of some mods as separate branches derived from `master`. The list of supported mods can be found [here](https://github.com/FWGS/hlsdk-portable/wiki/Mods). Note that some branches are unstable and incomplete.
|
||||
|
||||
MSVCDir="z:\home\$USER\.wine\drive_c\Program Files\Microsoft Visual Studio" wine cmd /c compile.bat
|
||||
To get the mod branch locally run the following git command:
|
||||
|
||||
The libraries built this way are always GoldSource compatible.
|
||||
```
|
||||
git fetch origin asheep:asheep
|
||||
```
|
||||
|
||||
There're dsp projects for Visual Studio 6 in `cl_dll` and `dlls` directories, but we don't keep them up-to-date. You're free to adapt them for yourself and try to import into the newer Visual Studio versions.
|
||||
This is considering that you have set **FWGS/hlsdk-portable** as an `origin` remote and want to fetch `asheep` branch.
|
||||
|
||||
#### Using mingw
|
||||
</p>
|
||||
</details>
|
||||
|
||||
TODO
|
||||
# Obtaining source code
|
||||
|
||||
### Linux
|
||||
Either clone the repository via [git](`https://git-scm.com/downloads`) or just download ZIP via **Code** button on github. The first option is more preferable as it also allows you to search through the repo history, switch between branches and clone the vgui submodule.
|
||||
|
||||
(cd dlls && make)
|
||||
(cd cl_dll && make)
|
||||
To clone the repository with git type in Git Bash (on Windows) or in terminal (on Unix-like operating systems):
|
||||
|
||||
### OS X
|
||||
```
|
||||
git clone --recursive https://github.com/FWGS/hlsdk-portable
|
||||
```
|
||||
|
||||
Nothing here.
|
||||
# Build Instructions
|
||||
|
||||
### FreeBSD
|
||||
## Windows x86.
|
||||
|
||||
(cd dlls && gmake CXX=clang++ CC=clang)
|
||||
(cd cl_dll && gmake CXX=clang++ CC=clang)
|
||||
### Prerequisites
|
||||
|
||||
### Android
|
||||
Install and run [Visual Studio Installer](https://visualstudio.microsoft.com/downloads/). The installer allows you to choose specific components. Select `Desktop development with C++`. You can untick everything you don't need in Installation details, but you must keep `MSVC` ticked. You may also keep `C++ CMake tools for Windows` ticked as you'll need **cmake**. Alternatively you can install **cmake** from the [cmake.org](https://cmake.org/download/) and during installation tick *Add to the PATH...*.
|
||||
|
||||
Just typical `ndk-build`.
|
||||
TODO: describe what it is.
|
||||
### Opening command prompt
|
||||
|
||||
### Building GoldSource-compatible libraries
|
||||
If **cmake** was installed with Visual Studio Installer, you'll need to run `Developer command prompt for VS` via Windows `Start` menu. If **cmake** was installed with cmake installer, you can run the regular Windows `cmd`.
|
||||
|
||||
To enable building the goldsource compatible client library add GOLDSOURCE_SUPPORT flag when calling cmake:
|
||||
Inside the prompt navigate to the hlsdk directory, using `cd` command, e.g.
|
||||
```
|
||||
cd C:\Users\username\projects\hlsdk-portable
|
||||
```
|
||||
|
||||
cmake .. -DGOLDSOURCE_SUPPORT=ON
|
||||
Note: if hlsdk-portable is unpacked on another disk, nagivate there first:
|
||||
```
|
||||
D:
|
||||
cd projects\hlsdk-portable
|
||||
```
|
||||
|
||||
or when using make without cmake:
|
||||
### Building
|
||||
|
||||
make GOLDSOURCE_SUPPORT=1
|
||||
Сonfigure the project:
|
||||
```
|
||||
cmake -A Win32 -B build
|
||||
```
|
||||
Note that you must repeat the configuration step if you modify `CMakeLists.txt` files or want to reconfigure the project with different parameters.
|
||||
|
||||
Unlike original client by Valve the resulting client library will not depend on vgui or SDL2 just like the one that's used in FWGS Xash3d.
|
||||
The next step is to compile the libraries:
|
||||
```
|
||||
cmake --build build --config Release
|
||||
```
|
||||
`hl.dll` and `client.dll` will appear in the `build/dlls/Release` and `build/cl_dll/Release` directories.
|
||||
|
||||
Note for **Windows**: it's not possible to create GoldSource compatible libraries using mingw, only msvc builds will work.
|
||||
If you have a mod and want to automatically install libraries to the mod directory, set **GAMEDIR** variable to the directory name and **CMAKE_INSTALL_PREFIX** to your Half-Life or Xash3D installation path:
|
||||
```
|
||||
cmake -A Win32 -B build -DGAMEDIR=mod -DCMAKE_INSTALL_PREFIX="C:\Program Files (x86)\Steam\steamapps\common\Half-Life"
|
||||
```
|
||||
Then call `cmake` with `--target install` parameter:
|
||||
```
|
||||
cmake --build build --config Release --target install
|
||||
```
|
||||
|
||||
Note for **Linux**: GoldSource requires libraries (both client and server) to be compiled with libstdc++ bundled with g++ of major version 4 (versions from 4.6 to 4.9 should work).
|
||||
If your Linux distribution does not provide compatible g++ version you have several options.
|
||||
#### Choosing Visual Studio version
|
||||
|
||||
#### Method 1: Statically build with c++ library
|
||||
You can explicitly choose a Visual Studio version on the configuration step by specifying cmake generator:
|
||||
```
|
||||
cmake -G "Visual Studio 16 2019" -A Win32 -B build
|
||||
```
|
||||
|
||||
This one is the most simple but has a drawback.
|
||||
### Editing code in Visual Studio
|
||||
|
||||
cmake ../ -DGOLDSOURCE_SUPPORT=ON -DCMAKE_C_FLAGS="-static-libstdc++ -static-libgcc"
|
||||
After the configuration step, `HLSDK-PORTABLE.sln` should appear in the `build` directory. You can open this solution in Visual Studio and continue developing there.
|
||||
|
||||
The drawback is that the compiled libraries will be larger in size.
|
||||
## Windows x86. Using Microsoft Visual Studio 6
|
||||
|
||||
#### Method 2: Build in Steam Runtime chroot
|
||||
Microsoft Visual Studio 6 is very old, but if you still have it installed, you can use it to build this hlsdk. There are no project files, but two `.bat` files, for server and client libraries. They require variable **MSVCDir** to be set to the installation path of Visual Studio:
|
||||
|
||||
This is the official way to build Steam compatible games for Linux.
|
||||
```
|
||||
set MSVCDir=C:\Program Files\Microsoft Visual Studio
|
||||
cd dlls && compile.bat && cd ../cl_dll && compile.bat
|
||||
```
|
||||
|
||||
Clone https://github.com/ValveSoftware/steam-runtime and follow instructions https://github.com/ValveSoftware/steam-runtime#building-in-the-runtime
|
||||
`hl.dll` and `client.dll` will appear in `dlls/` and `cl_dll/` diretories. The libraries built with msvc6 should be compatible with Windows XP.
|
||||
|
||||
sudo ./setup_chroot.sh --i386
|
||||
## Linux x86. Portable steam-compatible build using Steam Runtime in chroot
|
||||
|
||||
Then use cmake and make as usual, but prepend the commands with `schroot --chroot steamrt_scout_i386 --`:
|
||||
### Prerequisites
|
||||
|
||||
mkdir build-in-steamrt && cd build-in-steamrt
|
||||
schroot --chroot steamrt_scout_i386 -- cmake ../ -DGOLDSOURCE_SUPPORT=ON
|
||||
schroot --chroot steamrt_scout_i386 -- make
|
||||
The official way to build Steam compatible games for Linux is through steam-runtime.
|
||||
|
||||
#### Method 3: Create your own chroot with older distro that includes g++ 4.
|
||||
Install schroot. On Ubuntu or Debian:
|
||||
|
||||
Use the most suitable way for you to create an old distro 32-bit chroot. E.g. on Debian (and similar) you can use debootstrap.
|
||||
```
|
||||
sudo apt install schroot
|
||||
```
|
||||
|
||||
sudo debootstrap --arch=i386 jessie /var/chroot/jessie-debian-i386 # On Ubuntu type trusty instead of jessie
|
||||
sudo chroot /var/chroot/jessie-debian-i386
|
||||
Clone https://github.com/ValveSoftware/steam-runtime and follow instructions: [download](https://github.com/ValveSoftware/steam-runtime/blob/e014a74f60b45a861d38a867b1c81efe8484f77a/README.md#downloading-a-steam-runtime) and [setup](https://github.com/ValveSoftware/steam-runtime/blob/e014a74f60b45a861d38a867b1c81efe8484f77a/README.md#using-schroot) the chroot.
|
||||
|
||||
Inside chroot install cmake, make, g++ and libsdl2-dev. Then exit the chroot.
|
||||
```
|
||||
sudo ./setup_chroot.sh --i386 --tarball ./com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz
|
||||
```
|
||||
|
||||
On the host system install schroot. Then create and adapt the following config in /etc/schroot/chroot.d/jessie.conf (you can choose a different name):
|
||||
### Building
|
||||
|
||||
Now you can use cmake and make prepending the commands with `schroot --chroot steamrt_scout_i386 --`:
|
||||
```
|
||||
schroot --chroot steamrt_scout_i386 -- cmake -B build-in-steamrt -S .
|
||||
schroot --chroot steamrt_scout_i386 -- cmake --build build-in-steamrt
|
||||
```
|
||||
|
||||
## Linux x86. Portable steam-compatible build without Steam Runtime
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Install C++ compilers, cmake and x86 development libraries for C, C++ and SDL2. On Ubuntu/Debian:
|
||||
```
|
||||
sudo apt install cmake build-essential gcc-multilib g++-multilib libsdl2-dev:i386
|
||||
```
|
||||
|
||||
### Building
|
||||
|
||||
```
|
||||
cmake -B build -S .
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
Note that the libraries built this way might be not compatible with Steam Half-Life. If you have such issue you can configure it to build statically with c++ and gcc libraries:
|
||||
```
|
||||
cmake .. -DCMAKE_C_FLAGS="-static-libstdc++ -static-libgcc"
|
||||
```
|
||||
To ensure portability it's still better to build using Steam Runtime or another chroot of some older distro.
|
||||
|
||||
## Linux x86. Portable steam-compatible build in your own chroot
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Use the most suitable way for you to create an old distro 32-bit chroot. E.g. on Ubuntu/Debian you can use debootstrap.
|
||||
|
||||
```
|
||||
sudo apt install debootstrap schroot
|
||||
sudo mkdir -p /var/choots
|
||||
sudo debootstrap --arch=i386 jessie /var/chroots/jessie-i386 # On Ubuntu type trusty instead of jessie
|
||||
sudo chroot /var/chroots/jessie-i386
|
||||
```
|
||||
|
||||
```
|
||||
# inside chroot
|
||||
apt install cmake build-essential gcc-multilib g++-multilib libsdl2-dev
|
||||
exit
|
||||
```
|
||||
|
||||
Create and adapt the following config in /etc/schroot/chroot.d/jessie.conf (you can choose a different name):
|
||||
|
||||
```
|
||||
[jessie]
|
||||
type=directory
|
||||
description=Debian jessie i386
|
||||
directory=/var/chroot/debian-jessie-i386/
|
||||
directory=/var/chroots/jessie-i386/
|
||||
users=yourusername
|
||||
groups=yourusername
|
||||
groups=adm
|
||||
root-groups=root
|
||||
preserve-environment=true
|
||||
personality=linux32
|
||||
```
|
||||
|
||||
Insert your actual user name in place of `yourusername`. Then prepend any make or cmake call with `schroot -c jessie --`:
|
||||
Insert your actual user name in place of `yourusername`.
|
||||
|
||||
mkdir build-in-chroot && cd build-in-chroot
|
||||
schroot --chroot jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON
|
||||
schroot --chroot jessie -- make
|
||||
### Building
|
||||
|
||||
#### Method 4: Install the needed g++ version yourself
|
||||
|
||||
TODO: describe steps.
|
||||
|
||||
#### Configuring Qt Creator to use toolchain from chroot
|
||||
|
||||
Create a file with the following contents anywhere:
|
||||
|
||||
```sh
|
||||
#!/bin/sh
|
||||
schroot --chroot steamrt_scout_i386 -- cmake "$@"
|
||||
Prepend any make or cmake call with `schroot -c jessie --`:
|
||||
```
|
||||
schroot --chroot jessie -- cmake -B build-in-chroot -S .
|
||||
schroot --chroot jessie -- cmake --build build-in-chroot
|
||||
```
|
||||
|
||||
Make it executable.
|
||||
In Qt Creator go to `Tools` -> `Options` -> `Build & Run` -> `CMake`. Add a new cmake tool and specify the path of previously created file.
|
||||
Go to `Kits` tab, clone your default configuration and choose your CMake tool there.
|
||||
Choose the new kit when opening CMakeLists.txt.
|
||||
## Android
|
||||
|
||||
TODO
|
||||
|
||||
## Nintendo Switch
|
||||
|
||||
### Prerequisites
|
||||
|
||||
1. Set up [`dkp-pacman`](https://devkitpro.org/wiki/devkitPro_pacman).
|
||||
2. Install dependency packages:
|
||||
```
|
||||
sudo dkp-pacman -S switch-dev dkp-toolchain-vars switch-mesa switch-libdrm_nouveau switch-sdl2
|
||||
```
|
||||
3. Make sure the `DEVKITPRO` environment variable is set to the devkitPro SDK root:
|
||||
```
|
||||
export DEVKITPRO=/opt/devkitpro
|
||||
```
|
||||
4. Install libsolder:
|
||||
```
|
||||
source $DEVKITPRO/switchvars.sh
|
||||
git clone https://github.com/fgsfdsfgs/libsolder.git
|
||||
make -C libsolder install
|
||||
```
|
||||
|
||||
### Building using CMake
|
||||
```
|
||||
mkdir build && cd build
|
||||
aarch64-none-elf-cmake -G"Unix Makefiles" -DCMAKE_PROJECT_HLSDK-PORTABLE_INCLUDE="$DEVKITPRO/portlibs/switch/share/SolderShim.cmake" ..
|
||||
make -j
|
||||
```
|
||||
|
||||
### Building using waf
|
||||
```
|
||||
./waf configure -T release --nswitch
|
||||
./waf build
|
||||
```
|
||||
|
||||
## PlayStation Vita
|
||||
|
||||
### Prerequisites
|
||||
|
||||
1. Set up [VitaSDK](https://vitasdk.org/).
|
||||
2. Install [vita-rtld](https://github.com/fgsfdsfgs/vita-rtld):
|
||||
```
|
||||
git clone https://github.com/fgsfdsfgs/vita-rtld.git && cd vita-rtld
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make -j2 install
|
||||
```
|
||||
|
||||
### Building with waf:
|
||||
```
|
||||
./waf configure -T release --psvita
|
||||
./waf build
|
||||
```
|
||||
|
||||
### Building with CMake:
|
||||
```
|
||||
mkdir build && cd build
|
||||
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="$VITASDK/share/vita.toolchain.cmake" -DCMAKE_PROJECT_HLSDK-PORTABLE_INCLUDE="$VITASDK/share/vrtld_shim.cmake" ..
|
||||
make -j
|
||||
```
|
||||
|
||||
## Other platforms
|
||||
|
||||
Building on other architectures (e.g x86_64 or arm) and POSIX-compliant OSes (e.g. FreeBSD) is supported.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Install C and C++ compilers (like gcc or clang), cmake and make.
|
||||
|
||||
### Building
|
||||
|
||||
```
|
||||
cmake -B build -S .
|
||||
cmake --build build
|
||||
```
|
||||
|
||||
### Building with waf
|
||||
|
||||
To use waf, you need to install python (2.7 minimum)
|
||||
|
||||
```
|
||||
(./waf configure -T release)
|
||||
(./waf)
|
||||
```
|
||||
|
||||
## Build options
|
||||
|
||||
Some useful build options that can be set during the cmake step.
|
||||
|
||||
* **GOLDSOURCE_SUPPORT** - allows to turn off/on the support for GoldSource input. Set to **ON** by default on Windows and Linux, **OFF** on other platforms.
|
||||
* **USE_VGUI** - whether to use VGUI library. **OFF** by default. You need to init `vgui_support` submodule in order to build with VGUI.
|
||||
|
||||
This list is incomplete. Look at `CMakeLists.txt` to see all available options.
|
||||
|
||||
Prepend option names with `-D` when passing to cmake. Boolean options can take values **OFF** and **ON**. Example:
|
||||
|
||||
```
|
||||
cmake .. -DUSE_VGUI=ON -DGOLDSOURCE_SUPPORT=ON -DCROWBAR_IDLE_ANIM=ON -DCROWBAR_FIX_RAPID_CROWBAR=ON
|
||||
```
|
||||
|
|
18
appveyor.yml
18
appveyor.yml
|
@ -1,28 +1,28 @@
|
|||
version: 1.0.{build}
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- os: Visual Studio 2013
|
||||
GENERATOR_NAME: "Visual Studio 12 2013"
|
||||
- os: Visual Studio 2015
|
||||
GENERATOR_NAME: "Visual Studio 14 2015"
|
||||
# TODO: Uncomment when AppVeyor will provide XP toolchain for VS2017
|
||||
# - os: Visual Studio 2017
|
||||
# GENERATOR_NAME: "Visual Studio 15 2017"
|
||||
|
||||
clone_folder: c:\projects\xash\hlsdk-xash3d
|
||||
clone_folder: c:\projects\xash\hlsdk-portable
|
||||
|
||||
build:
|
||||
project: INSTALL.vcxproj
|
||||
project: build/INSTALL.vcxproj
|
||||
verbosity: normal
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
before_build:
|
||||
- git submodule update --init --recursive
|
||||
- cmake -G "%GENERATOR_NAME%"
|
||||
- cmake -G "%GENERATOR_NAME%" -B build -DCMAKE_INSTALL_PREFIX="dist"
|
||||
|
||||
artifacts:
|
||||
- path: dist
|
||||
name: hlsdk-msvc
|
||||
type: zip
|
||||
|
|
|
@ -73,7 +73,6 @@ SRCS+=./input_mouse.cpp
|
|||
#SRCS+=./inputw32.cpp
|
||||
SRCS+=./menu.cpp
|
||||
SRCS+=./message.cpp
|
||||
SRCS+=./overview.cpp
|
||||
SRCS+=./parsemsg.cpp
|
||||
SRCS_C+=../pm_shared/pm_debug.c
|
||||
SRCS_C+=../pm_shared/pm_math.c
|
||||
|
|
|
@ -20,13 +20,12 @@
|
|||
# SOFTWARE.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 2.6.0)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project (CLDLL)
|
||||
|
||||
set (CLDLL_LIBRARY client)
|
||||
|
||||
|
||||
add_definitions(-DCLIENT_WEAPONS -DCLIENT_DLL)
|
||||
add_definitions(-DCLIENT_DLL)
|
||||
|
||||
if(NOT MSVC)
|
||||
add_compile_options(-fno-exceptions) # GCC/Clang flag
|
||||
|
@ -45,6 +44,15 @@ if (GOLDSOURCE_SUPPORT)
|
|||
add_definitions(-DGOLDSOURCE_SUPPORT)
|
||||
endif()
|
||||
|
||||
if (USE_VGUI)
|
||||
add_definitions(-DUSE_VGUI)
|
||||
if (USE_NOVGUI_MOTD)
|
||||
add_definitions(-DUSE_NOVGUI_MOTD)
|
||||
endif()
|
||||
if (USE_NOVGUI_SCOREBOARD)
|
||||
add_definitions(-DUSE_NOVGUI_SCOREBOARD)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set (CLDLL_SOURCES
|
||||
../dlls/crossbow.cpp
|
||||
|
@ -93,7 +101,6 @@ set (CLDLL_SOURCES
|
|||
input_xash3d.cpp
|
||||
menu.cpp
|
||||
message.cpp
|
||||
overview.cpp
|
||||
parsemsg.cpp
|
||||
../pm_shared/pm_debug.c
|
||||
../pm_shared/pm_math.c
|
||||
|
@ -107,11 +114,52 @@ set (CLDLL_SOURCES
|
|||
train.cpp
|
||||
tri.cpp
|
||||
util.cpp
|
||||
view.cpp
|
||||
scoreboard.cpp
|
||||
MOTD.cpp)
|
||||
view.cpp)
|
||||
|
||||
include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/false_vgui/include)
|
||||
if (USE_VGUI)
|
||||
list(APPEND CLDLL_SOURCES
|
||||
vgui_int.cpp
|
||||
vgui_ClassMenu.cpp
|
||||
vgui_ConsolePanel.cpp
|
||||
vgui_ControlConfigPanel.cpp
|
||||
vgui_CustomObjects.cpp
|
||||
vgui_MOTDWindow.cpp
|
||||
vgui_SchemeManager.cpp
|
||||
vgui_ScorePanel.cpp
|
||||
vgui_TeamFortressViewport.cpp
|
||||
vgui_SpectatorPanel.cpp
|
||||
vgui_teammenu.cpp
|
||||
voice_status.cpp
|
||||
../game_shared/vgui_checkbutton2.cpp
|
||||
../game_shared/vgui_grid.cpp
|
||||
../game_shared/vgui_helpers.cpp
|
||||
../game_shared/vgui_listbox.cpp
|
||||
../game_shared/vgui_loadtga.cpp
|
||||
../game_shared/vgui_scrollbar2.cpp
|
||||
../game_shared/vgui_slider2.cpp
|
||||
../game_shared/voice_banmgr.cpp
|
||||
)
|
||||
if (USE_NOVGUI_MOTD)
|
||||
list(APPEND CLDLL_SOURCES MOTD.cpp)
|
||||
endif()
|
||||
if (USE_NOVGUI_SCOREBOARD)
|
||||
list(APPEND CLDLL_SOURCES scoreboard.cpp)
|
||||
endif()
|
||||
else()
|
||||
list(APPEND CLDLL_SOURCES
|
||||
MOTD.cpp
|
||||
scoreboard.cpp)
|
||||
endif()
|
||||
|
||||
include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public)
|
||||
|
||||
if (USE_VGUI)
|
||||
SET(CMAKE_SKIP_RPATH TRUE)
|
||||
link_directories(${CMAKE_SOURCE_DIR}/vgui_support/vgui-dev/lib)
|
||||
include_directories(../vgui_support/vgui-dev/include)
|
||||
else()
|
||||
include_directories(../utils/fake_vgui/include)
|
||||
endif()
|
||||
|
||||
if(USE_VOICEMGR)
|
||||
#set(CLDLL_SOURCES
|
||||
|
@ -121,24 +169,45 @@ if(USE_VOICEMGR)
|
|||
endif()
|
||||
|
||||
add_library (${CLDLL_LIBRARY} SHARED ${CLDLL_SOURCES})
|
||||
|
||||
if (GOLDSOURCE_SUPPORT)
|
||||
target_link_libraries( ${CLDLL_LIBRARY} ${CMAKE_DL_LIBS} )
|
||||
endif()
|
||||
|
||||
if (USE_VGUI)
|
||||
if (WIN32)
|
||||
add_library(vgui SHARED IMPORTED)
|
||||
set_property(TARGET vgui PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/vgui_support/vgui-dev/lib/win32_vc6/vgui.dll")
|
||||
set_property(TARGET vgui PROPERTY IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/vgui_support/vgui-dev/lib/win32_vc6/vgui.lib")
|
||||
target_link_libraries(${CLDLL_LIBRARY} vgui)
|
||||
elseif(APPLE)
|
||||
target_link_libraries(${CLDLL_LIBRARY} "-Wl,--no-undefined -L${CMAKE_SOURCE_DIR}/vgui_support/vgui-dev/lib vgui.dylib")
|
||||
else()
|
||||
target_link_libraries(${CLDLL_LIBRARY} :vgui.so)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries( ${CLDLL_LIBRARY} user32.lib )
|
||||
if (GOLDSOURCE_SUPPORT)
|
||||
target_link_libraries( ${CLDLL_LIBRARY} winmm.lib )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_target_properties (${CLDLL_LIBRARY} PROPERTIES
|
||||
POSITION_INDEPENDENT_CODE 1)
|
||||
|
||||
if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android")
|
||||
set(CLDLL_NAME "client")
|
||||
if(64BIT)
|
||||
set(CLDLL_NAME "client64")
|
||||
endif()
|
||||
|
||||
set_target_properties(${CLDLL_LIBRARY} PROPERTIES
|
||||
OUTPUT_NAME ${CLDLL_NAME}
|
||||
PREFIX "")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set_property(TARGET ${CLDLL_LIBRARY} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
endif()
|
||||
|
||||
install( TARGETS ${CLDLL_LIBRARY}
|
||||
DESTINATION "${GAMEDIR}/${CLIENT_INSTALL_DIR}/"
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "studio_util.h"
|
||||
#include "r_studioint.h"
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "studio_util.h"
|
||||
#include "r_studioint.h"
|
||||
|
|
|
@ -26,13 +26,17 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if !USE_VGUI || USE_NOVGUI_MOTD
|
||||
DECLARE_MESSAGE( m_MOTD, MOTD )
|
||||
#endif
|
||||
|
||||
int CHudMOTD::Init( void )
|
||||
{
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
#if !USE_VGUI || USE_NOVGUI_MOTD
|
||||
HOOK_MESSAGE( MOTD );
|
||||
#endif
|
||||
|
||||
m_bShow = false;
|
||||
|
||||
|
@ -66,7 +70,7 @@ int CHudMOTD::Draw( float fTime )
|
|||
if( !m_bShow )
|
||||
return 1;
|
||||
gHUD.m_iNoConsolePrint |= 1 << 1;
|
||||
bool bScroll;
|
||||
//bool bScroll;
|
||||
// find the top of where the MOTD should be drawn, so the whole thing is centered in the screen
|
||||
int ypos = ( ScreenHeight - LINE_HEIGHT * m_iLines ) / 2; // shift it up slightly
|
||||
char *ch = m_szMOTD;
|
||||
|
@ -80,13 +84,13 @@ int CHudMOTD::Draw( float fTime )
|
|||
{
|
||||
ypos = ROW_RANGE_MIN + 7 + scroll;
|
||||
if( ypos > ROW_RANGE_MIN + 4 )
|
||||
scroll-= ( ypos - ( ROW_RANGE_MIN + 4 ) ) / 3.0;
|
||||
scroll-= ( ypos - ( ROW_RANGE_MIN + 4 ) ) / 3.0f;
|
||||
if( ypos + height < ROW_RANGE_MAX )
|
||||
scroll+= ( ROW_RANGE_MAX - ( ypos + height ) ) / 3.0;
|
||||
scroll+= ( ROW_RANGE_MAX - ( ypos + height ) ) / 3.0f;
|
||||
ypos_r = ROW_RANGE_MIN;
|
||||
height = ROW_RANGE_MAX;
|
||||
}
|
||||
int ymax = ypos + height;
|
||||
// int ymax = ypos + height;
|
||||
if( xmax > ScreenWidth - 30 ) xmax = ScreenWidth - 30;
|
||||
gHUD.DrawDarkRectangle( xpos - 5, ypos_r - 5, xmax - xpos + 10, height + 10 );
|
||||
while( *ch )
|
||||
|
@ -130,7 +134,8 @@ int CHudMOTD::MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf )
|
|||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int is_finished = READ_BYTE();
|
||||
strncat( m_szMOTD, READ_STRING(), sizeof(m_szMOTD) - 1 );
|
||||
strncat( m_szMOTD, READ_STRING(), sizeof(m_szMOTD) - strlen(m_szMOTD) - 1 );
|
||||
m_szMOTD[sizeof(m_szMOTD) - 1] = '\0';
|
||||
|
||||
if( is_finished )
|
||||
{
|
||||
|
@ -157,7 +162,7 @@ int CHudMOTD::MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf )
|
|||
if( length > m_iMaxLength )
|
||||
{
|
||||
m_iMaxLength = length;
|
||||
length = 0;
|
||||
// length = 0;
|
||||
}
|
||||
m_bShow = true;
|
||||
}
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
CC?=gcc
|
||||
CXX?=g++
|
||||
SRCS+=../dlls/crossbow.cpp
|
||||
SRCS+=../dlls/crowbar.cpp
|
||||
SRCS+=../dlls/egon.cpp
|
||||
SRCS+=./ev_hldm.cpp
|
||||
SRCS+=../dlls/gauss.cpp
|
||||
SRCS+=../dlls/handgrenade.cpp
|
||||
SRCS+=./hl/hl_baseentity.cpp
|
||||
SRCS+=./hl/hl_events.cpp
|
||||
SRCS+=./hl/hl_objects.cpp
|
||||
SRCS+=./hl/hl_weapons.cpp
|
||||
SRCS+=../dlls/glock.cpp
|
||||
SRCS+=../dlls/hornetgun.cpp
|
||||
#SRCS+=../common/interface.cpp
|
||||
SRCS+=../dlls/mp5.cpp
|
||||
SRCS+=../dlls/python.cpp
|
||||
SRCS+=../dlls/rpg.cpp
|
||||
SRCS+=../dlls/satchel.cpp
|
||||
SRCS+=../dlls/shotgun.cpp
|
||||
SRCS+=../dlls/squeakgrenade.cpp
|
||||
SRCS+=../dlls/tripmine.cpp
|
||||
#SRCS+=../game_shared/voice_banmgr.cpp
|
||||
#SRCS+=../game_shared/voice_status.cpp
|
||||
SRCS+=./ammo.cpp
|
||||
SRCS+=./ammo_secondary.cpp
|
||||
SRCS+=./ammohistory.cpp
|
||||
SRCS+=./battery.cpp
|
||||
SRCS+=./cdll_int.cpp
|
||||
SRCS+=./com_weapons.cpp
|
||||
SRCS+=./death.cpp
|
||||
SRCS+=./demo.cpp
|
||||
SRCS+=./entity.cpp
|
||||
SRCS+=./ev_common.cpp
|
||||
SRCS+=./events.cpp
|
||||
SRCS+=./flashlight.cpp
|
||||
SRCS+=./GameStudioModelRenderer.cpp
|
||||
SRCS+=./geiger.cpp
|
||||
SRCS+=./health.cpp
|
||||
SRCS+=./hud.cpp
|
||||
SRCS+=./hud_msg.cpp
|
||||
SRCS+=./hud_redraw.cpp
|
||||
#SRCS+=./hud_servers.cpp
|
||||
SRCS+=./hud_spectator.cpp
|
||||
SRCS+=./hud_update.cpp
|
||||
SRCS+=./in_camera.cpp
|
||||
SRCS+=./input.cpp
|
||||
SRCS+=./input_mouse.cpp
|
||||
SRCS+=./input_goldsource.cpp
|
||||
SRCS+=./menu.cpp
|
||||
SRCS+=./message.cpp
|
||||
SRCS+=./overview.cpp
|
||||
SRCS+=./parsemsg.cpp
|
||||
SRCS_C+=../pm_shared/pm_debug.c
|
||||
SRCS_C+=../pm_shared/pm_math.c
|
||||
SRCS_C+=../pm_shared/pm_shared.c
|
||||
SRCS+=./saytext.cpp
|
||||
SRCS+=./status_icons.cpp
|
||||
SRCS+=./statusbar.cpp
|
||||
SRCS+=./studio_util.cpp
|
||||
SRCS+=./StudioModelRenderer.cpp
|
||||
SRCS+=./text_message.cpp
|
||||
SRCS+=./train.cpp
|
||||
SRCS+=./tri.cpp
|
||||
SRCS+=./util.cpp
|
||||
SRCS+=./view.cpp
|
||||
SRCS+=./input_xash3d.cpp
|
||||
SRCS+=./scoreboard.cpp
|
||||
SRCS+=./MOTD.cpp
|
||||
INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include
|
||||
DEFINES = -Wno-write-strings -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL
|
||||
CFLAGS = -m32
|
||||
OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o)
|
||||
|
||||
LIBS=-lm
|
||||
ifeq ($(GOLDSOURCE_SUPPORT),1)
|
||||
DEFINES += -DGOLDSOURCE_SUPPORT
|
||||
endif
|
||||
|
||||
ifeq ($(shell uname -s),Linux)
|
||||
LIBS += -ldl
|
||||
endif
|
||||
|
||||
%.o : %.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $(DEFINES) -fPIC -c $< -o $@
|
||||
|
||||
%.o : %.cpp
|
||||
$(CXX) $(CFLAGS) $(INCLUDES) $(DEFINES) -fPIC -c $< -o $@
|
||||
client.so : $(OBJS)
|
||||
$(CXX) $(CFLAGS) $(OBJS) -o client.so -shared -Wl,--no-undefined -fPIC $(LIBS)
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJS)
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "studio_util.h"
|
||||
#include "r_studioint.h"
|
||||
|
@ -138,27 +136,27 @@ void CStudioModelRenderer::StudioCalcBoneAdj( float dadt, float *adj, const byte
|
|||
int a, b;
|
||||
a = ( pcontroller1[j] + 128 ) % 256;
|
||||
b = ( pcontroller2[j] + 128 ) % 256;
|
||||
value = ( ( a * dadt ) + ( b * ( 1 - dadt ) ) - 128 ) * ( 360.0 / 256.0 ) + pbonecontroller[j].start;
|
||||
value = ( ( a * dadt ) + ( b * ( 1.0f - dadt ) ) - 128.0f ) * ( 360.0f / 256.0f ) + pbonecontroller[j].start;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = ( ( pcontroller1[i] * dadt + ( pcontroller2[i] ) * ( 1.0 - dadt ) ) ) * ( 360.0 / 256.0 ) + pbonecontroller[j].start;
|
||||
value = ( ( pcontroller1[i] * dadt + ( pcontroller2[i] ) * ( 1.0f - dadt ) ) ) * ( 360.0f / 256.0f ) + pbonecontroller[j].start;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = ( pcontroller1[i] * dadt + pcontroller2[i] * ( 1.0 - dadt ) ) / 255.0;
|
||||
if( value < 0 ) value = 0;
|
||||
if( value > 1.0 ) value = 1.0;
|
||||
value = ( 1.0 - value ) * pbonecontroller[j].start + value * pbonecontroller[j].end;
|
||||
value = ( pcontroller1[i] * dadt + pcontroller2[i] * ( 1.0f - dadt ) ) / 255.0f;
|
||||
if( value < 0.0f ) value = 0.0f;
|
||||
if( value > 1.0f ) value = 1.0f;
|
||||
value = ( 1.0f - value ) * pbonecontroller[j].start + value * pbonecontroller[j].end;
|
||||
}
|
||||
// Con_DPrintf( "%d %d %f : %f\n", m_pCurrentEntity->curstate.controller[j], m_pCurrentEntity->latched.prevcontroller[j], value, dadt );
|
||||
}
|
||||
else
|
||||
{
|
||||
value = mouthopen / 64.0;
|
||||
if( value > 1.0 ) value = 1.0;
|
||||
value = ( 1.0 - value ) * pbonecontroller[j].start + value * pbonecontroller[j].end;
|
||||
value = mouthopen / 64.0f;
|
||||
if( value > 1.0f ) value = 1.0f;
|
||||
value = ( 1.0f - value ) * pbonecontroller[j].start + value * pbonecontroller[j].end;
|
||||
// Con_DPrintf( "%d %f\n", mouthopen, value );
|
||||
}
|
||||
switch( pbonecontroller[j].type & STUDIO_TYPES )
|
||||
|
@ -166,7 +164,7 @@ void CStudioModelRenderer::StudioCalcBoneAdj( float dadt, float *adj, const byte
|
|||
case STUDIO_XR:
|
||||
case STUDIO_YR:
|
||||
case STUDIO_ZR:
|
||||
adj[j] = value * ( M_PI / 180.0 );
|
||||
adj[j] = value * ( M_PI_F / 180.0f );
|
||||
break;
|
||||
case STUDIO_X:
|
||||
case STUDIO_Y:
|
||||
|
@ -305,7 +303,7 @@ void CStudioModelRenderer::StudioCalcBonePosition( int frame, float s, mstudiobo
|
|||
// and there's more data in the span
|
||||
if( panimvalue->num.valid > k + 1 )
|
||||
{
|
||||
pos[j] += ( panimvalue[k + 1].value * ( 1.0 - s ) + s * panimvalue[k + 2].value ) * pbone->scale[j];
|
||||
pos[j] += ( panimvalue[k + 1].value * ( 1.0f - s ) + s * panimvalue[k + 2].value ) * pbone->scale[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -317,7 +315,7 @@ void CStudioModelRenderer::StudioCalcBonePosition( int frame, float s, mstudiobo
|
|||
// are we at the end of the repeating values section and there's another section with data?
|
||||
if( panimvalue->num.total <= k + 1 )
|
||||
{
|
||||
pos[j] += ( panimvalue[panimvalue->num.valid].value * ( 1.0 - s ) + s * panimvalue[panimvalue->num.valid + 2].value ) * pbone->scale[j];
|
||||
pos[j] += ( panimvalue[panimvalue->num.valid].value * ( 1.0f - s ) + s * panimvalue[panimvalue->num.valid + 2].value ) * pbone->scale[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -344,12 +342,12 @@ void CStudioModelRenderer::StudioSlerpBones( vec4_t q1[], float pos1[][3], vec4_
|
|||
vec4_t q3;
|
||||
float s1;
|
||||
|
||||
if( s < 0 )
|
||||
s = 0;
|
||||
else if( s > 1.0 )
|
||||
s = 1.0;
|
||||
if( s < 0.0f )
|
||||
s = 0.0f;
|
||||
else if( s > 1.0f )
|
||||
s = 1.0f;
|
||||
|
||||
s1 = 1.0 - s;
|
||||
s1 = 1.0f - s;
|
||||
|
||||
for( i = 0; i < m_pStudioHeader->numbones; i++ )
|
||||
{
|
||||
|
@ -410,17 +408,17 @@ void CStudioModelRenderer::StudioPlayerBlend( mstudioseqdesc_t *pseqdesc, int *p
|
|||
*pBlend = ( *pPitch * 3 );
|
||||
if( *pBlend < pseqdesc->blendstart[0] )
|
||||
{
|
||||
*pPitch -= pseqdesc->blendstart[0] / 3.0;
|
||||
*pPitch -= pseqdesc->blendstart[0] / 3.0f;
|
||||
*pBlend = 0;
|
||||
}
|
||||
else if( *pBlend > pseqdesc->blendend[0] )
|
||||
{
|
||||
*pPitch -= pseqdesc->blendend[0] / 3.0;
|
||||
*pPitch -= pseqdesc->blendend[0] / 3.0f;
|
||||
*pBlend = 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( pseqdesc->blendend[0] - pseqdesc->blendstart[0] < 0.1 ) // catch qc error
|
||||
if( pseqdesc->blendend[0] - pseqdesc->blendstart[0] < 0.1f ) // catch qc error
|
||||
*pBlend = 127;
|
||||
else
|
||||
*pBlend = 255 * ( *pBlend - pseqdesc->blendstart[0] ) / ( pseqdesc->blendend[0] - pseqdesc->blendstart[0] );
|
||||
|
@ -475,11 +473,11 @@ void CStudioModelRenderer::StudioSetUpTransform( int trivial_accept )
|
|||
if( m_fDoInterp )
|
||||
{
|
||||
// ugly hack to interpolate angle, position. current is reached 0.1 seconds after being set
|
||||
f = f - 1.0;
|
||||
f = f - 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
f = 0;
|
||||
f = 0.0f;
|
||||
}
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
|
@ -489,7 +487,7 @@ void CStudioModelRenderer::StudioSetUpTransform( int trivial_accept )
|
|||
|
||||
// NOTE: Because multiplayer lag can be relatively large, we don't want to cap
|
||||
// f at 1.5 anymore.
|
||||
//if( f > -1.0 && f < 1.5 ) {}
|
||||
//if( f > -1.0f && f < 1.5f ) {}
|
||||
//Con_DPrintf( "%.0f %.0f\n",m_pCurrentEntity->msg_angles[0][YAW], m_pCurrentEntity->msg_angles[1][YAW] );
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
|
@ -499,13 +497,13 @@ void CStudioModelRenderer::StudioSetUpTransform( int trivial_accept )
|
|||
ang2 = m_pCurrentEntity->latched.prevangles[i];
|
||||
|
||||
d = ang1 - ang2;
|
||||
if( d > 180 )
|
||||
if( d > 180.0f )
|
||||
{
|
||||
d -= 360;
|
||||
d -= 360.0f;
|
||||
}
|
||||
else if( d < -180 )
|
||||
else if( d < -180.0f )
|
||||
{
|
||||
d += 360;
|
||||
d += 360.0f;
|
||||
}
|
||||
|
||||
angles[i] += d * f;
|
||||
|
@ -547,9 +545,9 @@ void CStudioModelRenderer::StudioSetUpTransform( int trivial_accept )
|
|||
{
|
||||
for( i = 0; i < 4; i++ )
|
||||
{
|
||||
(*m_paliastransform)[0][i] *= m_fSoftwareXScale * ( 1.0 / ( ZISCALE * 0x10000 ) );
|
||||
(*m_paliastransform)[1][i] *= m_fSoftwareYScale * ( 1.0 / ( ZISCALE * 0x10000 ) );
|
||||
(*m_paliastransform)[2][i] *= 1.0 / ( ZISCALE * 0x10000 );
|
||||
(*m_paliastransform)[0][i] *= m_fSoftwareXScale * ( 1.0f / ( ZISCALE * 0x10000 ) );
|
||||
(*m_paliastransform)[1][i] *= m_fSoftwareYScale * ( 1.0f / ( ZISCALE * 0x10000 ) );
|
||||
(*m_paliastransform)[2][i] *= 1.0f / ( ZISCALE * 0x10000 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -567,14 +565,14 @@ StudioEstimateInterpolant
|
|||
*/
|
||||
float CStudioModelRenderer::StudioEstimateInterpolant( void )
|
||||
{
|
||||
float dadt = 1.0;
|
||||
float dadt = 1.0f;
|
||||
|
||||
if( m_fDoInterp && ( m_pCurrentEntity->curstate.animtime >= m_pCurrentEntity->latched.prevanimtime + 0.01 ) )
|
||||
if( m_fDoInterp && ( m_pCurrentEntity->curstate.animtime >= m_pCurrentEntity->latched.prevanimtime + 0.01f ) )
|
||||
{
|
||||
dadt = ( m_clTime - m_pCurrentEntity->curstate.animtime ) / 0.1;
|
||||
if( dadt > 2.0 )
|
||||
dadt = ( m_clTime - m_pCurrentEntity->curstate.animtime ) / 0.1f;
|
||||
if( dadt > 2.0f )
|
||||
{
|
||||
dadt = 2.0;
|
||||
dadt = 2.0f;
|
||||
}
|
||||
}
|
||||
return dadt;
|
||||
|
@ -598,14 +596,14 @@ void CStudioModelRenderer::StudioCalcRotations( float pos[][3], vec4_t *q, mstud
|
|||
|
||||
if( f > pseqdesc->numframes - 1 )
|
||||
{
|
||||
f = 0; // bah, fix this bug with changing sequences too fast
|
||||
f = 0.0f; // bah, fix this bug with changing sequences too fast
|
||||
}
|
||||
// BUG ( somewhere else ) but this code should validate this data.
|
||||
// This could cause a crash if the frame # is negative, so we'll go ahead
|
||||
// and clamp it here
|
||||
else if( f < -0.01 )
|
||||
else if( f < -0.01f )
|
||||
{
|
||||
f = -0.01;
|
||||
f = -0.01f;
|
||||
}
|
||||
|
||||
frame = (int)f;
|
||||
|
@ -635,18 +633,18 @@ void CStudioModelRenderer::StudioCalcRotations( float pos[][3], vec4_t *q, mstud
|
|||
|
||||
if( pseqdesc->motiontype & STUDIO_X )
|
||||
{
|
||||
pos[pseqdesc->motionbone][0] = 0.0;
|
||||
pos[pseqdesc->motionbone][0] = 0.0f;
|
||||
}
|
||||
if( pseqdesc->motiontype & STUDIO_Y )
|
||||
{
|
||||
pos[pseqdesc->motionbone][1] = 0.0;
|
||||
pos[pseqdesc->motionbone][1] = 0.0f;
|
||||
}
|
||||
if( pseqdesc->motiontype & STUDIO_Z )
|
||||
{
|
||||
pos[pseqdesc->motionbone][2] = 0.0;
|
||||
pos[pseqdesc->motionbone][2] = 0.0f;
|
||||
}
|
||||
|
||||
s = 0 * ( ( 1.0 - ( f - (int)( f ) ) ) / ( pseqdesc->numframes ) ) * m_pCurrentEntity->curstate.framerate;
|
||||
s = 0 * ( ( 1.0f - ( f - (int)( f ) ) ) / ( pseqdesc->numframes ) ) * m_pCurrentEntity->curstate.framerate;
|
||||
|
||||
if( pseqdesc->motiontype & STUDIO_LX )
|
||||
{
|
||||
|
@ -679,15 +677,15 @@ void CStudioModelRenderer::StudioFxTransform( cl_entity_t *ent, float transform[
|
|||
int axis = gEngfuncs.pfnRandomLong( 0, 1 );
|
||||
if( axis == 1 ) // Choose between x & z
|
||||
axis = 2;
|
||||
VectorScale( transform[axis], gEngfuncs.pfnRandomFloat( 1, 1.484 ), transform[axis] );
|
||||
VectorScale( transform[axis], gEngfuncs.pfnRandomFloat( 1.0f, 1.484f ), transform[axis] );
|
||||
}
|
||||
else if( gEngfuncs.pfnRandomLong( 0, 49 ) == 0 )
|
||||
{
|
||||
float offset;
|
||||
int axis = gEngfuncs.pfnRandomLong(0,1);
|
||||
/*int axis = gEngfuncs.pfnRandomLong(0,1);
|
||||
if( axis == 1 ) // Choose between x & z
|
||||
axis = 2;
|
||||
offset = gEngfuncs.pfnRandomFloat( -10, 10 );
|
||||
axis = 2;*/
|
||||
offset = gEngfuncs.pfnRandomFloat( -10.0f, 10.0f );
|
||||
transform[gEngfuncs.pfnRandomLong( 0, 2 )][3] += offset;
|
||||
}
|
||||
break;
|
||||
|
@ -695,7 +693,7 @@ void CStudioModelRenderer::StudioFxTransform( cl_entity_t *ent, float transform[
|
|||
{
|
||||
float scale;
|
||||
|
||||
scale = 1.0 + ( m_clTime - ent->curstate.animtime ) * 10.0;
|
||||
scale = 1.0f + ( m_clTime - ent->curstate.animtime ) * 10.0f;
|
||||
if( scale > 2 ) // Don't blow up more than 200%
|
||||
scale = 2;
|
||||
transform[0][1] *= scale;
|
||||
|
@ -734,7 +732,7 @@ float CStudioModelRenderer::StudioEstimateFrame( mstudioseqdesc_t *pseqdesc )
|
|||
|
||||
if( pseqdesc->numframes <= 1 )
|
||||
{
|
||||
f = 0;
|
||||
f = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1188,10 +1186,10 @@ void CStudioModelRenderer::StudioEstimateGait( entity_state_t *pplayer )
|
|||
vec3_t est_velocity;
|
||||
|
||||
dt = ( m_clTime - m_clOldTime );
|
||||
if( dt < 0 )
|
||||
dt = 0;
|
||||
else if( dt > 1.0 )
|
||||
dt = 1;
|
||||
if( dt < 0.0f )
|
||||
dt = 0.0f;
|
||||
else if( dt > 1.0f )
|
||||
dt = 1.0f;
|
||||
|
||||
if( dt == 0 || m_pPlayerInfo->renderframe == m_nFrameCount )
|
||||
{
|
||||
|
@ -1221,29 +1219,29 @@ void CStudioModelRenderer::StudioEstimateGait( entity_state_t *pplayer )
|
|||
if( est_velocity[1] == 0 && est_velocity[0] == 0 )
|
||||
{
|
||||
float flYawDiff = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw;
|
||||
flYawDiff = flYawDiff - (int)( flYawDiff / 360 ) * 360;
|
||||
if( flYawDiff > 180 )
|
||||
flYawDiff -= 360;
|
||||
if( flYawDiff < -180 )
|
||||
flYawDiff += 360;
|
||||
flYawDiff = flYawDiff - (int)( flYawDiff / 360.0f ) * 360.0f;
|
||||
if( flYawDiff > 180.0f )
|
||||
flYawDiff -= 360.0f;
|
||||
if( flYawDiff < -180.0f )
|
||||
flYawDiff += 360.0f;
|
||||
|
||||
if( dt < 0.25 )
|
||||
flYawDiff *= dt * 4;
|
||||
if( dt < 0.25f )
|
||||
flYawDiff *= dt * 4.0f;
|
||||
else
|
||||
flYawDiff *= dt;
|
||||
|
||||
m_pPlayerInfo->gaityaw += flYawDiff;
|
||||
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - (int)( m_pPlayerInfo->gaityaw / 360 ) * 360;
|
||||
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - (int)( m_pPlayerInfo->gaityaw / 360.0f ) * 360.0f;
|
||||
|
||||
m_flGaitMovement = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pPlayerInfo->gaityaw = ( atan2( est_velocity[1], est_velocity[0] ) * 180 / M_PI );
|
||||
if( m_pPlayerInfo->gaityaw > 180 )
|
||||
m_pPlayerInfo->gaityaw = 180;
|
||||
if( m_pPlayerInfo->gaityaw < -180 )
|
||||
m_pPlayerInfo->gaityaw = -180;
|
||||
m_pPlayerInfo->gaityaw = ( atan2( est_velocity[1], est_velocity[0] ) * 180.0f / M_PI_F );
|
||||
if( m_pPlayerInfo->gaityaw > 180.0f )
|
||||
m_pPlayerInfo->gaityaw = 180.0f;
|
||||
if( m_pPlayerInfo->gaityaw < -180.0f )
|
||||
m_pPlayerInfo->gaityaw = -180.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1277,10 +1275,10 @@ void CStudioModelRenderer::StudioProcessGait( entity_state_t *pplayer )
|
|||
// Con_DPrintf( "%f %d\n", m_pCurrentEntity->angles[PITCH], m_pCurrentEntity->blending[0] );
|
||||
|
||||
dt = ( m_clTime - m_clOldTime );
|
||||
if( dt < 0 )
|
||||
dt = 0;
|
||||
else if( dt > 1.0 )
|
||||
dt = 1;
|
||||
if( dt < 0.0f )
|
||||
dt = 0.0f;
|
||||
else if( dt > 1.0f )
|
||||
dt = 1.0f;
|
||||
|
||||
StudioEstimateGait( pplayer );
|
||||
|
||||
|
@ -1288,38 +1286,38 @@ void CStudioModelRenderer::StudioProcessGait( entity_state_t *pplayer )
|
|||
|
||||
// calc side to side turning
|
||||
flYaw = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw;
|
||||
flYaw = flYaw - (int)( flYaw / 360 ) * 360;
|
||||
if( flYaw < -180 )
|
||||
flYaw = flYaw + 360;
|
||||
if( flYaw > 180 )
|
||||
flYaw = flYaw - 360;
|
||||
flYaw = flYaw - (int)( flYaw / 360.0f ) * 360.0f;
|
||||
if( flYaw < -180.0f )
|
||||
flYaw = flYaw + 360.0f;
|
||||
if( flYaw > 180.0f )
|
||||
flYaw = flYaw - 360.0f;
|
||||
|
||||
if( flYaw > 120 )
|
||||
if( flYaw > 120.0f )
|
||||
{
|
||||
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - 180;
|
||||
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - 180.0f;
|
||||
m_flGaitMovement = -m_flGaitMovement;
|
||||
flYaw = flYaw - 180;
|
||||
flYaw = flYaw - 180.0f;
|
||||
}
|
||||
else if( flYaw < -120 )
|
||||
else if( flYaw < -120.0f )
|
||||
{
|
||||
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw + 180;
|
||||
m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw + 180.0f;
|
||||
m_flGaitMovement = -m_flGaitMovement;
|
||||
flYaw = flYaw + 180;
|
||||
flYaw = flYaw + 180.0f;
|
||||
}
|
||||
|
||||
// adjust torso
|
||||
m_pCurrentEntity->curstate.controller[0] = ( ( flYaw / 4.0 ) + 30 ) / ( 60.0 / 255.0 );
|
||||
m_pCurrentEntity->curstate.controller[1] = ( ( flYaw / 4.0 ) + 30 ) / ( 60.0 / 255.0 );
|
||||
m_pCurrentEntity->curstate.controller[2] = ( ( flYaw / 4.0 ) + 30 ) / ( 60.0 / 255.0 );
|
||||
m_pCurrentEntity->curstate.controller[3] = ( ( flYaw / 4.0 ) + 30 ) / ( 60.0 / 255.0 );
|
||||
m_pCurrentEntity->curstate.controller[0] = ( ( flYaw / 4.0f ) + 30.0f ) / ( 60.0f / 255.0f );
|
||||
m_pCurrentEntity->curstate.controller[1] = ( ( flYaw / 4.0f ) + 30.0f ) / ( 60.0f / 255.0f );
|
||||
m_pCurrentEntity->curstate.controller[2] = ( ( flYaw / 4.0f ) + 30.0f ) / ( 60.0f / 255.0f );
|
||||
m_pCurrentEntity->curstate.controller[3] = ( ( flYaw / 4.0f ) + 30.0f ) / ( 60.0f / 255.0f );
|
||||
m_pCurrentEntity->latched.prevcontroller[0] = m_pCurrentEntity->curstate.controller[0];
|
||||
m_pCurrentEntity->latched.prevcontroller[1] = m_pCurrentEntity->curstate.controller[1];
|
||||
m_pCurrentEntity->latched.prevcontroller[2] = m_pCurrentEntity->curstate.controller[2];
|
||||
m_pCurrentEntity->latched.prevcontroller[3] = m_pCurrentEntity->curstate.controller[3];
|
||||
|
||||
m_pCurrentEntity->angles[YAW] = m_pPlayerInfo->gaityaw;
|
||||
if( m_pCurrentEntity->angles[YAW] < -0 )
|
||||
m_pCurrentEntity->angles[YAW] += 360;
|
||||
if( m_pCurrentEntity->angles[YAW] < -0.0f )
|
||||
m_pCurrentEntity->angles[YAW] += 360.0f;
|
||||
m_pCurrentEntity->latched.prevangles[YAW] = m_pCurrentEntity->angles[YAW];
|
||||
|
||||
if( pplayer->gaitsequence >= m_pStudioHeader->numseq )
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "ammohistory.h"
|
||||
#if USE_VGUI
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#endif
|
||||
|
||||
WEAPON *gpActiveSel; // NULL means off, 1 means just the menu bar, otherwise
|
||||
// this points to the active weapon menu item
|
||||
|
@ -77,7 +80,7 @@ void WeaponsResource::LoadWeaponSprites( WEAPON *pWeapon )
|
|||
else
|
||||
iRes = 640;
|
||||
|
||||
char sz[128];
|
||||
char sz[256];
|
||||
|
||||
if( !pWeapon )
|
||||
return;
|
||||
|
@ -356,7 +359,7 @@ void CHudAmmo::Think( void )
|
|||
{
|
||||
WEAPON *p = gWR.GetWeapon( i );
|
||||
|
||||
if( p )
|
||||
if( p && p->iId )
|
||||
{
|
||||
if( gHUD.m_iWeaponBits & ( 1 << p->iId ) )
|
||||
gWR.PickupWeapon( p );
|
||||
|
@ -673,10 +676,11 @@ int CHudAmmo::MsgFunc_WeaponList( const char *pszName, int iSize, void *pbuf )
|
|||
// Slot button pressed
|
||||
void CHudAmmo::SlotInput( int iSlot )
|
||||
{
|
||||
#if USE_VGUI
|
||||
// Let the Viewport use it first, for menus
|
||||
// if( gViewPort && gViewPort->SlotInput( iSlot ) )
|
||||
// return;
|
||||
|
||||
if( gViewPort && gViewPort->SlotInput( iSlot ) )
|
||||
return;
|
||||
#endif
|
||||
gWR.SelectSlot(iSlot, FALSE, 1);
|
||||
}
|
||||
|
||||
|
@ -864,7 +868,7 @@ int CHudAmmo::Draw( float flTime )
|
|||
a = (int)Q_max( MIN_ALPHA, m_fFade );
|
||||
|
||||
if( m_fFade > 0 )
|
||||
m_fFade -= ( gHUD.m_flTimeDelta * 20 );
|
||||
m_fFade -= ( (float)gHUD.m_flTimeDelta * 20.0f );
|
||||
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
****/
|
||||
#pragma once
|
||||
#ifndef __AMMO_H__
|
||||
#if !defined(__AMMO_H__)
|
||||
#define __AMMO_H__
|
||||
|
||||
#define MAX_WEAPON_NAME 128
|
||||
|
|
|
@ -63,7 +63,7 @@ int CHudAmmoSecondary::Draw( float flTime )
|
|||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
a = (int)Q_max( MIN_ALPHA, m_fFade );
|
||||
if( m_fFade > 0 )
|
||||
m_fFade -= ( gHUD.m_flTimeDelta * 20 ); // slowly lower alpha to fade out icons
|
||||
m_fFade -= ( (float)gHUD.m_flTimeDelta * 20.0f ); // slowly lower alpha to fade out icons
|
||||
ScaleColors( r, g, b, a );
|
||||
|
||||
AmmoWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
// ammohistory.h
|
||||
//
|
||||
#pragma once
|
||||
#ifndef AMMOHISTORY_H
|
||||
#if !defined(AMMOHISTORY_H)
|
||||
#define AMMOHISTORY_H
|
||||
|
||||
// this is the max number of items in each bucket
|
||||
|
|
|
@ -78,7 +78,7 @@ int CHudBattery::Draw( float flTime )
|
|||
wrect_t rc;
|
||||
|
||||
rc = *m_prc2;
|
||||
rc.top += m_iHeight * ( (float)( 100 - ( Q_min( 100, m_iBat ) ) ) * 0.01 ); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
|
||||
rc.top += m_iHeight * ( (float)( 100 - ( Q_min( 100, m_iBat ) ) ) * 0.01f ); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
|
||||
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
|
||||
|
@ -91,7 +91,7 @@ int CHudBattery::Draw( float flTime )
|
|||
if( m_fFade > FADE_TIME )
|
||||
m_fFade = FADE_TIME;
|
||||
|
||||
m_fFade -= ( gHUD.m_flTimeDelta * 20 );
|
||||
m_fFade -= ( (float)gHUD.m_flTimeDelta * 20.0f );
|
||||
if( m_fFade <= 0 )
|
||||
{
|
||||
a = 128;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// Camera.h -- defines and such for a 3rd person camera
|
||||
// NOTE: must include quakedef.h first
|
||||
#pragma once
|
||||
#ifndef _CAMERA_H_
|
||||
#if !defined(_CAMERA_H_)
|
||||
#define _CAMERA_H_
|
||||
|
||||
// pitch, yaw, dist
|
||||
|
|
|
@ -23,11 +23,18 @@
|
|||
#include "netadr.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#if defined(GOLDSOURCE_SUPPORT) && (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && (defined(__i386) || defined(_M_IX86))
|
||||
#define USE_VGUI_FOR_GOLDSOURCE_SUPPORT
|
||||
#if USE_VGUI
|
||||
#include "vgui_int.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#endif
|
||||
|
||||
#if GOLDSOURCE_SUPPORT && (_WIN32 || __linux__ || __APPLE__) && (__i386 || _M_IX86)
|
||||
#define USE_FAKE_VGUI !USE_VGUI
|
||||
#if USE_FAKE_VGUI
|
||||
#include "VGUI_Panel.h"
|
||||
#include "VGUI_App.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
@ -38,6 +45,9 @@ extern "C"
|
|||
|
||||
cl_enginefunc_t gEngfuncs;
|
||||
CHud gHUD;
|
||||
#if USE_VGUI
|
||||
TeamFortressViewport *gViewPort = NULL;
|
||||
#endif
|
||||
mobile_engfuncs_t *gMobileEngfuncs = NULL;
|
||||
|
||||
extern "C" int g_bhopcap;
|
||||
|
@ -124,7 +134,7 @@ HUD_ConnectionlessPacket
|
|||
int DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size )
|
||||
{
|
||||
// Parse stuff from args
|
||||
int max_buffer_size = *response_buffer_size;
|
||||
// int max_buffer_size = *response_buffer_size;
|
||||
|
||||
// Zero it out since we aren't going to respond.
|
||||
// If we wanted to response, we'd write data into response_buffer
|
||||
|
@ -157,7 +167,17 @@ int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
|
|||
if( iVersion != CLDLL_INTERFACE_VERSION )
|
||||
return 0;
|
||||
|
||||
memcpy( &gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t) );
|
||||
// for now filterstuffcmd is last in the engine interface
|
||||
memcpy( &gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t) - sizeof( void * ) );
|
||||
|
||||
if( gEngfuncs.pfnGetCvarPointer( "cl_filterstuffcmd" ) == 0 )
|
||||
{
|
||||
gEngfuncs.pfnFilteredClientCmd = gEngfuncs.pfnClientCmd;
|
||||
}
|
||||
else
|
||||
{
|
||||
gEngfuncs.pfnFilteredClientCmd = pEnginefuncs->pfnFilteredClientCmd;
|
||||
}
|
||||
|
||||
EV_HookEvents();
|
||||
|
||||
|
@ -183,7 +203,7 @@ int *HUD_GetRect( void )
|
|||
return extent;
|
||||
}
|
||||
|
||||
#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT
|
||||
#if USE_FAKE_VGUI
|
||||
class TeamFortressViewport : public vgui::Panel
|
||||
{
|
||||
public:
|
||||
|
@ -238,7 +258,7 @@ so the HUD can reinitialize itself.
|
|||
int DLLEXPORT HUD_VidInit( void )
|
||||
{
|
||||
gHUD.VidInit();
|
||||
#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT
|
||||
#if USE_FAKE_VGUI
|
||||
vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel();
|
||||
if (root) {
|
||||
gEngfuncs.Con_Printf( "Root VGUI panel exists\n" );
|
||||
|
@ -256,6 +276,8 @@ int DLLEXPORT HUD_VidInit( void )
|
|||
} else {
|
||||
gEngfuncs.Con_Printf( "Root VGUI panel does not exist\n" );
|
||||
}
|
||||
#elif USE_VGUI
|
||||
VGui_Startup();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
@ -274,6 +296,9 @@ void DLLEXPORT HUD_Init( void )
|
|||
{
|
||||
InitInput();
|
||||
gHUD.Init();
|
||||
#if USE_VGUI
|
||||
Scheme_Init();
|
||||
#endif
|
||||
|
||||
gEngfuncs.pfnHookUserMsg( "Bhopcap", __MsgFunc_Bhopcap );
|
||||
}
|
||||
|
@ -337,7 +362,9 @@ Called by engine every frame that client .dll is loaded
|
|||
|
||||
void DLLEXPORT HUD_Frame( double time )
|
||||
{
|
||||
#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT
|
||||
#if USE_VGUI
|
||||
GetClientVoiceMgr()->Frame(time);
|
||||
#elif USE_FAKE_VGUI
|
||||
if (!gViewPort)
|
||||
gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect());
|
||||
#else
|
||||
|
@ -355,7 +382,9 @@ Called when a player starts or stops talking.
|
|||
|
||||
void DLLEXPORT HUD_VoiceStatus( int entindex, qboolean bTalking )
|
||||
{
|
||||
|
||||
#if USE_VGUI
|
||||
GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -26,26 +26,31 @@
|
|||
// - Handling the custum HUD-update packets
|
||||
//
|
||||
#pragma once
|
||||
#ifndef CL_DLL_H
|
||||
#if !defined(CL_DLL_H)
|
||||
#define CL_DLL_H
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
typedef float vec_t;
|
||||
typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf );
|
||||
// redefine
|
||||
//typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf );
|
||||
|
||||
#include "util_vector.h"
|
||||
|
||||
#include "../engine/cdll_int.h"
|
||||
#include "../dlls/cdll_dll.h"
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#if !_WIN32
|
||||
#define _cdecl
|
||||
#endif
|
||||
#include "exportdef.h"
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__LP64__) || defined(__LLP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
|
||||
#define XASH_64BIT
|
||||
#if HAVE_CMATH
|
||||
#include <cmath>
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
#if __LP64__ || __LLP64__ || _WIN64 || (__x86_64__ && !__ILP32__) || _M_X64 || __ia64 || _M_IA64 || __aarch64__ || __powerpc64__
|
||||
#define XASH_64BIT 1
|
||||
#endif
|
||||
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
//
|
||||
// cl_util.h
|
||||
//
|
||||
#ifndef CL_UTIL_H
|
||||
#if !defined(CL_UTIL_H)
|
||||
#define CL_UTIL_H
|
||||
#include "exportdef.h"
|
||||
#include "cvardef.h"
|
||||
|
||||
#ifndef TRUE
|
||||
#if !defined(TRUE)
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
@ -108,7 +108,8 @@ inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b )
|
|||
inline int DrawConsoleString( int x, int y, const char *string )
|
||||
{
|
||||
if( hud_textmode->value == 1 )
|
||||
return gHUD.DrawHudString( x, y, 9999, (char*)string, 255 * g_hud_text_color[0], 255 * g_hud_text_color[1], 255 * g_hud_text_color[2] );
|
||||
return gHUD.DrawHudString( x, y, 9999, (char*)string, (int)( (float)g_hud_text_color[0] * 255.0f ),
|
||||
(int)( (float)g_hud_text_color[1] * 255.0f ), (int)( (float)g_hud_text_color[2] * 255.0f ) );
|
||||
return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string );
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ void HUD_PlaybackEvent( int flags, const edict_t *pInvoker, unsigned short event
|
|||
|
||||
// Weapon prediction events are assumed to occur at the player's origin
|
||||
org = g_finalstate->playerstate.origin;
|
||||
ang = v_angles;
|
||||
ang = v_client_aimangles;
|
||||
gEngfuncs.pfnPlaybackEvent( flags, pInvoker, eventindex, delay, org, ang, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2 );
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ Always 0.0 on client, even if not predicting weapons ( won't get called
|
|||
*/
|
||||
float UTIL_WeaponTimeBase( void )
|
||||
{
|
||||
return 0.0;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
static unsigned int glSeed = 0;
|
||||
|
@ -254,7 +254,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high )
|
|||
|
||||
tensixrand = U_Random() & 65535;
|
||||
|
||||
offset = (float)tensixrand / 65536.0;
|
||||
offset = (float)tensixrand / 65536.0f;
|
||||
|
||||
return ( low + offset * range );
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ extern cvar_t *cl_lw;
|
|||
|
||||
extern int g_runfuncs;
|
||||
extern vec3_t v_angles;
|
||||
extern vec3_t v_client_aimangles;
|
||||
extern float g_lastFOV;
|
||||
extern struct local_state_s *g_finalstate;
|
||||
#endif
|
||||
|
|
|
@ -7,7 +7,7 @@ set PATH=%MSVCDir%\VC98\Bin;%MSVCDir%\Common\MSDev98\Bin\;%PATH%
|
|||
echo -- Compiler is MSVC6
|
||||
|
||||
set XASH3DSRC=..\..\Xash3D_original
|
||||
set INCLUDES=-I../common -I../engine -I../pm_shared -I../game_shared -I../public -I../external -I../dlls -I../utils/false_vgui/include
|
||||
set INCLUDES=-I../common -I../engine -I../pm_shared -I../game_shared -I../public -I../external -I../dlls -I../utils/fake_vgui/include
|
||||
set SOURCES=../dlls/crossbow.cpp ^
|
||||
../dlls/crowbar.cpp ^
|
||||
../dlls/egon.cpp ^
|
||||
|
@ -54,7 +54,6 @@ set SOURCES=../dlls/crossbow.cpp ^
|
|||
input_xash3d.cpp ^
|
||||
menu.cpp ^
|
||||
message.cpp ^
|
||||
overview.cpp ^
|
||||
parsemsg.cpp ^
|
||||
../pm_shared/pm_debug.c ^
|
||||
../pm_shared/pm_math.c ^
|
||||
|
@ -71,12 +70,11 @@ set SOURCES=../dlls/crossbow.cpp ^
|
|||
view.cpp ^
|
||||
scoreboard.cpp ^
|
||||
MOTD.cpp
|
||||
set DEFINES=/DCLIENT_DLL /DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR /DGOLDSOURCE_SUPPORT
|
||||
set DEFINES=/DCLIENT_DLL /DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR /DGOLDSOURCE_SUPPORT /DNDEBUG
|
||||
set LIBS=user32.lib Winmm.lib
|
||||
set OUTNAME=client.dll
|
||||
set DEBUG=/debug
|
||||
|
||||
cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% %DEBUG%
|
||||
cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% /release
|
||||
|
||||
echo -- Compile done. Cleaning...
|
||||
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if USE_VGUI
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#endif
|
||||
|
||||
DECLARE_MESSAGE( m_DeathNotice, DeathMsg )
|
||||
|
||||
struct DeathNoticeItem {
|
||||
|
@ -71,7 +75,7 @@ int CHudDeathNotice::Init( void )
|
|||
|
||||
HOOK_MESSAGE( DeathMsg );
|
||||
|
||||
CVAR_CREATE( "hud_deathnotice_time", "6", 0 );
|
||||
CVAR_CREATE( "hud_deathnotice_time", "6", FCVAR_ARCHIVE );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -110,7 +114,9 @@ int CHudDeathNotice::Draw( float flTime )
|
|||
|
||||
// Only draw if the viewport will let me
|
||||
// vgui dropped out
|
||||
//if( gViewPort && gViewPort->AllowedToPrintText() )
|
||||
#if USE_VGUI
|
||||
if( gViewPort && gViewPort->AllowedToPrintText() )
|
||||
#endif
|
||||
{
|
||||
// Draw the death notice
|
||||
y = YRES( DEATHNOTICE_TOP ) + 2 + ( 20 * i ); //!!!
|
||||
|
@ -167,6 +173,12 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu
|
|||
char killedwith[32];
|
||||
strcpy( killedwith, "d_" );
|
||||
strncat( killedwith, READ_STRING(), sizeof(killedwith) - strlen(killedwith) - 1 );
|
||||
killedwith[sizeof(killedwith) - 1] = '\0';
|
||||
|
||||
#if USE_VGUI
|
||||
if (gViewPort)
|
||||
gViewPort->DeathMsg( killer, victim );
|
||||
#endif
|
||||
|
||||
gHUD.m_Spectator.DeathMessage( victim );
|
||||
|
||||
|
@ -182,9 +194,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu
|
|||
i = MAX_DEATHNOTICES - 1;
|
||||
}
|
||||
|
||||
//if(gViewPort)
|
||||
// gViewPort->GetAllPlayersInfo();
|
||||
gHUD.m_Scoreboard.GetAllPlayersInfo();
|
||||
gHUD.GetAllPlayersInfo();
|
||||
|
||||
// Get the Killer's name
|
||||
const char *killer_name = "";
|
||||
|
@ -197,14 +207,14 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu
|
|||
else
|
||||
{
|
||||
rgDeathNoticeList[i].KillerColor = GetClientColor( killer );
|
||||
strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH );
|
||||
strncpy( rgDeathNoticeList[i].szKiller, killer_name, MAX_PLAYER_NAME_LENGTH - 1 );
|
||||
rgDeathNoticeList[i].szKiller[MAX_PLAYER_NAME_LENGTH - 1] = 0;
|
||||
}
|
||||
|
||||
// Get the Victim's name
|
||||
const char *victim_name = "";
|
||||
// If victim is -1, the killer killed a specific, non-player object (like a sentrygun)
|
||||
if( ( (char)victim ) != -1 )
|
||||
if( ( (signed char)victim ) != -1 )
|
||||
victim_name = g_PlayerInfoList[victim].name;
|
||||
if( !victim_name )
|
||||
{
|
||||
|
@ -214,12 +224,12 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu
|
|||
else
|
||||
{
|
||||
rgDeathNoticeList[i].VictimColor = GetClientColor( victim );
|
||||
strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH );
|
||||
strncpy( rgDeathNoticeList[i].szVictim, victim_name, MAX_PLAYER_NAME_LENGTH - 1 );
|
||||
rgDeathNoticeList[i].szVictim[MAX_PLAYER_NAME_LENGTH - 1] = 0;
|
||||
}
|
||||
|
||||
// Is it a non-player object kill?
|
||||
if( ( (char)victim ) == -1 )
|
||||
if( ( (signed char)victim ) == -1 )
|
||||
{
|
||||
rgDeathNoticeList[i].iNonPlayerKill = TRUE;
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "cl_util.h"
|
||||
#include "demo.h"
|
||||
#include "demo_api.h"
|
||||
#include <memory.h>
|
||||
|
||||
int g_demosniper = 0;
|
||||
int g_demosniperdamage = 0;
|
||||
|
@ -88,12 +87,12 @@ void DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer )
|
|||
g_demosniperorg[1] = *(float *)&buffer[i];
|
||||
i += sizeof(float);
|
||||
g_demosniperorg[2] = *(float *)&buffer[i];
|
||||
i += sizeof(float);
|
||||
// i += sizeof(float);
|
||||
}
|
||||
break;
|
||||
case TYPE_ZOOM:
|
||||
g_demozoom = *(float *)&buffer[i];
|
||||
i += sizeof(float);
|
||||
// i += sizeof(float);
|
||||
break;
|
||||
default:
|
||||
gEngfuncs.Con_DPrintf( "Unknown demo buffer type, skipping.\n" );
|
||||
|
|
|
@ -222,12 +222,12 @@ void DLLEXPORT HUD_TxferPredictionData( struct entity_state_s *ps, const struct
|
|||
VectorCopy( ppcd->vuser3, pcd->vuser3 );
|
||||
VectorCopy( ppcd->vuser4, pcd->vuser4 );
|
||||
|
||||
memcpy( wd, pwd, 32 * sizeof(weapon_data_t) );
|
||||
memcpy( wd, pwd, MAX_WEAPONS * sizeof(weapon_data_t) );
|
||||
}
|
||||
|
||||
/*
|
||||
//#define TEST_IT
|
||||
#if defined( TEST_IT )
|
||||
//#define TEST_IT 1
|
||||
#if TEST_IT
|
||||
|
||||
cl_entity_t mymodel[9];
|
||||
|
||||
|
@ -269,8 +269,8 @@ void MoveModel( void )
|
|||
}
|
||||
#endif
|
||||
|
||||
//#define TRACE_TEST
|
||||
#if defined( TRACE_TEST )
|
||||
//#define TRACE_TEST 1
|
||||
#if TRACE_TEST
|
||||
|
||||
extern int hitent;
|
||||
|
||||
|
@ -319,12 +319,12 @@ void Particles( void )
|
|||
|
||||
curtime = gEngfuncs.GetClientTime();
|
||||
|
||||
if( ( curtime - lasttime ) < 2.0 )
|
||||
if( ( curtime - lasttime ) < 2.0f )
|
||||
return;
|
||||
|
||||
if( !color )
|
||||
{
|
||||
color = gEngfuncs.pfnRegisterVariable ( "color","255 0 0", 0 );
|
||||
color = gEngfuncs.pfnRegisterVariable( "color", "255 0 0", 0 );
|
||||
}
|
||||
|
||||
lasttime = curtime;
|
||||
|
@ -342,8 +342,8 @@ void Particles( void )
|
|||
|
||||
for( j = 0; j < 3; j++ )
|
||||
{
|
||||
p->org[j] = v_origin[j] + gEngfuncs.pfnRandomFloat( -32.0, 32.0 );
|
||||
p->vel[j] = gEngfuncs.pfnRandomFloat( -100.0, 100.0 );
|
||||
p->org[j] = v_origin[j] + gEngfuncs.pfnRandomFloat( -32.0f, 32.0f );
|
||||
p->vel[j] = gEngfuncs.pfnRandomFloat( -100.0f, 100.0f );
|
||||
}
|
||||
|
||||
if( color )
|
||||
|
@ -361,7 +361,7 @@ void Particles( void )
|
|||
gEngfuncs.pEfxAPI->R_GetPackedColor( &p->packedColor, p->color );
|
||||
|
||||
// p->die is set to current time so all you have to do is add an additional time to it
|
||||
p->die += 3.0;
|
||||
p->die += 3.0f;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -384,7 +384,7 @@ void TempEnts( void )
|
|||
|
||||
curtime = gEngfuncs.GetClientTime();
|
||||
|
||||
if( ( curtime - lasttime ) < 10.0 )
|
||||
if( ( curtime - lasttime ) < 10.0f )
|
||||
return;
|
||||
|
||||
lasttime = curtime;
|
||||
|
@ -417,16 +417,16 @@ void TempEnts( void )
|
|||
p->entity.curstate.origin[j] = origin[j];
|
||||
|
||||
// Store velocity in baseline origin
|
||||
p->entity.baseline.origin[j] = gEngfuncs.pfnRandomFloat( -100, 100 );
|
||||
p->entity.baseline.origin[j] = gEngfuncs.pfnRandomFloat( -100.0f, 100.0f );
|
||||
}
|
||||
|
||||
// p->die is set to current time so all you have to do is add an additional time to it
|
||||
p->die += 10.0;
|
||||
p->die += 10.0f;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#if defined( BEAM_TEST )
|
||||
#if BEAM_TEST
|
||||
// Note can't index beam[0] in Beam callback, so don't use that index
|
||||
// Room for 1 beam ( 0 can't be used )
|
||||
static cl_entity_t beams[2];
|
||||
|
@ -510,10 +510,10 @@ void DLLEXPORT HUD_CreateEntities( void )
|
|||
// Load an appropriate model into it ( gEngfuncs.CL_LoadModel )
|
||||
// Call gEngfuncs.CL_CreateVisibleEntity to add it to the visedicts list
|
||||
/*
|
||||
#if defined( TEST_IT )
|
||||
#if TEST_IT
|
||||
MoveModel();
|
||||
#endif
|
||||
#if defined( TRACE_TEST )
|
||||
#if TRACE_TEST
|
||||
TraceModel();
|
||||
#endif
|
||||
*/
|
||||
|
@ -523,11 +523,15 @@ void DLLEXPORT HUD_CreateEntities( void )
|
|||
/*
|
||||
TempEnts();
|
||||
*/
|
||||
#if defined( BEAM_TEST )
|
||||
#if BEAM_TEST
|
||||
Beams();
|
||||
#endif
|
||||
// Add in any game specific objects
|
||||
Game_AddObjects();
|
||||
|
||||
#if USE_VGUI
|
||||
GetClientVoiceMgr()->CreateEntities();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -626,7 +630,7 @@ void DLLEXPORT HUD_TempEntUpdate (
|
|||
//freq = client_time * 0.01;
|
||||
fastFreq = client_time * 5.5;
|
||||
gravity = -frametime * cl_gravity;
|
||||
gravitySlow = gravity * 0.5;
|
||||
gravitySlow = gravity * 0.5f;
|
||||
|
||||
while( pTemp )
|
||||
{
|
||||
|
@ -634,7 +638,7 @@ void DLLEXPORT HUD_TempEntUpdate (
|
|||
|
||||
active = 1;
|
||||
|
||||
life = pTemp->die - client_time;
|
||||
life = pTemp->die - (float)client_time;
|
||||
pnext = pTemp->next;
|
||||
if( life < 0 )
|
||||
{
|
||||
|
@ -674,9 +678,9 @@ void DLLEXPORT HUD_TempEntUpdate (
|
|||
gEngfuncs.pEfxAPI->R_SparkEffect( pTemp->entity.origin, 8, -200, 200 );
|
||||
|
||||
// Reduce life
|
||||
pTemp->entity.baseline.framerate -= 0.1;
|
||||
pTemp->entity.baseline.framerate -= 0.1f;
|
||||
|
||||
if( pTemp->entity.baseline.framerate <= 0.0 )
|
||||
if( pTemp->entity.baseline.framerate <= 0.0f )
|
||||
{
|
||||
pTemp->die = client_time;
|
||||
}
|
||||
|
@ -700,11 +704,11 @@ void DLLEXPORT HUD_TempEntUpdate (
|
|||
}
|
||||
else if( pTemp->flags & FTENT_SINEWAVE )
|
||||
{
|
||||
pTemp->x += pTemp->entity.baseline.origin[0] * frametime;
|
||||
pTemp->y += pTemp->entity.baseline.origin[1] * frametime;
|
||||
pTemp->x += pTemp->entity.baseline.origin[0] * (float)frametime;
|
||||
pTemp->y += pTemp->entity.baseline.origin[1] * (float)frametime;
|
||||
|
||||
pTemp->entity.origin[0] = pTemp->x + sin( pTemp->entity.baseline.origin[2] + client_time * pTemp->entity.prevstate.frame ) * ( 10 * pTemp->entity.curstate.framerate );
|
||||
pTemp->entity.origin[1] = pTemp->y + sin( pTemp->entity.baseline.origin[2] + fastFreq + 0.7 ) * ( 8 * pTemp->entity.curstate.framerate );
|
||||
pTemp->entity.origin[1] = pTemp->y + sin( pTemp->entity.baseline.origin[2] + fastFreq + 0.7f ) * ( 8 * pTemp->entity.curstate.framerate );
|
||||
pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime;
|
||||
}
|
||||
else if( pTemp->flags & FTENT_SPIRAL )
|
||||
|
@ -713,19 +717,19 @@ void DLLEXPORT HUD_TempEntUpdate (
|
|||
s = sin( pTemp->entity.baseline.origin[2] + fastFreq );
|
||||
c = cos( pTemp->entity.baseline.origin[2] + fastFreq );*/
|
||||
|
||||
pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * frametime + 8 * sin( client_time * 20 + (size_t)pTemp );
|
||||
pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (size_t)pTemp );
|
||||
pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime;
|
||||
pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * (float)frametime + 8 * sin( client_time * 20 + (size_t)pTemp );
|
||||
pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * (float)frametime + 4 * sin( client_time * 30 + (size_t)pTemp );
|
||||
pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * (float)frametime;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( i = 0; i < 3; i++ )
|
||||
pTemp->entity.origin[i] += pTemp->entity.baseline.origin[i] * frametime;
|
||||
pTemp->entity.origin[i] += pTemp->entity.baseline.origin[i] * (float)frametime;
|
||||
}
|
||||
|
||||
if( pTemp->flags & FTENT_SPRANIMATE )
|
||||
{
|
||||
pTemp->entity.curstate.frame += frametime * pTemp->entity.curstate.framerate;
|
||||
pTemp->entity.curstate.frame += (float)frametime * pTemp->entity.curstate.framerate;
|
||||
if( pTemp->entity.curstate.frame >= pTemp->frameMax )
|
||||
{
|
||||
pTemp->entity.curstate.frame = pTemp->entity.curstate.frame - (int)( pTemp->entity.curstate.frame );
|
||||
|
@ -755,9 +759,9 @@ void DLLEXPORT HUD_TempEntUpdate (
|
|||
|
||||
if( pTemp->flags & FTENT_ROTATE )
|
||||
{
|
||||
pTemp->entity.angles[0] += pTemp->entity.baseline.angles[0] * frametime;
|
||||
pTemp->entity.angles[1] += pTemp->entity.baseline.angles[1] * frametime;
|
||||
pTemp->entity.angles[2] += pTemp->entity.baseline.angles[2] * frametime;
|
||||
pTemp->entity.angles[0] += pTemp->entity.baseline.angles[0] * (float)frametime;
|
||||
pTemp->entity.angles[1] += pTemp->entity.baseline.angles[1] * (float)frametime;
|
||||
pTemp->entity.angles[2] += pTemp->entity.baseline.angles[2] * (float)frametime;
|
||||
|
||||
VectorCopy( pTemp->entity.angles, pTemp->entity.latched.prevangles );
|
||||
}
|
||||
|
@ -809,7 +813,7 @@ void DLLEXPORT HUD_TempEntUpdate (
|
|||
{
|
||||
// Chop spark speeds a bit more
|
||||
//
|
||||
VectorScale( pTemp->entity.baseline.origin, 0.6, pTemp->entity.baseline.origin );
|
||||
VectorScale( pTemp->entity.baseline.origin, 0.6f, pTemp->entity.baseline.origin );
|
||||
|
||||
if( Length( pTemp->entity.baseline.origin ) < 10 )
|
||||
{
|
||||
|
@ -829,13 +833,13 @@ void DLLEXPORT HUD_TempEntUpdate (
|
|||
float proj, damp;
|
||||
|
||||
// Place at contact point
|
||||
VectorMA( pTemp->entity.prevstate.origin, traceFraction * frametime, pTemp->entity.baseline.origin, pTemp->entity.origin );
|
||||
VectorMA( pTemp->entity.prevstate.origin, traceFraction * (float)frametime, pTemp->entity.baseline.origin, pTemp->entity.origin );
|
||||
// Damp velocity
|
||||
damp = pTemp->bounceFactor;
|
||||
if( pTemp->flags & ( FTENT_GRAVITY | FTENT_SLOWGRAVITY ) )
|
||||
{
|
||||
damp *= 0.5;
|
||||
if( traceNormal[2] > 0.9 ) // Hit floor?
|
||||
damp *= 0.5f;
|
||||
if( traceNormal[2] > 0.9f ) // Hit floor?
|
||||
{
|
||||
if( pTemp->entity.baseline.origin[2] <= 0 && pTemp->entity.baseline.origin[2] >= gravity*3 )
|
||||
{
|
||||
|
@ -942,7 +946,7 @@ Indices must start at 1, not zero.
|
|||
*/
|
||||
cl_entity_t DLLEXPORT *HUD_GetUserEntity( int index )
|
||||
{
|
||||
#if defined( BEAM_TEST )
|
||||
#if BEAM_TEST
|
||||
// None by default, you would return a valic pointer if you create a client side
|
||||
// beam and attach it to a client side entity.
|
||||
if( index > 0 && index <= 1 )
|
||||
|
|
|
@ -72,18 +72,18 @@ void EV_SnarkFire( struct event_args_s *args );
|
|||
void EV_TrainPitchAdjust( struct event_args_s *args );
|
||||
}
|
||||
|
||||
#define VECTOR_CONE_1DEGREES Vector( 0.00873, 0.00873, 0.00873 )
|
||||
#define VECTOR_CONE_2DEGREES Vector( 0.01745, 0.01745, 0.01745 )
|
||||
#define VECTOR_CONE_3DEGREES Vector( 0.02618, 0.02618, 0.02618 )
|
||||
#define VECTOR_CONE_4DEGREES Vector( 0.03490, 0.03490, 0.03490 )
|
||||
#define VECTOR_CONE_5DEGREES Vector( 0.04362, 0.04362, 0.04362 )
|
||||
#define VECTOR_CONE_6DEGREES Vector( 0.05234, 0.05234, 0.05234 )
|
||||
#define VECTOR_CONE_7DEGREES Vector( 0.06105, 0.06105, 0.06105 )
|
||||
#define VECTOR_CONE_8DEGREES Vector( 0.06976, 0.06976, 0.06976 )
|
||||
#define VECTOR_CONE_9DEGREES Vector( 0.07846, 0.07846, 0.07846 )
|
||||
#define VECTOR_CONE_10DEGREES Vector( 0.08716, 0.08716, 0.08716 )
|
||||
#define VECTOR_CONE_15DEGREES Vector( 0.13053, 0.13053, 0.13053 )
|
||||
#define VECTOR_CONE_20DEGREES Vector( 0.17365, 0.17365, 0.17365 )
|
||||
#define VECTOR_CONE_1DEGREES Vector( 0.00873f, 0.00873f, 0.00873f )
|
||||
#define VECTOR_CONE_2DEGREES Vector( 0.01745f, 0.01745f, 0.01745f )
|
||||
#define VECTOR_CONE_3DEGREES Vector( 0.02618f, 0.02618f, 0.02618f )
|
||||
#define VECTOR_CONE_4DEGREES Vector( 0.03490f, 0.03490f, 0.03490f )
|
||||
#define VECTOR_CONE_5DEGREES Vector( 0.04362f, 0.04362f, 0.04362f )
|
||||
#define VECTOR_CONE_6DEGREES Vector( 0.05234f, 0.05234f, 0.05234f )
|
||||
#define VECTOR_CONE_7DEGREES Vector( 0.06105f, 0.06105f, 0.06105f )
|
||||
#define VECTOR_CONE_8DEGREES Vector( 0.06976f, 0.06976f, 0.06976f )
|
||||
#define VECTOR_CONE_9DEGREES Vector( 0.07846f, 0.07846f, 0.07846f )
|
||||
#define VECTOR_CONE_10DEGREES Vector( 0.08716f, 0.08716f, 0.08716f )
|
||||
#define VECTOR_CONE_15DEGREES Vector( 0.13053f, 0.13053f, 0.13053f )
|
||||
#define VECTOR_CONE_20DEGREES Vector( 0.17365f, 0.17365f, 0.17365f )
|
||||
|
||||
// play a strike sound based on the texture that was hit by the attack traceline. VecSrc/VecEnd are the
|
||||
// original traceline endpoints used by the attacker, iBulletType is the type of bullet that hit the texture.
|
||||
|
@ -247,7 +247,7 @@ char *EV_HLDM_DamageDecal( physent_t *pe )
|
|||
}
|
||||
else if( pe->rendermode != kRenderNormal )
|
||||
{
|
||||
sprintf( decalname, "{bproof1" );
|
||||
strcpy( decalname, "{bproof1" );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -425,7 +425,7 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int
|
|||
tracer = EV_HLDM_CheckTracer( idx, vecSrc, tr.endpos, forward, right, iBulletType, iTracerFreq, tracerCount );
|
||||
|
||||
// do damage, paint decals
|
||||
if( tr.fraction != 1.0 )
|
||||
if( tr.fraction != 1.0f )
|
||||
{
|
||||
switch( iBulletType )
|
||||
{
|
||||
|
@ -458,7 +458,8 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int
|
|||
//======================
|
||||
// GLOCK START
|
||||
//======================
|
||||
void EV_FireGlock1( event_args_t *args )
|
||||
// Shared Glock fire implementation for EV_FireGlock1 and EV_FireGlock2.
|
||||
static void EV_FireGlock_Impl( event_args_t *args )
|
||||
{
|
||||
int idx;
|
||||
vec3_t origin;
|
||||
|
@ -485,7 +486,7 @@ void EV_FireGlock1( event_args_t *args )
|
|||
if( EV_IsLocal( idx ) )
|
||||
{
|
||||
EV_MuzzleFlash();
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( empty ? GLOCK_SHOOT_EMPTY : GLOCK_SHOOT, 2 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( empty ? GLOCK_SHOOT_EMPTY : GLOCK_SHOOT, 0 );
|
||||
|
||||
V_PunchAxis( 0, -2.0 );
|
||||
}
|
||||
|
@ -500,53 +501,17 @@ void EV_FireGlock1( event_args_t *args )
|
|||
|
||||
VectorCopy( forward, vecAiming );
|
||||
|
||||
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, 0, args->fparam1, args->fparam2 );
|
||||
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 );
|
||||
}
|
||||
|
||||
void EV_FireGlock1( event_args_t *args )
|
||||
{
|
||||
EV_FireGlock_Impl( args );
|
||||
}
|
||||
|
||||
void EV_FireGlock2( event_args_t *args )
|
||||
{
|
||||
int idx;
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
vec3_t velocity;
|
||||
|
||||
vec3_t ShellVelocity;
|
||||
vec3_t ShellOrigin;
|
||||
int shell;
|
||||
vec3_t vecSrc, vecAiming;
|
||||
vec3_t vecSpread;
|
||||
vec3_t up, right, forward;
|
||||
|
||||
idx = args->entindex;
|
||||
VectorCopy( args->origin, origin );
|
||||
VectorCopy( args->angles, angles );
|
||||
VectorCopy( args->velocity, velocity );
|
||||
int empty = args->bparam1;
|
||||
|
||||
AngleVectors( angles, forward, right, up );
|
||||
|
||||
shell = gEngfuncs.pEventAPI->EV_FindModelIndex( "models/shell.mdl" );// brass shell
|
||||
|
||||
if( EV_IsLocal( idx ) )
|
||||
{
|
||||
// Add muzzle flash to current weapon model
|
||||
EV_MuzzleFlash();
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( empty ? GLOCK_SHOOT_EMPTY : GLOCK_SHOOT, 2 );
|
||||
|
||||
V_PunchAxis( 0, -2.0 );
|
||||
}
|
||||
|
||||
EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 );
|
||||
|
||||
EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHELL );
|
||||
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/pl_gun3.wav", gEngfuncs.pfnRandomFloat( 0.92, 1.0 ), ATTN_NORM, 0, 98 + gEngfuncs.pfnRandomLong( 0, 3 ) );
|
||||
|
||||
EV_GetGunPosition( args, vecSrc, origin );
|
||||
|
||||
VectorCopy( forward, vecAiming );
|
||||
|
||||
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 );
|
||||
EV_FireGlock_Impl( args );
|
||||
}
|
||||
//======================
|
||||
// GLOCK END
|
||||
|
@ -567,7 +532,7 @@ void EV_FireShotGunDouble( event_args_t *args )
|
|||
vec3_t ShellOrigin;
|
||||
int shell;
|
||||
vec3_t vecSrc, vecAiming;
|
||||
vec3_t vecSpread;
|
||||
//vec3_t vecSpread;
|
||||
vec3_t up, right, forward;
|
||||
//float flSpread = 0.01;
|
||||
|
||||
|
@ -584,7 +549,7 @@ void EV_FireShotGunDouble( event_args_t *args )
|
|||
{
|
||||
// Add muzzle flash to current weapon model
|
||||
EV_MuzzleFlash();
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( SHOTGUN_FIRE2, 2 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( SHOTGUN_FIRE2, 0 );
|
||||
V_PunchAxis( 0, -10.0 );
|
||||
}
|
||||
|
||||
|
@ -621,7 +586,7 @@ void EV_FireShotGunSingle( event_args_t *args )
|
|||
vec3_t ShellOrigin;
|
||||
int shell;
|
||||
vec3_t vecSrc, vecAiming;
|
||||
vec3_t vecSpread;
|
||||
//vec3_t vecSpread;
|
||||
vec3_t up, right, forward;
|
||||
//float flSpread = 0.01;
|
||||
|
||||
|
@ -638,7 +603,7 @@ void EV_FireShotGunSingle( event_args_t *args )
|
|||
{
|
||||
// Add muzzle flash to current weapon model
|
||||
EV_MuzzleFlash();
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( SHOTGUN_FIRE, 2 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( SHOTGUN_FIRE, 0 );
|
||||
|
||||
V_PunchAxis( 0, -5.0 );
|
||||
}
|
||||
|
@ -695,7 +660,7 @@ void EV_FireMP5( event_args_t *args )
|
|||
{
|
||||
// Add muzzle flash to current weapon model
|
||||
EV_MuzzleFlash();
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_FIRE1 + gEngfuncs.pfnRandomLong( 0, 2 ), 2 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_FIRE1 + gEngfuncs.pfnRandomLong( 0, 2 ), 0 );
|
||||
|
||||
V_PunchAxis( 0, gEngfuncs.pfnRandomFloat( -2, 2 ) );
|
||||
}
|
||||
|
@ -717,14 +682,7 @@ void EV_FireMP5( event_args_t *args )
|
|||
EV_GetGunPosition( args, vecSrc, origin );
|
||||
VectorCopy( forward, vecAiming );
|
||||
|
||||
if( gEngfuncs.GetMaxClients() > 1 )
|
||||
{
|
||||
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 );
|
||||
}
|
||||
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 );
|
||||
}
|
||||
|
||||
// We only predict the animation and sound
|
||||
|
@ -739,7 +697,7 @@ void EV_FireMP52( event_args_t *args )
|
|||
|
||||
if( EV_IsLocal( idx ) )
|
||||
{
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_LAUNCH, 2 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_LAUNCH, 0 );
|
||||
V_PunchAxis( 0, -10 );
|
||||
}
|
||||
|
||||
|
@ -805,7 +763,7 @@ void EV_FirePython( event_args_t *args )
|
|||
|
||||
VectorCopy( forward, vecAiming );
|
||||
|
||||
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_357, 0, 0, args->fparam1, args->fparam2 );
|
||||
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_357, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 );
|
||||
}
|
||||
//======================
|
||||
// PHYTON END
|
||||
|
@ -815,6 +773,7 @@ void EV_FirePython( event_args_t *args )
|
|||
//======================
|
||||
// GAUSS START
|
||||
//======================
|
||||
#define SND_STOP (1 << 5)
|
||||
#define SND_CHANGE_PITCH (1 << 7) // duplicated in protocol.h change sound pitch
|
||||
|
||||
void EV_SpinGauss( event_args_t *args )
|
||||
|
@ -835,6 +794,7 @@ void EV_SpinGauss( event_args_t *args )
|
|||
pitch = args->iparam1;
|
||||
|
||||
iSoundState = args->bparam1 ? SND_CHANGE_PITCH : 0;
|
||||
iSoundState = args->bparam2 ? SND_STOP : iSoundState;
|
||||
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "ambience/pulsemachine.wav", 1.0, ATTN_NORM, iSoundState, pitch );
|
||||
}
|
||||
|
@ -901,14 +861,14 @@ void EV_FireGauss( event_args_t *args )
|
|||
|
||||
if( EV_IsLocal( idx ) )
|
||||
{
|
||||
V_PunchAxis( 0, -2.0 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( GAUSS_FIRE2, 2 );
|
||||
V_PunchAxis( 0.0f, -2.0f );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( GAUSS_FIRE2, 0 );
|
||||
|
||||
if( m_fPrimaryFire == false )
|
||||
g_flApplyVel = flDamage;
|
||||
}
|
||||
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/gauss2.wav", 0.5 + flDamage * ( 1.0 / 400.0 ), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) );
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/gauss2.wav", 0.5f + flDamage * ( 1.0f / 400.0f ), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) );
|
||||
|
||||
while( flDamage > 10 && nMaxHits > 0 )
|
||||
{
|
||||
|
@ -943,16 +903,16 @@ void EV_FireGauss( event_args_t *args )
|
|||
idx | 0x1000,
|
||||
tr.endpos,
|
||||
m_iBeam,
|
||||
0.1,
|
||||
m_fPrimaryFire ? 1.0 : 2.5,
|
||||
0.0,
|
||||
m_fPrimaryFire ? 128.0 : flDamage,
|
||||
0.1f,
|
||||
m_fPrimaryFire ? 1.0f : 2.5f,
|
||||
0.0f,
|
||||
(m_fPrimaryFire ? 128.0f : flDamage) / 255.0f,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
m_fPrimaryFire ? 255 : 255,
|
||||
m_fPrimaryFire ? 128 : 255,
|
||||
m_fPrimaryFire ? 0 : 255
|
||||
(m_fPrimaryFire ? 255 : 255) / 255.0f,
|
||||
(m_fPrimaryFire ? 128 : 255) / 255.0f,
|
||||
(m_fPrimaryFire ? 0 : 255) / 255.0f
|
||||
);
|
||||
}
|
||||
else
|
||||
|
@ -960,16 +920,16 @@ void EV_FireGauss( event_args_t *args )
|
|||
gEngfuncs.pEfxAPI->R_BeamPoints( vecSrc,
|
||||
tr.endpos,
|
||||
m_iBeam,
|
||||
0.1,
|
||||
m_fPrimaryFire ? 1.0 : 2.5,
|
||||
0.0,
|
||||
m_fPrimaryFire ? 128.0 : flDamage,
|
||||
0.1f,
|
||||
m_fPrimaryFire ? 1.0f : 2.5f,
|
||||
0.0f,
|
||||
(m_fPrimaryFire ? 128.0f : flDamage) / 255.0f,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
m_fPrimaryFire ? 255 : 255,
|
||||
m_fPrimaryFire ? 128 : 255,
|
||||
m_fPrimaryFire ? 0 : 255
|
||||
(m_fPrimaryFire ? 255 : 255) / 255.0f,
|
||||
(m_fPrimaryFire ? 128 : 255) / 255.0f,
|
||||
(m_fPrimaryFire ? 0 : 255) / 255.0f
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -985,13 +945,13 @@ void EV_FireGauss( event_args_t *args )
|
|||
|
||||
n = -DotProduct( tr.plane.normal, forward );
|
||||
|
||||
if( n < 0.5 ) // 60 degrees
|
||||
if( n < 0.5f ) // 60 degrees
|
||||
{
|
||||
// ALERT( at_console, "reflect %f\n", n );
|
||||
// reflect
|
||||
vec3_t r;
|
||||
|
||||
VectorMA( forward, 2.0 * n, tr.plane.normal, r );
|
||||
VectorMA( forward, 2.0f * n, tr.plane.normal, r );
|
||||
|
||||
flMaxFrac = flMaxFrac - tr.fraction;
|
||||
|
||||
|
@ -1000,18 +960,18 @@ void EV_FireGauss( event_args_t *args )
|
|||
VectorMA( tr.endpos, 8.0, forward, vecSrc );
|
||||
VectorMA( vecSrc, 8192.0, forward, vecDest );
|
||||
|
||||
gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage * n / 255.0, flDamage * n * 0.5 * 0.1, FTENT_FADEOUT );
|
||||
gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage * n / 255.0f, flDamage * n * 0.5f * 0.1f, FTENT_FADEOUT );
|
||||
|
||||
vec3_t fwd;
|
||||
VectorAdd( tr.endpos, tr.plane.normal, fwd );
|
||||
|
||||
gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 3, 0.1, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 100,
|
||||
gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 3, 0.1, gEngfuncs.pfnRandomFloat( 10.0f, 20.0f ) / 100.0f, 100,
|
||||
255, 100 );
|
||||
|
||||
// lose energy
|
||||
if( n == 0 )
|
||||
if( n == 0.0f )
|
||||
{
|
||||
n = 0.1;
|
||||
n = 0.1f;
|
||||
}
|
||||
|
||||
flDamage = flDamage * ( 1 - n );
|
||||
|
@ -1021,7 +981,7 @@ void EV_FireGauss( event_args_t *args )
|
|||
// tunnel
|
||||
EV_HLDM_DecalGunshot( &tr, BULLET_MONSTER_12MM );
|
||||
|
||||
gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 1.0, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0, 6.0, FTENT_FADEOUT );
|
||||
gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 1.0, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0f, 6.0f, FTENT_FADEOUT );
|
||||
|
||||
// limit it to one hole punch
|
||||
if( fHasPunched )
|
||||
|
@ -1067,7 +1027,7 @@ void EV_FireGauss( event_args_t *args )
|
|||
{
|
||||
vec3_t fwd;
|
||||
VectorSubtract( tr.endpos, forward, fwd );
|
||||
gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 3, 0.1, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 100,
|
||||
gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 3, 0.1, gEngfuncs.pfnRandomFloat( 10.0f, 20.0f ) / 100.0f, 100,
|
||||
255, 100 );
|
||||
}
|
||||
|
||||
|
@ -1076,13 +1036,13 @@ void EV_FireGauss( event_args_t *args )
|
|||
|
||||
EV_HLDM_DecalGunshot( &beam_tr, BULLET_MONSTER_12MM );
|
||||
|
||||
gEngfuncs.pEfxAPI->R_TempSprite( beam_tr.endpos, vec3_origin, 0.1, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0, 6.0, FTENT_FADEOUT );
|
||||
gEngfuncs.pEfxAPI->R_TempSprite( beam_tr.endpos, vec3_origin, 0.1, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0f, 6.0f, FTENT_FADEOUT );
|
||||
|
||||
// balls
|
||||
{
|
||||
vec3_t fwd;
|
||||
VectorSubtract( beam_tr.endpos, forward, fwd );
|
||||
gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, beam_tr.endpos, fwd, m_iBalls, (int)( flDamage * 0.3 ), 0.1, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 200,
|
||||
gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, beam_tr.endpos, fwd, m_iBalls, (int)( flDamage * 0.3f ), 0.1, gEngfuncs.pfnRandomFloat( 10.0f, 20.0f ) / 100.0f, 200,
|
||||
255, 40 );
|
||||
}
|
||||
|
||||
|
@ -1102,11 +1062,11 @@ void EV_FireGauss( event_args_t *args )
|
|||
{
|
||||
// slug doesn't punch through ever with primary
|
||||
// fire, so leave a little glowy bit and make some balls
|
||||
gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, 200.0 / 255.0, 0.3, FTENT_FADEOUT );
|
||||
gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, 200.0f / 255.0f, 0.3, FTENT_FADEOUT );
|
||||
{
|
||||
vec3_t fwd;
|
||||
VectorAdd( tr.endpos, tr.plane.normal, fwd );
|
||||
gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 8, 0.6, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 100,
|
||||
gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 8, 0.6, gEngfuncs.pfnRandomFloat( 10.0f, 20.0f ) / 100.0f, 100,
|
||||
255, 200 );
|
||||
}
|
||||
}
|
||||
|
@ -1138,7 +1098,7 @@ enum crowbar_e
|
|||
CROWBAR_ATTACK2MISS,
|
||||
CROWBAR_ATTACK2HIT,
|
||||
CROWBAR_ATTACK3MISS,
|
||||
#ifndef CROWBAR_IDLE_ANIM
|
||||
#if !CROWBAR_IDLE_ANIM
|
||||
CROWBAR_ATTACK3HIT
|
||||
#else
|
||||
CROWBAR_ATTACK3HIT,
|
||||
|
@ -1155,8 +1115,8 @@ void EV_Crowbar( event_args_t *args )
|
|||
{
|
||||
int idx;
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
vec3_t velocity;
|
||||
//vec3_t angles;
|
||||
//vec3_t velocity;
|
||||
|
||||
idx = args->entindex;
|
||||
VectorCopy( args->origin, origin );
|
||||
|
@ -1169,13 +1129,13 @@ void EV_Crowbar( event_args_t *args )
|
|||
switch( (g_iSwing++) % 3 )
|
||||
{
|
||||
case 0:
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 1 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 0 );
|
||||
break;
|
||||
case 1:
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK2MISS, 1 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK2MISS, 0 );
|
||||
break;
|
||||
case 2:
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK3MISS, 1 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK3MISS, 0 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1238,14 +1198,14 @@ void EV_FireCrossbow2( event_args_t *args )
|
|||
VectorMA( vecSrc, 8192, forward, vecEnd );
|
||||
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xbow_fire1.wav", 1, ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) );
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) );
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat( 0.95f, 1.0f ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) );
|
||||
|
||||
if( EV_IsLocal( idx ) )
|
||||
{
|
||||
if( args->iparam1 )
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE1, 1 );
|
||||
else if( args->iparam2 )
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE3, 1 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE1, 0 );
|
||||
else
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE3, 0 );
|
||||
}
|
||||
|
||||
// Store off the old count
|
||||
|
@ -1257,7 +1217,7 @@ void EV_FireCrossbow2( event_args_t *args )
|
|||
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr );
|
||||
|
||||
//We hit something
|
||||
if( tr.fraction < 1.0 )
|
||||
if( tr.fraction < 1.0f )
|
||||
{
|
||||
physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent );
|
||||
|
||||
|
@ -1277,7 +1237,7 @@ void EV_FireCrossbow2( event_args_t *args )
|
|||
//Stick to world but don't stick to glass, it might break and leave the bolt floating. It can still stick to other non-transparent breakables though.
|
||||
else if( pe->rendermode == kRenderNormal )
|
||||
{
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( 0, tr.endpos, CHAN_BODY, "weapons/xbow_hit1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, PITCH_NORM );
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( 0, tr.endpos, CHAN_BODY, "weapons/xbow_hit1.wav", gEngfuncs.pfnRandomFloat( 0.95f, 1.0f ), ATTN_NORM, 0, PITCH_NORM );
|
||||
|
||||
//Not underwater, do some sparks...
|
||||
if( gEngfuncs.PM_PointContents( tr.endpos, NULL ) != CONTENTS_WATER )
|
||||
|
@ -1313,17 +1273,17 @@ void EV_FireCrossbow( event_args_t *args )
|
|||
VectorCopy( args->origin, origin );
|
||||
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xbow_fire1.wav", 1, ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) );
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) );
|
||||
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat( 0.95f, 1.0f ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) );
|
||||
|
||||
//Only play the weapon anims if I shot it.
|
||||
if( EV_IsLocal( idx ) )
|
||||
{
|
||||
if( args->iparam1 )
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE1, 1 );
|
||||
else if ( args->iparam2 )
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE3, 1 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE1, 0 );
|
||||
else
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE3, 0 );
|
||||
|
||||
V_PunchAxis( 0, -2.0 );
|
||||
V_PunchAxis( 0.0f, -2.0f );
|
||||
}
|
||||
}
|
||||
//======================
|
||||
|
@ -1361,7 +1321,7 @@ void EV_FireRpg( event_args_t *args )
|
|||
//Only play the weapon anims if I shot it.
|
||||
if( EV_IsLocal( idx ) )
|
||||
{
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( RPG_FIRE2, 1 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( RPG_FIRE2, 0 );
|
||||
|
||||
V_PunchAxis( 0, -5.0 );
|
||||
}
|
||||
|
@ -1371,7 +1331,7 @@ void EV_FireRpg( event_args_t *args )
|
|||
//======================
|
||||
|
||||
//======================
|
||||
// EGON END
|
||||
// EGON START
|
||||
//======================
|
||||
enum egon_e
|
||||
{
|
||||
|
@ -1462,7 +1422,7 @@ void EV_EgonFire( event_args_t *args )
|
|||
|
||||
//Only play the weapon anims if I shot it.
|
||||
if( EV_IsLocal( idx ) )
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 1 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 0 );
|
||||
|
||||
if( iStartup == 1 && EV_IsLocal( idx ) && !( pBeam || pBeam2 || pFlare ) && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction.
|
||||
{
|
||||
|
@ -1500,10 +1460,11 @@ void EV_EgonFire( event_args_t *args )
|
|||
float g = 50.0f;
|
||||
float b = 125.0f;
|
||||
|
||||
if( IEngineStudio.IsHardware() )
|
||||
// if( IEngineStudio.IsHardware() )
|
||||
{
|
||||
r /= 100.0f;
|
||||
g /= 100.0f;
|
||||
r /= 255.0f;
|
||||
g /= 255.0f;
|
||||
b /= 255.0f;
|
||||
}
|
||||
|
||||
pBeam = gEngfuncs.pEfxAPI->R_BeamEntPoint( idx | 0x1000, tr.endpos, iBeamModelIndex, 99999, 3.5, 0.2, 0.7, 55, 0, 0, r, g, b );
|
||||
|
@ -1541,13 +1502,13 @@ void EV_EgonStop( event_args_t *args )
|
|||
{
|
||||
if( pBeam )
|
||||
{
|
||||
pBeam->die = 0.0;
|
||||
pBeam->die = 0.0f;
|
||||
pBeam = NULL;
|
||||
}
|
||||
|
||||
if( pBeam2 )
|
||||
{
|
||||
pBeam2->die = 0.0;
|
||||
pBeam2->die = 0.0f;
|
||||
pBeam2 = NULL;
|
||||
}
|
||||
|
||||
|
@ -1592,7 +1553,7 @@ enum hgun_e
|
|||
void EV_HornetGunFire( event_args_t *args )
|
||||
{
|
||||
int idx; //, iFireMode;
|
||||
vec3_t origin, angles, vecSrc, forward, right, up;
|
||||
vec3_t origin, angles; //, vecSrc, forward, right, up;
|
||||
|
||||
idx = args->entindex;
|
||||
VectorCopy( args->origin, origin );
|
||||
|
@ -1603,7 +1564,7 @@ void EV_HornetGunFire( event_args_t *args )
|
|||
if( EV_IsLocal( idx ) )
|
||||
{
|
||||
V_PunchAxis( 0, gEngfuncs.pfnRandomLong( 0, 2 ) );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( HGUN_SHOOT, 1 );
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( HGUN_SHOOT, 0 );
|
||||
}
|
||||
|
||||
switch( gEngfuncs.pfnRandomLong( 0, 2 ) )
|
||||
|
@ -1648,6 +1609,7 @@ void EV_TripmineFire( event_args_t *args )
|
|||
pmtrace_t tr;
|
||||
|
||||
idx = args->entindex;
|
||||
const bool last = args->bparam1 != 0;
|
||||
VectorCopy( args->origin, vecSrc );
|
||||
VectorCopy( args->angles, angles );
|
||||
|
||||
|
@ -1667,10 +1629,10 @@ void EV_TripmineFire( event_args_t *args )
|
|||
// Now add in all of the players.
|
||||
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 );
|
||||
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
|
||||
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecSrc + forward * 128, PM_NORMAL, -1, &tr );
|
||||
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecSrc + forward * 128.0f, PM_NORMAL, -1, &tr );
|
||||
|
||||
//Hit something solid
|
||||
if( tr.fraction < 1.0 )
|
||||
if( tr.fraction < 1.0f && !last )
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation ( TRIPMINE_DRAW, 0 );
|
||||
|
||||
gEngfuncs.pEventAPI->EV_PopPMStates();
|
||||
|
@ -1698,7 +1660,7 @@ enum squeak_e
|
|||
void EV_SnarkFire( event_args_t *args )
|
||||
{
|
||||
int idx;
|
||||
vec3_t vecSrc, angles, view_ofs, forward;
|
||||
vec3_t vecSrc, angles, /*view_ofs,*/ forward;
|
||||
pmtrace_t tr;
|
||||
|
||||
idx = args->entindex;
|
||||
|
@ -1722,7 +1684,7 @@ void EV_SnarkFire( event_args_t *args )
|
|||
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc + forward * 20, vecSrc + forward * 64, PM_NORMAL, -1, &tr );
|
||||
|
||||
//Find space to drop the thing.
|
||||
if( tr.allsolid == 0 && tr.startsolid == 0 && tr.fraction > 0.25 )
|
||||
if( tr.allsolid == 0 && tr.startsolid == 0 && tr.fraction > 0.25f )
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( SQUEAK_THROW, 0 );
|
||||
|
||||
gEngfuncs.pEventAPI->EV_PopPMStates();
|
||||
|
@ -1751,9 +1713,9 @@ void EV_TrainPitchAdjust( event_args_t *args )
|
|||
us_params = (unsigned short)args->iparam1;
|
||||
stop = args->bparam1;
|
||||
|
||||
m_flVolume = (float)( us_params & 0x003f ) / 40.0;
|
||||
m_flVolume = (float)( us_params & 0x003f ) / 40.0f;
|
||||
noise = (int)( ( ( us_params ) >> 12 ) & 0x0007 );
|
||||
pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) );
|
||||
pitch = (int)( 10.0f * (float)( ( us_params >> 6 ) & 0x003f ) );
|
||||
|
||||
switch( noise )
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ void CHudFlashlight::Reset( void )
|
|||
m_fFade = 0;
|
||||
m_fOn = 0;
|
||||
m_iBat = 100;
|
||||
m_flBat = 1.0;
|
||||
m_flBat = 1.0f;
|
||||
}
|
||||
|
||||
int CHudFlashlight::VidInit( void )
|
||||
|
@ -75,7 +75,7 @@ int CHudFlashlight::MsgFunc_FlashBat( const char *pszName, int iSize, void *pbu
|
|||
BEGIN_READ( pbuf, iSize );
|
||||
int x = READ_BYTE();
|
||||
m_iBat = x;
|
||||
m_flBat = ( (float)x ) / 100.0;
|
||||
m_flBat = ( (float)x ) / 100.0f;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ int CHudFlashlight::MsgFunc_Flashlight( const char *pszName, int iSize, void *p
|
|||
m_fOn = READ_BYTE();
|
||||
int x = READ_BYTE();
|
||||
m_iBat = x;
|
||||
m_flBat = ( (float)x ) / 100.0;
|
||||
m_flBat = ( (float)x ) / 100.0f;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ int CHudFlashlight::Draw( float flTime )
|
|||
else
|
||||
a = MIN_ALPHA;
|
||||
|
||||
if( m_flBat < 0.20 )
|
||||
if( m_flBat < 0.20f )
|
||||
UnpackRGB( r,g,b, RGB_REDISH );
|
||||
else
|
||||
UnpackRGB( r,g,b, RGB_YELLOWISH );
|
||||
|
@ -144,7 +144,7 @@ int CHudFlashlight::Draw( float flTime )
|
|||
|
||||
// draw the flashlight energy level
|
||||
x = ScreenWidth - m_iWidth - m_iWidth / 2;
|
||||
int iOffset = m_iWidth * ( 1.0 - m_flBat );
|
||||
int iOffset = m_iWidth * ( 1.0f - m_flBat );
|
||||
if( iOffset < m_iWidth )
|
||||
{
|
||||
rc = *m_prc2;
|
||||
|
|
|
@ -66,7 +66,7 @@ int CHudGeiger::Draw( float flTime )
|
|||
int pct;
|
||||
float flvol = 0.0f;
|
||||
//int rg[3];
|
||||
int i;
|
||||
int i = 0;
|
||||
|
||||
if( m_iGeigerRange < 1000 && m_iGeigerRange > 0 )
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ int CHudGeiger::Draw( float flTime )
|
|||
else if( m_iGeigerRange > 600 )
|
||||
{
|
||||
pct = 2;
|
||||
flvol = 0.4; //Con_Printf( "range > 600\n" );
|
||||
flvol = 0.4f; //Con_Printf( "range > 600\n" );
|
||||
//rg[0] = 1;
|
||||
//rg[1] = 1;
|
||||
i = 2;
|
||||
|
@ -86,7 +86,7 @@ int CHudGeiger::Draw( float flTime )
|
|||
else if( m_iGeigerRange > 500 )
|
||||
{
|
||||
pct = 4;
|
||||
flvol = 0.5; //Con_Printf( "range > 500\n" );
|
||||
flvol = 0.5f; //Con_Printf( "range > 500\n" );
|
||||
//rg[0] = 1;
|
||||
//rg[1] = 2;
|
||||
i = 2;
|
||||
|
@ -94,7 +94,7 @@ int CHudGeiger::Draw( float flTime )
|
|||
else if( m_iGeigerRange > 400 )
|
||||
{
|
||||
pct = 8;
|
||||
flvol = 0.6; //Con_Printf( "range > 400\n" );
|
||||
flvol = 0.6f; //Con_Printf( "range > 400\n" );
|
||||
//rg[0] = 1;
|
||||
//rg[1] = 2;
|
||||
//rg[2] = 3;
|
||||
|
@ -103,7 +103,7 @@ int CHudGeiger::Draw( float flTime )
|
|||
else if( m_iGeigerRange > 300 )
|
||||
{
|
||||
pct = 8;
|
||||
flvol = 0.7; //Con_Printf( "range > 300\n" );
|
||||
flvol = 0.7f; //Con_Printf( "range > 300\n" );
|
||||
//rg[0] = 2;
|
||||
//rg[1] = 3;
|
||||
//rg[2] = 4;
|
||||
|
@ -112,7 +112,7 @@ int CHudGeiger::Draw( float flTime )
|
|||
else if( m_iGeigerRange > 200 )
|
||||
{
|
||||
pct = 28;
|
||||
flvol = 0.78; //Con_Printf( "range > 200\n" );
|
||||
flvol = 0.78f; //Con_Printf( "range > 200\n" );
|
||||
//rg[0] = 2;
|
||||
//rg[1] = 3;
|
||||
//rg[2] = 4;
|
||||
|
@ -121,7 +121,7 @@ int CHudGeiger::Draw( float flTime )
|
|||
else if( m_iGeigerRange > 150 )
|
||||
{
|
||||
pct = 40;
|
||||
flvol = 0.80; //Con_Printf( "range > 150\n" );
|
||||
flvol = 0.80f; //Con_Printf( "range > 150\n" );
|
||||
//rg[0] = 3;
|
||||
//rg[1] = 4;
|
||||
//rg[2] = 5;
|
||||
|
@ -139,7 +139,7 @@ int CHudGeiger::Draw( float flTime )
|
|||
else if( m_iGeigerRange > 75 )
|
||||
{
|
||||
pct = 80;
|
||||
flvol = 0.9; //Con_Printf( "range > 75\n" );
|
||||
flvol = 0.9f; //Con_Printf( "range > 75\n" );
|
||||
//gflGeigerDelay = cl.time + GEIGERDELAY * 0.75;
|
||||
//rg[0] = 4;
|
||||
//rg[1] = 5;
|
||||
|
@ -149,7 +149,7 @@ int CHudGeiger::Draw( float flTime )
|
|||
else if( m_iGeigerRange > 50 )
|
||||
{
|
||||
pct = 90;
|
||||
flvol = 0.95; //Con_Printf( "range > 50\n" );
|
||||
flvol = 0.95f; //Con_Printf( "range > 50\n" );
|
||||
//rg[0] = 5;
|
||||
//rg[1] = 6;
|
||||
i = 2;
|
||||
|
@ -157,17 +157,17 @@ int CHudGeiger::Draw( float flTime )
|
|||
else
|
||||
{
|
||||
pct = 95;
|
||||
flvol = 1.0; //Con_Printf( "range < 50\n" );
|
||||
flvol = 1.0f; //Con_Printf( "range < 50\n" );
|
||||
//rg[0] = 5;
|
||||
//rg[1] = 6;
|
||||
i = 2;
|
||||
}
|
||||
|
||||
flvol = ( flvol * ( ( rand() & 127 ) ) / 255 ) + 0.25; // UTIL_RandomFloat( 0.25, 0.5 );
|
||||
flvol = ( flvol * ( ( rand() & 127 ) ) / 255 ) + 0.25f; // UTIL_RandomFloat( 0.25f, 0.5f );
|
||||
|
||||
if( ( rand() & 127 ) < pct || ( rand() & 127 ) < pct )
|
||||
{
|
||||
//S_StartDynamicSound( -1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0, 0, 100 );
|
||||
//S_StartDynamicSound( -1, 0, rgsfx[rand() % i], r_origin, flvol, 1.0f, 0, 100 );
|
||||
char sz[256];
|
||||
|
||||
int j = rand() & 1;
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
// implementation of CHudHealth class
|
||||
//
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cmath>
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
@ -152,13 +152,14 @@ int CHudHealth::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf )
|
|||
// Green <-> Yellow <-> Red ramp
|
||||
void CHudHealth::GetPainColor( int &r, int &g, int &b )
|
||||
{
|
||||
#if 0
|
||||
int iHealth = m_iHealth;
|
||||
|
||||
if( iHealth > 25 )
|
||||
iHealth -= 25;
|
||||
else if( iHealth < 0 )
|
||||
iHealth = 0;
|
||||
#if 0
|
||||
|
||||
g = iHealth * 255 / 100;
|
||||
r = 255 - g;
|
||||
b = 0;
|
||||
|
@ -191,7 +192,7 @@ int CHudHealth::Draw( float flTime )
|
|||
// Has health changed? Flash the health #
|
||||
if( m_fFade )
|
||||
{
|
||||
m_fFade -= ( gHUD.m_flTimeDelta * 20 );
|
||||
m_fFade -= ( (float)gHUD.m_flTimeDelta * 20.0f );
|
||||
if( m_fFade <= 0 )
|
||||
{
|
||||
a = MIN_ALPHA;
|
||||
|
@ -270,27 +271,27 @@ void CHudHealth::CalcDamageDirection( vec3_t vecFrom )
|
|||
}
|
||||
else
|
||||
{
|
||||
if( side > 0 )
|
||||
if( side > 0.0f )
|
||||
{
|
||||
if( side > 0.3 )
|
||||
if( side > 0.3f )
|
||||
m_fAttackFront = Q_max( m_fAttackFront, side );
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = fabs( side );
|
||||
if( f > 0.3 )
|
||||
if( f > 0.3f )
|
||||
m_fAttackRear = Q_max( m_fAttackRear, f );
|
||||
}
|
||||
|
||||
if( front > 0 )
|
||||
if( front > 0.0f )
|
||||
{
|
||||
if( front > 0.3 )
|
||||
if( front > 0.3f )
|
||||
m_fAttackRight = Q_max( m_fAttackRight, front );
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = fabs( front );
|
||||
if( f > 0.3 )
|
||||
if( f > 0.3f )
|
||||
m_fAttackLeft = Q_max( m_fAttackLeft, f );
|
||||
}
|
||||
}
|
||||
|
@ -310,10 +311,10 @@ int CHudHealth::DrawPain( float flTime )
|
|||
float fFade = gHUD.m_flTimeDelta * 2;
|
||||
|
||||
// SPR_Draw top
|
||||
if( m_fAttackFront > 0.4 )
|
||||
if( m_fAttackFront > 0.4f )
|
||||
{
|
||||
GetPainColor( r, g, b );
|
||||
shade = a * Q_max( m_fAttackFront, 0.5 );
|
||||
shade = a * Q_max( m_fAttackFront, 0.5f );
|
||||
ScaleColors( r, g, b, shade );
|
||||
SPR_Set( m_hSprite, r, g, b );
|
||||
|
||||
|
@ -324,10 +325,10 @@ int CHudHealth::DrawPain( float flTime )
|
|||
} else
|
||||
m_fAttackFront = 0;
|
||||
|
||||
if( m_fAttackRight > 0.4 )
|
||||
if( m_fAttackRight > 0.4f )
|
||||
{
|
||||
GetPainColor( r, g, b );
|
||||
shade = a * Q_max( m_fAttackRight, 0.5 );
|
||||
shade = a * Q_max( m_fAttackRight, 0.5f );
|
||||
ScaleColors( r, g, b, shade );
|
||||
SPR_Set( m_hSprite, r, g, b );
|
||||
|
||||
|
@ -339,10 +340,10 @@ int CHudHealth::DrawPain( float flTime )
|
|||
else
|
||||
m_fAttackRight = 0;
|
||||
|
||||
if( m_fAttackRear > 0.4 )
|
||||
if( m_fAttackRear > 0.4f )
|
||||
{
|
||||
GetPainColor( r, g, b );
|
||||
shade = a * Q_max( m_fAttackRear, 0.5 );
|
||||
shade = a * Q_max( m_fAttackRear, 0.5f );
|
||||
ScaleColors( r, g, b, shade );
|
||||
SPR_Set( m_hSprite, r, g, b );
|
||||
|
||||
|
@ -354,10 +355,10 @@ int CHudHealth::DrawPain( float flTime )
|
|||
else
|
||||
m_fAttackRear = 0;
|
||||
|
||||
if( m_fAttackLeft > 0.4 )
|
||||
if( m_fAttackLeft > 0.4f )
|
||||
{
|
||||
GetPainColor( r, g, b );
|
||||
shade = a * Q_max( m_fAttackLeft, 0.5 );
|
||||
shade = a * Q_max( m_fAttackLeft, 0.5f );
|
||||
ScaleColors( r, g, b, shade );
|
||||
SPR_Set( m_hSprite, r, g, b );
|
||||
|
||||
|
@ -382,7 +383,7 @@ int CHudHealth::DrawDamage( float flTime )
|
|||
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
|
||||
a = (int)( fabs( sin( flTime * 2 ) ) * 256.0 );
|
||||
a = (int)( fabs( sin( flTime * 2.0f ) ) * 256.0f );
|
||||
|
||||
ScaleColors( r, g, b, a );
|
||||
|
||||
|
@ -461,7 +462,7 @@ void CHudHealth::UpdateTiles( float flTime, long bitsDamage )
|
|||
if( pdmg->y )
|
||||
pdmg->y -= giDmgHeight;
|
||||
}
|
||||
pdmg = &m_dmg[i];
|
||||
// pdmg = &m_dmg[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
****/
|
||||
#pragma once
|
||||
#ifndef HEALTH_H
|
||||
#if !defined(HEALTH_H)
|
||||
#define HEALTH_H
|
||||
|
||||
#define DMG_IMAGE_LIFE 2 // seconds that image is up
|
||||
|
|
|
@ -350,3 +350,4 @@ float CBasePlayer::TouchGravGun( CBaseEntity*e, int s ) { return 0; }
|
|||
void CBasePlayer::Touch( CBaseEntity * ) {}
|
||||
|
||||
void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType ){}
|
||||
void CSprite::AnimateUntilDead( void ) {}
|
||||
|
|
|
@ -68,25 +68,25 @@ void UpdateBeams( void )
|
|||
if( pBeam )
|
||||
{
|
||||
pBeam->target = tr.endpos;
|
||||
pBeam->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
|
||||
pBeam->die = gEngfuncs.GetClientTime() + 0.1f; // We keep it alive just a little bit forward in the future, just in case.
|
||||
}
|
||||
|
||||
if( pBeam2 )
|
||||
{
|
||||
pBeam2->target = tr.endpos;
|
||||
pBeam2->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
|
||||
pBeam2->die = gEngfuncs.GetClientTime() + 0.1f; // We keep it alive just a little bit forward in the future, just in case.
|
||||
}
|
||||
|
||||
if( pFlare ) // Vit_amiN: beam flare
|
||||
{
|
||||
pFlare->entity.origin = tr.endpos;
|
||||
pFlare->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
|
||||
pFlare->die = gEngfuncs.GetClientTime() + 0.1f; // We keep it alive just a little bit forward in the future, just in case.
|
||||
|
||||
if( gEngfuncs.GetMaxClients() != 1 ) // Singleplayer always draws the egon's energy beam flare
|
||||
{
|
||||
pFlare->flags |= FTENT_NOMODEL;
|
||||
|
||||
if( !( tr.allsolid || tr.ent <= 0 || tr.fraction == 1.0 ) ) // Beam hit some non-world entity
|
||||
if( !( tr.allsolid || tr.ent <= 0 || tr.fraction == 1.0f ) ) // Beam hit some non-world entity
|
||||
{
|
||||
physent_t *pEntity = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent );
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ extern globalvars_t *gpGlobals;
|
|||
extern int g_iUser1;
|
||||
|
||||
// Pool of client side entities/entvars_t
|
||||
static entvars_t ev[32];
|
||||
static entvars_t ev[MAX_WEAPONS];
|
||||
static int num_ents = 0;
|
||||
|
||||
// The entity we'll use to represent the local client
|
||||
|
@ -45,7 +45,7 @@ static CBasePlayer player;
|
|||
// Local version of game .dll global variables ( time, etc. )
|
||||
static globalvars_t Globals;
|
||||
|
||||
static CBasePlayerWeapon *g_pWpns[32];
|
||||
static CBasePlayerWeapon *g_pWpns[MAX_WEAPONS];
|
||||
|
||||
float g_flApplyVel = 0.0;
|
||||
int g_irunninggausspred = 0;
|
||||
|
@ -163,7 +163,7 @@ BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, i
|
|||
|
||||
m_fInReload = TRUE;
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0f;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -218,8 +218,8 @@ BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWe
|
|||
SendWeaponAnim( iAnim, skiplocal, body );
|
||||
|
||||
g_irunninggausspred = false;
|
||||
m_pPlayer->m_flNextAttack = 0.5;
|
||||
m_flTimeWeaponIdle = 1.0;
|
||||
m_pPlayer->m_flNextAttack = 0.5f;
|
||||
m_flTimeWeaponIdle = 1.0f;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ BOOL CBasePlayerWeapon::PlayEmptySound( void )
|
|||
{
|
||||
if( m_iPlayEmptySound )
|
||||
{
|
||||
HUD_PlaySound( "weapons/357_cock1.wav", 0.8 );
|
||||
HUD_PlaySound( "weapons/357_cock1.wav", 0.8f );
|
||||
m_iPlayEmptySound = 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -296,8 +296,8 @@ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecD
|
|||
{
|
||||
// get circular gaussian spread
|
||||
do {
|
||||
x = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 );
|
||||
y = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 );
|
||||
x = RANDOM_FLOAT( -0.5f, 0.5f ) + RANDOM_FLOAT( -0.5f, 0.5f );
|
||||
y = RANDOM_FLOAT( -0.5f, 0.5f ) + RANDOM_FLOAT( -0.5f, 0.5f );
|
||||
z = x * x + y * y;
|
||||
} while( z > 1 );
|
||||
}
|
||||
|
@ -305,13 +305,13 @@ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecD
|
|||
{
|
||||
//Use player's random seed.
|
||||
// get circular gaussian spread
|
||||
x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5, 0.5 );
|
||||
y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5, 0.5 );
|
||||
z = x * x + y * y;
|
||||
x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5f, 0.5f ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5f, 0.5f );
|
||||
y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5f, 0.5f ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5f, 0.5f );
|
||||
// z = x * x + y * y;
|
||||
}
|
||||
}
|
||||
|
||||
return Vector( x * vecSpread.x, y * vecSpread.y, 0.0 );
|
||||
return Vector( x * vecSpread.x, y * vecSpread.y, 0.0f );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -323,11 +323,15 @@ Handles weapon firing, reloading, etc.
|
|||
*/
|
||||
void CBasePlayerWeapon::ItemPostFrame( void )
|
||||
{
|
||||
if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= 0.0 ) )
|
||||
if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= 0.0f ) )
|
||||
{
|
||||
#if 0 // FIXME, need ammo on client to make this work right
|
||||
#if 1
|
||||
// complete the reload.
|
||||
int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] );
|
||||
ItemInfo itemInfo;
|
||||
memset( &itemInfo, 0, sizeof( itemInfo ) );
|
||||
GetItemInfo( &itemInfo );
|
||||
|
||||
int j = Q_min( itemInfo.iMaxClip - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] );
|
||||
|
||||
// Add them to the clip
|
||||
m_iClip += j;
|
||||
|
@ -338,7 +342,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
|||
m_fInReload = FALSE;
|
||||
}
|
||||
|
||||
if( ( m_pPlayer->pev->button & IN_ATTACK2 ) && ( m_flNextSecondaryAttack <= 0.0 ) )
|
||||
if( ( m_pPlayer->pev->button & IN_ATTACK2 ) && ( m_flNextSecondaryAttack <= 0.0f ) )
|
||||
{
|
||||
if( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] )
|
||||
{
|
||||
|
@ -348,7 +352,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
|||
SecondaryAttack();
|
||||
m_pPlayer->pev->button &= ~IN_ATTACK2;
|
||||
}
|
||||
else if( ( m_pPlayer->pev->button & IN_ATTACK ) && ( m_flNextPrimaryAttack <= 0.0 ) )
|
||||
else if( ( m_pPlayer->pev->button & IN_ATTACK ) && ( m_flNextPrimaryAttack <= 0.0f ) )
|
||||
{
|
||||
if( ( m_iClip == 0 && pszAmmo1() ) || ( iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) )
|
||||
{
|
||||
|
@ -368,7 +372,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
|||
m_fFireOnEmpty = FALSE;
|
||||
|
||||
// weapon is useable. Reload if empty and weapon has waited as long as it has to after firing
|
||||
if( m_iClip == 0 && !( iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack < 0.0 )
|
||||
if( m_iClip == 0 && !( iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack <= 0.0f )
|
||||
{
|
||||
Reload();
|
||||
return;
|
||||
|
@ -483,7 +487,7 @@ Don't actually trace, but act like the trace didn't hit anything.
|
|||
void UTIL_TraceLine( const Vector &vecStart, const Vector &vecEnd, IGNORE_MONSTERS igmon, edict_t *pentIgnore, TraceResult *ptr )
|
||||
{
|
||||
memset( ptr, 0, sizeof(*ptr) );
|
||||
ptr->flFraction = 1.0;
|
||||
ptr->flFraction = 1.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -748,7 +752,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
|
|||
if( !pWeapon )
|
||||
return;
|
||||
|
||||
for( i = 0; i < 32; i++ )
|
||||
for( i = 0; i < MAX_WEAPONS; i++ )
|
||||
{
|
||||
pCurrent = g_pWpns[i];
|
||||
if( !pCurrent )
|
||||
|
@ -895,19 +899,15 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
|
|||
|
||||
if( player.m_pActiveItem->m_iId == WEAPON_RPG )
|
||||
{
|
||||
from->client.vuser2[1] = ( (CRpg *)player.m_pActiveItem)->m_fSpotActive;
|
||||
from->client.vuser2[2] = ( (CRpg *)player.m_pActiveItem)->m_cActiveRockets;
|
||||
to->client.vuser2[1] = ( (CRpg *)player.m_pActiveItem)->m_fSpotActive;
|
||||
to->client.vuser2[2] = ( (CRpg *)player.m_pActiveItem)->m_cActiveRockets;
|
||||
}
|
||||
|
||||
// Make sure that weapon animation matches what the game .dll is telling us
|
||||
// over the wire ( fixes some animation glitches )
|
||||
if( g_runfuncs && ( HUD_GetWeaponAnim() != to->client.weaponanim ) )
|
||||
{
|
||||
int body = 2;
|
||||
|
||||
//Pop the model to body 0.
|
||||
if( pWeapon == &g_Tripmine )
|
||||
body = 0;
|
||||
int body = 0;
|
||||
|
||||
//Show laser sight/scope combo
|
||||
if( pWeapon == &g_Python && bIsMultiplayer() )
|
||||
|
@ -917,7 +917,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
|
|||
HUD_SendWeaponAnim( to->client.weaponanim, body, 1 );
|
||||
}
|
||||
|
||||
for( i = 0; i < 32; i++ )
|
||||
for( i = 0; i < MAX_WEAPONS; i++ )
|
||||
{
|
||||
pCurrent = g_pWpns[i];
|
||||
|
||||
|
@ -944,73 +944,73 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
|
|||
pto->iuser3 = pCurrent->m_fireState;
|
||||
|
||||
// Decrement weapon counters, server does this at same time ( during post think, after doing everything else )
|
||||
pto->m_flNextReload -= cmd->msec / 1000.0;
|
||||
pto->m_fNextAimBonus -= cmd->msec / 1000.0;
|
||||
pto->m_flNextPrimaryAttack -= cmd->msec / 1000.0;
|
||||
pto->m_flNextSecondaryAttack -= cmd->msec / 1000.0;
|
||||
pto->m_flTimeWeaponIdle -= cmd->msec / 1000.0;
|
||||
pto->fuser1 -= cmd->msec / 1000.0;
|
||||
pto->m_flNextReload -= cmd->msec / 1000.0f;
|
||||
pto->m_fNextAimBonus -= cmd->msec / 1000.0f;
|
||||
pto->m_flNextPrimaryAttack -= cmd->msec / 1000.0f;
|
||||
pto->m_flNextSecondaryAttack -= cmd->msec / 1000.0f;
|
||||
pto->m_flTimeWeaponIdle -= cmd->msec / 1000.0f;
|
||||
pto->fuser1 -= cmd->msec / 1000.0f;
|
||||
|
||||
to->client.vuser3[2] = pCurrent->m_iSecondaryAmmoType;
|
||||
to->client.vuser4[0] = pCurrent->m_iPrimaryAmmoType;
|
||||
to->client.vuser4[1] = player.m_rgAmmo[pCurrent->m_iPrimaryAmmoType];
|
||||
to->client.vuser4[2] = player.m_rgAmmo[pCurrent->m_iSecondaryAmmoType];
|
||||
|
||||
/* if( pto->m_flPumpTime != -9999 )
|
||||
/* if( pto->m_flPumpTime != -9999.0f )
|
||||
{
|
||||
pto->m_flPumpTime -= cmd->msec / 1000.0;
|
||||
if( pto->m_flPumpTime < -0.001 )
|
||||
pto->m_flPumpTime = -0.001;
|
||||
pto->m_flPumpTime -= cmd->msec / 1000.0f;
|
||||
if( pto->m_flPumpTime < -0.001f )
|
||||
pto->m_flPumpTime = -0.001f;
|
||||
}*/
|
||||
|
||||
if( pto->m_fNextAimBonus < -1.0 )
|
||||
if( pto->m_fNextAimBonus < -1.0f )
|
||||
{
|
||||
pto->m_fNextAimBonus = -1.0;
|
||||
pto->m_fNextAimBonus = -1.0f;
|
||||
}
|
||||
|
||||
if( pto->m_flNextPrimaryAttack < -1.0 )
|
||||
if( pto->m_flNextPrimaryAttack < -1.0f )
|
||||
{
|
||||
pto->m_flNextPrimaryAttack = -1.0;
|
||||
pto->m_flNextPrimaryAttack = -1.0f;
|
||||
}
|
||||
|
||||
if( pto->m_flNextSecondaryAttack < -0.001 )
|
||||
if( pto->m_flNextSecondaryAttack < -0.001f )
|
||||
{
|
||||
pto->m_flNextSecondaryAttack = -0.001;
|
||||
pto->m_flNextSecondaryAttack = -0.001f;
|
||||
}
|
||||
|
||||
if( pto->m_flTimeWeaponIdle < -0.001 )
|
||||
if( pto->m_flTimeWeaponIdle < -0.001f )
|
||||
{
|
||||
pto->m_flTimeWeaponIdle = -0.001;
|
||||
pto->m_flTimeWeaponIdle = -0.001f;
|
||||
}
|
||||
|
||||
if( pto->m_flNextReload < -0.001 )
|
||||
if( pto->m_flNextReload < -0.001f )
|
||||
{
|
||||
pto->m_flNextReload = -0.001;
|
||||
pto->m_flNextReload = -0.001f;
|
||||
}
|
||||
|
||||
if( pto->fuser1 < -0.001 )
|
||||
if( pto->fuser1 < -0.001f )
|
||||
{
|
||||
pto->fuser1 = -0.001;
|
||||
pto->fuser1 = -0.001f;
|
||||
}
|
||||
}
|
||||
|
||||
// m_flNextAttack is now part of the weapons, but is part of the player instead
|
||||
to->client.m_flNextAttack -= cmd->msec / 1000.0;
|
||||
if( to->client.m_flNextAttack < -0.001 )
|
||||
to->client.m_flNextAttack -= cmd->msec / 1000.0f;
|
||||
if( to->client.m_flNextAttack < -0.001f )
|
||||
{
|
||||
to->client.m_flNextAttack = -0.001;
|
||||
to->client.m_flNextAttack = -0.001f;
|
||||
}
|
||||
|
||||
to->client.fuser2 -= cmd->msec / 1000.0;
|
||||
if( to->client.fuser2 < -0.001 )
|
||||
to->client.fuser2 -= cmd->msec / 1000.0f;
|
||||
if( to->client.fuser2 < -0.001f )
|
||||
{
|
||||
to->client.fuser2 = -0.001;
|
||||
to->client.fuser2 = -0.001f;
|
||||
}
|
||||
|
||||
to->client.fuser3 -= cmd->msec / 1000.0;
|
||||
if( to->client.fuser3 < -0.001 )
|
||||
to->client.fuser3 -= cmd->msec / 1000.0f;
|
||||
if( to->client.fuser3 < -0.001f )
|
||||
{
|
||||
to->client.fuser3 = -0.001;
|
||||
to->client.fuser3 = -0.001f;
|
||||
}
|
||||
|
||||
// Store off the last position from the predicted state.
|
||||
|
@ -1035,7 +1035,7 @@ void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s
|
|||
{
|
||||
g_runfuncs = runfuncs;
|
||||
|
||||
#if defined( CLIENT_WEAPONS )
|
||||
#if CLIENT_WEAPONS
|
||||
if( cl_lw && cl_lw->value )
|
||||
{
|
||||
HUD_WeaponsPostThink( from, to, cmd, time, random_seed );
|
||||
|
|
247
cl_dll/hud.cpp
247
cl_dll/hud.cpp
|
@ -23,11 +23,72 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
#include "hud_servers.h"
|
||||
#if USE_VGUI
|
||||
#include "vgui_int.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#endif
|
||||
|
||||
#include "demo.h"
|
||||
#include "demo_api.h"
|
||||
|
||||
hud_player_info_t g_PlayerInfoList[MAX_PLAYERS+1]; // player info from the engine
|
||||
extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional player info sent directly to the client dll
|
||||
team_info_t g_TeamInfo[MAX_TEAMS + 1];
|
||||
int g_IsSpectator[MAX_PLAYERS+1];
|
||||
int g_iPlayerClass;
|
||||
int g_iTeamNumber;
|
||||
int g_iUser1 = 0;
|
||||
int g_iUser2 = 0;
|
||||
int g_iUser3 = 0;
|
||||
|
||||
#if USE_VGUI
|
||||
#include "vgui_ScorePanel.h"
|
||||
|
||||
class CHLVoiceStatusHelper : public IVoiceStatusHelper
|
||||
{
|
||||
public:
|
||||
virtual void GetPlayerTextColor(int entindex, int color[3])
|
||||
{
|
||||
color[0] = color[1] = color[2] = 255;
|
||||
|
||||
if( entindex >= 0 && entindex < sizeof(g_PlayerExtraInfo)/sizeof(g_PlayerExtraInfo[0]) )
|
||||
{
|
||||
int iTeam = g_PlayerExtraInfo[entindex].teamnumber;
|
||||
|
||||
if ( iTeam < 0 )
|
||||
{
|
||||
iTeam = 0;
|
||||
}
|
||||
|
||||
iTeam = iTeam % iNumberOfTeamColors;
|
||||
|
||||
color[0] = iTeamColors[iTeam][0];
|
||||
color[1] = iTeamColors[iTeam][1];
|
||||
color[2] = iTeamColors[iTeam][2];
|
||||
}
|
||||
}
|
||||
|
||||
virtual void UpdateCursorState()
|
||||
{
|
||||
gViewPort->UpdateCursorState();
|
||||
}
|
||||
|
||||
virtual int GetAckIconHeight()
|
||||
{
|
||||
return ScreenHeight - gHUD.m_iFontHeight*3 - 6;
|
||||
}
|
||||
|
||||
virtual bool CanShowSpeakerLabels()
|
||||
{
|
||||
if( gViewPort && gViewPort->m_pScoreBoard )
|
||||
return !gViewPort->m_pScoreBoard->isVisible();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
};
|
||||
static CHLVoiceStatusHelper g_VoiceStatusHelper;
|
||||
#endif
|
||||
|
||||
cvar_t *hud_textmode;
|
||||
float g_hud_text_color[3];
|
||||
|
||||
|
@ -81,73 +142,182 @@ int __MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf )
|
|||
// TFFree Command Menu
|
||||
void __CmdFunc_OpenCommandMenu( void )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if ( gViewPort )
|
||||
{
|
||||
gViewPort->ShowCommandMenu( gViewPort->m_StandardMenu );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// TFC "special" command
|
||||
void __CmdFunc_InputPlayerSpecial( void )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if ( gViewPort )
|
||||
{
|
||||
gViewPort->InputPlayerSpecial();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void __CmdFunc_CloseCommandMenu( void )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if ( gViewPort )
|
||||
{
|
||||
gViewPort->InputSignalHideCommandMenu();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void __CmdFunc_ForceCloseCommandMenu( void )
|
||||
{
|
||||
}
|
||||
|
||||
void __CmdFunc_ToggleServerBrowser( void )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if ( gViewPort )
|
||||
{
|
||||
gViewPort->HideCommandMenu();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// TFFree Command Menu Message Handlers
|
||||
int __MsgFunc_ValClass( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_ValClass( pszName, iSize, pbuf );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __MsgFunc_TeamNames( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_TeamNames( pszName, iSize, pbuf );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __MsgFunc_Feign( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_Feign( pszName, iSize, pbuf );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __MsgFunc_Detpack( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_Detpack( pszName, iSize, pbuf );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __MsgFunc_VGUIMenu( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_VGUIMenu( pszName, iSize, pbuf );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if USE_VGUI && !USE_NOVGUI_MOTD
|
||||
int __MsgFunc_MOTD(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_MOTD( pszName, iSize, pbuf );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int __MsgFunc_BuildSt( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_BuildSt( pszName, iSize, pbuf );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __MsgFunc_RandomPC( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_RandomPC( pszName, iSize, pbuf );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __MsgFunc_ServerName( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_ServerName( pszName, iSize, pbuf );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if USE_VGUI && !USE_NOVGUI_SCOREBOARD
|
||||
int __MsgFunc_ScoreInfo(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_ScoreInfo( pszName, iSize, pbuf );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __MsgFunc_TeamScore(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_TeamScore( pszName, iSize, pbuf );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __MsgFunc_TeamInfo(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_TeamInfo( pszName, iSize, pbuf );
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int __MsgFunc_Spectator( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_Spectator( pszName, iSize, pbuf );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if USE_VGUI
|
||||
int __MsgFunc_SpecFade(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_SpecFade( pszName, iSize, pbuf );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __MsgFunc_ResetFade(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_ResetFade( pszName, iSize, pbuf );
|
||||
return 0;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
int __MsgFunc_AllowSpec( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if (gViewPort)
|
||||
return gViewPort->MsgFunc_AllowSpec( pszName, iSize, pbuf );
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -167,7 +337,6 @@ void CHud::Init( void )
|
|||
HOOK_COMMAND( "-commandmenu", CloseCommandMenu );
|
||||
HOOK_COMMAND( "ForceCloseCommandMenu", ForceCloseCommandMenu );
|
||||
HOOK_COMMAND( "special", InputPlayerSpecial );
|
||||
HOOK_COMMAND( "togglebrowser", ToggleServerBrowser );
|
||||
|
||||
HOOK_MESSAGE( ValClass );
|
||||
HOOK_MESSAGE( TeamNames );
|
||||
|
@ -177,9 +346,24 @@ void CHud::Init( void )
|
|||
HOOK_MESSAGE( RandomPC );
|
||||
HOOK_MESSAGE( ServerName );
|
||||
|
||||
#if USE_VGUI && !USE_NOVGUI_MOTD
|
||||
HOOK_MESSAGE( MOTD );
|
||||
#endif
|
||||
|
||||
#if USE_VGUI && !USE_NOVGUI_SCOREBOARD
|
||||
HOOK_MESSAGE( ScoreInfo );
|
||||
HOOK_MESSAGE( TeamScore );
|
||||
HOOK_MESSAGE( TeamInfo );
|
||||
#endif
|
||||
|
||||
HOOK_MESSAGE( Spectator );
|
||||
HOOK_MESSAGE( AllowSpec );
|
||||
|
||||
#if USE_VGUI
|
||||
HOOK_MESSAGE( SpecFade );
|
||||
HOOK_MESSAGE( ResetFade );
|
||||
#endif
|
||||
|
||||
// VGUI Menus
|
||||
HOOK_MESSAGE( VGUIMenu );
|
||||
|
||||
|
@ -190,8 +374,9 @@ void CHud::Init( void )
|
|||
m_iLogo = 0;
|
||||
m_iFOV = 0;
|
||||
|
||||
CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 );
|
||||
default_fov = CVAR_CREATE( "default_fov", "90", 0 );
|
||||
CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", FCVAR_ARCHIVE );
|
||||
CVAR_CREATE( "cl_autowepswitch", "1", FCVAR_ARCHIVE | FCVAR_USERINFO );
|
||||
default_fov = CVAR_CREATE( "default_fov", "90", FCVAR_ARCHIVE );
|
||||
m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE );
|
||||
m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE );
|
||||
cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" );
|
||||
|
@ -229,11 +414,19 @@ void CHud::Init( void )
|
|||
m_AmmoSecondary.Init();
|
||||
m_TextMessage.Init();
|
||||
m_StatusIcons.Init();
|
||||
#if USE_VGUI
|
||||
GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort);
|
||||
#endif
|
||||
|
||||
#if !USE_VGUI || USE_NOVGUI_MOTD
|
||||
m_MOTD.Init();
|
||||
#endif
|
||||
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
|
||||
m_Scoreboard.Init();
|
||||
#endif
|
||||
|
||||
m_Menu.Init();
|
||||
|
||||
|
||||
MsgFunc_ResetHUD( 0, 0, NULL );
|
||||
}
|
||||
|
||||
|
@ -326,8 +519,8 @@ void CHud::VidInit( void )
|
|||
sprintf( sz, "sprites/%s.spr", p->szSprite );
|
||||
m_rghSprites[index] = SPR_Load( sz );
|
||||
m_rgrcRects[index] = p->rc;
|
||||
strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH );
|
||||
|
||||
strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH - 1 );
|
||||
m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH + ( MAX_SPRITE_NAME_LENGTH - 1 )] = '\0';
|
||||
index++;
|
||||
}
|
||||
|
||||
|
@ -369,8 +562,8 @@ void CHud::VidInit( void )
|
|||
sprintf( sz, "sprites/%s.spr", p->szSprite );
|
||||
m_rghSprites[index] = SPR_Load( sz );
|
||||
m_rgrcRects[index] = p->rc;
|
||||
strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH );
|
||||
|
||||
strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH - 1 );
|
||||
m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH + ( MAX_SPRITE_NAME_LENGTH - 1 )] = '\0';
|
||||
index++;
|
||||
}
|
||||
|
||||
|
@ -410,8 +603,15 @@ void CHud::VidInit( void )
|
|||
m_AmmoSecondary.VidInit();
|
||||
m_TextMessage.VidInit();
|
||||
m_StatusIcons.VidInit();
|
||||
m_Scoreboard.VidInit();
|
||||
#if USE_VGUI
|
||||
GetClientVoiceMgr()->VidInit();
|
||||
#endif
|
||||
#if !USE_VGUI || USE_NOVGUI_MOTD
|
||||
m_MOTD.VidInit();
|
||||
#endif
|
||||
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
|
||||
m_Scoreboard.VidInit();
|
||||
#endif
|
||||
}
|
||||
|
||||
int CHud::MsgFunc_Logo( const char *pszName, int iSize, void *pbuf )
|
||||
|
@ -587,3 +787,22 @@ float CHud::GetSensitivity( void )
|
|||
{
|
||||
return m_flMouseSensitivity;
|
||||
}
|
||||
|
||||
void CHud::GetAllPlayersInfo()
|
||||
{
|
||||
for( int i = 1; i < MAX_PLAYERS; i++ )
|
||||
{
|
||||
GetPlayerInfo( i, &g_PlayerInfoList[i] );
|
||||
|
||||
if( g_PlayerInfoList[i].thisplayer )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if(gViewPort)
|
||||
gViewPort->m_pScoreBoard->m_iPlayerNum = i;
|
||||
#endif
|
||||
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
|
||||
m_Scoreboard.m_iPlayerNum = i; // !!!HACK: this should be initialized elsewhere... maybe gotten from the engine
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
58
cl_dll/hud.h
58
cl_dll/hud.h
|
@ -20,7 +20,7 @@
|
|||
// CHud handles the message, calculation, and drawing the HUD
|
||||
//
|
||||
#pragma once
|
||||
#ifndef HUD_H
|
||||
#if !defined(HUD_H)
|
||||
#define HUD_H
|
||||
#define RGB_YELLOWISH 0x00FFA000 //255,160,0
|
||||
#define RGB_REDISH 0x00FF1010 //255,160,0
|
||||
|
@ -63,6 +63,9 @@ typedef struct cvar_s cvar_t;
|
|||
|
||||
#define MAX_MOTD_LENGTH 1536
|
||||
|
||||
#define MAX_SERVERNAME_LENGTH 64
|
||||
#define MAX_TEAMNAME_SIZE 32
|
||||
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
//
|
||||
|
@ -89,6 +92,9 @@ struct HUDLIST
|
|||
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
#if USE_VGUI
|
||||
#include "voice_status.h" // base voice handling class
|
||||
#endif
|
||||
#include "hud_spectator.h"
|
||||
|
||||
//
|
||||
|
@ -196,11 +202,7 @@ private:
|
|||
int m_iPos;
|
||||
};
|
||||
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
//
|
||||
// REMOVED: Vgui has replaced this.
|
||||
//
|
||||
#if !USE_VGUI || USE_NOVGUI_MOTD
|
||||
class CHudMOTD : public CHudBase
|
||||
{
|
||||
public:
|
||||
|
@ -222,7 +224,9 @@ protected:
|
|||
int m_iLines;
|
||||
int m_iMaxLength;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
|
||||
class CHudScoreboard : public CHudBase
|
||||
{
|
||||
public:
|
||||
|
@ -249,6 +253,7 @@ public:
|
|||
|
||||
void GetAllPlayersInfo( void );
|
||||
};
|
||||
#endif
|
||||
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
|
@ -283,41 +288,6 @@ protected:
|
|||
float *m_pflNameColors[MAX_STATUSBAR_LINES];
|
||||
};
|
||||
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
//
|
||||
// REMOVED: Vgui has replaced this.
|
||||
//
|
||||
/*
|
||||
class CHudScoreboard : public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
void InitHUDData( void );
|
||||
int VidInit( void );
|
||||
int Draw( float flTime );
|
||||
int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, char *team = NULL ); // returns the ypos where it finishes drawing
|
||||
void UserCmd_ShowScores( void );
|
||||
void UserCmd_HideScores( void );
|
||||
int MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf );
|
||||
int MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf );
|
||||
int MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf );
|
||||
void DeathMsg( int killer, int victim );
|
||||
|
||||
int m_iNumTeams;
|
||||
|
||||
int m_iLastKilledBy;
|
||||
int m_fLastKillTime;
|
||||
int m_iPlayerNum;
|
||||
int m_iShowscoresHeld;
|
||||
|
||||
void GetAllPlayersInfo( void );
|
||||
|
||||
private:
|
||||
struct cvar_s *cl_showpacketloss;
|
||||
};
|
||||
*/
|
||||
|
||||
struct extra_player_info_t
|
||||
{
|
||||
short frags;
|
||||
|
@ -633,8 +603,12 @@ public:
|
|||
CHudAmmoSecondary m_AmmoSecondary;
|
||||
CHudTextMessage m_TextMessage;
|
||||
CHudStatusIcons m_StatusIcons;
|
||||
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
|
||||
CHudScoreboard m_Scoreboard;
|
||||
#endif
|
||||
#if !USE_VGUI || USE_NOVGUI_MOTD
|
||||
CHudMOTD m_MOTD;
|
||||
#endif
|
||||
|
||||
void Init( void );
|
||||
void VidInit( void );
|
||||
|
@ -670,6 +644,8 @@ public:
|
|||
void AddHudElem( CHudBase *p );
|
||||
|
||||
float GetSensitivity();
|
||||
|
||||
void GetAllPlayersInfo( void );
|
||||
};
|
||||
|
||||
extern CHud gHUD;
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#define HUD_IFACEH
|
||||
|
||||
#include "exportdef.h"
|
||||
|
||||
typedef int (*pfnUserMsgHook)( const char *pszName, int iSize, void *pbuf );
|
||||
// redefine
|
||||
// typedef int (*pfnUserMsgHook)( const char *pszName, int iSize, void *pbuf );
|
||||
#include "wrect.h"
|
||||
#include "../engine/cdll_int.h"
|
||||
extern cl_enginefunc_t gEngfuncs;
|
||||
|
|
|
@ -15,11 +15,16 @@
|
|||
//
|
||||
// hud_redraw.cpp
|
||||
//
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
//#include "triangleapi.h"
|
||||
|
||||
#if USE_VGUI
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#endif
|
||||
|
||||
#define MAX_LOGO_FRAMES 56
|
||||
|
||||
int grgLogoFrame[MAX_LOGO_FRAMES] =
|
||||
|
@ -38,6 +43,11 @@ extern cvar_t *sensitivity;
|
|||
// Think
|
||||
void CHud::Think( void )
|
||||
{
|
||||
#if USE_VGUI
|
||||
m_scrinfo.iSize = sizeof(m_scrinfo);
|
||||
GetScreenInfo(&m_scrinfo);
|
||||
#endif
|
||||
|
||||
int newfov;
|
||||
HUDLIST *pList = m_pHudList;
|
||||
|
||||
|
@ -86,20 +96,47 @@ int CHud::Redraw( float flTime, int intermission )
|
|||
{
|
||||
m_fOldTime = m_flTime; // save time of previous redraw
|
||||
m_flTime = flTime;
|
||||
m_flTimeDelta = (double)m_flTime - m_fOldTime;
|
||||
m_flTimeDelta = (double)( m_flTime - m_fOldTime );
|
||||
static float m_flShotTime = 0;
|
||||
|
||||
// Clock was reset, reset delta
|
||||
if( m_flTimeDelta < 0 )
|
||||
m_flTimeDelta = 0;
|
||||
|
||||
#if USE_VGUI
|
||||
// Bring up the scoreboard during intermission
|
||||
if (gViewPort)
|
||||
{
|
||||
if( m_iIntermission && !intermission )
|
||||
{
|
||||
// Have to do this here so the scoreboard goes away
|
||||
m_iIntermission = intermission;
|
||||
gViewPort->HideCommandMenu();
|
||||
gViewPort->HideScoreBoard();
|
||||
gViewPort->UpdateSpectatorPanel();
|
||||
}
|
||||
else if( !m_iIntermission && intermission )
|
||||
{
|
||||
m_iIntermission = intermission;
|
||||
gViewPort->HideCommandMenu();
|
||||
gViewPort->HideVGUIMenu();
|
||||
#if !USE_NOVGUI_SCOREBOARD
|
||||
gViewPort->ShowScoreBoard();
|
||||
#endif
|
||||
gViewPort->UpdateSpectatorPanel();
|
||||
// Take a screenshot if the client's got the cvar set
|
||||
if( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
|
||||
m_flShotTime = flTime + 1.0; // Take a screenshot in a second
|
||||
}
|
||||
}
|
||||
#else
|
||||
if( !m_iIntermission && intermission )
|
||||
{
|
||||
// Take a screenshot if the client's got the cvar set
|
||||
if( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
|
||||
m_flShotTime = flTime + 1.0; // Take a screenshot in a second
|
||||
m_flShotTime = flTime + 1.0f; // Take a screenshot in a second
|
||||
}
|
||||
|
||||
#endif
|
||||
if( m_flShotTime && m_flShotTime < flTime )
|
||||
{
|
||||
gEngfuncs.pfnClientCmd( "snapshot\n" );
|
||||
|
@ -164,9 +201,7 @@ int CHud::Redraw( float flTime, int intermission )
|
|||
|
||||
if( m_hsprCursor == 0 )
|
||||
{
|
||||
char sz[256];
|
||||
sprintf( sz, "sprites/cursor.spr" );
|
||||
m_hsprCursor = SPR_Load( sz );
|
||||
m_hsprCursor = SPR_Load( "sprites/cursor.spr" );
|
||||
}
|
||||
|
||||
SPR_Set( m_hsprCursor, 250, 250, 250 );
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,40 +0,0 @@
|
|||
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#if !defined( HUD_SERVERSH )
|
||||
#define HUD_SERVERSH
|
||||
#pragma once
|
||||
|
||||
#define NET_CALLBACK /* */
|
||||
|
||||
// Dispatchers
|
||||
void NET_CALLBACK ListResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK ServerResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK PingResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK RulesResponse( struct net_response_s *response );
|
||||
void NET_CALLBACK PlayersResponse( struct net_response_s *response );
|
||||
|
||||
void ServersInit( void );
|
||||
void ServersShutdown( void );
|
||||
void ServersThink( double time );
|
||||
void ServersCancel( void );
|
||||
|
||||
// Get list and get server info from each
|
||||
void ServersList( void );
|
||||
|
||||
// Query for IP / IPX LAN servers
|
||||
void BroadcastServersList( int clearpending );
|
||||
|
||||
void ServerPing( int server );
|
||||
void ServerRules( int server );
|
||||
void ServerPlayers( int server );
|
||||
|
||||
int ServersGetCount( void );
|
||||
const char *ServersGetInfo( int server );
|
||||
int ServersIsQuerying( void );
|
||||
void SortServers( const char *fieldname );
|
||||
#endif // HUD_SERVERSH
|
|
@ -9,6 +9,10 @@
|
|||
#include "cl_util.h"
|
||||
#include "cl_entity.h"
|
||||
#include "triangleapi.h"
|
||||
#if USE_VGUI
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "vgui_SpectatorPanel.h"
|
||||
#endif
|
||||
#include "hltv.h"
|
||||
|
||||
#include "pm_shared.h"
|
||||
|
@ -69,15 +73,23 @@ void SpectatorSpray( void )
|
|||
VectorScale( forward, 128, forward );
|
||||
VectorAdd( forward, v_origin, forward );
|
||||
pmtrace_t * trace = gEngfuncs.PM_TraceLine( v_origin, forward, PM_TRACELINE_PHYSENTSONLY, 2, -1 );
|
||||
if( trace->fraction != 1.0 )
|
||||
if( trace->fraction != 1.0f )
|
||||
{
|
||||
sprintf( string, "drc_spray %.2f %.2f %.2f %i",
|
||||
trace->endpos[0], trace->endpos[1], trace->endpos[2], trace->ent );
|
||||
(double)trace->endpos[0], (double)trace->endpos[1], (double)trace->endpos[2], trace->ent );
|
||||
gEngfuncs.pfnServerCmd( string );
|
||||
}
|
||||
}
|
||||
|
||||
void SpectatorHelp( void )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if( gViewPort )
|
||||
{
|
||||
gViewPort->ShowVGUIMenu( MENU_SPECHELP );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
char *text = CHudTextMessage::BufferedLocaliseTextString( "#Spec_Help_Text" );
|
||||
|
||||
|
@ -100,10 +112,33 @@ void SpectatorMenu( void )
|
|||
gEngfuncs.Con_Printf( "usage: spec_menu <0|1>\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
#if USE_VGUI
|
||||
gViewPort->m_pSpectatorPanel->ShowMenu( atoi( gEngfuncs.Cmd_Argv( 1 ) ) != 0 );
|
||||
#endif
|
||||
}
|
||||
|
||||
void ToggleScores( void )
|
||||
{
|
||||
#if USE_VGUI && !USE_NOVGUI_SCOREBOARD
|
||||
if( gViewPort )
|
||||
{
|
||||
if( gViewPort->IsScoreBoardVisible() )
|
||||
{
|
||||
gViewPort->HideScoreBoard();
|
||||
}
|
||||
else
|
||||
{
|
||||
gViewPort->ShowScoreBoard();
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (gHUD.m_Scoreboard.m_iShowscoresHeld) {
|
||||
gHUD.m_Scoreboard.UserCmd_HideScores();
|
||||
} else {
|
||||
gHUD.m_Scoreboard.UserCmd_ShowScores();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -355,7 +390,7 @@ int CHudSpectator::Draw( float flTime )
|
|||
int lx;
|
||||
|
||||
char string[256];
|
||||
float * color;
|
||||
float *color;
|
||||
|
||||
// draw only in spectator mode
|
||||
if( !g_iUser1 )
|
||||
|
@ -392,8 +427,7 @@ int CHudSpectator::Draw( float flTime )
|
|||
return 1;
|
||||
|
||||
// make sure we have player info
|
||||
//gViewPort->GetAllPlayersInfo();
|
||||
gHUD.m_Scoreboard.GetAllPlayersInfo();
|
||||
gHUD.GetAllPlayersInfo();
|
||||
|
||||
// loop through all the players and draw additional infos to their sprites on the map
|
||||
for( int i = 0; i < MAX_PLAYERS; i++ )
|
||||
|
@ -414,12 +448,12 @@ int CHudSpectator::Draw( float flTime )
|
|||
color = GetClientColor( i + 1 );
|
||||
|
||||
// draw the players name and health underneath
|
||||
sprintf( string, "%s", g_PlayerInfoList[i + 1].name );
|
||||
strcpy( string, g_PlayerInfoList[i + 1].name );
|
||||
|
||||
lx = strlen( string ) * 3; // 3 is avg. character length :)
|
||||
|
||||
DrawSetTextColor( color[0], color[1], color[2] );
|
||||
DrawConsoleString( m_vPlayerPos[i][0] - lx,m_vPlayerPos[i][1], string );
|
||||
DrawConsoleString( m_vPlayerPos[i][0] - lx,m_vPlayerPos[i][1], string );
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -503,7 +537,7 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf )
|
|||
msg->holdtime = READ_FLOAT(); // holdtime
|
||||
msg->fxtime = READ_FLOAT(); // fxtime;
|
||||
|
||||
strncpy( m_HUDMessageText[m_lastHudMessage], READ_STRING(), 128 );
|
||||
strncpy( m_HUDMessageText[m_lastHudMessage], READ_STRING(), 127 );
|
||||
m_HUDMessageText[m_lastHudMessage][127] = 0; // text
|
||||
|
||||
msg->pMessage = m_HUDMessageText[m_lastHudMessage];
|
||||
|
@ -529,14 +563,21 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf )
|
|||
READ_LONG(); // total number of spectator slots
|
||||
m_iSpectatorNumber = READ_LONG(); // total number of spectator
|
||||
READ_WORD(); // total number of relay proxies
|
||||
#if USE_VGUI
|
||||
gViewPort->UpdateSpectatorPanel();
|
||||
#endif
|
||||
break;
|
||||
case DRC_CMD_BANNER:
|
||||
// gEngfuncs.Con_DPrintf( "GUI: Banner %s\n",READ_STRING() ); // name of banner tga eg gfx/temp/7454562234563475.tga
|
||||
#if USE_VGUI
|
||||
gViewPort->m_pSpectatorPanel->m_TopBanner->LoadImage( READ_STRING() );
|
||||
gViewPort->UpdateSpectatorPanel();
|
||||
#endif
|
||||
break;
|
||||
case DRC_CMD_FADE:
|
||||
break;
|
||||
case DRC_CMD_STUFFTEXT:
|
||||
ClientCmd( READ_STRING() );
|
||||
gEngfuncs.pfnFilteredClientCmd( READ_STRING() );
|
||||
break;
|
||||
default:
|
||||
gEngfuncs.Con_DPrintf( "CHudSpectator::DirectorMessage: unknown command %i.\n", cmd );
|
||||
|
@ -573,8 +614,7 @@ void CHudSpectator::FindNextPlayer( bool bReverse )
|
|||
int iDir = bReverse ? -1 : 1;
|
||||
|
||||
// make sure we have player info
|
||||
//gViewPort->GetAllPlayersInfo();
|
||||
gHUD.m_Scoreboard.GetAllPlayersInfo();
|
||||
gHUD.GetAllPlayersInfo();
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -611,6 +651,68 @@ void CHudSpectator::FindNextPlayer( bool bReverse )
|
|||
VectorCopy( pEnt->angles, vJumpAngles );
|
||||
}
|
||||
iJumpSpectator = 1;
|
||||
#if USE_VGUI
|
||||
gViewPort->MsgFunc_ResetFade( NULL, 0, NULL );
|
||||
#endif
|
||||
}
|
||||
|
||||
void CHudSpectator::FindPlayer(const char *name)
|
||||
{
|
||||
// MOD AUTHORS: Modify the logic of this function if you want to restrict the observer to watching
|
||||
// only a subset of the players. e.g. Make it check the target's team.
|
||||
|
||||
// if we are NOT in HLTV mode, spectator targets are set on server
|
||||
if ( !gEngfuncs.IsSpectateOnly() )
|
||||
{
|
||||
char cmdstring[32];
|
||||
// forward command to server
|
||||
sprintf(cmdstring,"follow %s",name);
|
||||
gEngfuncs.pfnServerCmd(cmdstring);
|
||||
return;
|
||||
}
|
||||
|
||||
g_iUser2 = 0;
|
||||
|
||||
// make sure we have player info
|
||||
gHUD.GetAllPlayersInfo();
|
||||
|
||||
cl_entity_t * pEnt = NULL;
|
||||
|
||||
for (int i = 1; i < MAX_PLAYERS; i++ )
|
||||
{
|
||||
|
||||
pEnt = gEngfuncs.GetEntityByIndex( i );
|
||||
|
||||
if ( !IsActivePlayer( pEnt ) )
|
||||
continue;
|
||||
|
||||
if(!stricmp(g_PlayerInfoList[pEnt->index].name,name))
|
||||
{
|
||||
g_iUser2 = i;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Did we find a target?
|
||||
if ( !g_iUser2 )
|
||||
{
|
||||
gEngfuncs.Con_DPrintf( "No observer targets.\n" );
|
||||
// take save camera position
|
||||
VectorCopy(m_cameraOrigin, vJumpOrigin);
|
||||
VectorCopy(m_cameraAngles, vJumpAngles);
|
||||
}
|
||||
else
|
||||
{
|
||||
// use new entity position for roaming
|
||||
VectorCopy ( pEnt->origin, vJumpOrigin );
|
||||
VectorCopy ( pEnt->angles, vJumpAngles );
|
||||
}
|
||||
|
||||
iJumpSpectator = 1;
|
||||
#if USE_VGUI
|
||||
gViewPort->MsgFunc_ResetFade( NULL, 0, NULL );
|
||||
#endif
|
||||
}
|
||||
|
||||
void CHudSpectator::HandleButtonsDown( int ButtonPressed )
|
||||
|
@ -622,6 +724,11 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed )
|
|||
|
||||
// gEngfuncs.Con_Printf( " HandleButtons:%i\n", ButtonPressed );
|
||||
|
||||
#if USE_VGUI
|
||||
if( !gViewPort )
|
||||
return;
|
||||
#endif
|
||||
|
||||
//Not in intermission.
|
||||
if( gHUD.m_iIntermission )
|
||||
return;
|
||||
|
@ -637,8 +744,10 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed )
|
|||
return;
|
||||
|
||||
// enable spectator screen
|
||||
//if( ButtonPressed & IN_DUCK )
|
||||
// gViewPort->m_pSpectatorPanel->ShowMenu( !gViewPort->m_pSpectatorPanel->m_menuVisible );
|
||||
#if USE_VGUI
|
||||
if( ButtonPressed & IN_DUCK )
|
||||
gViewPort->m_pSpectatorPanel->ShowMenu( !gViewPort->m_pSpectatorPanel->m_menuVisible );
|
||||
#endif
|
||||
|
||||
// 'Use' changes inset window mode
|
||||
if( ButtonPressed & IN_USE )
|
||||
|
@ -705,6 +814,14 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed )
|
|||
|
||||
void CHudSpectator::HandleButtonsUp( int ButtonPressed )
|
||||
{
|
||||
#if USE_VGUI
|
||||
if( !gViewPort )
|
||||
return;
|
||||
|
||||
if( !gViewPort->m_pSpectatorPanel->isVisible() )
|
||||
return; // dont do anything if not in spectator mode
|
||||
#endif
|
||||
|
||||
if( ButtonPressed & ( IN_FORWARD | IN_BACK ) )
|
||||
m_zoomDelta = 0.0f;
|
||||
|
||||
|
@ -800,12 +917,19 @@ void CHudSpectator::SetModes( int iNewMainMode, int iNewInsetMode )
|
|||
SetCrosshair( 0, m_crosshairRect, 0, 0, 0 );
|
||||
}
|
||||
|
||||
#if USE_VGUI
|
||||
gViewPort->MsgFunc_ResetFade( NULL, 0, NULL );
|
||||
#endif
|
||||
|
||||
char string[128];
|
||||
sprintf( string, "#Spec_Mode%d", g_iUser1 );
|
||||
sprintf( string, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( string ) );
|
||||
gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( string ) + 1, string );
|
||||
}
|
||||
|
||||
#if USE_VGUI
|
||||
gViewPort->UpdateSpectatorPanel();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CHudSpectator::IsActivePlayer( cl_entity_t *ent )
|
||||
|
@ -820,12 +944,13 @@ bool CHudSpectator::IsActivePlayer( cl_entity_t *ent )
|
|||
|
||||
bool CHudSpectator::ParseOverviewFile()
|
||||
{
|
||||
char filename[255] = { 0 };
|
||||
char levelname[255] = { 0 };
|
||||
char filename[512] = { 0 };
|
||||
char levelname[256] = { 0 };
|
||||
char token[1024] = { 0 };
|
||||
float height;
|
||||
bool ret = false;
|
||||
|
||||
char *pfile = NULL;
|
||||
char *afile = NULL, *pfile = NULL;
|
||||
|
||||
memset( &m_OverviewData, 0, sizeof(m_OverviewData) );
|
||||
|
||||
|
@ -842,20 +967,20 @@ bool CHudSpectator::ParseOverviewFile()
|
|||
m_OverviewData.layersHeights[0] = 0.0f;
|
||||
strcpy( m_OverviewData.map, gEngfuncs.pfnGetLevelName() );
|
||||
|
||||
if( strlen( m_OverviewData.map ) == 0 )
|
||||
return false; // not active yet
|
||||
if( m_OverviewData.map[0] == '\0' )
|
||||
return ret; // not active yet
|
||||
|
||||
strcpy( levelname, m_OverviewData.map + 5 );
|
||||
levelname[strlen( levelname ) - 4] = 0;
|
||||
|
||||
sprintf( filename, "overviews/%s.txt", levelname );
|
||||
|
||||
pfile = (char *)gEngfuncs.COM_LoadFile( filename, 5, NULL );
|
||||
afile = pfile = (char *)gEngfuncs.COM_LoadFile( filename, 5, NULL );
|
||||
|
||||
if( !pfile )
|
||||
{
|
||||
gEngfuncs.Con_DPrintf( "Couldn't open file %s. Using default values for overiew mode.\n", filename );
|
||||
return false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
while( true )
|
||||
|
@ -872,7 +997,7 @@ bool CHudSpectator::ParseOverviewFile()
|
|||
if( stricmp( token, "{" ) )
|
||||
{
|
||||
gEngfuncs.Con_Printf( "Error parsing overview file %s. (expected { )\n", filename );
|
||||
return false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
pfile = gEngfuncs.COM_ParseFile( pfile, token );
|
||||
|
@ -912,7 +1037,7 @@ bool CHudSpectator::ParseOverviewFile()
|
|||
else
|
||||
{
|
||||
gEngfuncs.Con_Printf( "Error parsing overview file %s. (%s unkown)\n", filename, token );
|
||||
return false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
pfile = gEngfuncs.COM_ParseFile( pfile, token ); // parse next token
|
||||
|
@ -924,7 +1049,7 @@ bool CHudSpectator::ParseOverviewFile()
|
|||
if( m_OverviewData.layers == OVERVIEW_MAX_LAYERS )
|
||||
{
|
||||
gEngfuncs.Con_Printf( "Error parsing overview file %s. ( too many layers )\n", filename );
|
||||
return false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
pfile = gEngfuncs.COM_ParseFile( pfile, token );
|
||||
|
@ -932,7 +1057,7 @@ bool CHudSpectator::ParseOverviewFile()
|
|||
if( stricmp( token, "{" ) )
|
||||
{
|
||||
gEngfuncs.Con_Printf( "Error parsing overview file %s. (expected { )\n", filename );
|
||||
return false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
pfile = gEngfuncs.COM_ParseFile( pfile, token );
|
||||
|
@ -953,7 +1078,7 @@ bool CHudSpectator::ParseOverviewFile()
|
|||
else
|
||||
{
|
||||
gEngfuncs.Con_Printf( "Error parsing overview file %s. (%s unkown)\n", filename, token );
|
||||
return false;
|
||||
goto end;
|
||||
}
|
||||
|
||||
pfile = gEngfuncs.COM_ParseFile( pfile, token ); // parse next token
|
||||
|
@ -963,12 +1088,14 @@ bool CHudSpectator::ParseOverviewFile()
|
|||
}
|
||||
}
|
||||
|
||||
gEngfuncs.COM_FreeFile( pfile );
|
||||
|
||||
m_mapZoom = m_OverviewData.zoom;
|
||||
m_mapOrigin = m_OverviewData.origin;
|
||||
|
||||
return true;
|
||||
ret = true;
|
||||
end:
|
||||
gEngfuncs.COM_FreeFile( afile );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CHudSpectator::LoadMapSprites()
|
||||
|
@ -987,15 +1114,15 @@ void CHudSpectator::DrawOverviewLayer()
|
|||
float screenaspect, xs, ys, xStep, yStep, x, y, z;
|
||||
int ix, iy, i, xTiles, yTiles, frame;
|
||||
|
||||
qboolean hasMapImage = m_MapSprite?TRUE:FALSE;
|
||||
model_t * dummySprite = (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprUnkownMap);
|
||||
qboolean hasMapImage = m_MapSprite ? TRUE : FALSE;
|
||||
model_t *dummySprite = (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprUnkownMap );
|
||||
|
||||
if ( hasMapImage)
|
||||
if( hasMapImage )
|
||||
{
|
||||
i = m_MapSprite->numframes / (4*3);
|
||||
i = sqrt(float(i));
|
||||
xTiles = i*4;
|
||||
yTiles = i*3;
|
||||
i = m_MapSprite->numframes / ( 4 * 3 );
|
||||
i = sqrt( float( i ) );
|
||||
xTiles = i * 4;
|
||||
yTiles = i * 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1014,7 +1141,7 @@ void CHudSpectator::DrawOverviewLayer()
|
|||
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture );
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
|
||||
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 );
|
||||
gEngfuncs.pTriAPI->Color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
frame = 0;
|
||||
|
||||
|
@ -1143,7 +1270,7 @@ void CHudSpectator::DrawOverviewEntities()
|
|||
|
||||
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
|
||||
|
||||
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 );
|
||||
gEngfuncs.pTriAPI->Color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
gEngfuncs.pTriAPI->TexCoord2f(1, 0);
|
||||
VectorMA( origin, 16.0f * sizeScale, up, point );
|
||||
|
@ -1183,28 +1310,28 @@ void CHudSpectator::DrawOverviewEntities()
|
|||
hSpriteModel = (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprBeam );
|
||||
gEngfuncs.pTriAPI->SpriteTexture( hSpriteModel, 0 );
|
||||
|
||||
gEngfuncs.pTriAPI->Color4f( r, g, b, 0.3 );
|
||||
gEngfuncs.pTriAPI->Color4f( r, g, b, 0.3f );
|
||||
|
||||
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4, origin[1] + 4, origin[2] - zScale );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4, origin[1] - 4, origin[2] - zScale );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4, origin[1] - 4, z );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4, origin[1] + 4, z );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 0.0f );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4.0f, origin[1] + 4.0f, origin[2] - zScale );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 0.0f );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4.0f, origin[1] - 4.0f, origin[2] - zScale );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 1.0f );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4.0f, origin[1] - 4.0f, z );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 1.0f );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4.0f, origin[1] + 4.0f, z );
|
||||
gEngfuncs.pTriAPI->End();
|
||||
|
||||
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4, origin[1] + 4, origin[2] - zScale );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4, origin[1] - 4, origin[2] - zScale );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4, origin[1] - 4, z );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4, origin[1] + 4, z );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 0.0f );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4.0f, origin[1] + 4.0f, origin[2] - zScale );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 0.0f );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4.0f, origin[1] - 4.0f, origin[2] - zScale );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 1.0f );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] + 4.0f, origin[1] - 4.0f, z );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 1.0f );
|
||||
gEngfuncs.pTriAPI->Vertex3f( origin[0] - 4.0f, origin[1] + 4.0f, z );
|
||||
gEngfuncs.pTriAPI->End();
|
||||
|
||||
// calculate screen position for name and infromation in hud::draw()
|
||||
|
@ -1265,7 +1392,7 @@ void CHudSpectator::DrawOverviewEntities()
|
|||
gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
|
||||
gEngfuncs.pTriAPI->SpriteTexture( hSpriteModel, 0 );
|
||||
|
||||
gEngfuncs.pTriAPI->Color4f( r, g, b, 1.0 );
|
||||
gEngfuncs.pTriAPI->Color4f( r, g, b, 1.0f );
|
||||
|
||||
AngleVectors( angles, forward, NULL, NULL );
|
||||
VectorScale( forward, 512.0f, forward );
|
||||
|
@ -1282,13 +1409,13 @@ void CHudSpectator::DrawOverviewEntities()
|
|||
VectorTransform( forward, rmatrix , left );
|
||||
|
||||
gEngfuncs.pTriAPI->Begin( TRI_TRIANGLES );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 0.0f );
|
||||
gEngfuncs.pTriAPI->Vertex3f( x + right[0], y + right[1], ( z + right[2] ) * zScale);
|
||||
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 1.0f );
|
||||
gEngfuncs.pTriAPI->Vertex3f( x, y, z * zScale );
|
||||
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 1.0f );
|
||||
gEngfuncs.pTriAPI->Vertex3f( x + left[0], y + left[1], ( z + left[2] ) * zScale );
|
||||
gEngfuncs.pTriAPI->End ();
|
||||
}
|
||||
|
@ -1329,7 +1456,7 @@ void CHudSpectator::CheckOverviewEntities()
|
|||
bool CHudSpectator::AddOverviewEntity( int type, struct cl_entity_s *ent, const char *modelname)
|
||||
{
|
||||
HSPRITE hSprite = 0;
|
||||
double duration = -1.0f; // duration -1 means show it only this frame;
|
||||
double duration = -1.0; // duration -1 means show it only this frame;
|
||||
|
||||
if( !ent )
|
||||
return false;
|
||||
|
@ -1451,6 +1578,9 @@ void CHudSpectator::CheckSettings()
|
|||
m_pip->value = INSET_OFF;
|
||||
|
||||
// draw small border around inset view, adjust upper black bar
|
||||
#if USE_VGUI
|
||||
gViewPort->m_pSpectatorPanel->EnableInsetView( m_pip->value != INSET_OFF );
|
||||
#endif
|
||||
}
|
||||
|
||||
int CHudSpectator::ToggleInset( bool allowOff )
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//=============================================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef HUD_SPECTATOR_H
|
||||
#if !defined(HUD_SPECTATOR_H)
|
||||
#define HUD_SPECTATOR_H
|
||||
|
||||
#include "cl_entity.h"
|
||||
|
@ -73,6 +73,7 @@ public:
|
|||
void HandleButtonsDown( int ButtonPressed );
|
||||
void HandleButtonsUp( int ButtonPressed );
|
||||
void FindNextPlayer( bool bReverse );
|
||||
void FindPlayer(const char *name);
|
||||
void DirectorMessage( int iSize, void *pbuf );
|
||||
void SetSpectatorStartPosition();
|
||||
int Init();
|
||||
|
|
|
@ -16,11 +16,10 @@
|
|||
// hud_update.cpp
|
||||
//
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
int CL_ButtonBits( int );
|
||||
void CL_ResetButtonBits( int bits );
|
||||
|
|
|
@ -15,6 +15,22 @@
|
|||
#include "camera.h"
|
||||
#include "in_defs.h"
|
||||
|
||||
#if _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#define HSPRITE WINDOWS_HSPRITE
|
||||
#include <windows.h>
|
||||
#undef HSPRITE
|
||||
#else
|
||||
typedef struct point_s
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
} POINT;
|
||||
#define GetCursorPos(x)
|
||||
#define SetCursorPos(x,y)
|
||||
#endif
|
||||
|
||||
float CL_KeyState( kbutton_t *key );
|
||||
|
||||
extern "C"
|
||||
|
@ -28,16 +44,16 @@ extern cl_enginefunc_t gEngfuncs;
|
|||
|
||||
//-------------------------------------------------- Constants
|
||||
|
||||
#define CAM_DIST_DELTA 1.0
|
||||
#define CAM_ANGLE_DELTA 2.5
|
||||
#define CAM_ANGLE_SPEED 2.5
|
||||
#define CAM_MIN_DIST 30.0
|
||||
#define CAM_ANGLE_MOVE .5
|
||||
#define MAX_ANGLE_DIFF 10.0
|
||||
#define PITCH_MAX 90.0
|
||||
#define PITCH_MIN 0
|
||||
#define YAW_MAX 135.0
|
||||
#define YAW_MIN -135.0
|
||||
#define CAM_DIST_DELTA 1.0f
|
||||
#define CAM_ANGLE_DELTA 2.5f
|
||||
#define CAM_ANGLE_SPEED 2.5f
|
||||
#define CAM_MIN_DIST 30.0f
|
||||
#define CAM_ANGLE_MOVE 0.5f
|
||||
#define MAX_ANGLE_DIFF 10.0f
|
||||
#define PITCH_MAX 90.0f
|
||||
#define PITCH_MIN 0.0f
|
||||
#define YAW_MAX 135.0f
|
||||
#define YAW_MIN -135.0f
|
||||
|
||||
enum ECAM_Command
|
||||
{
|
||||
|
@ -91,35 +107,35 @@ float MoveToward( float cur, float goal, float maxspeed )
|
|||
{
|
||||
if( cur != goal )
|
||||
{
|
||||
if( fabs( cur - goal ) > 180.0 )
|
||||
if( fabs( cur - goal ) > 180.0f )
|
||||
{
|
||||
if( cur < goal )
|
||||
cur += 360.0;
|
||||
cur += 360.0f;
|
||||
else
|
||||
cur -= 360.0;
|
||||
cur -= 360.0f;
|
||||
}
|
||||
|
||||
if( cur < goal )
|
||||
{
|
||||
if( cur < goal - 1.0 )
|
||||
cur += ( goal - cur ) / 4.0;
|
||||
if( cur < goal - 1.0f )
|
||||
cur += ( goal - cur ) * 0.25f;
|
||||
else
|
||||
cur = goal;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( cur > goal + 1.0 )
|
||||
cur -= ( cur - goal ) / 4.0;
|
||||
if( cur > goal + 1.0f )
|
||||
cur -= ( cur - goal ) * 0.25f;
|
||||
else
|
||||
cur = goal;
|
||||
}
|
||||
}
|
||||
|
||||
// bring cur back into range
|
||||
if( cur < 0 )
|
||||
cur += 360.0;
|
||||
else if( cur >= 360 )
|
||||
cur -= 360;
|
||||
if( cur < 0.0f )
|
||||
cur += 360.0f;
|
||||
else if( cur >= 360.0f )
|
||||
cur -= 360.0f;
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
@ -148,11 +164,14 @@ void DLLEXPORT CAM_Think( void )
|
|||
float dist;
|
||||
vec3_t camAngles;
|
||||
float flSensitivity;
|
||||
#ifdef LATER
|
||||
#if LATER
|
||||
int i;
|
||||
#endif
|
||||
vec3_t viewangles;
|
||||
|
||||
if( gEngfuncs.GetMaxClients() > 1 && CL_IsThirdPerson() )
|
||||
CAM_ToFirstPerson();
|
||||
|
||||
switch( (int)cam_command->value )
|
||||
{
|
||||
case CAM_COMMAND_TOTHIRDPERSON:
|
||||
|
@ -168,11 +187,11 @@ void DLLEXPORT CAM_Think( void )
|
|||
|
||||
if( !cam_thirdperson )
|
||||
return;
|
||||
#ifdef LATER
|
||||
#if LATER
|
||||
if( cam_contain->value )
|
||||
{
|
||||
gEngfuncs.GetClientOrigin( origin );
|
||||
ext[0] = ext[1] = ext[2] = 0.0;
|
||||
ext[0] = ext[1] = ext[2] = 0.0f;
|
||||
}
|
||||
#endif
|
||||
camAngles[PITCH] = cam_idealpitch->value;
|
||||
|
@ -195,7 +214,7 @@ void DLLEXPORT CAM_Think( void )
|
|||
//keep the camera within certain limits around the player (ie avoid certain bad viewing angles)
|
||||
if( cam_mouse.x>gEngfuncs.GetWindowCenterX() )
|
||||
{
|
||||
//if( ( camAngles[YAW] >= 225.0 ) || ( camAngles[YAW] < 135.0 ) )
|
||||
//if( ( camAngles[YAW] >= 225.0f ) || ( camAngles[YAW] < 135.0f ) )
|
||||
if( camAngles[YAW] < c_maxyaw->value )
|
||||
{
|
||||
camAngles[YAW] += CAM_ANGLE_MOVE * ( ( cam_mouse.x - gEngfuncs.GetWindowCenterX() ) / 2 );
|
||||
|
@ -207,7 +226,7 @@ void DLLEXPORT CAM_Think( void )
|
|||
}
|
||||
else if( cam_mouse.x<gEngfuncs.GetWindowCenterX() )
|
||||
{
|
||||
//if( ( camAngles[YAW] <= 135.0 ) || ( camAngles[YAW] > 225.0 ) )
|
||||
//if( ( camAngles[YAW] <= 135.0f ) || ( camAngles[YAW] > 225.0f ) )
|
||||
if( camAngles[YAW] > c_minyaw->value )
|
||||
{
|
||||
camAngles[YAW] -= CAM_ANGLE_MOVE * ( ( gEngfuncs.GetWindowCenterX() - cam_mouse.x ) / 2 );
|
||||
|
@ -315,7 +334,7 @@ void DLLEXPORT CAM_Think( void )
|
|||
cam_old_mouse_y = cam_mouse.y * gHUD.GetSensitivity();
|
||||
SetCursorPos( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() );
|
||||
}
|
||||
#ifdef LATER
|
||||
#if LATER
|
||||
if( cam_contain->value )
|
||||
{
|
||||
// check new ideal
|
||||
|
@ -363,12 +382,12 @@ void DLLEXPORT CAM_Think( void )
|
|||
if( camAngles[PITCH] - viewangles[PITCH] != cam_idealpitch->value )
|
||||
camAngles[PITCH] = MoveToward( camAngles[PITCH], cam_idealpitch->value + viewangles[PITCH], CAM_ANGLE_SPEED );
|
||||
|
||||
if( fabs( camAngles[2] - cam_idealdist->value ) < 2.0 )
|
||||
if( fabs( camAngles[2] - cam_idealdist->value ) < 2.0f )
|
||||
camAngles[2] = cam_idealdist->value;
|
||||
else
|
||||
camAngles[2] += ( cam_idealdist->value - camAngles[2] ) / 4.0;
|
||||
camAngles[2] += ( cam_idealdist->value - camAngles[2] ) * 0.25f;
|
||||
}
|
||||
#ifdef LATER
|
||||
#if LATER
|
||||
if( cam_contain->value )
|
||||
{
|
||||
// Test new position
|
||||
|
@ -382,9 +401,9 @@ void DLLEXPORT CAM_Think( void )
|
|||
|
||||
// check line from r_refdef.vieworg to pnt
|
||||
memset( &clip, 0, sizeof(moveclip_t) );
|
||||
ext[0] = ext[1] = ext[2] = 0.0;
|
||||
ext[0] = ext[1] = ext[2] = 0.0f;
|
||||
clip.trace = SV_ClipMoveToEntity( sv.edicts, r_refdef.vieworg, ext, ext, pnt );
|
||||
if( clip.trace.fraction != 1.0 )
|
||||
if( clip.trace.fraction != 1.0f )
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -459,7 +478,7 @@ void CAM_OutUp( void )
|
|||
void CAM_ToThirdPerson( void )
|
||||
{
|
||||
vec3_t viewangles;
|
||||
#if !defined( _DEBUG )
|
||||
#if !_DEBUG
|
||||
if( gEngfuncs.GetMaxClients() > 1 )
|
||||
{
|
||||
// no thirdperson in multiplayer.
|
||||
|
@ -516,9 +535,9 @@ void CAM_Init( void )
|
|||
|
||||
cam_command = gEngfuncs.pfnRegisterVariable( "cam_command", "0", 0 ); // tells camera to go to thirdperson
|
||||
cam_snapto = gEngfuncs.pfnRegisterVariable( "cam_snapto", "0", 0 ); // snap to thirdperson view
|
||||
cam_idealyaw = gEngfuncs.pfnRegisterVariable( "cam_idealyaw", "90", 0 ); // thirdperson yaw
|
||||
cam_idealyaw = gEngfuncs.pfnRegisterVariable( "cam_idealyaw", "0", 0 ); // thirdperson yaw
|
||||
cam_idealpitch = gEngfuncs.pfnRegisterVariable( "cam_idealpitch", "0", 0 ); // thirperson pitch
|
||||
cam_idealdist = gEngfuncs.pfnRegisterVariable( "cam_idealdist", "64", 0 ); // thirdperson distance
|
||||
cam_idealdist = gEngfuncs.pfnRegisterVariable( "cam_idealdist", "128", 0 ); // thirdperson distance
|
||||
cam_contain = gEngfuncs.pfnRegisterVariable( "cam_contain", "0", 0 ); // contain camera to world
|
||||
|
||||
c_maxpitch = gEngfuncs.pfnRegisterVariable( "c_maxpitch", "90.0", 0 );
|
||||
|
|
|
@ -16,17 +16,4 @@
|
|||
// fall over
|
||||
#define ROLL 2
|
||||
|
||||
#ifdef _WIN32
|
||||
#define HSPRITE HSPRITE_win32
|
||||
#include <windows.h>
|
||||
#undef HSPRITE
|
||||
#else
|
||||
typedef struct point_s
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
} POINT;
|
||||
#define GetCursorPos(x)
|
||||
#define SetCursorPos(x,y)
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -28,6 +28,10 @@ extern "C"
|
|||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if USE_VGUI
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
struct kbutton_s DLLEXPORT *KB_Find( const char *name );
|
||||
|
@ -169,7 +173,7 @@ int KB_ConvertString( char *in, char **ppout )
|
|||
*pEnd = '\0';
|
||||
|
||||
pBinding = NULL;
|
||||
if( strlen( binding + 1 ) > 0 )
|
||||
if( binding[1] != '\0' )
|
||||
{
|
||||
// See if there is a binding for binding?
|
||||
pBinding = gEngfuncs.Key_LookupBinding( binding + 1 );
|
||||
|
@ -376,7 +380,11 @@ Return 1 to allow engine to process the key, otherwise, act on it as needed
|
|||
============
|
||||
*/
|
||||
int DLLEXPORT HUD_Key_Event( int down, int keynum, const char *pszCurrentBinding )
|
||||
{
|
||||
{
|
||||
#if USE_VGUI
|
||||
if (gViewPort)
|
||||
return gViewPort->KeyInput(down, keynum, pszCurrentBinding);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -645,11 +653,27 @@ void IN_Impulse( void )
|
|||
void IN_ScoreDown( void )
|
||||
{
|
||||
KeyDown( &in_score );
|
||||
#if USE_VGUI && !USE_NOVGUI_SCOREBOARD
|
||||
if ( gViewPort )
|
||||
{
|
||||
gViewPort->ShowScoreBoard();
|
||||
}
|
||||
#else
|
||||
gHUD.m_Scoreboard.UserCmd_ShowScores();
|
||||
#endif
|
||||
}
|
||||
|
||||
void IN_ScoreUp( void )
|
||||
{
|
||||
KeyUp( &in_score );
|
||||
#if USE_VGUI && !USE_NOVGUI_SCOREBOARD
|
||||
if ( gViewPort )
|
||||
{
|
||||
gViewPort->HideScoreBoard();
|
||||
}
|
||||
#else
|
||||
gHUD.m_Scoreboard.UserCmd_HideScores();
|
||||
#endif
|
||||
}
|
||||
|
||||
void IN_MLookUp( void )
|
||||
|
@ -819,7 +843,7 @@ void DLLEXPORT CL_CreateMove( float frametime, struct usercmd_s *cmd, int active
|
|||
|
||||
// clip to maxspeed
|
||||
spd = gEngfuncs.GetClientMaxspeed();
|
||||
if( spd != 0.0 )
|
||||
if( spd != 0.0f )
|
||||
{
|
||||
// scale the 3 speeds so that the total velocity is not > cl.maxspeed
|
||||
float fmov = sqrt( ( cmd->forwardmove * cmd->forwardmove ) + ( cmd->sidemove * cmd->sidemove ) + ( cmd->upmove * cmd->upmove ) );
|
||||
|
@ -847,6 +871,12 @@ void DLLEXPORT CL_CreateMove( float frametime, struct usercmd_s *cmd, int active
|
|||
//
|
||||
cmd->buttons = CL_ButtonBits( 1 );
|
||||
|
||||
#if USE_VGUI
|
||||
// If they're in a modal dialog, ignore the attack button.
|
||||
if(GetClientVoiceMgr()->IsInSquelchMode())
|
||||
cmd->buttons &= ~IN_ATTACK;
|
||||
#endif
|
||||
|
||||
// Using joystick?
|
||||
if( in_joystick->value )
|
||||
{
|
||||
|
@ -901,9 +931,11 @@ int CL_ButtonBits( int bResetState )
|
|||
|
||||
if( in_attack.state & 3 )
|
||||
{
|
||||
#if !USE_VGUI || USE_NOVGUI_MOTD
|
||||
if( gHUD.m_MOTD.m_bShow )
|
||||
gHUD.m_MOTD.Reset();
|
||||
else
|
||||
#endif
|
||||
bits |= IN_ATTACK;
|
||||
}
|
||||
|
||||
|
@ -1082,6 +1114,10 @@ void InitInput( void )
|
|||
gEngfuncs.pfnAddCommand( "-reload", IN_ReloadUp );
|
||||
gEngfuncs.pfnAddCommand( "+alt1", IN_Alt1Down );
|
||||
gEngfuncs.pfnAddCommand( "-alt1", IN_Alt1Up );
|
||||
gEngfuncs.pfnAddCommand( "+score", IN_ScoreDown );
|
||||
gEngfuncs.pfnAddCommand( "-score", IN_ScoreUp );
|
||||
gEngfuncs.pfnAddCommand( "+showscores", IN_ScoreDown );
|
||||
gEngfuncs.pfnAddCommand( "-showscores", IN_ScoreUp );
|
||||
gEngfuncs.pfnAddCommand( "+graph", IN_GraphDown );
|
||||
gEngfuncs.pfnAddCommand( "-graph", IN_GraphUp );
|
||||
gEngfuncs.pfnAddCommand( "+break", IN_BreakDown );
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "input_mouse.h"
|
||||
|
||||
#ifdef SUPPORT_GOLDSOURCE_INPUT
|
||||
#if SUPPORT_GOLDSOURCE_INPUT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
@ -23,11 +23,11 @@
|
|||
#include "keydefs.h"
|
||||
#include "view.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#define USE_SDL2
|
||||
#if !_WIN32
|
||||
#define USE_SDL2 1
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
#define ARRAYSIZE(p) ( sizeof(p) /sizeof(p[0]) )
|
||||
#include <dlfcn.h>
|
||||
#include <SDL2/SDL_mouse.h>
|
||||
|
@ -114,7 +114,7 @@ static SDLFunction sdlFunctions[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
#include <process.h>
|
||||
#else
|
||||
typedef unsigned int DWORD;
|
||||
|
@ -149,16 +149,16 @@ extern cvar_t *cl_forwardspeed;
|
|||
extern cvar_t *cl_pitchspeed;
|
||||
extern cvar_t *cl_movespeedkey;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
static cvar_t* m_rawinput = NULL;
|
||||
static double s_flRawInputUpdateTime = 0.0f;
|
||||
static bool m_bRawInput = false;
|
||||
static bool m_bMouseThread = false;
|
||||
bool isMouseRelative = false;
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
#include "progdefs.h"
|
||||
extern globalvars_t *gpGlobals;
|
||||
#endif
|
||||
|
||||
int CL_IsDead( void );
|
||||
|
@ -184,7 +184,7 @@ static cvar_t *m_customaccel_max;
|
|||
//Mouse move is raised to this power before being scaled by scale factor
|
||||
static cvar_t *m_customaccel_exponent;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
// if threaded mouse is enabled then the time to sleep between polls
|
||||
static cvar_t *m_mousethread_sleep;
|
||||
#endif
|
||||
|
@ -218,7 +218,7 @@ enum _ControlList
|
|||
AxisTurn
|
||||
};
|
||||
|
||||
#if !defined(USE_SDL2) && defined(_WIN32)
|
||||
#if !USE_SDL2 && _WIN32
|
||||
DWORD dwAxisFlags[JOY_MAX_AXES] =
|
||||
{
|
||||
JOY_RETURNX,
|
||||
|
@ -232,9 +232,9 @@ DWORD dwAxisFlags[JOY_MAX_AXES] =
|
|||
|
||||
DWORD dwAxisMap[ JOY_MAX_AXES ];
|
||||
DWORD dwControlMap[ JOY_MAX_AXES ];
|
||||
#if defined(USE_SDL2)
|
||||
#if USE_SDL2
|
||||
int pdwRawValue[ JOY_MAX_AXES ];
|
||||
#elif defined(_WIN32)
|
||||
#elif _WIN32
|
||||
PDWORD pdwRawValue[ JOY_MAX_AXES ];
|
||||
#endif
|
||||
DWORD joy_oldbuttonstate, joy_oldpovstate;
|
||||
|
@ -242,9 +242,9 @@ DWORD joy_oldbuttonstate, joy_oldpovstate;
|
|||
int joy_id;
|
||||
DWORD joy_numbuttons;
|
||||
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
SDL_GameController *s_pJoystick = NULL;
|
||||
#elif defined(_WIN32)
|
||||
#elif _WIN32
|
||||
DWORD joy_flags;
|
||||
static JOYINFOEX ji;
|
||||
#endif
|
||||
|
@ -276,7 +276,7 @@ cvar_t *joy_wwhack2;
|
|||
|
||||
int joy_avail, joy_advancedinit, joy_haspov;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
unsigned int s_hMouseThreadId = 0;
|
||||
HANDLE s_hMouseThread = 0;
|
||||
HANDLE s_hMouseQuitEvent = 0;
|
||||
|
@ -300,7 +300,7 @@ void Force_CenterView_f (void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
|
||||
LONG mouseThreadActive = 0;
|
||||
LONG mouseThreadCenterX = 0;
|
||||
|
@ -382,14 +382,14 @@ void IN_SetMouseMode(bool enable)
|
|||
|
||||
if(enable)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
if (mouseparmsvalid)
|
||||
restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
|
||||
|
||||
m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0;
|
||||
m_bRawInput = m_rawinput && m_rawinput->value != 0;
|
||||
if(m_bRawInput)
|
||||
{
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
#endif
|
||||
isMouseRelative = true;
|
||||
|
@ -402,10 +402,10 @@ void IN_SetMouseMode(bool enable)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
if(isMouseRelative)
|
||||
{
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
#endif
|
||||
isMouseRelative = false;
|
||||
|
@ -423,7 +423,7 @@ void IN_SetMouseMode(bool enable)
|
|||
|
||||
void IN_SetVisibleMouse(bool visible)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
bool lockEntered = MouseThread_ActiveLock_Enter();
|
||||
#endif
|
||||
|
||||
|
@ -431,7 +431,7 @@ void IN_SetVisibleMouse(bool visible)
|
|||
|
||||
IN_SetMouseMode(!visible);
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
UpdateMouseThreadActive();
|
||||
if(lockEntered) MouseThread_ActiveLock_Exit();
|
||||
#endif
|
||||
|
@ -448,7 +448,7 @@ void GoldSourceInput::IN_ActivateMouse (void)
|
|||
{
|
||||
if (mouseinitialized)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
bool lockEntered = MouseThread_ActiveLock_Enter();
|
||||
#endif
|
||||
|
||||
|
@ -456,7 +456,7 @@ void GoldSourceInput::IN_ActivateMouse (void)
|
|||
|
||||
mouseactive = 1;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
UpdateMouseThreadActive();
|
||||
if(lockEntered) MouseThread_ActiveLock_Exit();
|
||||
#endif
|
||||
|
@ -476,7 +476,7 @@ void GoldSourceInput::IN_DeactivateMouse (void)
|
|||
{
|
||||
if (mouseinitialized)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
bool lockEntered = MouseThread_ActiveLock_Enter();
|
||||
#endif
|
||||
|
||||
|
@ -484,7 +484,7 @@ void GoldSourceInput::IN_DeactivateMouse (void)
|
|||
|
||||
mouseactive = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
UpdateMouseThreadActive();
|
||||
if(lockEntered) MouseThread_ActiveLock_Exit();
|
||||
#endif
|
||||
|
@ -502,7 +502,7 @@ void GoldSourceInput::IN_StartupMouse (void)
|
|||
return;
|
||||
|
||||
mouseinitialized = 1;
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0);
|
||||
|
||||
if (mouseparmsvalid)
|
||||
|
@ -537,7 +537,7 @@ void GoldSourceInput::IN_Shutdown (void)
|
|||
{
|
||||
IN_DeactivateMouse ();
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
if ( s_hMouseQuitEvent )
|
||||
{
|
||||
SetEvent( s_hMouseQuitEvent );
|
||||
|
@ -566,7 +566,7 @@ void GoldSourceInput::IN_Shutdown (void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
for (int j=0; j<ARRAYSIZE(sdlFunctions); ++j) {
|
||||
*(sdlFunctions[j].ppfnFunc) = NULL;
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ FIXME: Call through to engine?
|
|||
void IN_ResetMouse( void )
|
||||
{
|
||||
// no work to do in SDL
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
// reset only if mouse is active and not in visible mode:
|
||||
if(mouseactive && !iVisibleMouse && gEngfuncs.GetWindowCenterX && gEngfuncs.GetWindowCenterY)
|
||||
{
|
||||
|
@ -712,7 +712,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
|
|||
if(active)
|
||||
{
|
||||
int deltaX, deltaY;
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
if ( !m_bRawInput )
|
||||
{
|
||||
if ( m_bMouseThread )
|
||||
|
@ -735,7 +735,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
safe_pfnSDL_GetRelativeMouseState( &deltaX, &deltaY );
|
||||
current_pos.x = deltaX;
|
||||
current_pos.y = deltaY;
|
||||
|
@ -746,7 +746,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
if ( !m_bRawInput )
|
||||
{
|
||||
if ( m_bMouseThread )
|
||||
|
@ -771,7 +771,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
|
|||
my_accum = 0;
|
||||
|
||||
// reset mouse position if required, so there is room to move:
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
// do not reset if mousethread would do it:
|
||||
if ( m_bRawInput || !m_bMouseThread )
|
||||
#else
|
||||
|
@ -779,26 +779,27 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY)
|
|||
#endif
|
||||
IN_ResetMouse();
|
||||
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
// update m_bRawInput occasionally:
|
||||
if ( gpGlobals && gpGlobals->time - s_flRawInputUpdateTime > 1.0f )
|
||||
const float currentTime = gEngfuncs.GetClientTime();
|
||||
if ( currentTime - s_flRawInputUpdateTime > 1.0f || s_flRawInputUpdateTime == 0.0f )
|
||||
{
|
||||
s_flRawInputUpdateTime = gpGlobals->time;
|
||||
s_flRawInputUpdateTime = currentTime;
|
||||
|
||||
bool lockEntered = MouseThread_ActiveLock_Enter();
|
||||
|
||||
m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0;
|
||||
m_bRawInput = m_rawinput && m_rawinput->value != 0;
|
||||
|
||||
if(m_bRawInput && !isMouseRelative)
|
||||
{
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
#endif
|
||||
isMouseRelative = true;
|
||||
}
|
||||
else if(!m_bRawInput && isMouseRelative)
|
||||
{
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE);
|
||||
#endif
|
||||
isMouseRelative = false;
|
||||
|
@ -904,8 +905,8 @@ void GoldSourceInput::IN_MouseMove ( float frametime, usercmd_t *cmd)
|
|||
|
||||
dead_viewangles = viewangles; // keep them actual
|
||||
/*
|
||||
//#define TRACE_TEST
|
||||
#if defined( TRACE_TEST )
|
||||
//#define TRACE_TEST 1
|
||||
#if TRACE_TEST
|
||||
{
|
||||
int mx, my;
|
||||
void V_Move( int mx, int my );
|
||||
|
@ -928,7 +929,7 @@ void GoldSourceInput::IN_Accumulate (void)
|
|||
{
|
||||
if (mouseactive)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
if ( !m_bRawInput )
|
||||
{
|
||||
if ( !m_bMouseThread )
|
||||
|
@ -942,7 +943,7 @@ void GoldSourceInput::IN_Accumulate (void)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
int deltaX, deltaY;
|
||||
safe_pfnSDL_GetRelativeMouseState( &deltaX, &deltaY );
|
||||
mx_accum += deltaX;
|
||||
|
@ -956,7 +957,7 @@ void GoldSourceInput::IN_Accumulate (void)
|
|||
}
|
||||
|
||||
// force the mouse to the center, so there's room to move
|
||||
#ifdef _WIN32
|
||||
#if _WIN32
|
||||
// do not reset if mousethread would do it:
|
||||
if ( m_bRawInput || !m_bMouseThread )
|
||||
#else
|
||||
|
@ -997,7 +998,7 @@ void IN_StartupJoystick (void)
|
|||
|
||||
// assume no joystick
|
||||
joy_avail = 0;
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
int nJoysticks = safe_pfnSDL_NumJoysticks();
|
||||
if ( nJoysticks > 0 )
|
||||
{
|
||||
|
@ -1029,7 +1030,7 @@ void IN_StartupJoystick (void)
|
|||
{
|
||||
gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n");
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
#elif _WIN32
|
||||
int numdevs;
|
||||
JOYCAPS jc;
|
||||
MMRESULT mmr;
|
||||
|
@ -1084,7 +1085,7 @@ void IN_StartupJoystick (void)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
int RawValuePointer (int axis)
|
||||
{
|
||||
switch (axis)
|
||||
|
@ -1101,7 +1102,7 @@ int RawValuePointer (int axis)
|
|||
|
||||
}
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
#elif _WIN32
|
||||
PDWORD RawValuePointer (int axis)
|
||||
{
|
||||
switch (axis)
|
||||
|
@ -1184,7 +1185,7 @@ void Joy_AdvancedUpdate_f (void)
|
|||
dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS;
|
||||
}
|
||||
|
||||
#if !defined(USE_SDL2) && defined(_WIN32)
|
||||
#if !USE_SDL2 && _WIN32
|
||||
// compute the axes to collect from DirectInput
|
||||
joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV;
|
||||
for (i = 0; i < JOY_MAX_AXES; i++)
|
||||
|
@ -1216,7 +1217,7 @@ void GoldSourceInput::IN_Commands (void)
|
|||
|
||||
// loop through the joystick buttons
|
||||
// key a joystick event or auxillary event for higher number buttons for each state change
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
buttonstate = 0;
|
||||
for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ )
|
||||
{
|
||||
|
@ -1230,7 +1231,7 @@ void GoldSourceInput::IN_Commands (void)
|
|||
{
|
||||
pdwRawValue[i] = RawValuePointer(i);
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
#elif _WIN32
|
||||
buttonstate = ji.dwButtons;
|
||||
#endif
|
||||
|
||||
|
@ -1256,7 +1257,7 @@ void GoldSourceInput::IN_Commands (void)
|
|||
// this avoids any potential problems related to moving from one
|
||||
// direction to another without going through the center position
|
||||
povstate = 0;
|
||||
#if !defined(USE_SDL2) && defined(_WIN32)
|
||||
#if !USE_SDL2 && _WIN32
|
||||
if(ji.dwPOV != JOY_POVCENTERED)
|
||||
{
|
||||
if (ji.dwPOV == JOY_POVFORWARD)
|
||||
|
@ -1294,10 +1295,10 @@ IN_ReadJoystick
|
|||
*/
|
||||
int IN_ReadJoystick (void)
|
||||
{
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
safe_pfnSDL_JoystickUpdate();
|
||||
return 1;
|
||||
#elif defined(_WIN32)
|
||||
#elif _WIN32
|
||||
memset (&ji, 0, sizeof(ji));
|
||||
ji.dwSize = sizeof(ji);
|
||||
ji.dwFlags = joy_flags;
|
||||
|
@ -1374,9 +1375,9 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd )
|
|||
for (i = 0; i < JOY_MAX_AXES; i++)
|
||||
{
|
||||
// get the floating point zero-centered, potentially-inverted data for the current axis
|
||||
#ifdef USE_SDL2
|
||||
#if USE_SDL2
|
||||
fAxisValue = (float)pdwRawValue[i];
|
||||
#elif defined(_WIN32)
|
||||
#elif _WIN32
|
||||
fAxisValue = (float) *pdwRawValue[i];
|
||||
fAxisValue -= 32768.0;
|
||||
#endif
|
||||
|
@ -1570,8 +1571,9 @@ void GoldSourceInput::IN_Init (void)
|
|||
m_customaccel_max = gEngfuncs.pfnRegisterVariable ( "m_customaccel_max", "0", FCVAR_ARCHIVE );
|
||||
m_customaccel_exponent = gEngfuncs.pfnRegisterVariable ( "m_customaccel_exponent", "1", FCVAR_ARCHIVE );
|
||||
|
||||
#ifdef _WIN32
|
||||
m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0;
|
||||
#if _WIN32
|
||||
m_rawinput = gEngfuncs.pfnGetCvarPointer("m_rawinput");
|
||||
m_bRawInput = m_rawinput && m_rawinput->value != 0;
|
||||
m_bMouseThread = gEngfuncs.CheckParm ("-mousethread", NULL ) != NULL;
|
||||
m_mousethread_sleep = gEngfuncs.pfnRegisterVariable ( "m_mousethread_sleep", "1", FCVAR_ARCHIVE ); // default to less than 1000 Hz
|
||||
|
||||
|
@ -1600,8 +1602,8 @@ void GoldSourceInput::IN_Init (void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDL2
|
||||
#ifdef __APPLE__
|
||||
#if USE_SDL2
|
||||
#if __APPLE__
|
||||
#define SDL2_FULL_LIBNAME "libsdl2-2.0.0.dylib"
|
||||
#else
|
||||
#define SDL2_FULL_LIBNAME "libSDL2-2.0.so.0"
|
||||
|
|
|
@ -10,7 +10,7 @@ cvar_t *in_joystick;
|
|||
|
||||
FWGSInput fwgsInput;
|
||||
|
||||
#ifdef SUPPORT_GOLDSOURCE_INPUT
|
||||
#if SUPPORT_GOLDSOURCE_INPUT
|
||||
GoldSourceInput goldSourceInput;
|
||||
AbstractInput* currentInput = &goldSourceInput;
|
||||
#else
|
||||
|
@ -68,7 +68,7 @@ void IN_Shutdown( void )
|
|||
|
||||
void IN_Init( void )
|
||||
{
|
||||
#ifdef SUPPORT_GOLDSOURCE_INPUT
|
||||
#if SUPPORT_GOLDSOURCE_INPUT
|
||||
if (IsXashFWGS()) {
|
||||
gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" );
|
||||
currentInput = &fwgsInput;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#pragma once
|
||||
#ifndef INPUT_MOUSE_H
|
||||
|
||||
#include "build.h"
|
||||
|
||||
#if !defined(INPUT_MOUSE_H)
|
||||
#define INPUT_MOUSE_H
|
||||
#include "cl_dll.h"
|
||||
#include "usercmd.h"
|
||||
|
@ -45,8 +48,23 @@ protected:
|
|||
};
|
||||
|
||||
// No need for goldsource input support on the platforms that are not supported by GoldSource.
|
||||
#if defined(GOLDSOURCE_SUPPORT) && (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && (defined(__i386) || defined(_M_IX86))
|
||||
#define SUPPORT_GOLDSOURCE_INPUT
|
||||
#if GOLDSOURCE_SUPPORT && ( XASH_WIN32 || ( XASH_LINUX && !XASH_ANDROID ) || XASH_APPLE ) && XASH_X86
|
||||
#define SUPPORT_GOLDSOURCE_INPUT 1
|
||||
|
||||
#if _WIN32
|
||||
#define HSPRITE WINDOWS_HSPRITE
|
||||
#include <windows.h>
|
||||
#undef HSPRITE
|
||||
#else
|
||||
typedef struct point_s
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
} POINT;
|
||||
#define GetCursorPos(x)
|
||||
#define SetCursorPos(x,y)
|
||||
#endif
|
||||
|
||||
class GoldSourceInput : public AbstractInput
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -82,42 +82,42 @@ void IN_ToggleButtons( float forwardmove, float sidemove )
|
|||
}
|
||||
}
|
||||
|
||||
if( forwardmove > 0.7 && !( moveflags & F ) )
|
||||
if( forwardmove > 0.7f && !( moveflags & F ) )
|
||||
{
|
||||
moveflags |= F;
|
||||
in_forward.state |= BUTTON_DOWN;
|
||||
}
|
||||
if( forwardmove < 0.7 && ( moveflags & F ) )
|
||||
if( forwardmove < 0.7f && ( moveflags & F ) )
|
||||
{
|
||||
moveflags &= ~F;
|
||||
in_forward.state &= ~BUTTON_DOWN;
|
||||
}
|
||||
if( forwardmove < -0.7 && !( moveflags & B ) )
|
||||
if( forwardmove < -0.7f && !( moveflags & B ) )
|
||||
{
|
||||
moveflags |= B;
|
||||
in_back.state |= BUTTON_DOWN;
|
||||
}
|
||||
if( forwardmove > -0.7 && ( moveflags & B ) )
|
||||
if( forwardmove > -0.7f && ( moveflags & B ) )
|
||||
{
|
||||
moveflags &= ~B;
|
||||
in_back.state &= ~BUTTON_DOWN;
|
||||
}
|
||||
if( sidemove > 0.9 && !( moveflags & R ) )
|
||||
if( sidemove > 0.9f && !( moveflags & R ) )
|
||||
{
|
||||
moveflags |= R;
|
||||
in_moveright.state |= BUTTON_DOWN;
|
||||
}
|
||||
if( sidemove < 0.9 && ( moveflags & R ) )
|
||||
if( sidemove < 0.9f && ( moveflags & R ) )
|
||||
{
|
||||
moveflags &= ~R;
|
||||
in_moveright.state &= ~BUTTON_DOWN;
|
||||
}
|
||||
if( sidemove < -0.9 && !( moveflags & L ) )
|
||||
if( sidemove < -0.9f && !( moveflags & L ) )
|
||||
{
|
||||
moveflags |= L;
|
||||
in_moveleft.state |= BUTTON_DOWN;
|
||||
}
|
||||
if( sidemove > -0.9 && ( moveflags & L ) )
|
||||
if( sidemove > -0.9f && ( moveflags & L ) )
|
||||
{
|
||||
moveflags &= ~L;
|
||||
in_moveleft.state &= ~BUTTON_DOWN;
|
||||
|
@ -187,9 +187,11 @@ void FWGSInput::IN_Move( float frametime, usercmd_t *cmd )
|
|||
viewangles[YAW] -= ac_sidemove * 5;
|
||||
ac_sidemove = 0;
|
||||
}
|
||||
#if !USE_VGUI || USE_NOVGUI_MOTD
|
||||
if( gHUD.m_MOTD.m_bShow )
|
||||
gHUD.m_MOTD.scroll += rel_pitch;
|
||||
else
|
||||
#endif
|
||||
viewangles[PITCH] += rel_pitch;
|
||||
|
||||
if( viewangles[PITCH] > cl_pitchdown->value )
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if USE_VGUI
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#endif
|
||||
|
||||
#define MAX_MENU_STRING 512
|
||||
char g_szMenuString[MAX_MENU_STRING];
|
||||
char g_szPrelocalisedMenuString[MAX_MENU_STRING];
|
||||
|
@ -78,6 +82,11 @@ int CHudMenu::Draw( float flTime )
|
|||
}
|
||||
|
||||
// don't draw the menu if the scoreboard is being shown
|
||||
#if USE_VGUI
|
||||
if( gViewPort && gViewPort->IsScoreBoardVisible() )
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
// draw the menu, along the left-hand side of the screen
|
||||
// count the number of newlines
|
||||
int nlc = 0;
|
||||
|
@ -148,7 +157,7 @@ int CHudMenu::MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf )
|
|||
{
|
||||
if( !m_fWaitingForMore ) // this is the start of a new menu
|
||||
{
|
||||
strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING );
|
||||
strncpy( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -160,13 +169,13 @@ int CHudMenu::MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf )
|
|||
if( !NeedMore )
|
||||
{
|
||||
// we have the whole string, so we can localise it now
|
||||
strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING );
|
||||
strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING - 1 );
|
||||
g_szMenuString[MAX_MENU_STRING - 1] = '\0';
|
||||
|
||||
// Swap in characters
|
||||
if( KB_ConvertString( g_szMenuString, &temp ) )
|
||||
{
|
||||
strncpy( g_szMenuString, temp, MAX_MENU_STRING );
|
||||
strncpy( g_szMenuString, temp, MAX_MENU_STRING - 1 );
|
||||
g_szMenuString[MAX_MENU_STRING - 1] = '\0';
|
||||
free( temp );
|
||||
}
|
||||
|
|
|
@ -66,22 +66,22 @@ float CHudMessage::FadeBlend( float fadein, float fadeout, float hold, float loc
|
|||
float fadeTime = fadein + hold;
|
||||
float fadeBlend;
|
||||
|
||||
if( localTime < 0 )
|
||||
if( localTime < 0.0f )
|
||||
return 0;
|
||||
|
||||
if( localTime < fadein )
|
||||
{
|
||||
fadeBlend = 1 - ( ( fadein - localTime ) / fadein );
|
||||
fadeBlend = 1.0f - ( ( fadein - localTime ) / fadein );
|
||||
}
|
||||
else if( localTime > fadeTime )
|
||||
{
|
||||
if( fadeout > 0 )
|
||||
fadeBlend = 1 - ( ( localTime - fadeTime ) / fadeout );
|
||||
if( fadeout > 0.0f )
|
||||
fadeBlend = 1.0f - ( ( localTime - fadeTime ) / fadeout );
|
||||
else
|
||||
fadeBlend = 0;
|
||||
fadeBlend = 0.0f;
|
||||
}
|
||||
else
|
||||
fadeBlend = 1;
|
||||
fadeBlend = 1.0f;
|
||||
|
||||
return fadeBlend;
|
||||
}
|
||||
|
@ -91,14 +91,14 @@ int CHudMessage::XPosition( float x, int width, int totalWidth )
|
|||
{
|
||||
int xPos;
|
||||
|
||||
if( x == -1 )
|
||||
if( x == -1.0f )
|
||||
{
|
||||
xPos = ( ScreenWidth - width ) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( x < 0 )
|
||||
xPos = ( 1.0 + x ) * ScreenWidth - totalWidth; // Alight right
|
||||
if( x < 0.0f )
|
||||
xPos = ( 1.0f + x ) * ScreenWidth - totalWidth; // Alight right
|
||||
else
|
||||
xPos = x * ScreenWidth;
|
||||
}
|
||||
|
@ -116,12 +116,12 @@ int CHudMessage::YPosition( float y, int height )
|
|||
int yPos;
|
||||
|
||||
if( y == -1 ) // Centered?
|
||||
yPos = ( ScreenHeight - height ) * 0.5;
|
||||
yPos = ( ScreenHeight - height ) * 0.5f;
|
||||
else
|
||||
{
|
||||
// Alight bottom?
|
||||
if ( y < 0 )
|
||||
yPos = ( 1.0 + y ) * ScreenHeight - height; // Alight bottom
|
||||
yPos = ( 1.0f + y ) * ScreenHeight - height; // Alight bottom
|
||||
else // align top
|
||||
yPos = y * ScreenHeight;
|
||||
}
|
||||
|
@ -164,18 +164,20 @@ void CHudMessage::MessageScanNextChar( void )
|
|||
float deltaTime = m_parms.time - m_parms.charTime;
|
||||
|
||||
destRed = destGreen = destBlue = 0;
|
||||
if ( m_parms.time > m_parms.fadeTime )
|
||||
if( m_parms.time > m_parms.fadeTime )
|
||||
{
|
||||
blend = m_parms.fadeBlend;
|
||||
}
|
||||
else if ( deltaTime > m_parms.pMessage->fxtime )
|
||||
else if( deltaTime > m_parms.pMessage->fxtime )
|
||||
{
|
||||
blend = 0; // pure dest
|
||||
}
|
||||
else
|
||||
{
|
||||
destRed = m_parms.pMessage->r2;
|
||||
destGreen = m_parms.pMessage->g2;
|
||||
destBlue = m_parms.pMessage->b2;
|
||||
blend = 255 - (deltaTime * (1.0/m_parms.pMessage->fxtime) * 255.0 + 0.5);
|
||||
blend = 255 - ( deltaTime * ( 1.0f / m_parms.pMessage->fxtime) * 255.0f + 0.5f );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -208,7 +210,7 @@ void CHudMessage::MessageScanStart( void )
|
|||
|
||||
if( m_parms.time < m_parms.pMessage->fadein )
|
||||
{
|
||||
m_parms.fadeBlend = ( ( m_parms.pMessage->fadein - m_parms.time ) * ( 1.0 / m_parms.pMessage->fadein ) * 255 );
|
||||
m_parms.fadeBlend = ( ( m_parms.pMessage->fadein - m_parms.time ) * ( 1.0f / m_parms.pMessage->fadein ) * 255 );
|
||||
}
|
||||
else if( m_parms.time > m_parms.fadeTime )
|
||||
{
|
||||
|
@ -292,7 +294,7 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
|
|||
|
||||
for( j = 0; j < m_parms.lineLength; j++ )
|
||||
{
|
||||
m_parms.text = pLineStart[j];
|
||||
m_parms.text = (unsigned char)pLineStart[j];
|
||||
int next = m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text];
|
||||
MessageScanNextChar();
|
||||
|
||||
|
@ -350,9 +352,9 @@ int CHudMessage::Draw( float fTime )
|
|||
// Assume m_parms.time contains last time
|
||||
if( m_pMessages[i] )
|
||||
{
|
||||
pMessage = m_pMessages[i];
|
||||
// pMessage = m_pMessages[i];
|
||||
if( m_startTime[i] > gHUD.m_flTime )
|
||||
m_startTime[i] = gHUD.m_flTime + m_parms.time - m_startTime[i] + 0.2; // Server takes 0.2 seconds to spawn, adjust for this
|
||||
m_startTime[i] = gHUD.m_flTime + m_parms.time - m_startTime[i] + 0.2f; // Server takes 0.2 seconds to spawn, adjust for this
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,11 +430,11 @@ void CHudMessage::MessageAdd( const char *pName, float time )
|
|||
g_pCustomMessage.g2 = 110;
|
||||
g_pCustomMessage.b2 = 0;
|
||||
g_pCustomMessage.a2 = 0;
|
||||
g_pCustomMessage.x = -1; // Centered
|
||||
g_pCustomMessage.y = 0.7;
|
||||
g_pCustomMessage.fadein = 0.01;
|
||||
g_pCustomMessage.fadeout = 1.5;
|
||||
g_pCustomMessage.fxtime = 0.25;
|
||||
g_pCustomMessage.x = -1.0f; // Centered
|
||||
g_pCustomMessage.y = 0.7f;
|
||||
g_pCustomMessage.fadein = 0.01f;
|
||||
g_pCustomMessage.fadeout = 1.5f;
|
||||
g_pCustomMessage.fxtime = 0.25f;
|
||||
g_pCustomMessage.holdtime = 5;
|
||||
g_pCustomMessage.pName = g_pCustomName;
|
||||
strcpy( g_pCustomText, pName );
|
||||
|
@ -452,9 +454,9 @@ void CHudMessage::MessageAdd( const char *pName, float time )
|
|||
}
|
||||
|
||||
// get rid of any other messages in same location (only one displays at a time)
|
||||
if( fabs( tempMessage->y - m_pMessages[j]->y ) < 0.0001 )
|
||||
if( fabs( tempMessage->y - m_pMessages[j]->y ) < 0.0001f )
|
||||
{
|
||||
if ( fabs( tempMessage->x - m_pMessages[j]->x ) < 0.0001 )
|
||||
if( fabs( tempMessage->x - m_pMessages[j]->x ) < 0.0001f )
|
||||
{
|
||||
m_pMessages[j] = NULL;
|
||||
}
|
||||
|
|
|
@ -1,161 +0,0 @@
|
|||
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "cl_entity.h"
|
||||
#include "triangleapi.h"
|
||||
#include "overview.h"
|
||||
|
||||
// these are included for the math functions
|
||||
#include "com_model.h"
|
||||
#include "studio_util.h"
|
||||
|
||||
#pragma warning(disable: 4244)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
int CHudOverview::Init()
|
||||
{
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Loads new icons
|
||||
//-----------------------------------------------------------------------------
|
||||
int CHudOverview::VidInit()
|
||||
{
|
||||
m_hsprPlayer = gEngfuncs.pfnSPR_Load( "sprites/ring.spr" );
|
||||
m_hsprViewcone = gEngfuncs.pfnSPR_Load( "sprites/camera.spr" );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : flTime -
|
||||
// intermission -
|
||||
//-----------------------------------------------------------------------------
|
||||
int CHudOverview::Draw( float flTime )
|
||||
{
|
||||
#if 0
|
||||
// only draw in overview mode
|
||||
if( !gEngfuncs.Overview_GetOverviewState() )
|
||||
return 1;
|
||||
|
||||
// make sure we have player info
|
||||
//gViewPort->GetAllPlayersInfo();
|
||||
gHUD.m_Scoreboard.GetAllPlayersInfo();
|
||||
|
||||
// calculate player size on the overview
|
||||
int x1, y1, x2, y2;
|
||||
float v0[3] = { 0.0f }, v1[3] = { 64.0f, 64.0f };
|
||||
gEngfuncs.Overview_WorldToScreen( v0, &x1, &y1 );
|
||||
gEngfuncs.Overview_WorldToScreen( v1, &x2, &y2 );
|
||||
float scale = abs( x2 - x1 );
|
||||
|
||||
// loop through all the players and draw them on the map
|
||||
for( int i = 1; i < MAX_PLAYERS; i++ )
|
||||
{
|
||||
cl_entity_t *pl = gEngfuncs.GetEntityByIndex( i );
|
||||
|
||||
if( pl && pl->player && pl->curstate.health > 0 && pl->curstate.solid != SOLID_NOT )
|
||||
{
|
||||
int x, y, z = 0;
|
||||
float v[3] = { pl->origin[0], pl->origin[1], 0 };
|
||||
gEngfuncs.Overview_WorldToScreen( v, &x, &y );
|
||||
|
||||
// hack in some team colors
|
||||
float r, g, bc;
|
||||
if( g_PlayerExtraInfo[i].teamnumber == 1 )
|
||||
{
|
||||
r = 0.0f; g = 0.0f; bc = 1.0f;
|
||||
}
|
||||
else if( g_PlayerExtraInfo[i].teamnumber == 2 )
|
||||
{
|
||||
r = 1.0f; g = 0.0f; bc = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// just use the default orange color if the team isn't set
|
||||
r = 1.0f; g = 0.7f; bc = 0.0f;
|
||||
}
|
||||
|
||||
// set the current texture
|
||||
gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( m_hsprPlayer ), 0 );
|
||||
|
||||
// additive render mode
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
|
||||
|
||||
// no culling
|
||||
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
|
||||
|
||||
// draw a square
|
||||
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
|
||||
|
||||
// set the color to be that of the team
|
||||
gEngfuncs.pTriAPI->Color4f( r, g, bc, 1.0f );
|
||||
|
||||
// calculate rotational matrix
|
||||
vec3_t a, b, angles;
|
||||
float rmatrix[3][4]; // transformation matrix
|
||||
VectorCopy( pl->angles, angles );
|
||||
angles[0] = 0.0f;
|
||||
angles[1] += 90.f;
|
||||
angles[1] = -angles[1];
|
||||
angles[2] = 0.0f;
|
||||
AngleMatrix( angles, rmatrix );
|
||||
a[2] = 0;
|
||||
|
||||
a[0] = -scale; a[1] = -scale;
|
||||
VectorTransform( a, rmatrix, b );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z );
|
||||
|
||||
a[0] = -scale; a[1] = scale;
|
||||
VectorTransform( a, rmatrix, b );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z );
|
||||
|
||||
a[0] = scale; a[1] = scale;
|
||||
VectorTransform( a, rmatrix, b );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z );
|
||||
|
||||
a[0] = scale; a[1] = -scale;
|
||||
VectorTransform( a, rmatrix, b );
|
||||
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
|
||||
gEngfuncs.pTriAPI->Vertex3f( x + b[0], y + b[1], z );
|
||||
|
||||
// finish up
|
||||
gEngfuncs.pTriAPI->End();
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
|
||||
|
||||
// draw the players name and health underneath
|
||||
char string[256];
|
||||
sprintf( string, "%s (%i%%)", g_PlayerInfoList[i].name, pl->curstate.health );
|
||||
DrawConsoleString( x, y + ( 1.1 * scale ), string );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: called every time a server is connected to
|
||||
//-----------------------------------------------------------------------------
|
||||
void CHudOverview::InitHUDData()
|
||||
{
|
||||
//this block would force the spectator view to be on
|
||||
//gEngfuncs.Overview_SetDrawOverview( 1 );
|
||||
//gEngfuncs.Overview_SetDrawInset( 0 );
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#pragma once
|
||||
#ifndef OVERVIEW_H
|
||||
#define OVERVIEW_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles the drawing of the top-down map and all the things on it
|
||||
//-----------------------------------------------------------------------------
|
||||
class CHudOverview : public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init();
|
||||
int VidInit();
|
||||
|
||||
int Draw( float flTime );
|
||||
void InitHUDData( void );
|
||||
|
||||
private:
|
||||
HSPRITE m_hsprPlayer;
|
||||
HSPRITE m_hsprViewcone;
|
||||
};
|
||||
#endif // OVERVIEW_H
|
|
@ -16,7 +16,7 @@
|
|||
// parsemsg.h
|
||||
//
|
||||
#pragma once
|
||||
#ifndef PARSEMSG_H
|
||||
#if !defined(PARSEMSG_H)
|
||||
#define PARSEMSG_H
|
||||
|
||||
#define ASSERT( x )
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if USE_VGUI
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#endif
|
||||
|
||||
extern float *GetClientColor( int clientIndex );
|
||||
|
||||
#define MAX_LINES 5
|
||||
|
@ -95,6 +99,12 @@ int CHudSayText::Draw( float flTime )
|
|||
{
|
||||
int y = Y_START;
|
||||
|
||||
#if USE_VGUI
|
||||
if( ( gViewPort && gViewPort->AllowedToPrintText() == FALSE ) || !m_HUD_saytext->value )
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
|
||||
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
|
||||
flScrollTime = Q_min( flScrollTime, flTime + m_HUD_saytext_time->value );
|
||||
|
||||
|
@ -123,7 +133,7 @@ int CHudSayText::Draw( float flTime )
|
|||
static char buf[MAX_PLAYER_NAME_LENGTH + 32];
|
||||
|
||||
// draw the first x characters in the player color
|
||||
strncpy( buf, g_szLineBuffer[i], Q_min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 32 ) );
|
||||
strncpy( buf, g_szLineBuffer[i], Q_min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 31 ) );
|
||||
buf[Q_min( g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 31 )] = 0;
|
||||
DrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
|
||||
int x = DrawConsoleString( LINE_START, y, buf );
|
||||
|
@ -156,9 +166,18 @@ int CHudSayText::MsgFunc_SayText( const char *pszName, int iSize, void *pbuf )
|
|||
|
||||
void CHudSayText::SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex )
|
||||
{
|
||||
int i;
|
||||
#if USE_VGUI
|
||||
if( gViewPort && gViewPort->AllowedToPrintText() == FALSE )
|
||||
{
|
||||
// Print it straight to the console
|
||||
ConsolePrint( pszBuf );
|
||||
return;
|
||||
}
|
||||
#else
|
||||
ConsolePrint( pszBuf );
|
||||
#endif
|
||||
|
||||
int i;
|
||||
// find an empty string slot
|
||||
for( i = 0; i < MAX_LINES; i++ )
|
||||
{
|
||||
|
@ -259,7 +278,7 @@ void CHudSayText::EnsureTextFitsInOneLineAndWrapIfHaveTo( int line )
|
|||
if( !last_break )
|
||||
last_break = x - 1;
|
||||
|
||||
x = last_break;
|
||||
// x = last_break;
|
||||
|
||||
// find an empty string slot
|
||||
int j;
|
||||
|
|
|
@ -28,35 +28,34 @@
|
|||
|
||||
cvar_t *cl_scoreboard_bg;
|
||||
cvar_t *cl_showpacketloss;
|
||||
hud_player_info_t g_PlayerInfoList[MAX_PLAYERS + 1]; // player info from the engine
|
||||
extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS + 1]; // additional player info sent directly to the client dll
|
||||
team_info_t g_TeamInfo[MAX_TEAMS + 1];
|
||||
int g_iUser1;
|
||||
int g_iUser2;
|
||||
int g_iUser3;
|
||||
int g_iTeamNumber;
|
||||
int g_iPlayerClass;
|
||||
|
||||
//#include "vgui_TeamFortressViewport.h"
|
||||
|
||||
#if USE_VGUI
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#endif
|
||||
|
||||
DECLARE_COMMAND( m_Scoreboard, ShowScores )
|
||||
DECLARE_COMMAND( m_Scoreboard, HideScores )
|
||||
|
||||
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
|
||||
DECLARE_MESSAGE( m_Scoreboard, ScoreInfo )
|
||||
DECLARE_MESSAGE( m_Scoreboard, TeamInfo )
|
||||
DECLARE_MESSAGE( m_Scoreboard, TeamScore )
|
||||
#endif
|
||||
|
||||
int CHudScoreboard::Init( void )
|
||||
{
|
||||
gHUD.AddHudElem( this );
|
||||
|
||||
// Hook messages & commands here
|
||||
HOOK_COMMAND( "+showscores", ShowScores );
|
||||
HOOK_COMMAND( "-showscores", HideScores );
|
||||
// HOOK_COMMAND( "+showscores", ShowScores );
|
||||
// HOOK_COMMAND( "-showscores", HideScores );
|
||||
|
||||
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
|
||||
HOOK_MESSAGE( ScoreInfo );
|
||||
HOOK_MESSAGE( TeamScore );
|
||||
HOOK_MESSAGE( TeamInfo );
|
||||
#endif
|
||||
|
||||
InitHUDData();
|
||||
|
||||
|
@ -171,12 +170,12 @@ int CHudScoreboard::Draw( float fTime )
|
|||
DrawUtfString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 );
|
||||
}
|
||||
|
||||
list_slot += 1.2;
|
||||
list_slot += 1.2f;
|
||||
ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP );
|
||||
// xpos = NAME_RANGE_MIN + xpos_rel;
|
||||
FillRGBA( xpos - 4, ypos, FAR_RIGHT -2, 1, 255, 140, 0, 255 ); // draw the seperator line
|
||||
|
||||
list_slot += 0.8;
|
||||
list_slot += 0.8f;
|
||||
|
||||
if( !gHUD.m_Teamplay )
|
||||
{
|
||||
|
@ -328,7 +327,7 @@ int CHudScoreboard::Draw( float fTime )
|
|||
}
|
||||
|
||||
// draw all the players who are not in a team
|
||||
list_slot += 0.5;
|
||||
list_slot += 0.5f;
|
||||
DrawPlayers( xpos_rel, list_slot, 0, "" );
|
||||
|
||||
return 1;
|
||||
|
@ -454,7 +453,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset,
|
|||
if( g_PlayerInfoList[best_player].packetloss >= 63 )
|
||||
{
|
||||
UnpackRGB( r, g, b, RGB_REDISH );
|
||||
sprintf( buf, " !!!!" );
|
||||
strcpy( buf, " !!!!" );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -502,7 +501,9 @@ int CHudScoreboard::MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbu
|
|||
g_PlayerExtraInfo[cl].playerclass = playerclass;
|
||||
g_PlayerExtraInfo[cl].teamnumber = teamnumber;
|
||||
|
||||
//gViewPort->UpdateOnPlayerInfo();
|
||||
#if USE_VGUI
|
||||
gViewPort->UpdateOnPlayerInfo();
|
||||
#endif
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -521,7 +522,7 @@ int CHudScoreboard::MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf
|
|||
if( cl > 0 && cl <= MAX_PLAYERS )
|
||||
{
|
||||
// set the players team
|
||||
strncpy( g_PlayerExtraInfo[cl].teamname, READ_STRING(), MAX_TEAM_NAME );
|
||||
strncpy( g_PlayerExtraInfo[cl].teamname, READ_STRING(), MAX_TEAM_NAME - 1 );
|
||||
}
|
||||
|
||||
// rebuild the list of teams
|
||||
|
@ -563,7 +564,7 @@ int CHudScoreboard::MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf
|
|||
}
|
||||
m_iNumTeams = Q_max( j, m_iNumTeams );
|
||||
|
||||
strncpy( g_TeamInfo[j].name, g_PlayerExtraInfo[i].teamname, MAX_TEAM_NAME );
|
||||
strncpy( g_TeamInfo[j].name, g_PlayerExtraInfo[i].teamname, MAX_TEAM_NAME - 1 );
|
||||
g_TeamInfo[j].players = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
//======== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ========
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||
// the agreement/contract under which the contents have been supplied.
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// $Log: $
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include <windows.h>
|
||||
#include <dsound.h>
|
||||
#include <mmsystem.h>
|
||||
#include "r_studioint.h"
|
||||
|
||||
extern engine_studio_api_t IEngineStudio;
|
||||
|
||||
#define RENDERTYPE_UNDEFINED 0
|
||||
#define RENDERTYPE_SOFTWARE 1
|
||||
#define RENDERTYPE_HARDWARE 2
|
||||
|
||||
#define ENGINE_LAUNCHER_API_VERSION 1
|
||||
|
||||
LPDIRECTSOUND lpDS = NULL;
|
||||
LPDIRECTSOUNDBUFFER lpDSBuf = NULL;
|
||||
LPHWAVEOUT lpHW = NULL;
|
||||
|
||||
static HMODULE hEngine = 0;
|
||||
|
||||
typedef struct engine_api_s
|
||||
{
|
||||
int version;
|
||||
int rendertype;
|
||||
int size;
|
||||
|
||||
// Functions
|
||||
void ( *unused1 ) ( void );
|
||||
void ( *unused2 ) ( void );
|
||||
void ( *unused3 ) ( void );
|
||||
void ( *unused4 ) ( void );
|
||||
void ( *unused5 ) ( void );
|
||||
void ( *unused6 ) ( void );
|
||||
void ( *unused7 ) ( void );
|
||||
void ( *unused8 ) ( void );
|
||||
void ( *unused9 ) ( void );
|
||||
void ( *unused10 ) ( void );
|
||||
void ( *unused11 ) ( void );
|
||||
void ( *unused12 ) ( void );
|
||||
void ( *unused13 ) ( void );
|
||||
void ( *unused14 ) ( void );
|
||||
void ( *unused15 ) ( void );
|
||||
void ( *unused16 ) ( void );
|
||||
void ( *unused17 ) ( void );
|
||||
void ( *unused18 ) ( void );
|
||||
void ( *unused19 ) ( void );
|
||||
void ( *unused20 ) ( void );
|
||||
void ( *unused21 ) ( void );
|
||||
void ( *unused22 ) ( void );
|
||||
void ( *unused23 ) ( void );
|
||||
void ( *unused24 ) ( void );
|
||||
void ( *unused25 ) ( void );
|
||||
void ( *unused26 ) ( void );
|
||||
void ( *unused27 ) ( void );
|
||||
void ( *unused28 ) ( void );
|
||||
void ( *unused29 ) ( void );
|
||||
void ( *unused30 ) ( void );
|
||||
void ( *unused31 ) ( void );
|
||||
void ( *unused32 ) ( void );
|
||||
void ( *unused33 ) ( void );
|
||||
void ( *unused34 ) ( void );
|
||||
|
||||
void ( *S_GetDSPointer ) ( struct IDirectSound **lpDS, struct IDirectSoundBuffer **lpDSBuf );
|
||||
void *( *S_GetWAVPointer ) ( void );
|
||||
|
||||
void ( *unused35 ) ( void );
|
||||
void ( *unused36 ) ( void );
|
||||
void ( *unused37 ) ( void );
|
||||
void ( *unused38 ) ( void );
|
||||
void ( *unused39 ) ( void );
|
||||
void ( *unused40 ) ( void );
|
||||
void ( *unused41 ) ( void );
|
||||
void ( *unused42 ) ( void );
|
||||
void ( *unused43 ) ( void );
|
||||
void ( *unused44 ) ( void );
|
||||
void ( *unused45 ) ( void );
|
||||
void ( *unused46 ) ( void );
|
||||
void ( *unused47 ) ( void );
|
||||
void ( *unused48 ) ( void );
|
||||
void ( *unused49 ) ( void );
|
||||
void ( *unused50 ) ( void );
|
||||
void ( *unused51 ) ( void );
|
||||
void ( *unused52 ) ( void );
|
||||
void ( *unused53 ) ( void );
|
||||
void ( *unused54 ) ( void );
|
||||
void ( *unused55 ) ( void );
|
||||
} engine_api_t;
|
||||
|
||||
static engine_api_t engineapi;
|
||||
|
||||
typedef int (*engine_api_func)( int version, int size, struct engine_api_s *api );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Get launcher/engine interface from engine module
|
||||
// Input : hMod -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int Eng_LoadFunctions( HMODULE hMod )
|
||||
{
|
||||
engine_api_func pfnEngineAPI;
|
||||
|
||||
pfnEngineAPI = ( engine_api_func )GetProcAddress( hMod, "Sys_EngineAPI" );
|
||||
if( !pfnEngineAPI )
|
||||
return 0;
|
||||
|
||||
if( !(*pfnEngineAPI)( ENGINE_LAUNCHER_API_VERSION, sizeof( engine_api_t ), &engineapi ) )
|
||||
return 0;
|
||||
|
||||
// All is okay
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Load proper engine .dll and get pointer to either DSound and primary buffer or HWAVEOUT ( NT 4.0, e.g. )
|
||||
//-----------------------------------------------------------------------------
|
||||
void LoadSoundAPIs( void )
|
||||
{
|
||||
hEngine = ::LoadLibrary( IEngineStudio.IsHardware() ? "hw.dll" : "sw.dll" );
|
||||
if( hEngine )
|
||||
{
|
||||
if( Eng_LoadFunctions( hEngine ) )
|
||||
{
|
||||
if( engineapi.S_GetDSPointer && engineapi.S_GetWAVPointer )
|
||||
{
|
||||
engineapi.S_GetDSPointer(&lpDS, &lpDSBuf);
|
||||
lpHW = (HWAVEOUT FAR *)engineapi.S_GetWAVPointer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Close engine library, release sound pointers
|
||||
//-----------------------------------------------------------------------------
|
||||
void ShutdownSoundAPIs( void )
|
||||
{
|
||||
if( hEngine )
|
||||
{
|
||||
FreeLibrary( hEngine );
|
||||
hEngine = 0;
|
||||
}
|
||||
|
||||
lpDS = 0;
|
||||
lpDSBuf = 0;
|
||||
lpHW = 0;
|
||||
}
|
|
@ -141,7 +141,8 @@ void CHudStatusBar::ParseStatusString( int line_num )
|
|||
GetPlayerInfo( indexval, &g_PlayerInfoList[indexval] );
|
||||
if( g_PlayerInfoList[indexval].name != NULL )
|
||||
{
|
||||
strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH );
|
||||
strncpy( szRepString, g_PlayerInfoList[indexval].name, MAX_PLAYER_NAME_LENGTH - 1 );
|
||||
szRepString[MAX_PLAYER_NAME_LENGTH - 1] = '\0';
|
||||
m_pflNameColors[line_num] = GetClientColor( indexval );
|
||||
}
|
||||
else
|
||||
|
@ -231,7 +232,7 @@ int CHudStatusBar::MsgFunc_StatusText( const char *pszName, int iSize, void *pbu
|
|||
if( line < 0 || line >= MAX_STATUSBAR_LINES )
|
||||
return 1;
|
||||
|
||||
strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH );
|
||||
strncpy( m_szStatusText[line], READ_STRING(), MAX_STATUSTEXT_LENGTH - 1 );
|
||||
m_szStatusText[line][MAX_STATUSTEXT_LENGTH - 1] = 0; // ensure it's null terminated ( strncpy() won't null terminate if read string too long)
|
||||
|
||||
if( m_szStatusText[0] == 0 )
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include <memory.h>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
|
@ -23,13 +22,13 @@ void AngleMatrix( const float *angles, float (*matrix)[4] )
|
|||
float angle;
|
||||
float sr, sp, sy, cr, cp, cy;
|
||||
|
||||
angle = angles[YAW] * ( M_PI*2 / 360 );
|
||||
angle = angles[YAW] * ( M_PI_F * 2.0f / 360.0f );
|
||||
sy = sin( angle );
|
||||
cy = cos( angle );
|
||||
angle = angles[PITCH] * ( M_PI*2 / 360 );
|
||||
angle = angles[PITCH] * ( M_PI_F * 2.0f / 360.0f );
|
||||
sp = sin( angle );
|
||||
cp = cos( angle );
|
||||
angle = angles[ROLL] * ( M_PI*2 / 360 );
|
||||
angle = angles[ROLL] * ( M_PI_F * 2.0f / 360.0f );
|
||||
sr = sin( angle );
|
||||
cr = cos( angle );
|
||||
|
||||
|
@ -43,9 +42,9 @@ void AngleMatrix( const float *angles, float (*matrix)[4] )
|
|||
matrix[0][2] = (cr * sp * cy + -sr * -sy);
|
||||
matrix[1][2] = (cr * sp * sy + -sr* cy);
|
||||
matrix[2][2] = cr * cp;
|
||||
matrix[0][3] = 0.0;
|
||||
matrix[1][3] = 0.0;
|
||||
matrix[2][3] = 0.0;
|
||||
matrix[0][3] = 0.0f;
|
||||
matrix[1][3] = 0.0f;
|
||||
matrix[2][3] = 0.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -73,9 +72,9 @@ CrossProduct
|
|||
*/
|
||||
void CrossProduct( const float *v1, const float *v2, float *cross )
|
||||
{
|
||||
cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
|
||||
cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
|
||||
cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
|
||||
cross[0] = v1[1] * v2[2] - v1[2] * v2[1];
|
||||
cross[1] = v1[2] * v2[0] - v1[0] * v2[2];
|
||||
cross[2] = v1[0] * v2[1] - v1[1] * v2[0];
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -139,13 +138,13 @@ void AngleQuaternion( float *angles, vec4_t quaternion )
|
|||
float sr, sp, sy, cr, cp, cy;
|
||||
|
||||
// FIXME: rescale the inputs to 1/2 angle
|
||||
angle = angles[2] * 0.5;
|
||||
angle = angles[2] * 0.5f;
|
||||
sy = sin( angle );
|
||||
cy = cos( angle );
|
||||
angle = angles[1] * 0.5;
|
||||
angle = angles[1] * 0.5f;
|
||||
sp = sin( angle );
|
||||
cp = cos( angle );
|
||||
angle = angles[0] * 0.5;
|
||||
angle = angles[0] * 0.5f;
|
||||
sr = sin( angle );
|
||||
cr = cos( angle );
|
||||
|
||||
|
@ -185,18 +184,18 @@ void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt )
|
|||
|
||||
cosom = p[0] * q[0] + p[1] * q[1] + p[2] * q[2] + p[3] * q[3];
|
||||
|
||||
if( ( 1.0 + cosom ) > 0.000001 )
|
||||
if( ( 1.0f + cosom ) > 0.000001f )
|
||||
{
|
||||
if( ( 1.0 - cosom ) > 0.000001 )
|
||||
if( ( 1.0f - cosom ) > 0.000001f )
|
||||
{
|
||||
omega = acos( cosom );
|
||||
sinom = sin( omega );
|
||||
sclp = sin( ( 1.0 - t ) * omega ) / sinom;
|
||||
sclp = sin( ( 1.0f - t ) * omega ) / sinom;
|
||||
sclq = sin( t * omega ) / sinom;
|
||||
}
|
||||
else
|
||||
{
|
||||
sclp = 1.0 - t;
|
||||
sclp = 1.0f - t;
|
||||
sclq = t;
|
||||
}
|
||||
for( i = 0; i < 4; i++ )
|
||||
|
@ -210,8 +209,8 @@ void QuaternionSlerp( vec4_t p, vec4_t q, float t, vec4_t qt )
|
|||
qt[1] = q[0];
|
||||
qt[2] = -q[3];
|
||||
qt[3] = q[2];
|
||||
sclp = sin( ( 1.0 - t ) * ( 0.5 * M_PI ) );
|
||||
sclq = sin( t * ( 0.5 * M_PI ) );
|
||||
sclp = sin( ( 1.0f - t ) * ( 0.5f * M_PI_F ) );
|
||||
sclq = sin( t * ( 0.5f * M_PI_F ) );
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
qt[i] = sclp * p[i] + sclq * qt[i];
|
||||
|
@ -227,17 +226,17 @@ QuaternionMatrix
|
|||
*/
|
||||
void QuaternionMatrix( vec4_t quaternion, float (*matrix)[4] )
|
||||
{
|
||||
matrix[0][0] = 1.0 - 2.0 * quaternion[1] * quaternion[1] - 2.0 * quaternion[2] * quaternion[2];
|
||||
matrix[1][0] = 2.0 * quaternion[0] * quaternion[1] + 2.0 * quaternion[3] * quaternion[2];
|
||||
matrix[2][0] = 2.0 * quaternion[0] * quaternion[2] - 2.0 * quaternion[3] * quaternion[1];
|
||||
matrix[0][0] = 1.0f - 2.0f * quaternion[1] * quaternion[1] - 2.0f * quaternion[2] * quaternion[2];
|
||||
matrix[1][0] = 2.0f * quaternion[0] * quaternion[1] + 2.0f * quaternion[3] * quaternion[2];
|
||||
matrix[2][0] = 2.0f * quaternion[0] * quaternion[2] - 2.0f * quaternion[3] * quaternion[1];
|
||||
|
||||
matrix[0][1] = 2.0 * quaternion[0] * quaternion[1] - 2.0 * quaternion[3] * quaternion[2];
|
||||
matrix[1][1] = 1.0 - 2.0 * quaternion[0] * quaternion[0] - 2.0 * quaternion[2] * quaternion[2];
|
||||
matrix[2][1] = 2.0 * quaternion[1] * quaternion[2] + 2.0 * quaternion[3] * quaternion[0];
|
||||
matrix[0][1] = 2.0f * quaternion[0] * quaternion[1] - 2.0f * quaternion[3] * quaternion[2];
|
||||
matrix[1][1] = 1.0f - 2.0f * quaternion[0] * quaternion[0] - 2.0f * quaternion[2] * quaternion[2];
|
||||
matrix[2][1] = 2.0f * quaternion[1] * quaternion[2] + 2.0f * quaternion[3] * quaternion[0];
|
||||
|
||||
matrix[0][2] = 2.0 * quaternion[0] * quaternion[2] + 2.0 * quaternion[3] * quaternion[1];
|
||||
matrix[1][2] = 2.0 * quaternion[1] * quaternion[2] - 2.0 * quaternion[3] * quaternion[0];
|
||||
matrix[2][2] = 1.0 - 2.0 * quaternion[0] * quaternion[0] - 2.0 * quaternion[1] * quaternion[1];
|
||||
matrix[0][2] = 2.0f * quaternion[0] * quaternion[2] + 2.0f * quaternion[3] * quaternion[1];
|
||||
matrix[1][2] = 2.0f * quaternion[1] * quaternion[2] - 2.0f * quaternion[3] * quaternion[0];
|
||||
matrix[2][2] = 1.0f - 2.0f * quaternion[0] * quaternion[0] - 2.0f * quaternion[1] * quaternion[1];
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -4,16 +4,19 @@
|
|||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#pragma once
|
||||
#if !defined( STUDIO_UTIL_H )
|
||||
#if !defined(STUDIO_UTIL_H)
|
||||
#define STUDIO_UTIL_H
|
||||
|
||||
#ifndef M_PI
|
||||
#if !defined(M_PI)
|
||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
||||
#endif
|
||||
|
||||
#ifndef PITCH
|
||||
#if !defined(M_PI_F)
|
||||
#define M_PI_F (float)M_PI
|
||||
#endif
|
||||
|
||||
#if !defined(PITCH)
|
||||
// MOVEMENT INFO
|
||||
// up / down
|
||||
#define PITCH 0
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
|
||||
#if USE_VGUI
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#endif
|
||||
|
||||
DECLARE_MESSAGE( m_TextMessage, TextMsg )
|
||||
|
||||
int CHudTextMessage::Init( void )
|
||||
|
@ -178,23 +182,32 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf
|
|||
|
||||
char *psz = szBuf[5];
|
||||
|
||||
#if USE_VGUI
|
||||
if( gViewPort && gViewPort->AllowedToPrintText() == FALSE )
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
switch( msg_dest )
|
||||
{
|
||||
case HUD_PRINTCENTER:
|
||||
_snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] );
|
||||
psz[MSG_BUF_SIZE - 1] = '\0';
|
||||
CenterPrint( ConvertCRtoNL( psz ) );
|
||||
break;
|
||||
case HUD_PRINTNOTIFY:
|
||||
psz[0] = 1; // mark this message to go into the notify buffer
|
||||
_snprintf( psz + 1, MSG_BUF_SIZE - 1, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] );
|
||||
psz[MSG_BUF_SIZE - 2] = '\0';
|
||||
ConsolePrint( ConvertCRtoNL( psz ) );
|
||||
break;
|
||||
case HUD_PRINTTALK:
|
||||
_snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] );
|
||||
psz[MSG_BUF_SIZE - 1] = '\0';
|
||||
gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), MSG_BUF_SIZE );
|
||||
break;
|
||||
case HUD_PRINTCONSOLE:
|
||||
_snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] );
|
||||
psz[MSG_BUF_SIZE - 1] = '\0';
|
||||
ConsolePrint( ConvertCRtoNL( psz ) );
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
* All Rights Reserved.
|
||||
*
|
||||
****/
|
||||
|
||||
#ifndef __TF_DEFS_H
|
||||
#if !defined(__TF_DEFS_H)
|
||||
#define __TF_DEFS_H
|
||||
|
||||
//===========================================================================
|
||||
|
@ -46,7 +45,7 @@
|
|||
// Debug Options
|
||||
//#define MAP_DEBUG // Debug for Map code. I suggest running in a hi-res
|
||||
// mode and/or piping the output from the server to a file.
|
||||
#ifdef MAP_DEBUG
|
||||
#if MAP_DEBUG
|
||||
#define MDEBUG(x) x
|
||||
#else
|
||||
#define MDEBUG(x)
|
||||
|
@ -1155,7 +1154,7 @@ float already_chosen_map;
|
|||
#define TS_PRINT_LONG 2
|
||||
#define TS_PRINT_LONG_TO_ALL 3
|
||||
|
||||
#ifndef TF_DEFS_ONLY
|
||||
#if !defined(TF_DEFS_ONLY)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -23,8 +23,8 @@ extern "C"
|
|||
void DLLEXPORT HUD_DrawTransparentTriangles( void );
|
||||
}
|
||||
|
||||
//#define TEST_IT
|
||||
#if defined( TEST_IT )
|
||||
//#define TEST_IT 1
|
||||
#if TEST_IT
|
||||
|
||||
/*
|
||||
=================
|
||||
|
@ -50,9 +50,7 @@ void Draw_Triangles( void )
|
|||
|
||||
if( gHUD.m_hsprCursor == 0 )
|
||||
{
|
||||
char sz[256];
|
||||
sprintf( sz, "sprites/cursor.spr" );
|
||||
gHUD.m_hsprCursor = SPR_Load( sz );
|
||||
gHUD.m_hsprCursor = SPR_Load( "sprites/cursor.spr" );
|
||||
}
|
||||
|
||||
if( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 ) )
|
||||
|
@ -98,7 +96,7 @@ Non-transparent triangles-- add them here
|
|||
void DLLEXPORT HUD_DrawNormalTriangles( void )
|
||||
{
|
||||
gHUD.m_Spectator.DrawOverview();
|
||||
#if defined( TEST_IT )
|
||||
#if TEST_IT
|
||||
// Draw_Triangles();
|
||||
#endif
|
||||
}
|
||||
|
@ -112,7 +110,7 @@ Render any triangles with transparent rendermode needs here
|
|||
*/
|
||||
void DLLEXPORT HUD_DrawTransparentTriangles( void )
|
||||
{
|
||||
#if defined( TEST_IT )
|
||||
#if TEST_IT
|
||||
// Draw_Triangles();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -18,32 +18,34 @@
|
|||
// implementation of class-less helper functions
|
||||
//
|
||||
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cmath>
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#if !defined(M_PI)
|
||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
||||
#endif
|
||||
|
||||
#if !defined(M_PI_F)
|
||||
#define M_PI_F (float)M_PI
|
||||
#endif
|
||||
extern vec3_t vec3_origin;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// if C++ mangling differs from C symbol name
|
||||
#if _MSC_VER || __WATCOMC__
|
||||
vec3_t vec3_origin;
|
||||
#endif
|
||||
|
||||
double sqrt( double x );
|
||||
|
||||
float Length( const float *v )
|
||||
{
|
||||
int i;
|
||||
float length;
|
||||
|
||||
length = 0;
|
||||
length = 0.0f;
|
||||
for( i = 0; i < 3; i++ )
|
||||
length += v[i] * v[i];
|
||||
length = sqrt( length ); // FIXME
|
||||
|
@ -55,29 +57,29 @@ void VectorAngles( const float *forward, float *angles )
|
|||
{
|
||||
float tmp, yaw, pitch;
|
||||
|
||||
if( forward[1] == 0 && forward[0] == 0 )
|
||||
if( forward[1] == 0.0f && forward[0] == 0.0f )
|
||||
{
|
||||
yaw = 0;
|
||||
if( forward[2] > 0 )
|
||||
pitch = 90;
|
||||
yaw = 0.0f;
|
||||
if( forward[2] > 0.0f )
|
||||
pitch = 90.0f;
|
||||
else
|
||||
pitch = 270;
|
||||
pitch = 270.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
yaw = ( atan2( forward[1], forward[0]) * 180 / M_PI );
|
||||
if( yaw < 0 )
|
||||
yaw += 360;
|
||||
yaw = ( atan2( forward[1], forward[0]) * 180.0f / M_PI_F );
|
||||
if( yaw < 0.0f )
|
||||
yaw += 360.0f;
|
||||
|
||||
tmp = sqrt( forward[0] * forward[0] + forward[1] * forward[1] );
|
||||
pitch = ( atan2( forward[2], tmp ) * 180 / M_PI );
|
||||
if( pitch < 0 )
|
||||
pitch += 360;
|
||||
pitch = ( atan2( forward[2], tmp ) * 180.0f / M_PI_F );
|
||||
if( pitch < 0.0f )
|
||||
pitch += 360.0f;
|
||||
}
|
||||
|
||||
angles[0] = pitch;
|
||||
angles[1] = yaw;
|
||||
angles[2] = 0;
|
||||
angles[2] = 0.0f;
|
||||
}
|
||||
|
||||
float VectorNormalize( float *v )
|
||||
|
@ -89,7 +91,7 @@ float VectorNormalize( float *v )
|
|||
|
||||
if( length )
|
||||
{
|
||||
ilength = 1 / length;
|
||||
ilength = 1.0f / length;
|
||||
v[0] *= ilength;
|
||||
v[1] *= ilength;
|
||||
v[2] *= ilength;
|
||||
|
|
|
@ -16,14 +16,17 @@
|
|||
// A subset of the extdll.h in the project HL Entity DLL
|
||||
//
|
||||
#pragma once
|
||||
#ifndef UTIL_VECTOR_H
|
||||
#if !defined(UTIL_VECTOR_H)
|
||||
#define UTIL_VECTOR_H
|
||||
|
||||
// Misc C-runtime library headers
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "math.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#if HAVE_CMATH
|
||||
#include <cmath>
|
||||
#else
|
||||
#include <math.h>
|
||||
#endif
|
||||
// Header file containing definition of globalvars_t and entvars_t
|
||||
typedef unsigned int func_t; //
|
||||
typedef int string_t; // from engine's pr_comp.h;
|
||||
|
|
|
@ -0,0 +1,196 @@
|
|||
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||
// the agreement/contract under which the contents have been supplied.
|
||||
//
|
||||
// Purpose: TFC Class Menu
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// $Log: $
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "VGUI_Font.h"
|
||||
#include <VGUI_TextImage.h>
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "camera.h"
|
||||
#include "kbutton.h"
|
||||
#include "cvardef.h"
|
||||
#include "usercmd.h"
|
||||
#include "const.h"
|
||||
#include "camera.h"
|
||||
#include "in_defs.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include "vgui_int.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
|
||||
// Class Menu Dimensions
|
||||
#define CLASSMENU_TITLE_X XRES(40)
|
||||
#define CLASSMENU_TITLE_Y YRES(32)
|
||||
#define CLASSMENU_TOPLEFT_BUTTON_X XRES(40)
|
||||
#define CLASSMENU_TOPLEFT_BUTTON_Y YRES(80)
|
||||
#define CLASSMENU_BUTTON_SIZE_X XRES(124)
|
||||
#define CLASSMENU_BUTTON_SIZE_Y YRES(24)
|
||||
#define CLASSMENU_BUTTON_SPACER_Y YRES(8)
|
||||
#define CLASSMENU_WINDOW_X XRES(176)
|
||||
#define CLASSMENU_WINDOW_Y YRES(80)
|
||||
#define CLASSMENU_WINDOW_SIZE_X XRES(424)
|
||||
#define CLASSMENU_WINDOW_SIZE_Y YRES(312)
|
||||
#define CLASSMENU_WINDOW_TEXT_X XRES(150)
|
||||
#define CLASSMENU_WINDOW_TEXT_Y YRES(80)
|
||||
#define CLASSMENU_WINDOW_NAME_X XRES(150)
|
||||
#define CLASSMENU_WINDOW_NAME_Y YRES(8)
|
||||
#define CLASSMENU_WINDOW_PLAYERS_Y YRES(42)
|
||||
|
||||
// Creation
|
||||
CClassMenuPanel::CClassMenuPanel( int iTrans, int iRemoveMe, int x, int y, int wide, int tall ) : CMenuPanel( iTrans, iRemoveMe, x, y, wide, tall )
|
||||
{
|
||||
// don't show class graphics at below 640x480 resolution
|
||||
bool bShowClassGraphic = true;
|
||||
if( ScreenWidth < 640 )
|
||||
{
|
||||
bShowClassGraphic = false;
|
||||
}
|
||||
|
||||
memset( m_pClassImages, 0, sizeof(m_pClassImages) );
|
||||
|
||||
// Get the scheme used for the Titles
|
||||
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
|
||||
|
||||
// schemes
|
||||
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
|
||||
SchemeHandle_t hClassWindowText = pSchemes->getSchemeHandle( "Briefing Text" );
|
||||
|
||||
// color schemes
|
||||
int r, g, b, a;
|
||||
|
||||
// Create the title
|
||||
Label *pLabel = new Label( "", CLASSMENU_TITLE_X, CLASSMENU_TITLE_Y );
|
||||
pLabel->setParent( this );
|
||||
pLabel->setFont( pSchemes->getFont( hTitleScheme ) );
|
||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
||||
pLabel->setFgColor( r, g, b, a );
|
||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
||||
pLabel->setBgColor( r, g, b, a );
|
||||
pLabel->setContentAlignment( vgui::Label::a_west );
|
||||
pLabel->setText(gHUD.m_TextMessage.BufferedLocaliseTextString( "#Title_SelectYourClass" ) );
|
||||
|
||||
// Create the Scroll panel
|
||||
m_pScrollPanel = new CTFScrollPanel( CLASSMENU_WINDOW_X, CLASSMENU_WINDOW_Y, CLASSMENU_WINDOW_SIZE_X, CLASSMENU_WINDOW_SIZE_Y );
|
||||
m_pScrollPanel->setParent( this );
|
||||
//force the scrollbars on, so after the validate clientClip will be smaller
|
||||
m_pScrollPanel->setScrollBarAutoVisible( false, false );
|
||||
m_pScrollPanel->setScrollBarVisible( true, true );
|
||||
m_pScrollPanel->setBorder( new LineBorder( Color( 255 * 0.7, 170 * 0.7, 0, 0 ) ) );
|
||||
m_pScrollPanel->validate();
|
||||
|
||||
int clientWide=m_pScrollPanel->getClient()->getWide();
|
||||
|
||||
//turn scrollpanel back into auto show scrollbar mode and validate
|
||||
m_pScrollPanel->setScrollBarAutoVisible( false, true );
|
||||
m_pScrollPanel->setScrollBarVisible( false, false );
|
||||
m_pScrollPanel->validate();
|
||||
|
||||
// Create the Cancel button
|
||||
m_pCancelButton = new CommandButton( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Menu_Cancel" ), CLASSMENU_TOPLEFT_BUTTON_X, 0, CLASSMENU_BUTTON_SIZE_X, CLASSMENU_BUTTON_SIZE_Y );
|
||||
m_pCancelButton->setParent( this );
|
||||
m_pCancelButton->addActionSignal( new CMenuHandler_TextWindow( HIDE_TEXTWINDOW ) );
|
||||
|
||||
m_iCurrentInfo = 0;
|
||||
}
|
||||
|
||||
// Update
|
||||
void CClassMenuPanel::Update()
|
||||
{
|
||||
// Don't allow the player to join a team if they're not in a team
|
||||
if( !g_iTeamNumber )
|
||||
return;
|
||||
|
||||
int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y;
|
||||
|
||||
// If the player already has a class, make the cancel button visible
|
||||
if( g_iPlayerClass )
|
||||
{
|
||||
m_pCancelButton->setPos( CLASSMENU_TOPLEFT_BUTTON_X, iYPos );
|
||||
m_pCancelButton->setVisible( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pCancelButton->setVisible( false );
|
||||
}
|
||||
}
|
||||
|
||||
//======================================
|
||||
// Key inputs for the Class Menu
|
||||
bool CClassMenuPanel::SlotInput( int iSlot )
|
||||
{
|
||||
if( ( iSlot < 0 ) || ( iSlot > 9 ) )
|
||||
return false;
|
||||
|
||||
if( !m_pButtons[iSlot] )
|
||||
return false;
|
||||
|
||||
// Is the button pushable? (0 is special case)
|
||||
if( iSlot == 0 )
|
||||
{
|
||||
// Selects Civilian and RandomPC
|
||||
if( gViewPort->GetValidClasses( g_iTeamNumber ) == -1 )
|
||||
{
|
||||
m_pButtons[0]->fireActionSignal();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Select RandomPC
|
||||
iSlot = 10;
|
||||
}
|
||||
|
||||
if( !( m_pButtons[iSlot]->IsNotValid() ) )
|
||||
{
|
||||
m_pButtons[iSlot]->fireActionSignal();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//======================================
|
||||
// Update the Class menu before opening it
|
||||
void CClassMenuPanel::Open( void )
|
||||
{
|
||||
Update();
|
||||
CMenuPanel::Open();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Called each time a new level is started.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CClassMenuPanel::Initialize( void )
|
||||
{
|
||||
setVisible( false );
|
||||
m_pScrollPanel->setScrollValue( 0, 0 );
|
||||
}
|
||||
|
||||
//======================================
|
||||
// Mouse is over a class button, bring up the class info
|
||||
void CClassMenuPanel::SetActiveInfo( int iInput )
|
||||
{
|
||||
// Remove all the Info panels and bring up the specified one
|
||||
iInput = 0;
|
||||
|
||||
m_pButtons[iInput]->setArmed( true );
|
||||
m_pClassInfoPanel[iInput]->setVisible( true );
|
||||
m_iCurrentInfo = iInput;
|
||||
|
||||
m_pScrollPanel->setScrollValue( 0, 0 );
|
||||
m_pScrollPanel->validate();
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "vgui_ConsolePanel.h"
|
||||
#include "hud.h"
|
||||
#include <VGUI_ActionSignal.h>
|
||||
#include <VGUI_TextGrid.h>
|
||||
#include <VGUI_TextEntry.h>
|
||||
#include <VGUI_EtchedBorder.h>
|
||||
#include <VGUI_LoweredBorder.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class Handler : public ActionSignal
|
||||
{
|
||||
private:
|
||||
|
||||
ConsolePanel *_consolePanel;
|
||||
|
||||
public:
|
||||
|
||||
Handler( ConsolePanel *consolePanel )
|
||||
{
|
||||
_consolePanel = consolePanel;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void actionPerformed( Panel *panel )
|
||||
{
|
||||
_consolePanel->doExecCommand();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
ConsolePanel::ConsolePanel( int x, int y, int wide, int tall ) : Panel( x, y, wide, tall )
|
||||
{
|
||||
setBorder( new EtchedBorder() );
|
||||
|
||||
_textGrid = new TextGrid( 80, 21, 5, 5, 200, 100 );
|
||||
_textGrid->setBorder( new LoweredBorder() );
|
||||
_textGrid->setParent( this );
|
||||
|
||||
_textEntry=new TextEntry( "", 5, 5, 200, 20 );
|
||||
_textEntry->setParent( this );
|
||||
_textEntry->addActionSignal( new Handler( this ) );
|
||||
}
|
||||
|
||||
int ConsolePanel::print( const char *text )
|
||||
{
|
||||
return _textGrid->printf( "%s", text );
|
||||
}
|
||||
|
||||
int ConsolePanel::vprintf( const char *format, va_list argList )
|
||||
{
|
||||
return _textGrid->vprintf( format, argList );
|
||||
}
|
||||
|
||||
int ConsolePanel::printf( const char* format, ... )
|
||||
{
|
||||
va_list argList;
|
||||
va_start( argList, format );
|
||||
int ret = vprintf( format, argList );
|
||||
va_end( argList );
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ConsolePanel::doExecCommand()
|
||||
{
|
||||
char buf[2048];
|
||||
_textEntry->getText( 0, buf, sizeof buf );
|
||||
_textEntry->setText( null, 0 );
|
||||
gEngfuncs.pfnClientCmd( buf );
|
||||
}
|
||||
|
||||
void ConsolePanel::setSize( int wide, int tall )
|
||||
{
|
||||
Panel::setSize( wide, tall );
|
||||
|
||||
getPaintSize( wide, tall );
|
||||
|
||||
_textGrid->setBounds( 5, 5, wide - 10, tall - 35 );
|
||||
_textEntry->setBounds( 5, tall - 25, wide - 10, 20 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef CONSOLEPANEL_H
|
||||
#define CONSOLEPANEL_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <VGUI_Panel.h>
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class TextGrid;
|
||||
class TextEntry;
|
||||
}
|
||||
|
||||
class ConsolePanel : public vgui::Panel
|
||||
{
|
||||
private:
|
||||
vgui::TextGrid *_textGrid;
|
||||
vgui::TextEntry *_textEntry;
|
||||
public:
|
||||
ConsolePanel( int x, int y, int wide, int tall );
|
||||
public:
|
||||
virtual void setSize( int wide, int tall );
|
||||
virtual int print( const char *text );
|
||||
virtual int vprintf( const char *format, va_list argList );
|
||||
virtual int printf( const char *format, ... );
|
||||
virtual void doExecCommand();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,216 @@
|
|||
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include <stdio.h>
|
||||
#include "vgui_ControlConfigPanel.h"
|
||||
#include <VGUI_HeaderPanel.h>
|
||||
#include <VGUI_TablePanel.h>
|
||||
#include <VGUI_Label.h>
|
||||
#include <VGUI_ScrollPanel.h>
|
||||
#include <VGUI_Scheme.h>
|
||||
#include <VGUI_DataInputStream.h>
|
||||
#include <VGUI.h>
|
||||
#include <VGUI_TextEntry.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class FooTablePanel : public TablePanel
|
||||
{
|
||||
private:
|
||||
Label *_label;
|
||||
TextEntry *_textEntry;
|
||||
ControlConfigPanel *_controlConfigPanel;
|
||||
public:
|
||||
FooTablePanel( ControlConfigPanel *controlConfigPanel, int x, int y, int wide, int tall, int columnCount ) : TablePanel( x, y, wide, tall, columnCount )
|
||||
{
|
||||
_controlConfigPanel = controlConfigPanel;
|
||||
_label = new Label( "You are a dumb monkey", 0, 0, 100, 20 );
|
||||
_label->setBgColor( Scheme::sc_primary3 );
|
||||
_label->setFgColor( Scheme::sc_primary1 );
|
||||
_label->setFont( Scheme::sf_primary3 );
|
||||
|
||||
_textEntry=new TextEntry( "", 0, 0, 100, 20 );
|
||||
// _textEntry->setFont( Scheme::sf_primary3 );
|
||||
}
|
||||
public:
|
||||
virtual int getRowCount()
|
||||
{
|
||||
return _controlConfigPanel->GetCVarCount();
|
||||
}
|
||||
|
||||
virtual int getCellTall( int row )
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
|
||||
virtual Panel *getCellRenderer( int column, int row,bool columnSelected, bool rowSelected, bool cellSelected )
|
||||
{
|
||||
char cvar[128], desc[128], bind[128], bindAlt[128];
|
||||
_controlConfigPanel->GetCVar( row, cvar, 128, desc, 128 );
|
||||
|
||||
if( cellSelected )
|
||||
{
|
||||
_label->setBgColor( Scheme::sc_primary1 );
|
||||
_label->setFgColor( Scheme::sc_primary3 );
|
||||
}
|
||||
else if( rowSelected )
|
||||
{
|
||||
_label->setBgColor( Scheme::sc_primary2 );
|
||||
_label->setFgColor( Scheme::sc_primary1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
_label->setBgColor( Scheme::sc_primary3 );
|
||||
_label->setFgColor( Scheme::sc_primary1 );
|
||||
}
|
||||
|
||||
switch( column )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
_label->setText( desc );
|
||||
_label->setContentAlignment( Label::a_west );
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
_controlConfigPanel->GetCVarBind( cvar, bind, 128, bindAlt, 128 );
|
||||
_label->setText( bind );
|
||||
_label->setContentAlignment( Label::a_center );
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
_controlConfigPanel->GetCVarBind( cvar, bind, 128, bindAlt, 128 );
|
||||
_label->setText( bindAlt );
|
||||
_label->setContentAlignment( Label::a_center );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
_label->setText( "" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return _label;
|
||||
}
|
||||
virtual Panel *startCellEditing( int column, int row )
|
||||
{
|
||||
_textEntry->setText( "Goat", strlen( "Goat" ) );
|
||||
_textEntry->requestFocus();
|
||||
return _textEntry;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ControlConfigPanel::ControlConfigPanel( int x, int y, int wide, int tall ) : Panel( x, y, wide, tall )
|
||||
{
|
||||
setPaintBorderEnabled( false );
|
||||
setPaintBackgroundEnabled( false );
|
||||
setPaintEnabled( false );
|
||||
|
||||
_actionLabel = new Label( "Action" );
|
||||
_actionLabel->setBgColor( Scheme::sc_primary3 );
|
||||
_actionLabel->setFgColor( Scheme::sc_primary3 );
|
||||
|
||||
_keyButtonLabel = new Label( "Key / Button" );
|
||||
_keyButtonLabel->setBgColor( Scheme::sc_primary3 );
|
||||
_keyButtonLabel->setFgColor( Scheme::sc_primary3 );
|
||||
|
||||
_alternateLabel = new Label( "Alternate" );
|
||||
_alternateLabel->setBgColor( Scheme::sc_primary3 );
|
||||
_alternateLabel->setFgColor( Scheme::sc_primary3 );
|
||||
|
||||
_headerPanel=new HeaderPanel( 0, 0, wide, 20 );
|
||||
_headerPanel->setParent( this );
|
||||
|
||||
_headerPanel->addSectionPanel( _actionLabel );
|
||||
_headerPanel->addSectionPanel( _keyButtonLabel );
|
||||
_headerPanel->addSectionPanel( _alternateLabel );
|
||||
|
||||
_headerPanel->setSliderPos( 0, wide / 2 );
|
||||
_headerPanel->setSliderPos( 1, ( wide / 2 ) + ( wide / 4 ) );
|
||||
_headerPanel->setSliderPos( 2, wide );
|
||||
|
||||
_scrollPanel=new ScrollPanel( 0, 20, wide, tall - 20 );
|
||||
_scrollPanel->setParent( this );
|
||||
_scrollPanel->setPaintBorderEnabled( false );
|
||||
_scrollPanel->setPaintBackgroundEnabled( false );
|
||||
_scrollPanel->setPaintEnabled( false );
|
||||
_scrollPanel->getClient()->setPaintBorderEnabled( false );
|
||||
_scrollPanel->getClient()->setPaintBackgroundEnabled( false );
|
||||
_scrollPanel->getClient()->setPaintEnabled( false );
|
||||
_scrollPanel->setScrollBarVisible( false, true );
|
||||
|
||||
_tablePanel = new FooTablePanel( this, 0, 0, _scrollPanel->getClient()->getWide(), 800, 3 );
|
||||
_tablePanel->setParent( _scrollPanel->getClient() );
|
||||
_tablePanel->setHeaderPanel( _headerPanel );
|
||||
_tablePanel->setBgColor( Color( 200, 0, 0, 255 ) );
|
||||
_tablePanel->setFgColor( Color( Scheme::sc_primary2 ) );
|
||||
_tablePanel->setGridVisible( true, true );
|
||||
_tablePanel->setGridSize( 1, 1 );
|
||||
}
|
||||
|
||||
void ControlConfigPanel::AddCVar( const char *cvar, const char *desc )
|
||||
{
|
||||
_cvarDar.addElement( vgui_strdup( cvar ) );
|
||||
_descDar.addElement( vgui_strdup( desc ) );
|
||||
}
|
||||
|
||||
int ControlConfigPanel::GetCVarCount()
|
||||
{
|
||||
return _cvarDar.getCount();
|
||||
}
|
||||
|
||||
void ControlConfigPanel::GetCVar( int index, char *cvar, int cvarLen, char *desc, int descLen )
|
||||
{
|
||||
vgui_strcpy( cvar, cvarLen, _cvarDar[index] );
|
||||
vgui_strcpy( desc, descLen, _descDar[index] );
|
||||
}
|
||||
|
||||
void ControlConfigPanel::AddCVarFromInputStream( InputStream *is )
|
||||
{
|
||||
if( is == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DataInputStream dis( is );
|
||||
|
||||
bool success;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
char buf[256], cvar[128], desc[128];
|
||||
|
||||
dis.readLine( buf, 256, success );
|
||||
|
||||
if( !success )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if( sscanf( buf, "\"%[^\"]\" \"%[^\"]\"", cvar, desc ) == 2 )
|
||||
{
|
||||
AddCVar( cvar, desc );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ControlConfigPanel::GetCVarBind( const char *cvar, char *bind, int bindLen, char *bindAlt, int bindAltLen )
|
||||
{
|
||||
sprintf( bind,"%s : Bind", cvar );
|
||||
sprintf( bindAlt,"%s : BindAlt", cvar );
|
||||
}
|
||||
|
||||
void ControlConfigPanel::SetCVarBind( const char *cvar, const char *bind, const char *bindAlt )
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef CONTROLCONFIGPANEL_H
|
||||
#define CONTROLCONFIGPANEL_H
|
||||
|
||||
#include <VGUI_Panel.h>
|
||||
#include <VGUI_Dar.h>
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class HeaderPanel;
|
||||
class TablePanel;
|
||||
class ScrollPanel;
|
||||
class InputStream;
|
||||
class Label;
|
||||
}
|
||||
|
||||
class ControlConfigPanel : public vgui::Panel
|
||||
{
|
||||
private:
|
||||
vgui::HeaderPanel *_headerPanel;
|
||||
vgui::TablePanel *_tablePanel;
|
||||
vgui::ScrollPanel *_scrollPanel;
|
||||
vgui::Dar<char*> _cvarDar;
|
||||
vgui::Dar<char*> _descDar;
|
||||
vgui::Label *_actionLabel;
|
||||
vgui::Label *_keyButtonLabel;
|
||||
vgui::Label *_alternateLabel;
|
||||
public:
|
||||
ControlConfigPanel( int x, int y, int wide, int tall );
|
||||
void AddCVar( const char *cvar, const char *desc );
|
||||
void AddCVarFromInputStream( vgui::InputStream *is );
|
||||
int GetCVarCount();
|
||||
void GetCVar( int index, char *cvar, int cvarLen, char *desc, int descLen );
|
||||
void GetCVarBind( const char *cvar, char *bind, int bindLen, char *bindAlt, int bindAltLen );
|
||||
void SetCVarBind( const char *cvar, const char *bind, const char *bindAlt );
|
||||
};
|
||||
#endif
|
|
@ -0,0 +1,540 @@
|
|||
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||
// the agreement/contract under which the contents have been supplied.
|
||||
//
|
||||
// Purpose: Contains implementation of various VGUI-derived objects
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// $Log: $
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "VGUI_Font.h"
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "camera.h"
|
||||
#include "kbutton.h"
|
||||
#include "cvardef.h"
|
||||
#include "usercmd.h"
|
||||
#include "const.h"
|
||||
#include "camera.h"
|
||||
#include "in_defs.h"
|
||||
#include "parsemsg.h"
|
||||
|
||||
#include "vgui_int.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "vgui_loadtga.h"
|
||||
|
||||
// Arrow filenames
|
||||
const char *sArrowFilenames[] =
|
||||
{
|
||||
"arrowup",
|
||||
"arrowdn",
|
||||
"arrowlt",
|
||||
"arrowrt",
|
||||
};
|
||||
|
||||
// Get the name of TGA file, without a gamedir
|
||||
char *GetTGANameForRes( const char *pszName )
|
||||
{
|
||||
int i;
|
||||
char sz[256];
|
||||
static char gd[256];
|
||||
|
||||
if( ScreenWidth < 640 )
|
||||
i = 320;
|
||||
else
|
||||
i = 640;
|
||||
|
||||
sprintf( sz, pszName, i );
|
||||
sprintf( gd, "gfx/vgui/%s.tga", sz );
|
||||
return gd;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Loads a .tga file and returns a pointer to the VGUI tga object
|
||||
//-----------------------------------------------------------------------------
|
||||
BitmapTGA *LoadTGAForRes( const char* pImageName )
|
||||
{
|
||||
BitmapTGA *pTGA;
|
||||
char sz[256];
|
||||
|
||||
sprintf( sz, "%%d_%s", pImageName );
|
||||
pTGA = vgui_LoadTGA( GetTGANameForRes( sz ) );
|
||||
|
||||
return pTGA;
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// All TFC Hud buttons are derived from this one.
|
||||
CommandButton::CommandButton( const char *text, int x, int y, int wide, int tall, bool bNoHighlight ) : Button( "", x, y, wide, tall )
|
||||
{
|
||||
m_iPlayerClass = 0;
|
||||
m_bNoHighlight = bNoHighlight;
|
||||
m_bFlat = false;
|
||||
Init();
|
||||
setText( text );
|
||||
}
|
||||
|
||||
CommandButton::CommandButton( int iPlayerClass, const char *text, int x, int y, int wide, int tall, bool bFlat ) : Button( "", x, y, wide, tall )
|
||||
{
|
||||
m_iPlayerClass = iPlayerClass;
|
||||
m_bNoHighlight = false;
|
||||
m_bFlat = bFlat;
|
||||
Init();
|
||||
setText( text );
|
||||
}
|
||||
|
||||
CommandButton::CommandButton( const char *text, int x, int y, int wide, int tall, bool bNoHighlight, bool bFlat ) : Button( "", x, y, wide, tall )
|
||||
{
|
||||
m_iPlayerClass = 0;
|
||||
m_bFlat = bFlat;
|
||||
m_bNoHighlight = bNoHighlight;
|
||||
Init();
|
||||
setText( text );
|
||||
}
|
||||
|
||||
void CommandButton::Init( void )
|
||||
{
|
||||
m_pSubMenu = NULL;
|
||||
m_pSubLabel = NULL;
|
||||
m_pParentMenu = NULL;
|
||||
|
||||
// Set text color to orange
|
||||
setFgColor( Scheme::sc_primary1 );
|
||||
|
||||
// left align
|
||||
setContentAlignment( vgui::Label::a_west );
|
||||
|
||||
// Add the Highlight signal
|
||||
if( !m_bNoHighlight )
|
||||
addInputSignal( new CHandler_CommandButtonHighlight( this ) );
|
||||
|
||||
// not bound to any button yet
|
||||
m_cBoundKey = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Prepends the button text with the current bound key
|
||||
// if no bound key, then a clear space ' ' instead
|
||||
//-----------------------------------------------------------------------------
|
||||
void CommandButton::RecalculateText( void )
|
||||
{
|
||||
char szBuf[128];
|
||||
|
||||
if( m_cBoundKey != 0 )
|
||||
{
|
||||
if( m_cBoundKey == (char)255 )
|
||||
{
|
||||
strcpy( szBuf, m_sMainText );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( szBuf, " %c %s", m_cBoundKey, m_sMainText );
|
||||
}
|
||||
szBuf[MAX_BUTTON_SIZE-1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// just draw a space if no key bound
|
||||
sprintf( szBuf, " %s", m_sMainText );
|
||||
szBuf[MAX_BUTTON_SIZE - 1] = 0;
|
||||
}
|
||||
|
||||
Button::setText( szBuf );
|
||||
}
|
||||
|
||||
void CommandButton::setText( const char *text )
|
||||
{
|
||||
strncpy( m_sMainText, text, MAX_BUTTON_SIZE - 1 );
|
||||
m_sMainText[MAX_BUTTON_SIZE - 1] = 0;
|
||||
|
||||
RecalculateText();
|
||||
}
|
||||
|
||||
void CommandButton::setBoundKey( char boundKey )
|
||||
{
|
||||
m_cBoundKey = boundKey;
|
||||
RecalculateText();
|
||||
}
|
||||
|
||||
char CommandButton::getBoundKey( void )
|
||||
{
|
||||
return m_cBoundKey;
|
||||
}
|
||||
|
||||
void CommandButton::AddSubMenu( CCommandMenu *pNewMenu )
|
||||
{
|
||||
m_pSubMenu = pNewMenu;
|
||||
|
||||
// Prevent this button from being pushed
|
||||
setMouseClickEnabled( MOUSE_LEFT, false );
|
||||
}
|
||||
|
||||
void CommandButton::UpdateSubMenus( int iAdjustment )
|
||||
{
|
||||
if( m_pSubMenu )
|
||||
m_pSubMenu->RecalculatePositions( iAdjustment );
|
||||
}
|
||||
|
||||
void CommandButton::paint()
|
||||
{
|
||||
// Make the sub label paint the same as the button
|
||||
if( m_pSubLabel )
|
||||
{
|
||||
if( isSelected() )
|
||||
m_pSubLabel->PushDown();
|
||||
else
|
||||
m_pSubLabel->PushUp();
|
||||
}
|
||||
|
||||
// draw armed button text in white
|
||||
if( isArmed() )
|
||||
{
|
||||
setFgColor( Scheme::sc_secondary2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
setFgColor( Scheme::sc_primary1 );
|
||||
}
|
||||
|
||||
Button::paint();
|
||||
}
|
||||
|
||||
void CommandButton::paintBackground()
|
||||
{
|
||||
if( m_bFlat )
|
||||
{
|
||||
if( isArmed() )
|
||||
{
|
||||
// Orange Border
|
||||
drawSetColor( Scheme::sc_secondary1 );
|
||||
drawOutlinedRect( 0, 0, _size[0], _size[1] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( isArmed() )
|
||||
{
|
||||
// Orange highlight background
|
||||
drawSetColor( Scheme::sc_primary2 );
|
||||
drawFilledRect( 0, 0, _size[0], _size[1] );
|
||||
}
|
||||
|
||||
// Orange Border
|
||||
drawSetColor( Scheme::sc_secondary1 );
|
||||
drawOutlinedRect( 0, 0, _size[0], _size[1] );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Highlights the current button, and all it's parent menus
|
||||
//-----------------------------------------------------------------------------
|
||||
void CommandButton::cursorEntered( void )
|
||||
{
|
||||
// unarm all the other buttons in this menu
|
||||
CCommandMenu *containingMenu = getParentMenu();
|
||||
if( containingMenu )
|
||||
{
|
||||
containingMenu->ClearButtonsOfArmedState();
|
||||
|
||||
// make all our higher buttons armed
|
||||
CCommandMenu *pCParent = containingMenu->GetParentMenu();
|
||||
if( pCParent )
|
||||
{
|
||||
CommandButton *pParentButton = pCParent->FindButtonWithSubmenu( containingMenu );
|
||||
|
||||
pParentButton->cursorEntered();
|
||||
}
|
||||
}
|
||||
|
||||
// arm ourselves
|
||||
setArmed( true );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CommandButton::cursorExited( void )
|
||||
{
|
||||
// only clear ourselves if we have do not have a containing menu
|
||||
// only stay armed if we have a sub menu
|
||||
// the buttons only unarm themselves when another button is armed instead
|
||||
if( !getParentMenu() || !GetSubMenu() )
|
||||
{
|
||||
setArmed( false );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns the command menu that the button is part of, if any
|
||||
// Output : CCommandMenu *
|
||||
//-----------------------------------------------------------------------------
|
||||
CCommandMenu *CommandButton::getParentMenu( void )
|
||||
{
|
||||
return m_pParentMenu;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Sets the menu that contains this button
|
||||
// Input : *pParentMenu -
|
||||
//-----------------------------------------------------------------------------
|
||||
void CommandButton::setParentMenu( CCommandMenu *pParentMenu )
|
||||
{
|
||||
m_pParentMenu = pParentMenu;
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
int ClassButton::IsNotValid()
|
||||
{
|
||||
// If this is the main ChangeClass button, remove it if the player's only able to be civilians
|
||||
if( m_iPlayerClass == -1 )
|
||||
{
|
||||
if( gViewPort->GetValidClasses( g_iTeamNumber ) == -1 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only check current class if they've got autokill on
|
||||
bool bAutoKill = CVAR_GET_FLOAT( "hud_classautokill" ) != 0;
|
||||
if( bAutoKill )
|
||||
{
|
||||
// Is it the player's current class?
|
||||
if (
|
||||
(!gViewPort->IsRandomPC() && (m_iPlayerClass == g_iPlayerClass)) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Button with Class image beneath it
|
||||
CImageLabel::CImageLabel( const char *pImageName,int x,int y ) : Label( "", x, y )
|
||||
{
|
||||
setContentFitted( true );
|
||||
m_pTGA = LoadTGAForRes( pImageName );
|
||||
setImage( m_pTGA );
|
||||
}
|
||||
|
||||
CImageLabel::CImageLabel( const char *pImageName, int x, int y, int wide, int tall ) : Label( "", x, y, wide, tall )
|
||||
{
|
||||
setContentFitted( true );
|
||||
m_pTGA = LoadTGAForRes( pImageName );
|
||||
setImage( m_pTGA );
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Image size
|
||||
int CImageLabel::getImageWide( void )
|
||||
{
|
||||
if( m_pTGA )
|
||||
{
|
||||
int iXSize, iYSize;
|
||||
|
||||
m_pTGA->getSize( iXSize, iYSize );
|
||||
|
||||
return iXSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int CImageLabel::getImageTall( void )
|
||||
{
|
||||
if( m_pTGA )
|
||||
{
|
||||
int iXSize, iYSize;
|
||||
|
||||
m_pTGA->getSize( iXSize, iYSize );
|
||||
|
||||
return iYSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
void CImageLabel::LoadImage( const char *pImageName )
|
||||
{
|
||||
if( m_pTGA )
|
||||
delete m_pTGA;
|
||||
|
||||
// Load the Image
|
||||
m_pTGA = LoadTGAForRes( pImageName );
|
||||
|
||||
if( m_pTGA == NULL )
|
||||
{
|
||||
// we didn't find a matching image file for this resolution
|
||||
// try to load file resolution independent
|
||||
char sz[256];
|
||||
|
||||
sprintf( sz, "%s/%s", gEngfuncs.pfnGetGameDirectory(), pImageName );
|
||||
FileInputStream fis( sz, false );
|
||||
m_pTGA = new BitmapTGA( &fis, true );
|
||||
fis.close();
|
||||
}
|
||||
|
||||
if( m_pTGA == NULL )
|
||||
return; // unable to load image
|
||||
|
||||
int w,t;
|
||||
|
||||
m_pTGA->getSize( w, t );
|
||||
|
||||
setSize( XRES ( w ),YRES ( t) );
|
||||
setImage( m_pTGA );
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
// Various overloaded paint functions for Custom VGUI objects
|
||||
void CCommandMenu::paintBackground()
|
||||
{
|
||||
// Transparent black background
|
||||
|
||||
if( m_iSpectCmdMenu )
|
||||
drawSetColor( 0, 0, 0, 64 );
|
||||
else
|
||||
drawSetColor( Scheme::sc_primary3 );
|
||||
|
||||
drawFilledRect( 0, 0, _size[0], _size[1] );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// CUSTOM SCROLLPANEL
|
||||
//=================================================================================
|
||||
CTFScrollButton::CTFScrollButton( int iArrow, const char *text, int x, int y, int wide, int tall ) : CommandButton( text, x, y, wide, tall )
|
||||
{
|
||||
// Set text color to orange
|
||||
setFgColor( Scheme::sc_primary1 );
|
||||
|
||||
// Load in the arrow
|
||||
m_pTGA = LoadTGAForRes( sArrowFilenames[iArrow] );
|
||||
setImage( m_pTGA );
|
||||
|
||||
// Highlight signal
|
||||
InputSignal *pISignal = new CHandler_CommandButtonHighlight( this );
|
||||
addInputSignal( pISignal );
|
||||
}
|
||||
|
||||
void CTFScrollButton::paint( void )
|
||||
{
|
||||
if( !m_pTGA )
|
||||
return;
|
||||
|
||||
// draw armed button text in white
|
||||
if( isArmed() )
|
||||
{
|
||||
m_pTGA->setColor( Color( 255, 255, 255, 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pTGA->setColor( Color( 255, 255, 255, 128 ) );
|
||||
}
|
||||
|
||||
m_pTGA->doPaint( this );
|
||||
}
|
||||
|
||||
void CTFScrollButton::paintBackground( void )
|
||||
{
|
||||
/*
|
||||
if( isArmed() )
|
||||
{
|
||||
// Orange highlight background
|
||||
drawSetColor( Scheme::sc_primary2 );
|
||||
drawFilledRect( 0, 0, _size[0], _size[1] );
|
||||
}
|
||||
|
||||
// Orange Border
|
||||
drawSetColor( Scheme::sc_secondary1 );
|
||||
drawOutlinedRect( 0, 0, _size[0] - 1, _size[1] );
|
||||
*/
|
||||
}
|
||||
|
||||
void CTFSlider::paintBackground( void )
|
||||
{
|
||||
int wide, tall, nobx, noby;
|
||||
|
||||
getPaintSize( wide, tall );
|
||||
getNobPos( nobx, noby );
|
||||
|
||||
// Border
|
||||
drawSetColor( Scheme::sc_secondary1 );
|
||||
drawOutlinedRect( 0, 0, wide, tall );
|
||||
|
||||
if( isVertical() )
|
||||
{
|
||||
// Nob Fill
|
||||
drawSetColor( Scheme::sc_primary2 );
|
||||
drawFilledRect( 0, nobx, wide, noby );
|
||||
|
||||
// Nob Outline
|
||||
drawSetColor( Scheme::sc_primary1 );
|
||||
drawOutlinedRect( 0, nobx, wide, noby );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Nob Fill
|
||||
drawSetColor( Scheme::sc_primary2 );
|
||||
drawFilledRect( nobx, 0, noby, tall );
|
||||
|
||||
// Nob Outline
|
||||
drawSetColor( Scheme::sc_primary1 );
|
||||
drawOutlinedRect( nobx, 0, noby, tall );
|
||||
}
|
||||
}
|
||||
|
||||
CTFScrollPanel::CTFScrollPanel( int x, int y, int wide, int tall ) : ScrollPanel( x, y, wide, tall )
|
||||
{
|
||||
ScrollBar *pScrollBar = getVerticalScrollBar();
|
||||
pScrollBar->setButton( new CTFScrollButton( ARROW_UP, "", 0, 0, 16, 16 ), 0 );
|
||||
pScrollBar->setButton( new CTFScrollButton( ARROW_DOWN, "", 0, 0, 16, 16 ), 1 );
|
||||
pScrollBar->setSlider( new CTFSlider( 0, wide - 1, wide, ( tall - ( wide * 2 ) ) + 2, true ) );
|
||||
pScrollBar->setPaintBorderEnabled( false );
|
||||
pScrollBar->setPaintBackgroundEnabled( false );
|
||||
pScrollBar->setPaintEnabled( false );
|
||||
|
||||
pScrollBar = getHorizontalScrollBar();
|
||||
pScrollBar->setButton( new CTFScrollButton( ARROW_LEFT, "", 0, 0, 16, 16 ), 0 );
|
||||
pScrollBar->setButton( new CTFScrollButton( ARROW_RIGHT, "", 0, 0, 16, 16 ), 1 );
|
||||
pScrollBar->setSlider( new CTFSlider( tall, 0, wide - ( tall * 2 ), tall, false ) );
|
||||
pScrollBar->setPaintBorderEnabled( false );
|
||||
pScrollBar->setPaintBackgroundEnabled( false );
|
||||
pScrollBar->setPaintEnabled( false );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// CUSTOM HANDLERS
|
||||
//=================================================================================
|
||||
void CHandler_MenuButtonOver::cursorEntered(Panel *panel)
|
||||
{
|
||||
if( gViewPort && m_pMenuPanel )
|
||||
{
|
||||
m_pMenuPanel->SetActiveInfo( m_iButton );
|
||||
}
|
||||
}
|
||||
|
||||
void CMenuHandler_StringCommandClassSelect::actionPerformed( Panel *panel )
|
||||
{
|
||||
CMenuHandler_StringCommand::actionPerformed( panel );
|
||||
|
||||
// THIS IS NOW BEING DONE ON THE TFC SERVER TO AVOID KILLING SOMEONE THEN
|
||||
// HAVE THE SERVER SAY "SORRY...YOU CAN'T BE THAT CLASS".
|
||||
|
||||
bool bAutoKill = CVAR_GET_FLOAT( "hud_classautokill" ) != 0;
|
||||
if( bAutoKill && g_iPlayerClass != 0 )
|
||||
gEngfuncs.pfnClientCmd( "kill" );
|
||||
}
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||
// the agreement/contract under which the contents have been supplied.
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// $Log: $
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "VGUI_Font.h"
|
||||
#include "VGUI_ScrollPanel.h"
|
||||
#include "VGUI_TextImage.h"
|
||||
|
||||
#include <VGUI_StackLayout.h>
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "camera.h"
|
||||
#include "kbutton.h"
|
||||
#include "const.h"
|
||||
|
||||
#include "vgui_int.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
|
||||
#define MOTD_TITLE_X XRES(16)
|
||||
#define MOTD_TITLE_Y YRES(16)
|
||||
|
||||
#define MOTD_WINDOW_X XRES(112)
|
||||
#define MOTD_WINDOW_Y YRES(80)
|
||||
#define MOTD_WINDOW_SIZE_X XRES(424)
|
||||
#define MOTD_WINDOW_SIZE_Y YRES(312)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Displays the MOTD and basic server information
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMessageWindowPanel : public CMenuPanel
|
||||
{
|
||||
public:
|
||||
CMessageWindowPanel( const char *szMOTD, const char *szTitle, int iShadeFullScreen, int iRemoveMe, int x, int y, int wide, int tall );
|
||||
|
||||
private:
|
||||
CTransparentPanel *m_pBackgroundPanel;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Creates a new CMessageWindowPanel
|
||||
// Output : CMenuPanel - interface to the panel
|
||||
//-----------------------------------------------------------------------------
|
||||
CMenuPanel *CMessageWindowPanel_Create( const char *szMOTD, const char *szTitle, int iShadeFullscreen, int iRemoveMe, int x, int y, int wide, int tall )
|
||||
{
|
||||
return new CMessageWindowPanel( szMOTD, szTitle, iShadeFullscreen, iRemoveMe, x, y, wide, tall );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructs a message panel
|
||||
//-----------------------------------------------------------------------------
|
||||
CMessageWindowPanel::CMessageWindowPanel( const char *szMOTD, const char *szTitle, int iShadeFullscreen, int iRemoveMe, int x, int y, int wide, int tall ) : CMenuPanel( iShadeFullscreen ? 100 : 255, iRemoveMe, x, y, wide, tall )
|
||||
{
|
||||
// Get the scheme used for the Titles
|
||||
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
|
||||
|
||||
// schemes
|
||||
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
|
||||
SchemeHandle_t hMOTDText = pSchemes->getSchemeHandle( "Briefing Text" );
|
||||
|
||||
// color schemes
|
||||
int r, g, b, a;
|
||||
|
||||
// Create the window
|
||||
m_pBackgroundPanel = new CTransparentPanel( iShadeFullscreen ? 255 : 100, MOTD_WINDOW_X, MOTD_WINDOW_Y, MOTD_WINDOW_SIZE_X, MOTD_WINDOW_SIZE_Y );
|
||||
m_pBackgroundPanel->setParent( this );
|
||||
m_pBackgroundPanel->setBorder( new LineBorder( Color( 255 * 0.7, 170 * 0.7, 0, 0 ) ) );
|
||||
m_pBackgroundPanel->setVisible( true );
|
||||
|
||||
int iXSize,iYSize,iXPos,iYPos;
|
||||
m_pBackgroundPanel->getPos( iXPos, iYPos );
|
||||
m_pBackgroundPanel->getSize( iXSize, iYSize );
|
||||
|
||||
// Create the title
|
||||
Label *pLabel = new Label( "", iXPos + MOTD_TITLE_X, iYPos + MOTD_TITLE_Y );
|
||||
pLabel->setParent( this );
|
||||
pLabel->setFont( pSchemes->getFont( hTitleScheme ) );
|
||||
pLabel->setFont( Scheme::sf_primary1 );
|
||||
|
||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
||||
pLabel->setFgColor( r, g, b, a );
|
||||
pLabel->setFgColor( Scheme::sc_primary1 );
|
||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
||||
pLabel->setBgColor( r, g, b, a );
|
||||
pLabel->setContentAlignment( vgui::Label::a_west );
|
||||
pLabel->setText( "%s", szTitle);
|
||||
|
||||
// Create the Scroll panel
|
||||
ScrollPanel *pScrollPanel = new CTFScrollPanel( iXPos + XRES( 16 ), iYPos + MOTD_TITLE_Y * 2 + YRES( 16 ), iXSize - XRES( 32 ), iYSize - ( YRES( 48 ) + BUTTON_SIZE_Y * 2 ) );
|
||||
pScrollPanel->setParent( this );
|
||||
|
||||
// force the scrollbars on so clientClip will take them in account after the validate
|
||||
pScrollPanel->setScrollBarAutoVisible( false, false );
|
||||
pScrollPanel->setScrollBarVisible( true, true );
|
||||
pScrollPanel->validate();
|
||||
|
||||
// Create the text panel
|
||||
TextPanel *pText = new TextPanel( "", 0, 0, 64, 64 );
|
||||
pText->setParent( pScrollPanel->getClient() );
|
||||
|
||||
// get the font and colors from the scheme
|
||||
pText->setFont( pSchemes->getFont( hMOTDText ) );
|
||||
pSchemes->getFgColor( hMOTDText, r, g, b, a );
|
||||
pText->setFgColor( r, g, b, a );
|
||||
pSchemes->getBgColor( hMOTDText, r, g, b, a );
|
||||
pText->setBgColor( r, g, b, a );
|
||||
pText->setText( szMOTD );
|
||||
|
||||
// Get the total size of the MOTD text and resize the text panel
|
||||
int iScrollSizeX, iScrollSizeY;
|
||||
|
||||
// First, set the size so that the client's wdith is correct at least because the
|
||||
// width is critical for getting the "wrapped" size right.
|
||||
// You'll see a horizontal scroll bar if there is a single word that won't wrap in the
|
||||
// specified width.
|
||||
pText->getTextImage()->setSize( pScrollPanel->getClientClip()->getWide(), pScrollPanel->getClientClip()->getTall() );
|
||||
pText->getTextImage()->getTextSizeWrapped( iScrollSizeX, iScrollSizeY );
|
||||
|
||||
// Now resize the textpanel to fit the scrolled size
|
||||
pText->setSize( iScrollSizeX, iScrollSizeY );
|
||||
|
||||
//turn the scrollbars back into automode
|
||||
pScrollPanel->setScrollBarAutoVisible( true, true );
|
||||
pScrollPanel->setScrollBarVisible( false, false );
|
||||
|
||||
pScrollPanel->validate();
|
||||
|
||||
CommandButton *pButton = new CommandButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_OK" ), iXPos + XRES( 16 ), iYPos + iYSize - YRES( 16 ) - BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y );
|
||||
pButton->addActionSignal( new CMenuHandler_TextWindow( HIDE_TEXTWINDOW ) );
|
||||
pButton->setParent( this );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,556 @@
|
|||
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||
// the agreement/contract under which the contents have been supplied.
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// $Log: $
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "hud.h"
|
||||
#include "vgui_SchemeManager.h"
|
||||
#include "cvardef.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
cvar_t *g_CV_BitmapFonts;
|
||||
|
||||
|
||||
void Scheme_Init()
|
||||
{
|
||||
g_CV_BitmapFonts = gEngfuncs.pfnRegisterVariable("bitmapfonts", "1", 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Scheme managers data container
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSchemeManager::CScheme
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
SCHEME_NAME_LENGTH = 32,
|
||||
FONT_NAME_LENGTH = 48,
|
||||
FONT_FILENAME_LENGTH = 64,
|
||||
};
|
||||
|
||||
// name
|
||||
char schemeName[SCHEME_NAME_LENGTH];
|
||||
|
||||
// font
|
||||
char fontName[FONT_NAME_LENGTH];
|
||||
|
||||
int fontSize;
|
||||
int fontWeight;
|
||||
|
||||
vgui::Font *font;
|
||||
int ownFontPointer; // true if the font is ours to delete
|
||||
|
||||
// scheme
|
||||
byte fgColor[4];
|
||||
byte bgColor[4];
|
||||
byte armedFgColor[4];
|
||||
byte armedBgColor[4];
|
||||
byte mousedownFgColor[4];
|
||||
byte mousedownBgColor[4];
|
||||
byte borderColor[4];
|
||||
|
||||
// construction/destruction
|
||||
CScheme();
|
||||
~CScheme();
|
||||
};
|
||||
|
||||
CSchemeManager::CScheme::CScheme()
|
||||
{
|
||||
schemeName[0] = 0;
|
||||
fontName[0] = 0;
|
||||
fontSize = 0;
|
||||
fontWeight = 0;
|
||||
font = NULL;
|
||||
ownFontPointer = false;
|
||||
}
|
||||
|
||||
CSchemeManager::CScheme::~CScheme()
|
||||
{
|
||||
// only delete our font pointer if we own it
|
||||
if ( ownFontPointer )
|
||||
{
|
||||
delete font;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: resolution information
|
||||
// !! needs to be shared out
|
||||
//-----------------------------------------------------------------------------
|
||||
static int g_ResArray[] =
|
||||
{
|
||||
320,
|
||||
400,
|
||||
512,
|
||||
640,
|
||||
800,
|
||||
1024,
|
||||
1152,
|
||||
1280,
|
||||
1600
|
||||
};
|
||||
static int g_NumReses = sizeof(g_ResArray) / sizeof(int);
|
||||
|
||||
static byte *LoadFileByResolution( const char *filePrefix, int xRes, const char *filePostfix )
|
||||
{
|
||||
// find our resolution in the res array
|
||||
int resNum = g_NumReses - 1;
|
||||
while ( g_ResArray[resNum] > xRes )
|
||||
{
|
||||
resNum--;
|
||||
|
||||
if ( resNum < 0 )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// try open the file
|
||||
byte *pFile = NULL;
|
||||
while ( 1 )
|
||||
{
|
||||
|
||||
// try load
|
||||
char fname[256];
|
||||
sprintf( fname, "%s%d%s", filePrefix, g_ResArray[resNum], filePostfix );
|
||||
pFile = gEngfuncs.COM_LoadFile( fname, 5, NULL );
|
||||
|
||||
if ( pFile )
|
||||
break;
|
||||
|
||||
if ( resNum == 0 )
|
||||
return NULL;
|
||||
|
||||
resNum--;
|
||||
};
|
||||
|
||||
return pFile;
|
||||
}
|
||||
|
||||
static void ParseRGBAFromString( byte colorArray[4], const char *colorVector )
|
||||
{
|
||||
int r, g, b, a;
|
||||
sscanf( colorVector, "%d %d %d %d", &r, &g, &b, &a );
|
||||
colorArray[0] = r;
|
||||
colorArray[1] = g;
|
||||
colorArray[2] = b;
|
||||
colorArray[3] = a;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: initializes the scheme manager
|
||||
// loading the scheme files for the current resolution
|
||||
// Input : xRes -
|
||||
// yRes - dimensions of output window
|
||||
//-----------------------------------------------------------------------------
|
||||
CSchemeManager::CSchemeManager( int xRes, int yRes )
|
||||
{
|
||||
// basic setup
|
||||
m_pSchemeList = NULL;
|
||||
m_iNumSchemes = 0;
|
||||
|
||||
// find the closest matching scheme file to our resolution
|
||||
char token[1024];
|
||||
char *pFile = (char*)LoadFileByResolution( "", xRes, "_textscheme.txt" );
|
||||
m_xRes = xRes;
|
||||
|
||||
char *pFileStart = pFile;
|
||||
|
||||
byte *pFontData;
|
||||
int fontFileLength;
|
||||
char fontFilename[512];
|
||||
|
||||
//
|
||||
// Read the scheme descriptions from the text file, into a temporary array
|
||||
// format is simply:
|
||||
// <paramName name> = <paramValue>
|
||||
//
|
||||
// a <paramName name> of "SchemeName" signals a new scheme is being described
|
||||
//
|
||||
|
||||
const static int numTmpSchemes = 64;
|
||||
static CScheme tmpSchemes[numTmpSchemes];
|
||||
memset( tmpSchemes, 0, sizeof(tmpSchemes) );
|
||||
int currentScheme = -1;
|
||||
CScheme *pScheme = NULL;
|
||||
|
||||
if ( !pFile )
|
||||
{
|
||||
gEngfuncs.Con_DPrintf( "Unable to find *_textscheme.txt\n");
|
||||
goto buildDefaultFont;
|
||||
}
|
||||
|
||||
// record what has been entered so we can create defaults from the different values
|
||||
bool hasFgColor, hasBgColor, hasArmedFgColor, hasArmedBgColor, hasMouseDownFgColor, hasMouseDownBgColor;
|
||||
|
||||
pFile = gEngfuncs.COM_ParseFile( pFile, token );
|
||||
while ( strlen(token) > 0 && (currentScheme < numTmpSchemes) )
|
||||
{
|
||||
// get the paramName name
|
||||
static const int tokenSize = 64;
|
||||
char paramName[tokenSize], paramValue[tokenSize];
|
||||
|
||||
strncpy( paramName, token, tokenSize - 1 );
|
||||
paramName[tokenSize-1] = 0; // ensure null termination
|
||||
|
||||
// get the '=' character
|
||||
pFile = gEngfuncs.COM_ParseFile( pFile, token );
|
||||
if ( stricmp( token, "=" ) )
|
||||
{
|
||||
if ( currentScheme < 0 )
|
||||
{
|
||||
gEngfuncs.Con_Printf( "error parsing font scheme text file at file start - expected '=', found '%s''\n", token );
|
||||
}
|
||||
else
|
||||
{
|
||||
gEngfuncs.Con_Printf( "error parsing font scheme text file at scheme '%s' - expected '=', found '%s''\n", tmpSchemes[currentScheme].schemeName, token );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// get paramValue
|
||||
pFile = gEngfuncs.COM_ParseFile( pFile, token );
|
||||
strncpy( paramValue, token, tokenSize - 1 );
|
||||
paramValue[tokenSize-1] = 0; // ensure null termination
|
||||
|
||||
// is this a new scheme?
|
||||
if ( !stricmp(paramName, "SchemeName") )
|
||||
{
|
||||
// setup the defaults for the current scheme
|
||||
if ( pScheme )
|
||||
{
|
||||
// foreground color defaults (normal -> armed -> mouse down)
|
||||
if ( !hasFgColor )
|
||||
{
|
||||
pScheme->fgColor[0] = pScheme->fgColor[1] = pScheme->fgColor[2] = pScheme->fgColor[3] = 255;
|
||||
}
|
||||
if ( !hasArmedFgColor )
|
||||
{
|
||||
memcpy( pScheme->armedFgColor, pScheme->fgColor, sizeof(pScheme->armedFgColor) );
|
||||
}
|
||||
if ( !hasMouseDownFgColor )
|
||||
{
|
||||
memcpy( pScheme->mousedownFgColor, pScheme->armedFgColor, sizeof(pScheme->mousedownFgColor) );
|
||||
}
|
||||
|
||||
// background color (normal -> armed -> mouse down)
|
||||
if ( !hasBgColor )
|
||||
{
|
||||
pScheme->bgColor[0] = pScheme->bgColor[1] = pScheme->bgColor[2] = pScheme->bgColor[3] = 0;
|
||||
}
|
||||
if ( !hasArmedBgColor )
|
||||
{
|
||||
memcpy( pScheme->armedBgColor, pScheme->bgColor, sizeof(pScheme->armedBgColor) );
|
||||
}
|
||||
if ( !hasMouseDownBgColor )
|
||||
{
|
||||
memcpy( pScheme->mousedownBgColor, pScheme->armedBgColor, sizeof(pScheme->mousedownBgColor) );
|
||||
}
|
||||
|
||||
// font size
|
||||
if ( !pScheme->fontSize )
|
||||
{
|
||||
pScheme->fontSize = 17;
|
||||
}
|
||||
if ( !pScheme->fontName[0] )
|
||||
{
|
||||
strcpy( pScheme->fontName, "Arial" );
|
||||
}
|
||||
}
|
||||
|
||||
// create the new scheme
|
||||
currentScheme++;
|
||||
pScheme = &tmpSchemes[currentScheme];
|
||||
hasFgColor = hasBgColor = hasArmedFgColor = hasArmedBgColor = hasMouseDownFgColor = hasMouseDownBgColor = false;
|
||||
|
||||
strncpy( pScheme->schemeName, paramValue, CScheme::SCHEME_NAME_LENGTH - 1 );
|
||||
pScheme->schemeName[CScheme::SCHEME_NAME_LENGTH-1] = '\0'; // ensure null termination of string
|
||||
}
|
||||
|
||||
if ( !pScheme )
|
||||
{
|
||||
gEngfuncs.Con_Printf( "font scheme text file MUST start with a 'SchemeName'\n");
|
||||
break;
|
||||
}
|
||||
|
||||
// pull the data out into the scheme
|
||||
if ( !stricmp(paramName, "FontName") )
|
||||
{
|
||||
strncpy( pScheme->fontName, paramValue, CScheme::FONT_NAME_LENGTH - 1 );
|
||||
pScheme->fontName[CScheme::FONT_NAME_LENGTH-1] = 0;
|
||||
}
|
||||
else if ( !stricmp(paramName, "FontSize") )
|
||||
{
|
||||
pScheme->fontSize = atoi( paramValue );
|
||||
}
|
||||
else if ( !stricmp(paramName, "FontWeight") )
|
||||
{
|
||||
pScheme->fontWeight = atoi( paramValue );
|
||||
}
|
||||
else if ( !stricmp(paramName, "FgColor") )
|
||||
{
|
||||
ParseRGBAFromString( pScheme->fgColor, paramValue );
|
||||
hasFgColor = true;
|
||||
}
|
||||
else if ( !stricmp(paramName, "BgColor") )
|
||||
{
|
||||
ParseRGBAFromString( pScheme->bgColor, paramValue );
|
||||
hasBgColor = true;
|
||||
}
|
||||
else if ( !stricmp(paramName, "FgColorArmed") )
|
||||
{
|
||||
ParseRGBAFromString( pScheme->armedFgColor, paramValue );
|
||||
hasArmedFgColor = true;
|
||||
}
|
||||
else if ( !stricmp(paramName, "BgColorArmed") )
|
||||
{
|
||||
ParseRGBAFromString( pScheme->armedBgColor, paramValue );
|
||||
hasArmedBgColor = true;
|
||||
}
|
||||
else if ( !stricmp(paramName, "FgColorMousedown") )
|
||||
{
|
||||
ParseRGBAFromString( pScheme->mousedownFgColor, paramValue );
|
||||
hasMouseDownFgColor = true;
|
||||
}
|
||||
else if ( !stricmp(paramName, "BgColorMousedown") )
|
||||
{
|
||||
ParseRGBAFromString( pScheme->mousedownBgColor, paramValue );
|
||||
hasMouseDownBgColor = true;
|
||||
}
|
||||
else if ( !stricmp(paramName, "BorderColor") )
|
||||
{
|
||||
ParseRGBAFromString( pScheme->borderColor, paramValue );
|
||||
hasMouseDownBgColor = true;
|
||||
}
|
||||
|
||||
// get the new token last, so we now if the loop needs to be continued or not
|
||||
pFile = gEngfuncs.COM_ParseFile( pFile, token );
|
||||
}
|
||||
|
||||
// free the file
|
||||
gEngfuncs.COM_FreeFile( pFileStart );
|
||||
|
||||
|
||||
buildDefaultFont:
|
||||
|
||||
// make sure we have at least 1 valid font
|
||||
if ( currentScheme < 0 )
|
||||
{
|
||||
currentScheme = 0;
|
||||
strcpy( tmpSchemes[0].schemeName, "Default Scheme" );
|
||||
strcpy( tmpSchemes[0].fontName, "Arial" );
|
||||
tmpSchemes[0].fontSize = 0;
|
||||
tmpSchemes[0].fgColor[0] = tmpSchemes[0].fgColor[1] = tmpSchemes[0].fgColor[2] = tmpSchemes[0].fgColor[3] = 255;
|
||||
tmpSchemes[0].armedFgColor[0] = tmpSchemes[0].armedFgColor[1] = tmpSchemes[0].armedFgColor[2] = tmpSchemes[0].armedFgColor[3] = 255;
|
||||
tmpSchemes[0].mousedownFgColor[0] = tmpSchemes[0].mousedownFgColor[1] = tmpSchemes[0].mousedownFgColor[2] = tmpSchemes[0].mousedownFgColor[3] = 255;
|
||||
}
|
||||
|
||||
// we have the full list of schemes in the tmpSchemes array
|
||||
// now allocate the correct sized list
|
||||
m_iNumSchemes = currentScheme + 1; // 0-based index
|
||||
m_pSchemeList = new CScheme[ m_iNumSchemes ];
|
||||
|
||||
// copy in the data
|
||||
memcpy( m_pSchemeList, tmpSchemes, sizeof(CScheme) * m_iNumSchemes );
|
||||
|
||||
// create the fonts
|
||||
for ( int i = 0; i < m_iNumSchemes; i++ )
|
||||
{
|
||||
m_pSchemeList[i].font = NULL;
|
||||
|
||||
// see if the current font values exist in a previously loaded font
|
||||
for ( int j = 0; j < i; j++ )
|
||||
{
|
||||
// check if the font name, size, and weight are the same
|
||||
if ( !stricmp(m_pSchemeList[i].fontName, m_pSchemeList[j].fontName)
|
||||
&& m_pSchemeList[i].fontSize == m_pSchemeList[j].fontSize
|
||||
&& m_pSchemeList[i].fontWeight == m_pSchemeList[j].fontWeight )
|
||||
{
|
||||
// copy the pointer, but mark i as not owning it
|
||||
m_pSchemeList[i].font = m_pSchemeList[j].font;
|
||||
m_pSchemeList[i].ownFontPointer = false;
|
||||
}
|
||||
}
|
||||
|
||||
// if we haven't found the font already, load it ourselves
|
||||
if ( !m_pSchemeList[i].font )
|
||||
{
|
||||
fontFileLength = -1;
|
||||
pFontData = NULL;
|
||||
|
||||
if(g_CV_BitmapFonts && g_CV_BitmapFonts->value)
|
||||
{
|
||||
int fontRes = 640;
|
||||
if ( m_xRes >= 1600 )
|
||||
fontRes = 1600;
|
||||
else if ( m_xRes >= 1280 )
|
||||
fontRes = 1280;
|
||||
else if ( m_xRes >= 1152 )
|
||||
fontRes = 1152;
|
||||
else if ( m_xRes >= 1024 )
|
||||
fontRes = 1024;
|
||||
else if ( m_xRes >= 800 )
|
||||
fontRes = 800;
|
||||
|
||||
sprintf(fontFilename, "gfx\\vgui\\fonts\\%d_%s.tga", fontRes, m_pSchemeList[i].schemeName);
|
||||
pFontData = gEngfuncs.COM_LoadFile( fontFilename, 5, &fontFileLength );
|
||||
if(!pFontData)
|
||||
gEngfuncs.Con_Printf("Missing bitmap font: %s\n", fontFilename);
|
||||
}
|
||||
|
||||
m_pSchemeList[i].font = new vgui::Font(
|
||||
m_pSchemeList[i].fontName,
|
||||
pFontData,
|
||||
fontFileLength,
|
||||
m_pSchemeList[i].fontSize,
|
||||
0,
|
||||
0,
|
||||
m_pSchemeList[i].fontWeight,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false);
|
||||
|
||||
m_pSchemeList[i].ownFontPointer = true;
|
||||
}
|
||||
|
||||
// fix up alpha values; VGUI uses 1-A (A=0 being solid, A=255 transparent)
|
||||
m_pSchemeList[i].fgColor[3] = 255 - m_pSchemeList[i].fgColor[3];
|
||||
m_pSchemeList[i].bgColor[3] = 255 - m_pSchemeList[i].bgColor[3];
|
||||
m_pSchemeList[i].armedFgColor[3] = 255 - m_pSchemeList[i].armedFgColor[3];
|
||||
m_pSchemeList[i].armedBgColor[3] = 255 - m_pSchemeList[i].armedBgColor[3];
|
||||
m_pSchemeList[i].mousedownFgColor[3] = 255 - m_pSchemeList[i].mousedownFgColor[3];
|
||||
m_pSchemeList[i].mousedownBgColor[3] = 255 - m_pSchemeList[i].mousedownBgColor[3];
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: frees all the memory used by the scheme manager
|
||||
//-----------------------------------------------------------------------------
|
||||
CSchemeManager::~CSchemeManager()
|
||||
{
|
||||
delete [] m_pSchemeList;
|
||||
m_iNumSchemes = 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Finds a scheme in the list, by name
|
||||
// Input : char *schemeName - string name of the scheme
|
||||
// Output : SchemeHandle_t handle to the scheme
|
||||
//-----------------------------------------------------------------------------
|
||||
SchemeHandle_t CSchemeManager::getSchemeHandle( const char *schemeName )
|
||||
{
|
||||
// iterate through the list
|
||||
for ( int i = 0; i < m_iNumSchemes; i++ )
|
||||
{
|
||||
if ( !stricmp(schemeName, m_pSchemeList[i].schemeName) )
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: always returns a valid scheme handle
|
||||
// Input : schemeHandle -
|
||||
// Output : CScheme
|
||||
//-----------------------------------------------------------------------------
|
||||
CSchemeManager::CScheme *CSchemeManager::getSafeScheme( SchemeHandle_t schemeHandle )
|
||||
{
|
||||
if ( schemeHandle < m_iNumSchemes )
|
||||
return m_pSchemeList + schemeHandle;
|
||||
|
||||
return m_pSchemeList;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns the schemes pointer to a font
|
||||
// Input : schemeHandle -
|
||||
// Output : vgui::Font
|
||||
//-----------------------------------------------------------------------------
|
||||
vgui::Font *CSchemeManager::getFont( SchemeHandle_t schemeHandle )
|
||||
{
|
||||
return getSafeScheme( schemeHandle )->font;
|
||||
}
|
||||
|
||||
void CSchemeManager::getFgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
||||
{
|
||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
||||
r = pScheme->fgColor[0];
|
||||
g = pScheme->fgColor[1];
|
||||
b = pScheme->fgColor[2];
|
||||
a = pScheme->fgColor[3];
|
||||
}
|
||||
|
||||
void CSchemeManager::getBgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
||||
{
|
||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
||||
r = pScheme->bgColor[0];
|
||||
g = pScheme->bgColor[1];
|
||||
b = pScheme->bgColor[2];
|
||||
a = pScheme->bgColor[3];
|
||||
}
|
||||
|
||||
void CSchemeManager::getFgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
||||
{
|
||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
||||
r = pScheme->armedFgColor[0];
|
||||
g = pScheme->armedFgColor[1];
|
||||
b = pScheme->armedFgColor[2];
|
||||
a = pScheme->armedFgColor[3];
|
||||
}
|
||||
|
||||
void CSchemeManager::getBgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
||||
{
|
||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
||||
r = pScheme->armedBgColor[0];
|
||||
g = pScheme->armedBgColor[1];
|
||||
b = pScheme->armedBgColor[2];
|
||||
a = pScheme->armedBgColor[3];
|
||||
}
|
||||
|
||||
void CSchemeManager::getFgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
||||
{
|
||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
||||
r = pScheme->mousedownFgColor[0];
|
||||
g = pScheme->mousedownFgColor[1];
|
||||
b = pScheme->mousedownFgColor[2];
|
||||
a = pScheme->mousedownFgColor[3];
|
||||
}
|
||||
|
||||
void CSchemeManager::getBgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
||||
{
|
||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
||||
r = pScheme->mousedownBgColor[0];
|
||||
g = pScheme->mousedownBgColor[1];
|
||||
b = pScheme->mousedownBgColor[2];
|
||||
a = pScheme->mousedownBgColor[3];
|
||||
}
|
||||
|
||||
void CSchemeManager::getBorderColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a )
|
||||
{
|
||||
CScheme *pScheme = getSafeScheme( schemeHandle );
|
||||
r = pScheme->borderColor[0];
|
||||
g = pScheme->borderColor[1];
|
||||
b = pScheme->borderColor[2];
|
||||
a = pScheme->borderColor[3];
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include <VGUI_Font.h>
|
||||
|
||||
// handle to an individual scheme
|
||||
typedef int SchemeHandle_t;
|
||||
|
||||
// Register console variables, etc..
|
||||
void Scheme_Init();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Handles the loading of text scheme description from disk
|
||||
// supports different font/color/size schemes at different resolutions
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSchemeManager
|
||||
{
|
||||
public:
|
||||
// initialization
|
||||
CSchemeManager( int xRes, int yRes );
|
||||
virtual ~CSchemeManager();
|
||||
|
||||
// scheme handling
|
||||
SchemeHandle_t getSchemeHandle( const char *schemeName );
|
||||
|
||||
// getting info from schemes
|
||||
vgui::Font *getFont( SchemeHandle_t schemeHandle );
|
||||
void getFgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
||||
void getBgColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
||||
void getFgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
||||
void getBgArmedColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
||||
void getFgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
||||
void getBgMousedownColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
||||
void getBorderColor( SchemeHandle_t schemeHandle, int &r, int &g, int &b, int &a );
|
||||
|
||||
private:
|
||||
class CScheme;
|
||||
CScheme *m_pSchemeList;
|
||||
int m_iNumSchemes;
|
||||
|
||||
// Resolution we were initted at.
|
||||
int m_xRes;
|
||||
|
||||
CScheme *getSafeScheme( SchemeHandle_t schemeHandle );
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,311 @@
|
|||
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef SCOREPANEL_H
|
||||
#define SCOREPANEL_H
|
||||
|
||||
#include<VGUI_Panel.h>
|
||||
#include<VGUI_TablePanel.h>
|
||||
#include<VGUI_HeaderPanel.h>
|
||||
#include<VGUI_TextGrid.h>
|
||||
#include<VGUI_Label.h>
|
||||
#include<VGUI_TextImage.h>
|
||||
#include "../game_shared/vgui_listbox.h"
|
||||
#include "cl_util.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#define MAX_SCORES 10
|
||||
#define MAX_SCOREBOARD_TEAMS 5
|
||||
|
||||
// Scoreboard cells
|
||||
#define COLUMN_TRACKER 0
|
||||
#define COLUMN_NAME 1
|
||||
#define COLUMN_CLASS 2
|
||||
#define COLUMN_KILLS 3
|
||||
#define COLUMN_DEATHS 4
|
||||
#define COLUMN_LATENCY 5
|
||||
#define COLUMN_VOICE 6
|
||||
#define COLUMN_BLANK 7
|
||||
#define NUM_COLUMNS 8
|
||||
#define NUM_ROWS (MAX_PLAYERS + (MAX_SCOREBOARD_TEAMS * 2))
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
class CTextImage2 : public Image
|
||||
{
|
||||
public:
|
||||
CTextImage2()
|
||||
{
|
||||
_image[0] = new TextImage("");
|
||||
_image[1] = new TextImage("");
|
||||
}
|
||||
|
||||
~CTextImage2()
|
||||
{
|
||||
delete _image[0];
|
||||
delete _image[1];
|
||||
}
|
||||
|
||||
TextImage *GetImage(int image)
|
||||
{
|
||||
return _image[image];
|
||||
}
|
||||
|
||||
void getSize(int &wide, int &tall)
|
||||
{
|
||||
int w1, w2, t1, t2;
|
||||
_image[0]->getTextSize(w1, t1);
|
||||
_image[1]->getTextSize(w2, t2);
|
||||
|
||||
wide = w1 + w2;
|
||||
tall = Q_max(t1, t2);
|
||||
setSize(wide, tall);
|
||||
}
|
||||
|
||||
void doPaint(Panel *panel)
|
||||
{
|
||||
_image[0]->doPaint(panel);
|
||||
_image[1]->doPaint(panel);
|
||||
}
|
||||
|
||||
void setPos(int x, int y)
|
||||
{
|
||||
_image[0]->setPos(x, y);
|
||||
|
||||
int swide, stall;
|
||||
_image[0]->getSize(swide, stall);
|
||||
|
||||
int wide, tall;
|
||||
_image[1]->getSize(wide, tall);
|
||||
_image[1]->setPos(x + wide, y + (stall * 0.9) - tall);
|
||||
}
|
||||
|
||||
void setColor(Color color)
|
||||
{
|
||||
_image[0]->setColor(color);
|
||||
}
|
||||
|
||||
void setColor2(Color color)
|
||||
{
|
||||
_image[1]->setColor(color);
|
||||
}
|
||||
|
||||
private:
|
||||
TextImage *_image[2];
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Custom label for cells in the Scoreboard's Table Header
|
||||
//-----------------------------------------------------------------------------
|
||||
class CLabelHeader : public Label
|
||||
{
|
||||
public:
|
||||
CLabelHeader() : Label("")
|
||||
{
|
||||
_dualImage = new CTextImage2();
|
||||
_dualImage->setColor2(Color(255, 170, 0, 0));
|
||||
_row = -2;
|
||||
_useFgColorAsImageColor = true;
|
||||
_offset[0] = 0;
|
||||
_offset[1] = 0;
|
||||
}
|
||||
|
||||
~CLabelHeader()
|
||||
{
|
||||
delete _dualImage;
|
||||
}
|
||||
|
||||
void setRow(int row)
|
||||
{
|
||||
_row = row;
|
||||
}
|
||||
|
||||
void setFgColorAsImageColor(bool state)
|
||||
{
|
||||
_useFgColorAsImageColor = state;
|
||||
}
|
||||
|
||||
virtual void setText(int textBufferLen, const char* text)
|
||||
{
|
||||
_dualImage->GetImage(0)->setText(text);
|
||||
|
||||
// calculate the text size
|
||||
Font *font = _dualImage->GetImage(0)->getFont();
|
||||
_gap = 0;
|
||||
for (const char *ch = text; *ch != 0; ch++)
|
||||
{
|
||||
int a, b, c;
|
||||
font->getCharABCwide(*ch, a, b, c);
|
||||
_gap += (a + b + c);
|
||||
}
|
||||
|
||||
_gap += XRES(5);
|
||||
}
|
||||
|
||||
virtual void setText(const char* text)
|
||||
{
|
||||
// strip any non-alnum characters from the end
|
||||
char buf[512];
|
||||
strcpy(buf, text);
|
||||
|
||||
int len = strlen(buf);
|
||||
while (len && isspace(buf[--len]))
|
||||
{
|
||||
buf[len] = 0;
|
||||
}
|
||||
|
||||
CLabelHeader::setText(0, buf);
|
||||
}
|
||||
|
||||
void setText2(const char *text)
|
||||
{
|
||||
_dualImage->GetImage(1)->setText(text);
|
||||
}
|
||||
|
||||
void getTextSize(int &wide, int &tall)
|
||||
{
|
||||
_dualImage->getSize(wide, tall);
|
||||
}
|
||||
|
||||
void setFgColor(int r,int g,int b,int a)
|
||||
{
|
||||
Label::setFgColor(r,g,b,a);
|
||||
Color color(r,g,b,a);
|
||||
_dualImage->setColor(color);
|
||||
_dualImage->setColor2(color);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void setFgColor(Scheme::SchemeColor sc)
|
||||
{
|
||||
int r, g, b, a;
|
||||
Label::setFgColor(sc);
|
||||
Label::getFgColor( r, g, b, a );
|
||||
|
||||
// Call the r,g,b,a version so it sets the color in the dualImage..
|
||||
setFgColor( r, g, b, a );
|
||||
}
|
||||
|
||||
void setFont(Font *font)
|
||||
{
|
||||
_dualImage->GetImage(0)->setFont(font);
|
||||
}
|
||||
|
||||
void setFont2(Font *font)
|
||||
{
|
||||
_dualImage->GetImage(1)->setFont(font);
|
||||
}
|
||||
|
||||
// this adjust the absolute position of the text after alignment is calculated
|
||||
void setTextOffset(int x, int y)
|
||||
{
|
||||
_offset[0] = x;
|
||||
_offset[1] = y;
|
||||
}
|
||||
|
||||
void paint();
|
||||
void paintBackground();
|
||||
void calcAlignment(int iwide, int itall, int &x, int &y);
|
||||
|
||||
private:
|
||||
CTextImage2 *_dualImage;
|
||||
int _row;
|
||||
int _gap;
|
||||
int _offset[2];
|
||||
bool _useFgColorAsImageColor;
|
||||
};
|
||||
|
||||
class ScoreTablePanel;
|
||||
|
||||
#include "../game_shared/vgui_grid.h"
|
||||
#include "../game_shared/vgui_defaultinputsignal.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Scoreboard back panel
|
||||
//-----------------------------------------------------------------------------
|
||||
class ScorePanel : public Panel, public vgui::CDefaultInputSignal
|
||||
{
|
||||
private:
|
||||
// Default panel implementation doesn't forward mouse messages when there is no cursor and we need them.
|
||||
class HitTestPanel : public Panel
|
||||
{
|
||||
public:
|
||||
virtual void internalMousePressed(MouseCode code);
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Label m_TitleLabel;
|
||||
|
||||
// Here is how these controls are arranged hierarchically.
|
||||
// m_HeaderGrid
|
||||
// m_HeaderLabels
|
||||
|
||||
// m_PlayerGridScroll
|
||||
// m_PlayerGrid
|
||||
// m_PlayerEntries
|
||||
|
||||
CGrid m_HeaderGrid;
|
||||
CLabelHeader m_HeaderLabels[NUM_COLUMNS]; // Labels above the
|
||||
CLabelHeader *m_pCurrentHighlightLabel;
|
||||
int m_iHighlightRow;
|
||||
|
||||
vgui::CListBox m_PlayerList;
|
||||
CGrid m_PlayerGrids[NUM_ROWS]; // The grid with player and team info.
|
||||
CLabelHeader m_PlayerEntries[NUM_COLUMNS][NUM_ROWS]; // Labels for the grid entries.
|
||||
|
||||
ScorePanel::HitTestPanel m_HitTestPanel;
|
||||
CommandButton *m_pCloseButton;
|
||||
CLabelHeader* GetPlayerEntry(int x, int y) {return &m_PlayerEntries[x][y];}
|
||||
|
||||
public:
|
||||
|
||||
int m_iNumTeams;
|
||||
int m_iPlayerNum;
|
||||
int m_iShowscoresHeld;
|
||||
|
||||
int m_iRows;
|
||||
int m_iSortedRows[NUM_ROWS];
|
||||
int m_iIsATeam[NUM_ROWS];
|
||||
bool m_bHasBeenSorted[MAX_PLAYERS];
|
||||
int m_iLastKilledBy;
|
||||
int m_fLastKillTime;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
ScorePanel(int x,int y,int wide,int tall);
|
||||
|
||||
void Update( void );
|
||||
|
||||
void SortTeams( void );
|
||||
void SortPlayers( int iTeam, char *team );
|
||||
void RebuildTeams( void );
|
||||
|
||||
void FillGrid();
|
||||
|
||||
void DeathMsg( int killer, int victim );
|
||||
|
||||
void Initialize( void );
|
||||
|
||||
void Open( void );
|
||||
|
||||
void MouseOverCell(int row, int col);
|
||||
|
||||
// InputSignal overrides.
|
||||
public:
|
||||
|
||||
virtual void mousePressed(MouseCode code, Panel* panel);
|
||||
virtual void cursorMoved(int x, int y, Panel *panel);
|
||||
|
||||
friend class CLabelHeader;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,420 @@
|
|||
//========= Copyright <20> 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
// vgui_SpectatorPanel.cpp: implementation of the SpectatorPanel class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include "pm_shared.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "vgui_SpectatorPanel.h"
|
||||
#include "vgui_ScorePanel.h"
|
||||
|
||||
//#include "Exports.h"
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_ChatInputPosition
|
||||
|
||||
Sets the location of the input for chat text
|
||||
==========================
|
||||
*/
|
||||
|
||||
extern "C" void DLLEXPORT HUD_ChatInputPosition( int *x, int *y )
|
||||
{
|
||||
// RecClChatInputPosition( x, y );
|
||||
|
||||
if ( g_iUser1 != 0 || gEngfuncs.IsSpectateOnly() )
|
||||
{
|
||||
if ( gHUD.m_Spectator.m_pip->value == INSET_OFF )
|
||||
{
|
||||
*y = YRES( PANEL_HEIGHT );
|
||||
}
|
||||
else
|
||||
{
|
||||
*y = YRES( gHUD.m_Spectator.m_OverviewData.insetWindowHeight + 5 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
SpectatorPanel::SpectatorPanel( int x, int y, int wide, int tall ) : Panel( x, y, wide, tall )
|
||||
{
|
||||
}
|
||||
|
||||
SpectatorPanel::~SpectatorPanel()
|
||||
{
|
||||
}
|
||||
|
||||
void SpectatorPanel::ActionSignal( int cmd )
|
||||
{
|
||||
switch( cmd )
|
||||
{
|
||||
case SPECTATOR_PANEL_CMD_NONE : break;
|
||||
|
||||
case SPECTATOR_PANEL_CMD_OPTIONS : gViewPort->ShowCommandMenu( gViewPort->m_SpectatorOptionsMenu );
|
||||
break;
|
||||
|
||||
case SPECTATOR_PANEL_CMD_NEXTPLAYER : gHUD.m_Spectator.FindNextPlayer(true);
|
||||
break;
|
||||
|
||||
case SPECTATOR_PANEL_CMD_PREVPLAYER : gHUD.m_Spectator.FindNextPlayer(false);
|
||||
break;
|
||||
|
||||
case SPECTATOR_PANEL_CMD_PLAYERS : gViewPort->ShowCommandMenu( gViewPort->m_PlayerMenu );
|
||||
break;
|
||||
|
||||
case SPECTATOR_PANEL_CMD_HIDEMENU : ShowMenu(false);
|
||||
break;
|
||||
|
||||
case SPECTATOR_PANEL_CMD_CAMERA : gViewPort->ShowCommandMenu( gViewPort->m_SpectatorCameraMenu );
|
||||
break;
|
||||
|
||||
case SPECTATOR_PANEL_CMD_TOGGLE_INSET : gHUD.m_Spectator.SetModes( -1,
|
||||
gHUD.m_Spectator.ToggleInset(false) );
|
||||
break;
|
||||
|
||||
|
||||
default : gEngfuncs.Con_DPrintf("Unknown SpectatorPanel ActionSingal %i.\n",cmd); break;
|
||||
}
|
||||
}
|
||||
|
||||
void SpectatorPanel::Initialize()
|
||||
{
|
||||
int x, y, wide, tall;
|
||||
|
||||
getBounds( x, y, wide, tall );
|
||||
|
||||
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
|
||||
|
||||
SchemeHandle_t hSmallScheme = pSchemes->getSchemeHandle( "Team Info Text" );
|
||||
|
||||
m_TopBorder = new CTransparentPanel( 64, 0, 0, ScreenWidth, YRES( PANEL_HEIGHT ) );
|
||||
m_TopBorder->setParent( this );
|
||||
|
||||
m_BottomBorder = new CTransparentPanel( 64, 0, ScreenHeight - YRES( 32 ), ScreenWidth, YRES( PANEL_HEIGHT ) );
|
||||
m_BottomBorder->setParent( this );
|
||||
|
||||
setPaintBackgroundEnabled( false );
|
||||
|
||||
m_ExtraInfo = new Label( "Extra Info", 0, 0, wide, YRES( PANEL_HEIGHT ) );
|
||||
m_ExtraInfo->setParent( m_TopBorder );
|
||||
m_ExtraInfo->setFont( pSchemes->getFont( hSmallScheme ) );
|
||||
|
||||
m_ExtraInfo->setPaintBackgroundEnabled( false );
|
||||
m_ExtraInfo->setFgColor( 143, 143, 54, 0 );
|
||||
m_ExtraInfo->setContentAlignment( vgui::Label::a_west );
|
||||
|
||||
m_TimerImage = new CImageLabel( "timer", 0, 0, 14, 14 );
|
||||
m_TimerImage->setParent( m_TopBorder );
|
||||
|
||||
m_TopBanner = new CImageLabel( "banner", 0, 0, XRES( BANNER_WIDTH ), YRES( BANNER_HEIGHT ) );
|
||||
m_TopBanner->setParent( this );
|
||||
|
||||
m_CurrentTime = new Label( "00:00", 0, 0, wide, YRES( PANEL_HEIGHT ) );
|
||||
m_CurrentTime->setParent( m_TopBorder );
|
||||
m_CurrentTime->setFont( pSchemes->getFont( hSmallScheme ) );
|
||||
m_CurrentTime->setPaintBackgroundEnabled( false );
|
||||
m_CurrentTime->setFgColor( 143, 143, 54, 0 );
|
||||
m_CurrentTime->setContentAlignment( vgui::Label::a_west );
|
||||
|
||||
m_Separator = new Panel( 0, 0, XRES( 64 ), YRES( 96 ) );
|
||||
m_Separator->setParent( m_TopBorder );
|
||||
m_Separator->setFgColor( 59, 58, 34, 48 );
|
||||
m_Separator->setBgColor( 59, 58, 34, 48 );
|
||||
|
||||
for( int j = 0; j < TEAM_NUMBER; j++ )
|
||||
{
|
||||
m_TeamScores[j] = new Label( " ", 0, 0, wide, YRES( PANEL_HEIGHT ) );
|
||||
m_TeamScores[j]->setParent( m_TopBorder );
|
||||
m_TeamScores[j]->setFont( pSchemes->getFont( hSmallScheme ) );
|
||||
m_TeamScores[j]->setPaintBackgroundEnabled( false );
|
||||
m_TeamScores[j]->setFgColor( 143, 143, 54, 0 );
|
||||
m_TeamScores[j]->setContentAlignment( vgui::Label::a_west );
|
||||
m_TeamScores[j]->setVisible( false );
|
||||
}
|
||||
|
||||
// Initialize command buttons.
|
||||
// m_OptionButton = new ColorButton( CHudTextMessage::BufferedLocaliseTextString( "#SPECT_OPTIONS" ), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false );
|
||||
m_OptionButton = new DropDownButton( CHudTextMessage::BufferedLocaliseTextString( "#SPECT_OPTIONS" ), XRES(15), YRES(6), XRES(OPTIONS_BUTTON_X), YRES(20), false, false );
|
||||
m_OptionButton->setParent( m_BottomBorder );
|
||||
m_OptionButton->setContentAlignment( vgui::Label::a_center );
|
||||
m_OptionButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
|
||||
m_OptionButton->addActionSignal( new CSpectatorHandler_Command( this, SPECTATOR_PANEL_CMD_OPTIONS ) );
|
||||
m_OptionButton->setUnArmedBorderColor( 59, 58, 34, 48 );
|
||||
m_OptionButton->setArmedBorderColor( 194, 202, 54, 0 );
|
||||
m_OptionButton->setUnArmedColor( 143, 143, 54, 0 );
|
||||
m_OptionButton->setArmedColor( 194, 202, 54, 0 );
|
||||
|
||||
m_CamButton = new DropDownButton( CHudTextMessage::BufferedLocaliseTextString( "#CAM_OPTIONS" ), ScreenWidth - ( XRES ( CAMOPTIONS_BUTTON_X ) + 15 ), YRES(6), XRES ( CAMOPTIONS_BUTTON_X ), YRES(20), false, false );
|
||||
m_CamButton->setParent( m_BottomBorder );
|
||||
m_CamButton->setContentAlignment( vgui::Label::a_center );
|
||||
m_CamButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
|
||||
m_CamButton->addActionSignal( new CSpectatorHandler_Command( this, SPECTATOR_PANEL_CMD_CAMERA ) );
|
||||
m_CamButton->setUnArmedBorderColor( 59, 58, 34, 48 );
|
||||
m_CamButton->setArmedBorderColor( 194, 202, 54, 0 );
|
||||
m_CamButton->setUnArmedColor( 143, 143, 54, 0 );
|
||||
m_CamButton->setArmedColor( 194, 202, 54, 0 );
|
||||
|
||||
// m_PrevPlayerButton= new ColorButton("<", XRES( 15 + OPTIONS_BUTTON_X + 15 ), YRES(6), XRES(24), YRES(20), false, false );
|
||||
m_PrevPlayerButton= new CImageButton("arrowleft", XRES( 15 + OPTIONS_BUTTON_X + 15 ), YRES(6), XRES(24), YRES(20), false, false );
|
||||
m_PrevPlayerButton->setParent( m_BottomBorder );
|
||||
m_PrevPlayerButton->setContentAlignment( vgui::Label::a_center );
|
||||
m_PrevPlayerButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
|
||||
m_PrevPlayerButton->addActionSignal( new CSpectatorHandler_Command( this, SPECTATOR_PANEL_CMD_PREVPLAYER ) );
|
||||
m_PrevPlayerButton->setUnArmedBorderColor( 59, 58, 34, 48 );
|
||||
m_PrevPlayerButton->setArmedBorderColor( 194, 202, 54, 0 );
|
||||
m_PrevPlayerButton->setUnArmedColor( 143, 143, 54, 0 );
|
||||
m_PrevPlayerButton->setArmedColor( 194, 202, 54, 0 );
|
||||
|
||||
// m_NextPlayerButton= new ColorButton(">", (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ), YRES(6), XRES(24), YRES(20),false, false );
|
||||
m_NextPlayerButton= new CImageButton("arrowright", (ScreenWidth - (XRES ( CAMOPTIONS_BUTTON_X ) + 15)) - XRES ( 24 + 15 ), YRES(6), XRES(24), YRES(20),false, false );
|
||||
m_NextPlayerButton->setParent( m_BottomBorder );
|
||||
m_NextPlayerButton->setContentAlignment( vgui::Label::a_center );
|
||||
m_NextPlayerButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
|
||||
m_NextPlayerButton->addActionSignal( new CSpectatorHandler_Command( this, SPECTATOR_PANEL_CMD_NEXTPLAYER ) );
|
||||
m_NextPlayerButton->setUnArmedBorderColor( 59, 58, 34, 48 );
|
||||
m_NextPlayerButton->setArmedBorderColor( 194, 202, 54, 0 );
|
||||
m_NextPlayerButton->setUnArmedColor( 143, 143, 54, 0 );
|
||||
m_NextPlayerButton->setArmedColor( 194, 202, 54, 0 );
|
||||
|
||||
// Initialize the bottom title.
|
||||
float flLabelSize = ( ( ScreenWidth - ( XRES ( CAMOPTIONS_BUTTON_X ) + 15 ) ) - XRES( 24 + 15 ) ) - XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 38 );
|
||||
|
||||
m_BottomMainButton = new DropDownButton("Spectator Bottom",
|
||||
XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6), flLabelSize, YRES(20),
|
||||
false, false );
|
||||
|
||||
m_BottomMainButton->setParent(m_BottomBorder);
|
||||
m_BottomMainButton->setPaintBackgroundEnabled(false);
|
||||
m_BottomMainButton->setFgColor( Scheme::sc_primary1 );
|
||||
m_BottomMainButton->setContentAlignment( vgui::Label::a_center );
|
||||
m_BottomMainButton->setBorder( new LineBorder( Color( 59, 58, 34, 48 ) ) );
|
||||
m_BottomMainButton->setBoundKey( (char)255 ); // special no bound to avoid leading spaces in name
|
||||
m_BottomMainButton->addActionSignal( new CSpectatorHandler_Command(this,SPECTATOR_PANEL_CMD_PLAYERS) );
|
||||
m_BottomMainButton->setUnArmedBorderColor ( 59, 58, 34, 48 );
|
||||
m_BottomMainButton->setArmedBorderColor ( 194, 202, 54, 0 );
|
||||
m_BottomMainButton->setUnArmedColor ( 143, 143, 54, 0 );
|
||||
m_BottomMainButton->setArmedColor ( 194, 202, 54, 0 );
|
||||
|
||||
|
||||
m_BottomMainLabel = new Label("Spectator Bottom",
|
||||
XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6), flLabelSize, YRES(20));
|
||||
|
||||
m_BottomMainLabel->setParent( m_BottomBorder );
|
||||
m_BottomMainLabel->setPaintBackgroundEnabled( false );
|
||||
m_BottomMainLabel->setFgColor( Scheme::sc_primary1 );
|
||||
m_BottomMainLabel->setContentAlignment( vgui::Label::a_center );
|
||||
m_BottomMainLabel->setBorder( NULL );
|
||||
m_BottomMainLabel->setVisible(false);
|
||||
|
||||
m_InsetViewButton = new ColorButton( "", XRES( 2 ), YRES( 2 ), XRES( 240 ), YRES( 180 ), false, false );
|
||||
m_InsetViewButton->setParent( this );
|
||||
m_InsetViewButton->setBoundKey( (char)255 );
|
||||
m_InsetViewButton->addActionSignal( new CSpectatorHandler_Command( this, SPECTATOR_PANEL_CMD_TOGGLE_INSET ) );
|
||||
m_InsetViewButton->setUnArmedBorderColor( 59, 58, 34, 48 );
|
||||
m_InsetViewButton->setArmedBorderColor( 194, 202, 54, 0 );
|
||||
m_InsetViewButton->setUnArmedColor( 143, 143, 54, 0 );
|
||||
m_InsetViewButton->setArmedColor( 194, 202, 54, 0 );
|
||||
|
||||
m_menuVisible = false;
|
||||
m_insetVisible = false;
|
||||
// m_HideButton->setVisible( false );
|
||||
m_CamButton->setVisible( false );
|
||||
m_OptionButton->setVisible( false );
|
||||
m_NextPlayerButton->setVisible( false );
|
||||
m_PrevPlayerButton->setVisible( false );
|
||||
m_TopBanner->setVisible( false );
|
||||
m_ExtraInfo->setVisible( false );
|
||||
m_Separator->setVisible( false );
|
||||
m_TimerImage->setVisible( false );
|
||||
}
|
||||
|
||||
void SpectatorPanel::ShowMenu( bool isVisible )
|
||||
{
|
||||
// m_HideButton->setVisible(isVisible); m_HideButton->setArmed( false );
|
||||
m_OptionButton->setVisible(isVisible); m_OptionButton->setArmed( false );
|
||||
m_CamButton->setVisible(isVisible); m_CamButton->setArmed( false );
|
||||
m_NextPlayerButton->setVisible(isVisible); m_NextPlayerButton->setArmed( false );
|
||||
m_PrevPlayerButton->setVisible(isVisible); m_PrevPlayerButton->setArmed( false );
|
||||
|
||||
if( !isVisible )
|
||||
{
|
||||
int iLabelSizeX, iLabelSizeY;
|
||||
m_BottomMainLabel->setVisible(true);
|
||||
m_BottomMainButton->setVisible(false);
|
||||
|
||||
m_BottomMainLabel->getSize( iLabelSizeX, iLabelSizeY );
|
||||
m_BottomMainLabel->setPos( ( ScreenWidth / 2 ) - ( iLabelSizeX / 2 ), YRES( 6 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BottomMainButton->setPos( XRES( ( 15 + OPTIONS_BUTTON_X + 15 ) + 31 ), YRES(6) );
|
||||
m_BottomMainLabel->setVisible(false);
|
||||
m_BottomMainButton->setVisible(true);
|
||||
}
|
||||
|
||||
if( !isVisible )
|
||||
{
|
||||
gViewPort->HideCommandMenu();
|
||||
|
||||
// if switching from visible menu to invisible menu, show help text
|
||||
if( m_menuVisible && this->isVisible() )
|
||||
{
|
||||
char string[64];
|
||||
|
||||
_snprintf( string, sizeof(string) - 1, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( "#Spec_Duck" ) );
|
||||
string[sizeof(string) - 1] = '\0';
|
||||
|
||||
gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( string ) + 1, string );
|
||||
}
|
||||
}
|
||||
|
||||
m_menuVisible = isVisible;
|
||||
|
||||
gViewPort->UpdateCursorState();
|
||||
}
|
||||
|
||||
const char *GetSpectatorLabel( int iMode )
|
||||
{
|
||||
switch( iMode )
|
||||
{
|
||||
case OBS_CHASE_LOCKED:
|
||||
return "#OBS_CHASE_LOCKED";
|
||||
|
||||
case OBS_CHASE_FREE:
|
||||
return "#OBS_CHASE_FREE";
|
||||
|
||||
case OBS_ROAMING:
|
||||
return "#OBS_ROAMING";
|
||||
|
||||
case OBS_IN_EYE:
|
||||
return "#OBS_IN_EYE";
|
||||
|
||||
case OBS_MAP_FREE:
|
||||
return "#OBS_MAP_FREE";
|
||||
|
||||
case OBS_MAP_CHASE:
|
||||
return "#OBS_MAP_CHASE";
|
||||
|
||||
case OBS_NONE:
|
||||
default:
|
||||
return "#OBS_NONE";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void SpectatorPanel::EnableInsetView(bool isEnabled)
|
||||
{
|
||||
int x = gHUD.m_Spectator.m_OverviewData.insetWindowX;
|
||||
int y = gHUD.m_Spectator.m_OverviewData.insetWindowY;
|
||||
int wide = gHUD.m_Spectator.m_OverviewData.insetWindowWidth;
|
||||
int tall = gHUD.m_Spectator.m_OverviewData.insetWindowHeight;
|
||||
int offset = x + wide + 2;
|
||||
|
||||
if( isEnabled )
|
||||
{
|
||||
// short black bar to see full inset
|
||||
m_TopBorder->setBounds( XRES( offset ), 0, XRES(640 - offset ), YRES( PANEL_HEIGHT ) );
|
||||
|
||||
if( gEngfuncs.IsSpectateOnly() )
|
||||
{
|
||||
m_TopBanner->setVisible( true );
|
||||
m_TopBanner->setPos( XRES( offset ), 0 );
|
||||
}
|
||||
else
|
||||
m_TopBanner->setVisible( false );
|
||||
|
||||
m_InsetViewButton->setBounds( XRES( x -1 ), YRES( y ),
|
||||
XRES( wide +2), YRES( tall ) );
|
||||
m_InsetViewButton->setVisible( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
// full black bar, no inset border
|
||||
// show banner only in real HLTV mode
|
||||
if( gEngfuncs.IsSpectateOnly() )
|
||||
{
|
||||
m_TopBanner->setVisible( true );
|
||||
m_TopBanner->setPos( 0, 0 );
|
||||
}
|
||||
else
|
||||
m_TopBanner->setVisible( false );
|
||||
|
||||
m_TopBorder->setBounds( 0, 0, ScreenWidth, YRES( PANEL_HEIGHT ) );
|
||||
|
||||
m_InsetViewButton->setVisible( false );
|
||||
}
|
||||
|
||||
m_insetVisible = isEnabled;
|
||||
|
||||
Update();
|
||||
|
||||
m_CamButton->setText( CHudTextMessage::BufferedLocaliseTextString( GetSpectatorLabel( g_iUser1 ) ) );
|
||||
}
|
||||
|
||||
void SpectatorPanel::Update()
|
||||
{
|
||||
int iTextWidth, iTextHeight;
|
||||
int iTimeHeight, iTimeWidth;
|
||||
int offset, j;
|
||||
|
||||
if( m_insetVisible )
|
||||
offset = gHUD.m_Spectator.m_OverviewData.insetWindowX + gHUD.m_Spectator.m_OverviewData.insetWindowWidth + 2;
|
||||
else
|
||||
offset = 0;
|
||||
|
||||
bool visible = gHUD.m_Spectator.m_drawstatus->value != 0;
|
||||
|
||||
m_ExtraInfo->setVisible( visible );
|
||||
m_TimerImage->setVisible( visible );
|
||||
m_CurrentTime->setVisible( visible );
|
||||
m_Separator->setVisible( visible );
|
||||
|
||||
for( j = 0; j < TEAM_NUMBER; j++ )
|
||||
m_TeamScores[j]->setVisible( visible );
|
||||
|
||||
if( !visible )
|
||||
return;
|
||||
|
||||
m_ExtraInfo->getTextSize( iTextWidth, iTextHeight );
|
||||
m_CurrentTime->getTextSize( iTimeWidth, iTimeHeight );
|
||||
|
||||
iTimeWidth += XRES ( SEPERATOR_WIDTH*2 + 1 ); // +timer icon
|
||||
iTimeWidth += ( SEPERATOR_WIDTH-(iTimeWidth%SEPERATOR_WIDTH) );
|
||||
|
||||
if( iTimeWidth > iTextWidth )
|
||||
iTextWidth = iTimeWidth;
|
||||
|
||||
int xPos = ScreenWidth - ( iTextWidth + XRES ( SEPERATOR_WIDTH + offset ) );
|
||||
|
||||
m_ExtraInfo->setBounds( xPos, YRES( SEPERATOR_HEIGHT ), iTextWidth, iTextHeight );
|
||||
|
||||
m_TimerImage->setBounds( xPos, YRES( SEPERATOR_HEIGHT ) + iTextHeight , XRES(SEPERATOR_WIDTH*2 + 1), YRES(SEPERATOR_HEIGHT + 1) );
|
||||
|
||||
m_CurrentTime->setBounds( xPos + XRES ( SEPERATOR_WIDTH*2 + 1 ), YRES( SEPERATOR_HEIGHT ) + iTextHeight , iTimeWidth, iTimeHeight );
|
||||
|
||||
m_Separator->setPos( ScreenWidth - ( iTextWidth + XRES ( 2*SEPERATOR_WIDTH+SEPERATOR_WIDTH/2+offset ) ) , YRES( 5 ) );
|
||||
m_Separator->setSize( XRES( 1 ), PANEL_HEIGHT - 10 );
|
||||
|
||||
for( j = 0; j < TEAM_NUMBER; j++ )
|
||||
{
|
||||
int iwidth, iheight;
|
||||
|
||||
m_TeamScores[j]->getTextSize( iwidth, iheight );
|
||||
m_TeamScores[j]->setBounds( ScreenWidth - ( iTextWidth + XRES ( 2*SEPERATOR_WIDTH+2*SEPERATOR_WIDTH/2+offset ) + iwidth ), YRES( SEPERATOR_HEIGHT ) + ( iheight * j ), iwidth, iheight );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
// vgui_SpectatorPanel.h: interface for the SpectatorPanel class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SPECTATORPANEL_H
|
||||
#define SPECTATORPANEL_H
|
||||
|
||||
#include <VGUI_Panel.h>
|
||||
#include <VGUI_Label.h>
|
||||
#include <VGUI_Button.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
#define SPECTATOR_PANEL_CMD_NONE 0
|
||||
|
||||
#define SPECTATOR_PANEL_CMD_OPTIONS 1
|
||||
#define SPECTATOR_PANEL_CMD_PREVPLAYER 2
|
||||
#define SPECTATOR_PANEL_CMD_NEXTPLAYER 3
|
||||
#define SPECTATOR_PANEL_CMD_HIDEMENU 4
|
||||
#define SPECTATOR_PANEL_CMD_TOGGLE_INSET 5
|
||||
#define SPECTATOR_PANEL_CMD_CAMERA 6
|
||||
#define SPECTATOR_PANEL_CMD_PLAYERS 7
|
||||
|
||||
// spectator panel sizes
|
||||
#define PANEL_HEIGHT 64
|
||||
|
||||
#define BANNER_WIDTH 256
|
||||
#define BANNER_HEIGHT 64
|
||||
|
||||
#define OPTIONS_BUTTON_X 96
|
||||
#define CAMOPTIONS_BUTTON_X 200
|
||||
|
||||
|
||||
#define SEPERATOR_WIDTH 15
|
||||
#define SEPERATOR_HEIGHT 15
|
||||
|
||||
|
||||
#define TEAM_NUMBER 2
|
||||
|
||||
class SpectatorPanel : public Panel //, public vgui::CDefaultInputSignal
|
||||
{
|
||||
|
||||
public:
|
||||
SpectatorPanel( int x, int y, int wide, int tall );
|
||||
virtual ~SpectatorPanel();
|
||||
|
||||
void ActionSignal( int cmd );
|
||||
|
||||
// InputSignal overrides.
|
||||
public:
|
||||
void Initialize();
|
||||
void Update();
|
||||
|
||||
void EnableInsetView( bool isEnabled );
|
||||
void ShowMenu( bool isVisible );
|
||||
|
||||
DropDownButton * m_OptionButton;
|
||||
// CommandButton *m_HideButton;
|
||||
//ColorButton * m_PrevPlayerButton;
|
||||
//ColorButton * m_NextPlayerButton;
|
||||
CImageButton * m_PrevPlayerButton;
|
||||
CImageButton * m_NextPlayerButton;
|
||||
DropDownButton * m_CamButton;
|
||||
|
||||
CTransparentPanel *m_TopBorder;
|
||||
CTransparentPanel *m_BottomBorder;
|
||||
|
||||
ColorButton *m_InsetViewButton;
|
||||
|
||||
DropDownButton *m_BottomMainButton;
|
||||
CImageLabel *m_TimerImage;
|
||||
Label *m_BottomMainLabel;
|
||||
Label *m_CurrentTime;
|
||||
Label *m_ExtraInfo;
|
||||
Panel *m_Separator;
|
||||
|
||||
Label *m_TeamScores[TEAM_NUMBER];
|
||||
|
||||
CImageLabel *m_TopBanner;
|
||||
|
||||
bool m_menuVisible;
|
||||
bool m_insetVisible;
|
||||
};
|
||||
|
||||
class CSpectatorHandler_Command : public ActionSignal
|
||||
{
|
||||
|
||||
private:
|
||||
SpectatorPanel *m_pFather;
|
||||
int m_cmd;
|
||||
|
||||
public:
|
||||
CSpectatorHandler_Command( SpectatorPanel *panel, int cmd )
|
||||
{
|
||||
m_pFather = panel;
|
||||
m_cmd = cmd;
|
||||
}
|
||||
|
||||
virtual void actionPerformed( Panel *panel )
|
||||
{
|
||||
m_pFather->ActionSignal( m_cmd );
|
||||
}
|
||||
};
|
||||
#endif // !defined SPECTATORPANEL_H
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,127 @@
|
|||
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "vgui_int.h"
|
||||
#include <VGUI_Label.h>
|
||||
#include <VGUI_BorderLayout.h>
|
||||
#include <VGUI_LineBorder.h>
|
||||
#include <VGUI_SurfaceBase.h>
|
||||
#include <VGUI_TextEntry.h>
|
||||
#include <VGUI_ActionSignal.h>
|
||||
#include <string.h>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "camera.h"
|
||||
#include "kbutton.h"
|
||||
#include "cvardef.h"
|
||||
#include "usercmd.h"
|
||||
#include "const.h"
|
||||
#include "camera.h"
|
||||
#include "in_defs.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "vgui_ControlConfigPanel.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class TexturePanel : public Panel, public ActionSignal
|
||||
{
|
||||
private:
|
||||
int _bindIndex;
|
||||
TextEntry *_textEntry;
|
||||
public:
|
||||
TexturePanel() : Panel( 0, 0, 256, 276 )
|
||||
{
|
||||
_bindIndex = 2700;
|
||||
_textEntry = new TextEntry( "2700", 0, 0, 128, 20 );
|
||||
_textEntry->setParent( this );
|
||||
_textEntry->addActionSignal( this );
|
||||
}
|
||||
|
||||
virtual bool isWithin( int x, int y )
|
||||
{
|
||||
return _textEntry->isWithin( x, y );
|
||||
}
|
||||
|
||||
virtual void actionPerformed( Panel *panel )
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
_textEntry->getText( 0, buf, 256 );
|
||||
sscanf( buf, "%d", &_bindIndex);
|
||||
}
|
||||
protected:
|
||||
virtual void paintBackground()
|
||||
{
|
||||
Panel::paintBackground();
|
||||
|
||||
int wide, tall;
|
||||
|
||||
getPaintSize( wide, tall );
|
||||
|
||||
drawSetColor( 0, 0, 255, 0 );
|
||||
drawSetTexture( _bindIndex );
|
||||
drawTexturedRect( 0, 19, 257, 257 );
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
void VGui_ViewportPaintBackground( int extents[4] )
|
||||
{
|
||||
gEngfuncs.VGui_ViewportPaintBackground( extents );
|
||||
}
|
||||
|
||||
void* VGui_GetPanel()
|
||||
{
|
||||
return (Panel*)gEngfuncs.VGui_GetPanel();
|
||||
}
|
||||
|
||||
void VGui_Startup()
|
||||
{
|
||||
Panel *root = (Panel*)VGui_GetPanel();
|
||||
root->setBgColor( 128, 128, 0, 0 );
|
||||
// root->setNonPainted( false );
|
||||
// root->setBorder( new LineBorder() );
|
||||
root->setLayout( new BorderLayout( 0 ) );
|
||||
|
||||
// root->getSurfaceBase()->setEmulatedCursorVisible( true );
|
||||
|
||||
if( gViewPort != NULL )
|
||||
{
|
||||
// root->removeChild( gViewPort );
|
||||
|
||||
// free the memory
|
||||
// delete gViewPort;
|
||||
// gViewPort = NULL;
|
||||
|
||||
gViewPort->Initialize();
|
||||
}
|
||||
else
|
||||
{
|
||||
gViewPort = new TeamFortressViewport( 0, 0, root->getWide(), root->getTall() );
|
||||
gViewPort->setParent( root );
|
||||
}
|
||||
|
||||
/*
|
||||
TexturePanel *texturePanel = new TexturePanel();
|
||||
texturePanel->setParent( gViewPort );
|
||||
*/
|
||||
}
|
||||
|
||||
void VGui_Shutdown()
|
||||
{
|
||||
delete gViewPort;
|
||||
gViewPort = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef VGUI_INT_H
|
||||
#define VGUI_INT_H
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void VGui_Startup();
|
||||
void VGui_Shutdown();
|
||||
|
||||
//Only safe to call from inside subclass of Panel::paintBackground
|
||||
void VGui_ViewportPaintBackground(int extents[4]);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,394 @@
|
|||
//=========== (C) Copyright 1996-2002 Valve, L.L.C. All rights reserved. ===========
|
||||
//
|
||||
// The copyright to the contents herein is the property of Valve, L.L.C.
|
||||
// The contents may be used and/or copied only with the written permission of
|
||||
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
|
||||
// the agreement/contract under which the contents have been supplied.
|
||||
//
|
||||
// Purpose: TFC Team Menu
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// $Log: $
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "vgui_int.h"
|
||||
#include "VGUI_Font.h"
|
||||
#include "VGUI_ScrollPanel.h"
|
||||
#include "VGUI_TextImage.h"
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
|
||||
// Team Menu Dimensions
|
||||
#define TEAMMENU_TITLE_X XRES(40)
|
||||
#define TEAMMENU_TITLE_Y YRES(32)
|
||||
#define TEAMMENU_TOPLEFT_BUTTON_X XRES(40)
|
||||
#define TEAMMENU_TOPLEFT_BUTTON_Y YRES(80)
|
||||
#define TEAMMENU_BUTTON_SIZE_X XRES(124)
|
||||
#define TEAMMENU_BUTTON_SIZE_Y YRES(24)
|
||||
#define TEAMMENU_BUTTON_SPACER_Y YRES(8)
|
||||
#define TEAMMENU_WINDOW_X XRES(176)
|
||||
#define TEAMMENU_WINDOW_Y YRES(80)
|
||||
#define TEAMMENU_WINDOW_SIZE_X XRES(424)
|
||||
#define TEAMMENU_WINDOW_SIZE_Y YRES(312)
|
||||
#define TEAMMENU_WINDOW_TITLE_X XRES(16)
|
||||
#define TEAMMENU_WINDOW_TITLE_Y YRES(16)
|
||||
#define TEAMMENU_WINDOW_TEXT_X XRES(16)
|
||||
#define TEAMMENU_WINDOW_TEXT_Y YRES(48)
|
||||
#define TEAMMENU_WINDOW_TEXT_SIZE_Y YRES(178)
|
||||
#define TEAMMENU_WINDOW_INFO_X XRES(16)
|
||||
#define TEAMMENU_WINDOW_INFO_Y YRES(234)
|
||||
|
||||
// Creation
|
||||
CTeamMenuPanel::CTeamMenuPanel( int iTrans, int iRemoveMe, int x, int y, int wide, int tall ) : CMenuPanel( iTrans, iRemoveMe, x, y, wide, tall )
|
||||
{
|
||||
// Get the scheme used for the Titles
|
||||
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
|
||||
|
||||
// schemes
|
||||
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
|
||||
SchemeHandle_t hTeamWindowText = pSchemes->getSchemeHandle( "Briefing Text" );
|
||||
SchemeHandle_t hTeamInfoText = pSchemes->getSchemeHandle( "Team Info Text" );
|
||||
|
||||
// get the Font used for the Titles
|
||||
Font *pTitleFont = pSchemes->getFont( hTitleScheme );
|
||||
int r, g, b, a;
|
||||
|
||||
// Create the title
|
||||
Label *pLabel = new Label( "", TEAMMENU_TITLE_X, TEAMMENU_TITLE_Y );
|
||||
pLabel->setParent( this );
|
||||
pLabel->setFont( pTitleFont );
|
||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
||||
pLabel->setFgColor( r, g, b, a );
|
||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
||||
pLabel->setBgColor( r, g, b, a );
|
||||
pLabel->setContentAlignment( vgui::Label::a_west );
|
||||
pLabel->setText( "%s", gHUD.m_TextMessage.BufferedLocaliseTextString("#Title_SelectYourTeam"));
|
||||
|
||||
// Create the Info Window
|
||||
m_pTeamWindow = new CTransparentPanel( 255, TEAMMENU_WINDOW_X, TEAMMENU_WINDOW_Y, TEAMMENU_WINDOW_SIZE_X, TEAMMENU_WINDOW_SIZE_Y );
|
||||
m_pTeamWindow->setParent( this );
|
||||
m_pTeamWindow->setBorder( new LineBorder( Color( 255 * 0.7, 170 * 0.7 ,0 ,0 ) ) );
|
||||
|
||||
// Create the Map Name Label
|
||||
m_pMapTitle = new Label( "", TEAMMENU_WINDOW_TITLE_X, TEAMMENU_WINDOW_TITLE_Y );
|
||||
m_pMapTitle->setFont( pTitleFont );
|
||||
m_pMapTitle->setParent( m_pTeamWindow );
|
||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
||||
m_pMapTitle->setFgColor( r, g, b, a );
|
||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
||||
m_pMapTitle->setBgColor( r, g, b, a );
|
||||
m_pMapTitle->setContentAlignment( vgui::Label::a_west );
|
||||
|
||||
// Create the Scroll panel
|
||||
m_pScrollPanel = new CTFScrollPanel( TEAMMENU_WINDOW_TEXT_X, TEAMMENU_WINDOW_TEXT_Y, TEAMMENU_WINDOW_SIZE_X - ( TEAMMENU_WINDOW_TEXT_X * 2 ), TEAMMENU_WINDOW_TEXT_SIZE_Y );
|
||||
m_pScrollPanel->setParent( m_pTeamWindow );
|
||||
m_pScrollPanel->setScrollBarVisible( false, false );
|
||||
|
||||
// Create the Map Briefing panel
|
||||
m_pBriefing = new TextPanel("", 0, 0, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_TEXT_X, TEAMMENU_WINDOW_TEXT_SIZE_Y );
|
||||
m_pBriefing->setParent( m_pScrollPanel->getClient() );
|
||||
m_pBriefing->setFont( pSchemes->getFont( hTeamWindowText ) );
|
||||
pSchemes->getFgColor( hTeamWindowText, r, g, b, a );
|
||||
m_pBriefing->setFgColor( r, g, b, a );
|
||||
pSchemes->getBgColor( hTeamWindowText, r, g, b, a );
|
||||
m_pBriefing->setBgColor( r, g, b, a );
|
||||
|
||||
m_pBriefing->setText( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Map_Description_not_available" ) );
|
||||
|
||||
// Team Menu buttons
|
||||
for( int i = 1; i <= 5; i++ )
|
||||
{
|
||||
char sz[256];
|
||||
|
||||
int iYPos = TEAMMENU_TOPLEFT_BUTTON_Y + ( ( TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y ) * i );
|
||||
|
||||
// Team button
|
||||
m_pButtons[i] = new CommandButton( "", TEAMMENU_TOPLEFT_BUTTON_X, iYPos, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y, true );
|
||||
m_pButtons[i]->setParent( this );
|
||||
m_pButtons[i]->setContentAlignment( vgui::Label::a_west );
|
||||
m_pButtons[i]->setVisible( false );
|
||||
|
||||
// AutoAssign button uses special case
|
||||
if( i == 5 )
|
||||
{
|
||||
m_pButtons[5]->setBoundKey( '5' );
|
||||
m_pButtons[5]->setText( gHUD.m_TextMessage.BufferedLocaliseTextString( "#Team_AutoAssign" ) );
|
||||
m_pButtons[5]->setVisible( true );
|
||||
}
|
||||
|
||||
// Create the Signals
|
||||
sprintf( sz, "jointeam %d", i );
|
||||
m_pButtons[i]->addActionSignal( new CMenuHandler_StringCommandWatch( sz, true ) );
|
||||
m_pButtons[i]->addInputSignal( new CHandler_MenuButtonOver( this, i ) );
|
||||
|
||||
// Create the Team Info panel
|
||||
m_pTeamInfoPanel[i] = new TextPanel( "", TEAMMENU_WINDOW_INFO_X, TEAMMENU_WINDOW_INFO_Y, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_INFO_X, TEAMMENU_WINDOW_SIZE_X - TEAMMENU_WINDOW_INFO_Y );
|
||||
m_pTeamInfoPanel[i]->setParent( m_pTeamWindow );
|
||||
m_pTeamInfoPanel[i]->setFont( pSchemes->getFont( hTeamInfoText ) );
|
||||
m_pTeamInfoPanel[i]->setFgColor( iTeamColors[i % iNumberOfTeamColors][0],
|
||||
iTeamColors[i % iNumberOfTeamColors][1],
|
||||
iTeamColors[i % iNumberOfTeamColors][2],
|
||||
0 );
|
||||
m_pTeamInfoPanel[i]->setBgColor( 0, 0, 0, 255 );
|
||||
}
|
||||
|
||||
// Create the Cancel button
|
||||
m_pCancelButton = new CommandButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_Cancel" ), TEAMMENU_TOPLEFT_BUTTON_X, 0, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y );
|
||||
m_pCancelButton->setParent( this );
|
||||
m_pCancelButton->addActionSignal( new CMenuHandler_TextWindow( HIDE_TEXTWINDOW ) );
|
||||
|
||||
// Create the Spectate button
|
||||
m_pSpectateButton = new SpectateButton( CHudTextMessage::BufferedLocaliseTextString( "#Menu_Spectate" ), TEAMMENU_TOPLEFT_BUTTON_X, 0, TEAMMENU_BUTTON_SIZE_X, TEAMMENU_BUTTON_SIZE_Y, true );
|
||||
m_pSpectateButton->setParent( this );
|
||||
m_pSpectateButton->addActionSignal( new CMenuHandler_StringCommand( "spectate", true ) );
|
||||
m_pSpectateButton->setBoundKey( '6' );
|
||||
m_pSpectateButton->addInputSignal( new CHandler_MenuButtonOver( this, 6 ) );
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Called each time a new level is started.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTeamMenuPanel::Initialize( void )
|
||||
{
|
||||
m_bUpdatedMapName = false;
|
||||
m_iCurrentInfo = 0;
|
||||
m_pScrollPanel->setScrollValue( 0, 0 );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Called everytime the Team Menu is displayed
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTeamMenuPanel::Update( void )
|
||||
{
|
||||
int iYPos = TEAMMENU_TOPLEFT_BUTTON_Y;
|
||||
|
||||
// Set the team buttons
|
||||
for( int i = 1; i <= 4; i++ )
|
||||
{
|
||||
if( m_pButtons[i] )
|
||||
{
|
||||
if( i <= gViewPort->GetNumberOfTeams() )
|
||||
{
|
||||
m_pButtons[i]->setText( gViewPort->GetTeamName( i ) );
|
||||
|
||||
// bound key replacement
|
||||
char sz[32];
|
||||
sprintf( sz, "%d", i );
|
||||
m_pButtons[i]->setBoundKey( sz[0] );
|
||||
|
||||
m_pButtons[i]->setVisible( true );
|
||||
m_pButtons[i]->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos );
|
||||
iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y;
|
||||
|
||||
// Start with the first option up
|
||||
if( !m_iCurrentInfo )
|
||||
SetActiveInfo( i );
|
||||
|
||||
char szPlayerList[( MAX_PLAYER_NAME_LENGTH + 3 ) * 31]; // name + ", "
|
||||
strcpy(szPlayerList, "\n");
|
||||
// Update the Team Info
|
||||
// Now count the number of teammembers of this class
|
||||
int iTotal = 0;
|
||||
for( int j = 1; j < MAX_PLAYERS; j++ )
|
||||
{
|
||||
if( g_PlayerInfoList[j].name == NULL )
|
||||
continue; // empty player slot, skip
|
||||
if( g_PlayerInfoList[j].thisplayer )
|
||||
continue; // skip this player
|
||||
if( g_PlayerExtraInfo[j].teamnumber != i )
|
||||
continue; // skip over players in other teams
|
||||
|
||||
iTotal++;
|
||||
if( iTotal > 1 )
|
||||
strncat( szPlayerList, ", ", sizeof(szPlayerList) - strlen( szPlayerList ) - 1 );
|
||||
strncat( szPlayerList, g_PlayerInfoList[j].name, sizeof(szPlayerList) - strlen( szPlayerList ) - 1 );
|
||||
szPlayerList[sizeof(szPlayerList) - 1] = '\0';
|
||||
}
|
||||
|
||||
if( iTotal > 0 )
|
||||
{
|
||||
// Set the text of the info Panel
|
||||
char szText[( ( MAX_PLAYER_NAME_LENGTH + 3 ) * 31 ) + 256];
|
||||
if( iTotal == 1 )
|
||||
sprintf( szText, "%s: %d Player (%d points)", gViewPort->GetTeamName( i ), iTotal, g_TeamInfo[i].frags );
|
||||
else
|
||||
sprintf( szText, "%s: %d Players (%d points)", gViewPort->GetTeamName( i ), iTotal, g_TeamInfo[i].frags );
|
||||
strncat( szText, szPlayerList, sizeof(szText) - strlen( szText ) - 1 );
|
||||
szText[sizeof(szText) - 1] = '\0';
|
||||
|
||||
m_pTeamInfoPanel[i]->setText( szText );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pTeamInfoPanel[i]->setText( "" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Hide the button (may be visible from previous maps)
|
||||
m_pButtons[i]->setVisible( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Move the AutoAssign button into place
|
||||
m_pButtons[5]->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos );
|
||||
iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y;
|
||||
|
||||
// Spectate button
|
||||
if( m_pSpectateButton->IsNotValid() )
|
||||
{
|
||||
m_pSpectateButton->setVisible( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSpectateButton->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos );
|
||||
m_pSpectateButton->setVisible( true );
|
||||
iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y;
|
||||
}
|
||||
|
||||
// If the player is already in a team, make the cancel button visible
|
||||
if( g_iTeamNumber )
|
||||
{
|
||||
m_pCancelButton->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos );
|
||||
iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y;
|
||||
m_pCancelButton->setVisible( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pCancelButton->setVisible( false );
|
||||
}
|
||||
|
||||
// Set the Map Title
|
||||
if( !m_bUpdatedMapName )
|
||||
{
|
||||
const char *level = gEngfuncs.pfnGetLevelName();
|
||||
if( level && level[0] )
|
||||
{
|
||||
char sz[256];
|
||||
char szTitle[256];
|
||||
char *ch;
|
||||
|
||||
// Update the level name
|
||||
strcpy( sz, level );
|
||||
ch = strchr( sz, '/' );
|
||||
if( !ch )
|
||||
ch = strchr( sz, '\\' );
|
||||
strcpy( szTitle, ch + 1 );
|
||||
ch = strchr( szTitle, '.' );
|
||||
*ch = '\0';
|
||||
m_pMapTitle->setText( "%s", szTitle );
|
||||
*ch = '.';
|
||||
|
||||
// Update the map briefing
|
||||
strcpy( sz, level );
|
||||
ch = strchr( sz, '.' );
|
||||
*ch = '\0';
|
||||
strcat( sz, ".txt" );
|
||||
char *pfile = (char*)gEngfuncs.COM_LoadFile( sz, 5, NULL );
|
||||
if( pfile )
|
||||
{
|
||||
m_pBriefing->setText( pfile );
|
||||
|
||||
// Get the total size of the Briefing text and resize the text panel
|
||||
int iXSize, iYSize;
|
||||
m_pBriefing->getTextImage()->getTextSize( iXSize, iYSize );
|
||||
m_pBriefing->setSize( iXSize, iYSize );
|
||||
gEngfuncs.COM_FreeFile( pfile );
|
||||
}
|
||||
|
||||
m_bUpdatedMapName = true;
|
||||
}
|
||||
}
|
||||
|
||||
m_pScrollPanel->validate();
|
||||
}
|
||||
|
||||
//=====================================
|
||||
// Key inputs
|
||||
bool CTeamMenuPanel::SlotInput( int iSlot )
|
||||
{
|
||||
// Check for AutoAssign
|
||||
if( iSlot == 5 )
|
||||
{
|
||||
m_pButtons[5]->fireActionSignal();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Spectate
|
||||
if( iSlot == 6 )
|
||||
{
|
||||
m_pSpectateButton->fireActionSignal();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise, see if a particular team is selectable
|
||||
if( ( iSlot < 1 ) || ( iSlot > gViewPort->GetNumberOfTeams() ) )
|
||||
return false;
|
||||
|
||||
if( !m_pButtons[iSlot] )
|
||||
return false;
|
||||
|
||||
// Is the button pushable?
|
||||
if( m_pButtons[iSlot]->isVisible() )
|
||||
{
|
||||
m_pButtons[iSlot]->fireActionSignal();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//======================================
|
||||
// Update the Team menu before opening it
|
||||
void CTeamMenuPanel::Open( void )
|
||||
{
|
||||
Update();
|
||||
CMenuPanel::Open();
|
||||
}
|
||||
|
||||
void CTeamMenuPanel::paintBackground()
|
||||
{
|
||||
// make sure we get the map briefing up
|
||||
if( !m_bUpdatedMapName )
|
||||
Update();
|
||||
|
||||
CMenuPanel::paintBackground();
|
||||
}
|
||||
|
||||
//======================================
|
||||
// Mouse is over a team button, bring up the class info
|
||||
void CTeamMenuPanel::SetActiveInfo( int iInput )
|
||||
{
|
||||
// Remove all the Info panels and bring up the specified one
|
||||
m_pSpectateButton->setArmed( false );
|
||||
for( int i = 1; i <= 5; i++ )
|
||||
{
|
||||
m_pButtons[i]->setArmed( false );
|
||||
m_pTeamInfoPanel[i]->setVisible( false );
|
||||
}
|
||||
|
||||
// 6 is Spectate
|
||||
if( iInput == 6 )
|
||||
{
|
||||
m_pSpectateButton->setArmed( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pButtons[iInput]->setArmed( true );
|
||||
m_pTeamInfoPanel[iInput]->setVisible( true );
|
||||
}
|
||||
|
||||
m_iCurrentInfo = iInput;
|
||||
|
||||
m_pScrollPanel->validate();
|
||||
}
|
191
cl_dll/view.cpp
191
cl_dll/view.cpp
|
@ -25,6 +25,7 @@
|
|||
#include "screenfade.h"
|
||||
#include "shake.h"
|
||||
#include "hltv.h"
|
||||
#include "view.h"
|
||||
|
||||
// Spectator Mode
|
||||
extern "C"
|
||||
|
@ -36,10 +37,6 @@ extern "C"
|
|||
int iIsSpectator;
|
||||
}
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
int CL_IsThirdPerson( void );
|
||||
|
@ -91,6 +88,7 @@ float v_cameraFocusAngle = 35.0f;
|
|||
int v_cameraMode = CAM_MODE_FOCUS;
|
||||
qboolean v_resetCamera = 1;
|
||||
|
||||
vec3_t v_client_aimangles;
|
||||
vec3_t g_ev_punchangle;
|
||||
|
||||
cvar_t *scr_ofsx;
|
||||
|
@ -126,13 +124,13 @@ void V_NormalizeAngles( float *angles )
|
|||
// Normalize angles
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
if( angles[i] > 180.0 )
|
||||
if( angles[i] > 180.0f )
|
||||
{
|
||||
angles[i] -= 360.0;
|
||||
angles[i] -= 360.0f;
|
||||
}
|
||||
else if( angles[i] < -180.0 )
|
||||
else if( angles[i] < -180.0f )
|
||||
{
|
||||
angles[i] += 360.0;
|
||||
angles[i] += 360.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,13 +158,13 @@ void V_InterpolateAngles( float *start, float *end, float *output, float frac )
|
|||
ang2 = end[i];
|
||||
|
||||
d = ang2 - ang1;
|
||||
if( d > 180 )
|
||||
if( d > 180.0f )
|
||||
{
|
||||
d -= 360;
|
||||
d -= 360.0f;
|
||||
}
|
||||
else if( d < -180 )
|
||||
else if( d < -180.0f )
|
||||
{
|
||||
d += 360;
|
||||
d += 360.0f;
|
||||
}
|
||||
|
||||
output[i] = ang1 + d * frac;
|
||||
|
@ -199,11 +197,11 @@ float V_CalcBob( struct ref_params_s *pparams )
|
|||
|
||||
if( cycle < cl_bobup->value )
|
||||
{
|
||||
cycle = M_PI * cycle / cl_bobup->value;
|
||||
cycle = M_PI_F * cycle / cl_bobup->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
cycle = M_PI + M_PI * ( cycle - cl_bobup->value )/( 1.0 - cl_bobup->value );
|
||||
cycle = M_PI_F + M_PI_F * ( cycle - cl_bobup->value )/( 1.0f - cl_bobup->value );
|
||||
}
|
||||
|
||||
// bob is proportional to simulated velocity in the xy plane
|
||||
|
@ -212,9 +210,9 @@ float V_CalcBob( struct ref_params_s *pparams )
|
|||
vel[2] = 0;
|
||||
|
||||
bob = sqrt( vel[0] * vel[0] + vel[1] * vel[1] ) * cl_bob->value;
|
||||
bob = bob * 0.3 + bob * 0.7 * sin(cycle);
|
||||
bob = Q_min( bob, 4 );
|
||||
bob = Q_max( bob, -7 );
|
||||
bob = bob * 0.3f + bob * 0.7f * sin(cycle);
|
||||
bob = Q_min( bob, 4.0f );
|
||||
bob = Q_max( bob, -7.0f );
|
||||
return bob;
|
||||
}
|
||||
|
||||
|
@ -234,7 +232,7 @@ float V_CalcRoll( vec3_t angles, vec3_t velocity, float rollangle, float rollspe
|
|||
AngleVectors( angles, forward, right, up );
|
||||
|
||||
side = DotProduct( velocity, right );
|
||||
sign = side < 0 ? -1 : 1;
|
||||
sign = side < 0.0f ? -1.0f : 1.0f;
|
||||
side = fabs( side );
|
||||
|
||||
value = rollangle;
|
||||
|
@ -290,11 +288,11 @@ void V_CalcGunAngle( struct ref_params_s *pparams )
|
|||
return;
|
||||
|
||||
viewent->angles[YAW] = pparams->viewangles[YAW] + pparams->crosshairangle[YAW];
|
||||
viewent->angles[PITCH] = -pparams->viewangles[PITCH] + pparams->crosshairangle[PITCH] * 0.25;
|
||||
viewent->angles[PITCH] = -pparams->viewangles[PITCH] + pparams->crosshairangle[PITCH] * 0.25f;
|
||||
viewent->angles[ROLL] -= v_idlescale * sin( pparams->time * v_iroll_cycle.value ) * v_iroll_level.value;
|
||||
|
||||
// don't apply all of the v_ipitch to prevent normally unseen parts of viewmodel from coming into view.
|
||||
viewent->angles[PITCH] -= v_idlescale * sin( pparams->time * v_ipitch_cycle.value ) * ( v_ipitch_level.value * 0.5 );
|
||||
viewent->angles[PITCH] -= v_idlescale * sin( pparams->time * v_ipitch_cycle.value ) * ( v_ipitch_level.value * 0.5f );
|
||||
viewent->angles[YAW] -= v_idlescale * sin( pparams->time * v_iyaw_cycle.value ) * v_iyaw_level.value;
|
||||
|
||||
VectorCopy( viewent->angles, viewent->curstate.angles );
|
||||
|
@ -453,15 +451,15 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
}
|
||||
|
||||
gEngfuncs.V_CalcShake();
|
||||
gEngfuncs.V_ApplyShake( pparams->vieworg, pparams->viewangles, 1.0 );
|
||||
gEngfuncs.V_ApplyShake( pparams->vieworg, pparams->viewangles, 1.0f );
|
||||
|
||||
// never let view origin sit exactly on a node line, because a water plane can
|
||||
// dissapear when viewed with the eye exactly on it.
|
||||
// FIXME, we send origin at 1/128 now, change this?
|
||||
// the server protocol only specifies to 1/16 pixel, so add 1/32 in each axis
|
||||
pparams->vieworg[0] += 1.0 / 32;
|
||||
pparams->vieworg[1] += 1.0 / 32;
|
||||
pparams->vieworg[2] += 1.0 / 32;
|
||||
pparams->vieworg[0] += 1.0f / 32.0f;
|
||||
pparams->vieworg[1] += 1.0f / 32.0f;
|
||||
pparams->vieworg[2] += 1.0f / 32.0f;
|
||||
|
||||
// Check for problems around water, move the viewer artificially if necessary
|
||||
// -- this prevents drawing errors in GL due to waves
|
||||
|
@ -481,13 +479,13 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
pwater = gEngfuncs.GetEntityByIndex( waterEntity );
|
||||
if( pwater && ( pwater->model != NULL ) )
|
||||
{
|
||||
waterDist += ( pwater->curstate.scale * 16 ); // Add in wave height
|
||||
waterDist += ( pwater->curstate.scale * 16.0f ); // Add in wave height
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
waterEntity = 0; // Don't need this in software
|
||||
// waterEntity = 0; // Don't need this in software
|
||||
}
|
||||
|
||||
VectorCopy( pparams->vieworg, point );
|
||||
|
@ -553,7 +551,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
{
|
||||
vec3_t ofs;
|
||||
|
||||
ofs[0] = ofs[1] = ofs[2] = 0.0;
|
||||
ofs[0] = ofs[1] = ofs[2] = 0.0f;
|
||||
|
||||
CL_CameraOffset( (float *)&ofs );
|
||||
|
||||
|
@ -586,18 +584,18 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
VectorAdd( view->origin, pparams->viewheight, view->origin );
|
||||
|
||||
// Let the viewmodel shake at about 10% of the amplitude
|
||||
gEngfuncs.V_ApplyShake( view->origin, view->angles, 0.9 );
|
||||
gEngfuncs.V_ApplyShake( view->origin, view->angles, 0.9f );
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
view->origin[i] += bob * 0.4 * pparams->forward[i];
|
||||
view->origin[i] += bob * 0.4f * pparams->forward[i];
|
||||
}
|
||||
view->origin[2] += bob;
|
||||
|
||||
// throw in a little tilt.
|
||||
view->angles[YAW] -= bob * 0.5;
|
||||
view->angles[ROLL] -= bob * 1;
|
||||
view->angles[PITCH] -= bob * 0.3;
|
||||
view->angles[YAW] -= bob * 0.5f;
|
||||
view->angles[ROLL] -= bob * 1.0f;
|
||||
view->angles[PITCH] -= bob * 0.3f;
|
||||
|
||||
if( cl_viewbob && cl_viewbob->value )
|
||||
VectorCopy( view->angles, view->curstate.angles );
|
||||
|
@ -605,25 +603,25 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
// pushing the view origin down off of the same X/Z plane as the ent's origin will give the
|
||||
// gun a very nice 'shifting' effect when the player looks up/down. If there is a problem
|
||||
// with view model distortion, this may be a cause. (SJB).
|
||||
view->origin[2] -= 1;
|
||||
view->origin[2] -= 1.0f;
|
||||
|
||||
// fudge position around to keep amount of weapon visible
|
||||
// roughly equal with different FOV
|
||||
if( pparams->viewsize == 110 )
|
||||
if( pparams->viewsize == 110.0f )
|
||||
{
|
||||
view->origin[2] += 1;
|
||||
view->origin[2] += 1.0f;
|
||||
}
|
||||
else if( pparams->viewsize == 100 )
|
||||
else if( pparams->viewsize == 100.0f )
|
||||
{
|
||||
view->origin[2] += 2;
|
||||
view->origin[2] += 2.0f;
|
||||
}
|
||||
else if( pparams->viewsize == 90 )
|
||||
else if( pparams->viewsize == 90.0f )
|
||||
{
|
||||
view->origin[2] += 1;
|
||||
view->origin[2] += 1.0f;
|
||||
}
|
||||
else if( pparams->viewsize == 80 )
|
||||
else if( pparams->viewsize == 80.0f )
|
||||
{
|
||||
view->origin[2] += 0.5;
|
||||
view->origin[2] += 0.5f;
|
||||
}
|
||||
|
||||
// Add in the punchangle, if any
|
||||
|
@ -636,7 +634,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
|
||||
// smooth out stair step ups
|
||||
#if 1
|
||||
if( !pparams->smoothing && pparams->onground && pparams->simorg[2] - oldz > 0 )
|
||||
if( !pparams->smoothing && pparams->onground && pparams->simorg[2] - oldz > 0.0f )
|
||||
{
|
||||
float steptime;
|
||||
|
||||
|
@ -646,11 +644,11 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
//FIXME I_Error( "steptime < 0" );
|
||||
steptime = 0;
|
||||
|
||||
oldz += steptime * 150;
|
||||
oldz += steptime * 150.0f;
|
||||
if( oldz > pparams->simorg[2] )
|
||||
oldz = pparams->simorg[2];
|
||||
if( pparams->simorg[2] - oldz > 18 )
|
||||
oldz = pparams->simorg[2]- 18;
|
||||
if( pparams->simorg[2] - oldz > 18.0f )
|
||||
oldz = pparams->simorg[2]- 18.0f;
|
||||
pparams->vieworg[2] += oldz - pparams->simorg[2];
|
||||
view->origin[2] += oldz - pparams->simorg[2];
|
||||
}
|
||||
|
@ -665,7 +663,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
|
||||
VectorSubtract( pparams->simorg, lastorg, delta );
|
||||
|
||||
if( Length( delta ) != 0.0 )
|
||||
if( Length( delta ) != 0.0f )
|
||||
{
|
||||
VectorCopy( pparams->simorg, ViewInterp.Origins[ViewInterp.CurrentOrigin & ORIGIN_MASK] );
|
||||
ViewInterp.OriginTime[ViewInterp.CurrentOrigin & ORIGIN_MASK] = pparams->time;
|
||||
|
@ -682,9 +680,9 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
int foundidx;
|
||||
float t;
|
||||
|
||||
if( cl_vsmoothing->value < 0.0 )
|
||||
if( cl_vsmoothing->value < 0.0f )
|
||||
{
|
||||
gEngfuncs.Cvar_SetValue( "cl_vsmoothing", 0.0 );
|
||||
gEngfuncs.Cvar_SetValue( "cl_vsmoothing", 0.0f );
|
||||
}
|
||||
|
||||
t = pparams->time - cl_vsmoothing->value;
|
||||
|
@ -696,7 +694,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
break;
|
||||
}
|
||||
|
||||
if( i < ORIGIN_MASK && ViewInterp.OriginTime[foundidx & ORIGIN_MASK] != 0.0 )
|
||||
if( i < ORIGIN_MASK && ViewInterp.OriginTime[foundidx & ORIGIN_MASK] != 0.0f )
|
||||
{
|
||||
// Interpolate
|
||||
vec3_t delta;
|
||||
|
@ -713,7 +711,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
VectorMA( ViewInterp.Origins[foundidx & ORIGIN_MASK], frac, delta, neworg );
|
||||
|
||||
// Dont interpolate large changes
|
||||
if( Length( delta ) < 64 )
|
||||
if( Length( delta ) < 64.0f )
|
||||
{
|
||||
VectorSubtract( neworg, pparams->simorg, delta );
|
||||
|
||||
|
@ -727,21 +725,26 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams )
|
|||
|
||||
// Store off v_angles before munging for third person
|
||||
v_angles = pparams->viewangles;
|
||||
v_client_aimangles = pparams->cl_viewangles;
|
||||
v_lastAngles = pparams->viewangles;
|
||||
//v_cl_angles = pparams->cl_viewangles; // keep old user mouse angles !
|
||||
if( CL_IsThirdPerson() )
|
||||
{
|
||||
VectorCopy( camAngles, pparams->viewangles );
|
||||
float pitch = camAngles[0];
|
||||
}
|
||||
|
||||
// Apply this at all times
|
||||
{
|
||||
float pitch = pparams->viewangles[0];
|
||||
|
||||
// Normalize angles
|
||||
if( pitch > 180 )
|
||||
pitch -= 360.0;
|
||||
else if( pitch < -180 )
|
||||
pitch += 360;
|
||||
if( pitch > 180.0f )
|
||||
pitch -= 360.0f;
|
||||
else if( pitch < -180.0f )
|
||||
pitch += 360.0f;
|
||||
|
||||
// Player pitch is inverted
|
||||
pitch /= -3.0;
|
||||
pitch /= -3.0f;
|
||||
|
||||
// Slam local player's pitch value
|
||||
ent->angles[0] = pitch;
|
||||
|
@ -796,7 +799,7 @@ void V_SmoothInterpolateAngles( float * startAngle, float * endAngle, float * fi
|
|||
{
|
||||
frac = degreesPerSec * v_frametime;
|
||||
|
||||
threshhold= degreesPerSec / 4;
|
||||
threshhold= degreesPerSec / 4.0f;
|
||||
|
||||
if( absd < threshhold )
|
||||
{
|
||||
|
@ -811,7 +814,7 @@ void V_SmoothInterpolateAngles( float * startAngle, float * endAngle, float * fi
|
|||
}
|
||||
else
|
||||
{
|
||||
if( d > 0 )
|
||||
if( d > 0.0f )
|
||||
finalAngle[i] = startAngle[i] + frac;
|
||||
else
|
||||
finalAngle[i] = startAngle[i] - frac;
|
||||
|
@ -907,7 +910,7 @@ void V_GetChaseOrigin( float * angles, float * origin, float distance, float * r
|
|||
VectorCopy( ent1->origin, newOrigin );
|
||||
|
||||
if( ent1->player )
|
||||
newOrigin[2] += 17; // head level of living player
|
||||
newOrigin[2] += 17.0f; // head level of living player
|
||||
|
||||
// get new angle towards second target
|
||||
if( ent2 )
|
||||
|
@ -921,7 +924,7 @@ void V_GetChaseOrigin( float * angles, float * origin, float distance, float * r
|
|||
// if no second target is given, look down to dead player
|
||||
newAngle[0] = 90.0f;
|
||||
newAngle[1] = 0.0f;
|
||||
newAngle[2] = 0;
|
||||
newAngle[2] = 0.0f;
|
||||
}
|
||||
|
||||
// and smooth view
|
||||
|
@ -962,12 +965,12 @@ void V_GetSingleTargetCam( cl_entity_t * ent1, float * angle, float * origin )
|
|||
if( ent1->player )
|
||||
{
|
||||
if( deadPlayer )
|
||||
newOrigin[2] += 2; //laying on ground
|
||||
newOrigin[2] += 2.0f; //laying on ground
|
||||
else
|
||||
newOrigin[2] += 17; // head level of living player
|
||||
newOrigin[2] += 17.0f; // head level of living player
|
||||
}
|
||||
else
|
||||
newOrigin[2]+= 8; // object, tricky, must be above bomb in CS
|
||||
newOrigin[2]+= 8.0f; // object, tricky, must be above bomb in CS
|
||||
|
||||
// we have no second target, choose view direction based on
|
||||
// show front of primary target
|
||||
|
@ -1005,13 +1008,13 @@ float MaxAngleBetweenAngles( float *a1, float *a2 )
|
|||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
d = a2[i] - a1[i];
|
||||
if( d > 180 )
|
||||
if( d > 180.0f )
|
||||
{
|
||||
d -= 360;
|
||||
d -= 360.0f;
|
||||
}
|
||||
else if( d < -180 )
|
||||
else if( d < -180.0f )
|
||||
{
|
||||
d += 360;
|
||||
d += 360.0f;
|
||||
}
|
||||
|
||||
d = fabs( d );
|
||||
|
@ -1046,9 +1049,9 @@ void V_GetDoubleTargetsCam( cl_entity_t *ent1, cl_entity_t *ent2, float *angle,
|
|||
VectorCopy( ent1->origin, newOrigin );
|
||||
|
||||
if( ent1->player )
|
||||
newOrigin[2] += 17; // head level of living player
|
||||
newOrigin[2] += 17.0f; // head level of living player
|
||||
else
|
||||
newOrigin[2] += 8; // object, tricky, must be above bomb in CS
|
||||
newOrigin[2] += 8.0f; // object, tricky, must be above bomb in CS
|
||||
|
||||
// get new angle towards second target
|
||||
VectorSubtract( ent2->origin, ent1->origin, newAngle );
|
||||
|
@ -1151,9 +1154,9 @@ void V_GetDirectedChasePosition(cl_entity_t *ent1, cl_entity_t *ent2,float *angl
|
|||
VectorCopy( ent1->origin, newOrigin );
|
||||
|
||||
if( ent1->player )
|
||||
newOrigin[2] += 17; // head level of living player
|
||||
newOrigin[2] += 17.0f; // head level of living player
|
||||
else
|
||||
newOrigin[2] += 8; // object, tricky, must be above bomb in CS
|
||||
newOrigin[2] += 8.0f; // object, tricky, must be above bomb in CS
|
||||
|
||||
V_GetChaseOrigin( angle, newOrigin, distance, origin );
|
||||
}
|
||||
|
@ -1192,14 +1195,14 @@ void V_GetChasePos( int target, float *cl_angles, float *origin, float *angles )
|
|||
if( cl_angles == NULL ) // no mouse angles given, use entity angles ( locked mode )
|
||||
{
|
||||
VectorCopy( ent->angles, angles);
|
||||
angles[0] *= -1;
|
||||
angles[0] *= -1.0f;
|
||||
}
|
||||
else
|
||||
VectorCopy( cl_angles, angles );
|
||||
|
||||
VectorCopy( ent->origin, origin );
|
||||
|
||||
origin[2] += 28; // DEFAULT_VIEWHEIGHT - some offset
|
||||
origin[2] += 28.0f; // DEFAULT_VIEWHEIGHT - some offset
|
||||
|
||||
V_GetChaseOrigin( angles, origin, cl_chasedist->value, origin );
|
||||
}
|
||||
|
@ -1234,15 +1237,15 @@ void V_GetInEyePos( int target, float *origin, float *angles )
|
|||
|
||||
if( ent->curstate.solid == SOLID_NOT )
|
||||
{
|
||||
angles[ROLL] = 80; // dead view angle
|
||||
origin[2] += -8 ; // PM_DEAD_VIEWHEIGHT
|
||||
angles[ROLL] = 80.0f; // dead view angle
|
||||
origin[2] += -8.0f; // PM_DEAD_VIEWHEIGHT
|
||||
}
|
||||
else if( ent->curstate.usehull == 1 )
|
||||
origin[2] += 12; // VEC_DUCK_VIEW;
|
||||
origin[2] += 12.0f; // VEC_DUCK_VIEW;
|
||||
else
|
||||
// exacty eye position can't be caluculated since it depends on
|
||||
// client values like cl_bobcycle, this offset matches the default values
|
||||
origin[2] += 28; // DEFAULT_VIEWHEIGHT
|
||||
origin[2] += 28.0f; // DEFAULT_VIEWHEIGHT
|
||||
}
|
||||
|
||||
void V_GetMapFreePosition( float *cl_angles, float *origin, float *angles )
|
||||
|
@ -1306,7 +1309,7 @@ void V_GetMapChasePosition( int target, float *cl_angles, float *origin, float *
|
|||
|
||||
VectorNormalize( forward );
|
||||
|
||||
VectorMA( origin, -1536, forward, origin );
|
||||
VectorMA( origin, -1536.0f, forward, origin );
|
||||
}
|
||||
|
||||
int V_FindViewModelByWeaponModel( int weaponindex )
|
||||
|
@ -1536,8 +1539,8 @@ void DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams )
|
|||
}
|
||||
/*
|
||||
// Example of how to overlay the whole screen with red at 50 % alpha
|
||||
#define SF_TEST
|
||||
#if defined SF_TEST
|
||||
#define SF_TEST 1
|
||||
#if SF_TEST
|
||||
{
|
||||
screenfade_t sf;
|
||||
gEngfuncs.pfnGetScreenFade( &sf );
|
||||
|
@ -1565,8 +1568,8 @@ void V_DropPunchAngle( float frametime, float *ev_punchangle )
|
|||
float len;
|
||||
|
||||
len = VectorNormalize( ev_punchangle );
|
||||
len -= ( 10.0 + len * 0.5 ) * frametime;
|
||||
len = Q_max( len, 0.0 );
|
||||
len -= ( 10.0f + len * 0.5f ) * (float)frametime;
|
||||
len = Q_max( len, 0.0f );
|
||||
VectorScale( ev_punchangle, len, ev_punchangle );
|
||||
}
|
||||
|
||||
|
@ -1603,8 +1606,8 @@ void V_Init( void )
|
|||
cl_chasedist = gEngfuncs.pfnRegisterVariable( "cl_chasedist","112", 0 );
|
||||
}
|
||||
|
||||
//#define TRACE_TEST
|
||||
#if defined( TRACE_TEST )
|
||||
//#define TRACE_TEST 1
|
||||
#if TRACE_TEST
|
||||
|
||||
extern float in_fov;
|
||||
/*
|
||||
|
@ -1617,14 +1620,14 @@ float CalcFov( float fov_x, float width, float height )
|
|||
float a;
|
||||
float x;
|
||||
|
||||
if( fov_x < 1 || fov_x > 179 )
|
||||
fov_x = 90; // error, set to 90
|
||||
if( fov_x < 1.0f || fov_x > 179.0f )
|
||||
fov_x = 90.0f; // error, set to 90
|
||||
|
||||
x = width / tan( fov_x / 360 * M_PI );
|
||||
x = width / tan( fov_x / 360.0f * M_PI_F );
|
||||
|
||||
a = atan ( height / x );
|
||||
|
||||
a = a * 360 / M_PI;
|
||||
a = a * 360.0f / M_PI_F;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
@ -1646,8 +1649,8 @@ void V_Move( int mx, int my )
|
|||
|
||||
fov = CalcFov( in_fov, (float)ScreenWidth, (float)ScreenHeight );
|
||||
|
||||
c_x = (float)ScreenWidth / 2.0;
|
||||
c_y = (float)ScreenHeight / 2.0;
|
||||
c_x = (float)ScreenWidth / 2.0f;
|
||||
c_y = (float)ScreenHeight / 2.0f;
|
||||
|
||||
dx = (float)mx - c_x;
|
||||
dy = (float)my - c_y;
|
||||
|
@ -1656,8 +1659,8 @@ void V_Move( int mx, int my )
|
|||
fx = dx / c_x;
|
||||
fy = dy / c_y;
|
||||
|
||||
dX = fx * in_fov / 2.0 ;
|
||||
dY = fy * fov / 2.0;
|
||||
dX = fx * in_fov / 2.0f;
|
||||
dY = fy * fov / 2.0f;
|
||||
|
||||
newangles = v_angles;
|
||||
|
||||
|
@ -1672,10 +1675,10 @@ void V_Move( int mx, int my )
|
|||
// Trace
|
||||
tr = *( gEngfuncs.PM_TraceLine( (float *)&v_origin, (float *)&farpoint, PM_TRACELINE_PHYSENTSONLY, 2 /*point sized hull*/, -1 ) );
|
||||
|
||||
if( tr.fraction != 1.0 && tr.ent != 0 )
|
||||
if( tr.fraction != 1.0f && tr.ent != 0 )
|
||||
{
|
||||
hitent = PM_GetPhysEntInfo( tr.ent );
|
||||
PM_ParticleLine( (float *)&v_origin, (float *)&tr.endpos, 5, 1.0, 0.0 );
|
||||
PM_ParticleLine( (float *)&v_origin, (float *)&tr.endpos, 5, 1.0f, 0.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -9,6 +9,14 @@
|
|||
#define VIEWH
|
||||
#pragma once
|
||||
|
||||
#if !defined(M_PI)
|
||||
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
|
||||
#endif
|
||||
|
||||
#if !defined(M_PI_F)
|
||||
#define M_PI_F (float)M_PI
|
||||
#endif
|
||||
|
||||
void V_StartPitchDrift( void );
|
||||
void V_StopPitchDrift( void );
|
||||
#endif // !VIEWH
|
||||
|
|
|
@ -0,0 +1,873 @@
|
|||
//========= Copyright <20> 1996-2001, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#include "hud.h"
|
||||
|
||||
#include "cl_util.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
#include "demo.h"
|
||||
#include "demo_api.h"
|
||||
#include "voice_status.h"
|
||||
#include "r_efx.h"
|
||||
#include "entity_types.h"
|
||||
#include "VGUI_ActionSignal.h"
|
||||
#include "VGUI_Scheme.h"
|
||||
#include "VGUI_TextImage.h"
|
||||
#include "vgui_loadtga.h"
|
||||
#include "vgui_helpers.h"
|
||||
#include "VGUI_MouseCode.h"
|
||||
|
||||
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
|
||||
extern int cam_thirdperson;
|
||||
|
||||
|
||||
#define VOICE_MODEL_INTERVAL 0.3
|
||||
#define SCOREBOARD_BLINK_FREQUENCY 0.3 // How often to blink the scoreboard icons.
|
||||
#define SQUELCHOSCILLATE_PER_SECOND 2.0f
|
||||
|
||||
|
||||
extern BitmapTGA *LoadTGA( const char* pImageName );
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------- //
|
||||
// The voice manager for the client.
|
||||
// ---------------------------------------------------------------------- //
|
||||
CVoiceStatus g_VoiceStatus;
|
||||
|
||||
CVoiceStatus* GetClientVoiceMgr()
|
||||
{
|
||||
return &g_VoiceStatus;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------- //
|
||||
// CVoiceStatus.
|
||||
// ---------------------------------------------------------------------- //
|
||||
|
||||
static CVoiceStatus *g_pInternalVoiceStatus = NULL;
|
||||
|
||||
int __MsgFunc_VoiceMask(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
if(g_pInternalVoiceStatus)
|
||||
g_pInternalVoiceStatus->HandleVoiceMaskMsg(iSize, pbuf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int __MsgFunc_ReqState(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
if(g_pInternalVoiceStatus)
|
||||
g_pInternalVoiceStatus->HandleReqStateMsg(iSize, pbuf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int g_BannedPlayerPrintCount;
|
||||
void ForEachBannedPlayer(char id[16])
|
||||
{
|
||||
char str[256];
|
||||
sprintf(str, "BAN %d: %2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X%2X\n",
|
||||
g_BannedPlayerPrintCount++,
|
||||
id[0], id[1], id[2], id[3],
|
||||
id[4], id[5], id[6], id[7],
|
||||
id[8], id[9], id[10], id[11],
|
||||
id[12], id[13], id[14], id[15]
|
||||
);
|
||||
|
||||
gEngfuncs.pfnConsolePrint(str);
|
||||
}
|
||||
|
||||
|
||||
void ShowBannedCallback()
|
||||
{
|
||||
if(g_pInternalVoiceStatus)
|
||||
{
|
||||
g_BannedPlayerPrintCount = 0;
|
||||
gEngfuncs.pfnConsolePrint("------- BANNED PLAYERS -------\n");
|
||||
g_pInternalVoiceStatus->m_BanMgr.ForEachBannedPlayer(ForEachBannedPlayer);
|
||||
gEngfuncs.pfnConsolePrint("------------------------------\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------- //
|
||||
// CVoiceStatus.
|
||||
// ---------------------------------------------------------------------- //
|
||||
|
||||
CVoiceStatus::CVoiceStatus()
|
||||
{
|
||||
m_bBanMgrInitialized = false;
|
||||
m_LastUpdateServerState = 0;
|
||||
|
||||
m_pSpeakerLabelIcon = NULL;
|
||||
m_pScoreboardNeverSpoken = NULL;
|
||||
m_pScoreboardNotSpeaking = NULL;
|
||||
m_pScoreboardSpeaking = NULL;
|
||||
m_pScoreboardSpeaking2 = NULL;
|
||||
m_pScoreboardSquelch = NULL;
|
||||
m_pScoreboardBanned = NULL;
|
||||
|
||||
m_pLocalBitmap = NULL;
|
||||
m_pAckBitmap = NULL;
|
||||
|
||||
m_bTalking = m_bServerAcked = false;
|
||||
|
||||
memset(m_pBanButtons, 0, sizeof(m_pBanButtons));
|
||||
|
||||
m_pParentPanel = NULL;
|
||||
|
||||
m_bServerModEnable = -1;
|
||||
|
||||
m_pchGameDir = NULL;
|
||||
}
|
||||
|
||||
|
||||
CVoiceStatus::~CVoiceStatus()
|
||||
{
|
||||
g_pInternalVoiceStatus = NULL;
|
||||
|
||||
for(int i=0; i < MAX_VOICE_SPEAKERS; i++)
|
||||
{
|
||||
delete m_Labels[i].m_pLabel;
|
||||
m_Labels[i].m_pLabel = NULL;
|
||||
|
||||
delete m_Labels[i].m_pIcon;
|
||||
m_Labels[i].m_pIcon = NULL;
|
||||
|
||||
delete m_Labels[i].m_pBackground;
|
||||
m_Labels[i].m_pBackground = NULL;
|
||||
}
|
||||
|
||||
delete m_pLocalLabel;
|
||||
m_pLocalLabel = NULL;
|
||||
|
||||
FreeBitmaps();
|
||||
|
||||
if(m_pchGameDir)
|
||||
{
|
||||
if(m_bBanMgrInitialized)
|
||||
{
|
||||
m_BanMgr.SaveState(m_pchGameDir);
|
||||
}
|
||||
|
||||
free(m_pchGameDir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int CVoiceStatus::Init(
|
||||
IVoiceStatusHelper *pHelper,
|
||||
Panel **pParentPanel)
|
||||
{
|
||||
// Setup the voice_modenable cvar.
|
||||
gEngfuncs.pfnRegisterVariable("voice_modenable", "1", FCVAR_ARCHIVE);
|
||||
|
||||
gEngfuncs.pfnRegisterVariable("voice_clientdebug", "0", 0);
|
||||
|
||||
gEngfuncs.pfnAddCommand("voice_showbanned", ShowBannedCallback);
|
||||
|
||||
if(gEngfuncs.pfnGetGameDirectory())
|
||||
{
|
||||
m_BanMgr.Init(gEngfuncs.pfnGetGameDirectory());
|
||||
m_bBanMgrInitialized = true;
|
||||
}
|
||||
|
||||
assert(!g_pInternalVoiceStatus);
|
||||
g_pInternalVoiceStatus = this;
|
||||
|
||||
m_BlinkTimer = 0;
|
||||
m_VoiceHeadModel = 0;
|
||||
memset(m_Labels, 0, sizeof(m_Labels));
|
||||
|
||||
for(int i=0; i < MAX_VOICE_SPEAKERS; i++)
|
||||
{
|
||||
CVoiceLabel *pLabel = &m_Labels[i];
|
||||
|
||||
pLabel->m_pBackground = new Label("");
|
||||
|
||||
if((pLabel->m_pLabel = new Label("")) != 0)
|
||||
{
|
||||
pLabel->m_pLabel->setVisible( true );
|
||||
pLabel->m_pLabel->setFont( Scheme::sf_primary2 );
|
||||
pLabel->m_pLabel->setTextAlignment( Label::a_east );
|
||||
pLabel->m_pLabel->setContentAlignment( Label::a_east );
|
||||
pLabel->m_pLabel->setParent( pLabel->m_pBackground );
|
||||
}
|
||||
|
||||
if( (pLabel->m_pIcon = new ImagePanel( NULL )) != 0 )
|
||||
{
|
||||
pLabel->m_pIcon->setVisible( true );
|
||||
pLabel->m_pIcon->setParent( pLabel->m_pBackground );
|
||||
}
|
||||
|
||||
pLabel->m_clientindex = -1;
|
||||
}
|
||||
|
||||
m_pLocalLabel = new ImagePanel(NULL);
|
||||
|
||||
m_bInSquelchMode = false;
|
||||
|
||||
m_pHelper = pHelper;
|
||||
m_pParentPanel = pParentPanel;
|
||||
gHUD.AddHudElem(this);
|
||||
m_iFlags = HUD_ACTIVE;
|
||||
HOOK_MESSAGE(VoiceMask);
|
||||
HOOK_MESSAGE(ReqState);
|
||||
|
||||
// Cache the game directory for use when we shut down
|
||||
const char *pchGameDirT = gEngfuncs.pfnGetGameDirectory();
|
||||
m_pchGameDir = (char *)malloc(strlen(pchGameDirT) + 1);
|
||||
strcpy(m_pchGameDir, pchGameDirT);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int CVoiceStatus::VidInit()
|
||||
{
|
||||
FreeBitmaps();
|
||||
|
||||
|
||||
if( (m_pLocalBitmap = vgui_LoadTGA("gfx/vgui/icntlk_pl.tga")) != 0 )
|
||||
{
|
||||
m_pLocalBitmap->setColor(Color(255,255,255,135));
|
||||
}
|
||||
|
||||
if( (m_pAckBitmap = vgui_LoadTGA("gfx/vgui/icntlk_sv.tga")) != 0 )
|
||||
{
|
||||
m_pAckBitmap->setColor(Color(255,255,255,135)); // Give just a tiny bit of translucency so software draws correctly.
|
||||
}
|
||||
|
||||
m_pLocalLabel->setImage( m_pLocalBitmap );
|
||||
m_pLocalLabel->setVisible( false );
|
||||
|
||||
|
||||
if( (m_pSpeakerLabelIcon = vgui_LoadTGANoInvertAlpha("gfx/vgui/speaker4.tga" )) != 0 )
|
||||
m_pSpeakerLabelIcon->setColor( Color(255,255,255,1) ); // Give just a tiny bit of translucency so software draws correctly.
|
||||
|
||||
if ((m_pScoreboardNeverSpoken = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker1.tga")) != 0)
|
||||
m_pScoreboardNeverSpoken->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly.
|
||||
|
||||
if((m_pScoreboardNotSpeaking = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker2.tga")) != 0)
|
||||
m_pScoreboardNotSpeaking->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly.
|
||||
|
||||
if((m_pScoreboardSpeaking = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker3.tga")) != 0)
|
||||
m_pScoreboardSpeaking->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly.
|
||||
|
||||
if((m_pScoreboardSpeaking2 = vgui_LoadTGANoInvertAlpha("gfx/vgui/640_speaker4.tga")) != 0)
|
||||
m_pScoreboardSpeaking2->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly.
|
||||
|
||||
if((m_pScoreboardSquelch = vgui_LoadTGA("gfx/vgui/icntlk_squelch.tga")) != 0)
|
||||
m_pScoreboardSquelch->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly.
|
||||
|
||||
if((m_pScoreboardBanned = vgui_LoadTGA("gfx/vgui/640_voiceblocked.tga")) != 0)
|
||||
m_pScoreboardBanned->setColor(Color(255,255,255,1)); // Give just a tiny bit of translucency so software draws correctly.
|
||||
|
||||
// Figure out the voice head model height.
|
||||
m_VoiceHeadModelHeight = 45;
|
||||
char *pFile = (char *)gEngfuncs.COM_LoadFile("scripts/voicemodel.txt", 5, NULL);
|
||||
if(pFile)
|
||||
{
|
||||
char token[4096];
|
||||
gEngfuncs.COM_ParseFile(pFile, token);
|
||||
if(token[0] >= '0' && token[0] <= '9')
|
||||
{
|
||||
m_VoiceHeadModelHeight = (float)atof(token);
|
||||
}
|
||||
|
||||
gEngfuncs.COM_FreeFile(pFile);
|
||||
}
|
||||
|
||||
m_VoiceHeadModel = gEngfuncs.pfnSPR_Load("sprites/voiceicon.spr");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void CVoiceStatus::Frame(double frametime)
|
||||
{
|
||||
// check server banned players once per second
|
||||
if(gEngfuncs.GetClientTime() - m_LastUpdateServerState > 1)
|
||||
{
|
||||
UpdateServerState(false);
|
||||
}
|
||||
|
||||
m_BlinkTimer += frametime;
|
||||
|
||||
// Update speaker labels.
|
||||
if( m_pHelper->CanShowSpeakerLabels() )
|
||||
{
|
||||
for( int i=0; i < MAX_VOICE_SPEAKERS; i++ )
|
||||
m_Labels[i].m_pBackground->setVisible( m_Labels[i].m_clientindex != -1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i=0; i < MAX_VOICE_SPEAKERS; i++ )
|
||||
m_Labels[i].m_pBackground->setVisible( false );
|
||||
}
|
||||
|
||||
for(int i=0; i < VOICE_MAX_PLAYERS; i++)
|
||||
UpdateBanButton(i);
|
||||
}
|
||||
|
||||
|
||||
void CVoiceStatus::CreateEntities()
|
||||
{
|
||||
if(!m_VoiceHeadModel)
|
||||
return;
|
||||
|
||||
cl_entity_t *localPlayer = gEngfuncs.GetLocalPlayer();
|
||||
|
||||
int iOutModel = 0;
|
||||
for(int i=0; i < VOICE_MAX_PLAYERS; i++)
|
||||
{
|
||||
if(!m_VoicePlayers[i])
|
||||
continue;
|
||||
|
||||
cl_entity_s *pClient = gEngfuncs.GetEntityByIndex(i+1);
|
||||
|
||||
// Don't show an icon if the player is not in our PVS.
|
||||
if(!pClient || pClient->curstate.messagenum < localPlayer->curstate.messagenum)
|
||||
continue;
|
||||
|
||||
// Don't show an icon for dead or spectating players (ie: invisible entities).
|
||||
if(pClient->curstate.effects & EF_NODRAW)
|
||||
continue;
|
||||
|
||||
// Don't show an icon for the local player unless we're in thirdperson mode.
|
||||
if(pClient == localPlayer && !cam_thirdperson)
|
||||
continue;
|
||||
|
||||
cl_entity_s *pEnt = &m_VoiceHeadModels[iOutModel];
|
||||
++iOutModel;
|
||||
|
||||
memset(pEnt, 0, sizeof(*pEnt));
|
||||
|
||||
pEnt->curstate.rendermode = kRenderTransAdd;
|
||||
pEnt->curstate.renderamt = 255;
|
||||
pEnt->baseline.renderamt = 255;
|
||||
pEnt->curstate.renderfx = kRenderFxNoDissipation;
|
||||
pEnt->curstate.framerate = 1;
|
||||
pEnt->curstate.frame = 0;
|
||||
pEnt->model = (struct model_s*)gEngfuncs.GetSpritePointer(m_VoiceHeadModel);
|
||||
pEnt->angles[0] = pEnt->angles[1] = pEnt->angles[2] = 0;
|
||||
pEnt->curstate.scale = 0.5f;
|
||||
|
||||
pEnt->origin[0] = pEnt->origin[1] = 0;
|
||||
pEnt->origin[2] = 45;
|
||||
|
||||
VectorAdd(pEnt->origin, pClient->origin, pEnt->origin);
|
||||
|
||||
// Tell the engine.
|
||||
gEngfuncs.CL_CreateVisibleEntity(ET_NORMAL, pEnt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CVoiceStatus::UpdateSpeakerStatus( int entindex, qboolean bTalking )
|
||||
{
|
||||
cvar_t *pVoiceLoopback = NULL;
|
||||
|
||||
if ( !m_pParentPanel || !*m_pParentPanel )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( gEngfuncs.pfnGetCvarFloat( "voice_clientdebug" ) )
|
||||
{
|
||||
char msg[256];
|
||||
sprintf( msg, "CVoiceStatus::UpdateSpeakerStatus: ent %d talking = %d\n", entindex, bTalking );
|
||||
gEngfuncs.pfnConsolePrint( msg );
|
||||
}
|
||||
|
||||
int iLocalPlayerIndex = gEngfuncs.GetLocalPlayer()->index;
|
||||
|
||||
// Is it the local player talking?
|
||||
if ( entindex == -1 )
|
||||
{
|
||||
m_bTalking = !!bTalking;
|
||||
if( bTalking )
|
||||
{
|
||||
// Enable voice for them automatically if they try to talk.
|
||||
gEngfuncs.pfnClientCmd( "voice_modenable 1" );
|
||||
}
|
||||
|
||||
// now set the player index to the correct index for the local player
|
||||
// this will allow us to have the local player's icon flash in the scoreboard
|
||||
entindex = iLocalPlayerIndex;
|
||||
|
||||
pVoiceLoopback = gEngfuncs.pfnGetCvarPointer( "voice_loopback" );
|
||||
}
|
||||
else if ( entindex == -2 )
|
||||
{
|
||||
m_bServerAcked = !!bTalking;
|
||||
}
|
||||
|
||||
if ( entindex >= 0 && entindex <= VOICE_MAX_PLAYERS )
|
||||
{
|
||||
int iClient = entindex - 1;
|
||||
if ( iClient < 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CVoiceLabel *pLabel = FindVoiceLabel( iClient );
|
||||
if ( bTalking )
|
||||
{
|
||||
m_VoicePlayers[iClient] = true;
|
||||
m_VoiceEnabledPlayers[iClient] = true;
|
||||
|
||||
// If we don't have a label for this guy yet, then create one.
|
||||
if ( !pLabel )
|
||||
{
|
||||
// if this isn't the local player (unless they have voice_loopback on)
|
||||
if ( ( entindex != iLocalPlayerIndex ) || ( pVoiceLoopback && pVoiceLoopback->value ) )
|
||||
{
|
||||
if ( (pLabel = GetFreeVoiceLabel()) != 0 )
|
||||
{
|
||||
// Get the name from the engine.
|
||||
hud_player_info_t info;
|
||||
memset( &info, 0, sizeof( info ) );
|
||||
gEngfuncs.pfnGetPlayerInfo( entindex, &info );
|
||||
|
||||
char paddedName[512];
|
||||
_snprintf( paddedName, sizeof( paddedName ) - 1, "%s ", info.name );
|
||||
paddedName[sizeof(paddedName) - 1] = '\0';
|
||||
|
||||
int color[3];
|
||||
m_pHelper->GetPlayerTextColor( entindex, color );
|
||||
|
||||
if ( pLabel->m_pBackground )
|
||||
{
|
||||
pLabel->m_pBackground->setBgColor( color[0], color[1], color[2], 135 );
|
||||
pLabel->m_pBackground->setParent( *m_pParentPanel );
|
||||
pLabel->m_pBackground->setVisible( m_pHelper->CanShowSpeakerLabels() );
|
||||
}
|
||||
|
||||
if ( pLabel->m_pLabel )
|
||||
{
|
||||
pLabel->m_pLabel->setFgColor( 255, 255, 255, 0 );
|
||||
pLabel->m_pLabel->setBgColor( 0, 0, 0, 255 );
|
||||
pLabel->m_pLabel->setText( "%s", paddedName );
|
||||
}
|
||||
|
||||
pLabel->m_clientindex = iClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_VoicePlayers[iClient] = false;
|
||||
|
||||
// If we have a label for this guy, kill it.
|
||||
if ( pLabel )
|
||||
{
|
||||
pLabel->m_pBackground->setVisible( false );
|
||||
pLabel->m_clientindex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RepositionLabels();
|
||||
}
|
||||
|
||||
|
||||
void CVoiceStatus::UpdateServerState(bool bForce)
|
||||
{
|
||||
// Can't do anything when we're not in a level.
|
||||
char const *pLevelName = gEngfuncs.pfnGetLevelName();
|
||||
if( pLevelName[0] == 0 )
|
||||
{
|
||||
if( gEngfuncs.pfnGetCvarFloat("voice_clientdebug") )
|
||||
{
|
||||
gEngfuncs.pfnConsolePrint( "CVoiceStatus::UpdateServerState: pLevelName[0]==0\n" );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int bCVarModEnable = !!gEngfuncs.pfnGetCvarFloat("voice_modenable");
|
||||
if(bForce || m_bServerModEnable != bCVarModEnable)
|
||||
{
|
||||
m_bServerModEnable = bCVarModEnable;
|
||||
|
||||
char str[256];
|
||||
sprintf(str, "VModEnable %d", m_bServerModEnable);
|
||||
ServerCmd(str);
|
||||
|
||||
if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
|
||||
{
|
||||
char msg[256];
|
||||
sprintf(msg, "CVoiceStatus::UpdateServerState: Sending '%s'\n", str);
|
||||
gEngfuncs.pfnConsolePrint(msg);
|
||||
}
|
||||
}
|
||||
|
||||
char str[2048] = "vban";
|
||||
bool bChange = false;
|
||||
|
||||
for(unsigned long dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++)
|
||||
{
|
||||
unsigned int serverBanMask = 0;
|
||||
unsigned int banMask = 0;
|
||||
for(unsigned int i=0; i < 32; i++)
|
||||
{
|
||||
char playerID[16];
|
||||
if(!gEngfuncs.GetPlayerUniqueID(i+1, playerID))
|
||||
continue;
|
||||
|
||||
if(m_BanMgr.GetPlayerBan(playerID))
|
||||
banMask |= 1 << i;
|
||||
|
||||
if(m_ServerBannedPlayers[dw*32 + i])
|
||||
serverBanMask |= 1 << i;
|
||||
}
|
||||
|
||||
if(serverBanMask != banMask)
|
||||
bChange = true;
|
||||
|
||||
// Ok, the server needs to be updated.
|
||||
char numStr[512];
|
||||
sprintf(numStr, " %x", banMask);
|
||||
strcat(str, numStr);
|
||||
}
|
||||
|
||||
if(bChange || bForce)
|
||||
{
|
||||
if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
|
||||
{
|
||||
char msg[256];
|
||||
sprintf(msg, "CVoiceStatus::UpdateServerState: Sending '%s'\n", str);
|
||||
gEngfuncs.pfnConsolePrint(msg);
|
||||
}
|
||||
|
||||
gEngfuncs.pfnServerCmdUnreliable(str); // Tell the server..
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
|
||||
{
|
||||
gEngfuncs.pfnConsolePrint( "CVoiceStatus::UpdateServerState: no change\n" );
|
||||
}
|
||||
}
|
||||
|
||||
m_LastUpdateServerState = gEngfuncs.GetClientTime();
|
||||
}
|
||||
|
||||
void CVoiceStatus::UpdateSpeakerImage(Label *pLabel, int iPlayer)
|
||||
{
|
||||
m_pBanButtons[iPlayer-1] = pLabel;
|
||||
UpdateBanButton(iPlayer-1);
|
||||
}
|
||||
|
||||
void CVoiceStatus::UpdateBanButton(int iClient)
|
||||
{
|
||||
Label *pPanel = m_pBanButtons[iClient];
|
||||
|
||||
if (!pPanel)
|
||||
return;
|
||||
|
||||
char playerID[16];
|
||||
extern bool HACK_GetPlayerUniqueID( int iPlayer, char playerID[16] );
|
||||
if(!HACK_GetPlayerUniqueID(iClient+1, playerID))
|
||||
return;
|
||||
|
||||
// Figure out if it's blinking or not.
|
||||
bool bBlink = fmod(m_BlinkTimer, SCOREBOARD_BLINK_FREQUENCY*2) < SCOREBOARD_BLINK_FREQUENCY;
|
||||
bool bTalking = !!m_VoicePlayers[iClient];
|
||||
bool bBanned = m_BanMgr.GetPlayerBan(playerID);
|
||||
bool bNeverSpoken = !m_VoiceEnabledPlayers[iClient];
|
||||
|
||||
// Get the appropriate image to display on the panel.
|
||||
if (bBanned)
|
||||
{
|
||||
pPanel->setImage(m_pScoreboardBanned);
|
||||
}
|
||||
else if (bTalking)
|
||||
{
|
||||
if (bBlink)
|
||||
{
|
||||
pPanel->setImage(m_pScoreboardSpeaking2);
|
||||
}
|
||||
else
|
||||
{
|
||||
pPanel->setImage(m_pScoreboardSpeaking);
|
||||
}
|
||||
pPanel->setFgColor(255, 170, 0, 1);
|
||||
}
|
||||
else if (bNeverSpoken)
|
||||
{
|
||||
pPanel->setImage(m_pScoreboardNeverSpoken);
|
||||
pPanel->setFgColor(100, 100, 100, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
pPanel->setImage(m_pScoreboardNotSpeaking);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CVoiceStatus::HandleVoiceMaskMsg(int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
unsigned int dw;
|
||||
for(dw=0; dw < VOICE_MAX_PLAYERS_DW; dw++)
|
||||
{
|
||||
m_AudiblePlayers.SetDWord(dw, (unsigned long)READ_LONG());
|
||||
m_ServerBannedPlayers.SetDWord(dw, (unsigned long)READ_LONG());
|
||||
|
||||
if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
|
||||
{
|
||||
char str[256];
|
||||
gEngfuncs.pfnConsolePrint("CVoiceStatus::HandleVoiceMaskMsg\n");
|
||||
|
||||
sprintf(str, " - m_AudiblePlayers[%d] = %lu\n", dw, m_AudiblePlayers.GetDWord(dw));
|
||||
gEngfuncs.pfnConsolePrint(str);
|
||||
|
||||
sprintf(str, " - m_ServerBannedPlayers[%d] = %lu\n", dw, m_ServerBannedPlayers.GetDWord(dw));
|
||||
gEngfuncs.pfnConsolePrint(str);
|
||||
}
|
||||
}
|
||||
|
||||
m_bServerModEnable = READ_BYTE();
|
||||
}
|
||||
|
||||
void CVoiceStatus::HandleReqStateMsg(int iSize, void *pbuf)
|
||||
{
|
||||
if(gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
|
||||
{
|
||||
gEngfuncs.pfnConsolePrint("CVoiceStatus::HandleReqStateMsg\n");
|
||||
}
|
||||
|
||||
UpdateServerState(true);
|
||||
}
|
||||
|
||||
void CVoiceStatus::StartSquelchMode()
|
||||
{
|
||||
if(m_bInSquelchMode)
|
||||
return;
|
||||
|
||||
m_bInSquelchMode = true;
|
||||
m_pHelper->UpdateCursorState();
|
||||
}
|
||||
|
||||
void CVoiceStatus::StopSquelchMode()
|
||||
{
|
||||
m_bInSquelchMode = false;
|
||||
m_pHelper->UpdateCursorState();
|
||||
}
|
||||
|
||||
bool CVoiceStatus::IsInSquelchMode()
|
||||
{
|
||||
return m_bInSquelchMode;
|
||||
}
|
||||
|
||||
CVoiceLabel* CVoiceStatus::FindVoiceLabel(int clientindex)
|
||||
{
|
||||
for(int i=0; i < MAX_VOICE_SPEAKERS; i++)
|
||||
{
|
||||
if(m_Labels[i].m_clientindex == clientindex)
|
||||
return &m_Labels[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
CVoiceLabel* CVoiceStatus::GetFreeVoiceLabel()
|
||||
{
|
||||
return FindVoiceLabel(-1);
|
||||
}
|
||||
|
||||
|
||||
void CVoiceStatus::RepositionLabels()
|
||||
{
|
||||
// find starting position to draw from, along right-hand side of screen
|
||||
int y = ScreenHeight / 2;
|
||||
|
||||
int iconWide = 8, iconTall = 8;
|
||||
if( m_pSpeakerLabelIcon )
|
||||
{
|
||||
m_pSpeakerLabelIcon->getSize( iconWide, iconTall );
|
||||
}
|
||||
|
||||
// Reposition active labels.
|
||||
for(int i = 0; i < MAX_VOICE_SPEAKERS; i++)
|
||||
{
|
||||
CVoiceLabel *pLabel = &m_Labels[i];
|
||||
|
||||
if( pLabel->m_clientindex == -1 || !pLabel->m_pLabel )
|
||||
{
|
||||
if( pLabel->m_pBackground )
|
||||
pLabel->m_pBackground->setVisible( false );
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
int textWide, textTall;
|
||||
pLabel->m_pLabel->getContentSize( textWide, textTall );
|
||||
|
||||
// Don't let it stretch too far across their screen.
|
||||
if( textWide > (ScreenWidth*2)/3 )
|
||||
textWide = (ScreenWidth*2)/3;
|
||||
|
||||
// Setup the background label to fit everything in.
|
||||
int border = 2;
|
||||
int bgWide = textWide + iconWide + border*3;
|
||||
int bgTall = Q_max( textTall, iconTall ) + border*2;
|
||||
pLabel->m_pBackground->setBounds( ScreenWidth - bgWide - 8, y, bgWide, bgTall );
|
||||
|
||||
// Put the text at the left.
|
||||
pLabel->m_pLabel->setBounds( border, (bgTall - textTall) / 2, textWide, textTall );
|
||||
|
||||
// Put the icon at the right.
|
||||
int iconLeft = border + textWide + border;
|
||||
int iconTop = (bgTall - iconTall) / 2;
|
||||
if( pLabel->m_pIcon )
|
||||
{
|
||||
pLabel->m_pIcon->setImage( m_pSpeakerLabelIcon );
|
||||
pLabel->m_pIcon->setBounds( iconLeft, iconTop, iconWide, iconTall );
|
||||
}
|
||||
|
||||
y += bgTall + 2;
|
||||
}
|
||||
|
||||
if( m_pLocalBitmap && m_pAckBitmap && m_pLocalLabel && (m_bTalking || m_bServerAcked) )
|
||||
{
|
||||
m_pLocalLabel->setParent(*m_pParentPanel);
|
||||
m_pLocalLabel->setVisible( true );
|
||||
|
||||
if( m_bServerAcked && !!gEngfuncs.pfnGetCvarFloat("voice_clientdebug") )
|
||||
m_pLocalLabel->setImage( m_pAckBitmap );
|
||||
else
|
||||
m_pLocalLabel->setImage( m_pLocalBitmap );
|
||||
|
||||
int sizeX, sizeY;
|
||||
m_pLocalBitmap->getSize(sizeX, sizeY);
|
||||
|
||||
int local_xPos = ScreenWidth - sizeX - 10;
|
||||
int local_yPos = m_pHelper->GetAckIconHeight() - sizeY;
|
||||
|
||||
m_pLocalLabel->setPos( local_xPos, local_yPos );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pLocalLabel->setVisible( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CVoiceStatus::FreeBitmaps()
|
||||
{
|
||||
// Delete all the images we have loaded.
|
||||
delete m_pLocalBitmap;
|
||||
m_pLocalBitmap = NULL;
|
||||
|
||||
delete m_pAckBitmap;
|
||||
m_pAckBitmap = NULL;
|
||||
|
||||
delete m_pSpeakerLabelIcon;
|
||||
m_pSpeakerLabelIcon = NULL;
|
||||
|
||||
delete m_pScoreboardNeverSpoken;
|
||||
m_pScoreboardNeverSpoken = NULL;
|
||||
|
||||
delete m_pScoreboardNotSpeaking;
|
||||
m_pScoreboardNotSpeaking = NULL;
|
||||
|
||||
delete m_pScoreboardSpeaking;
|
||||
m_pScoreboardSpeaking = NULL;
|
||||
|
||||
delete m_pScoreboardSpeaking2;
|
||||
m_pScoreboardSpeaking2 = NULL;
|
||||
|
||||
delete m_pScoreboardSquelch;
|
||||
m_pScoreboardSquelch = NULL;
|
||||
|
||||
delete m_pScoreboardBanned;
|
||||
m_pScoreboardBanned = NULL;
|
||||
|
||||
// Clear references to the images in panels.
|
||||
for(int i=0; i < VOICE_MAX_PLAYERS; i++)
|
||||
{
|
||||
if (m_pBanButtons[i])
|
||||
{
|
||||
m_pBanButtons[i]->setImage(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if(m_pLocalLabel)
|
||||
m_pLocalLabel->setImage(NULL);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns true if the target client has been banned
|
||||
// Input : playerID -
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CVoiceStatus::IsPlayerBlocked(int iPlayer)
|
||||
{
|
||||
char playerID[16];
|
||||
if (!gEngfuncs.GetPlayerUniqueID(iPlayer, playerID))
|
||||
return false;
|
||||
|
||||
return m_BanMgr.GetPlayerBan(playerID);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: returns true if the player can't hear the other client due to game rules (eg. the other team)
|
||||
// Input : playerID -
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CVoiceStatus::IsPlayerAudible(int iPlayer)
|
||||
{
|
||||
return !!m_AudiblePlayers[iPlayer-1];
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: blocks/unblocks the target client from being heard
|
||||
// Input : playerID -
|
||||
// Output : Returns true on success, false on failure.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CVoiceStatus::SetPlayerBlockedState(int iPlayer, bool blocked)
|
||||
{
|
||||
if (gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
|
||||
{
|
||||
gEngfuncs.pfnConsolePrint( "CVoiceStatus::SetPlayerBlockedState part 1\n" );
|
||||
}
|
||||
|
||||
char playerID[16];
|
||||
if (!gEngfuncs.GetPlayerUniqueID(iPlayer, playerID))
|
||||
return;
|
||||
|
||||
if (gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
|
||||
{
|
||||
gEngfuncs.pfnConsolePrint( "CVoiceStatus::SetPlayerBlockedState part 2\n" );
|
||||
}
|
||||
|
||||
// Squelch or (try to) unsquelch this player.
|
||||
if (gEngfuncs.pfnGetCvarFloat("voice_clientdebug"))
|
||||
{
|
||||
char str[256];
|
||||
sprintf(str, "CVoiceStatus::SetPlayerBlockedState: setting player %d ban to %d\n", iPlayer, !m_BanMgr.GetPlayerBan(playerID));
|
||||
gEngfuncs.pfnConsolePrint(str);
|
||||
}
|
||||
|
||||
m_BanMgr.SetPlayerBan( playerID, blocked );
|
||||
UpdateServerState(false);
|
||||
}
|
|
@ -0,0 +1,228 @@
|
|||
//========= Copyright (c) 1996-2001, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
|
||||
#ifndef VOICE_STATUS_H
|
||||
#define VOICE_STATUS_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "VGUI_Label.h"
|
||||
#include "VGUI_LineBorder.h"
|
||||
#include "VGUI_ImagePanel.h"
|
||||
#include "VGUI_BitmapTGA.h"
|
||||
#include "VGUI_InputSignal.h"
|
||||
#include "VGUI_Button.h"
|
||||
#include "voice_common.h"
|
||||
#include "cl_entity.h"
|
||||
#include "voice_banmgr.h"
|
||||
#include "vgui_checkbutton2.h"
|
||||
#include "vgui_defaultinputsignal.h"
|
||||
|
||||
|
||||
class CVoiceStatus;
|
||||
|
||||
|
||||
class CVoiceLabel
|
||||
{
|
||||
public:
|
||||
vgui::Label *m_pLabel;
|
||||
vgui::Label *m_pBackground;
|
||||
vgui::ImagePanel *m_pIcon; // Voice icon next to player name.
|
||||
int m_clientindex; // Client index of the speaker. -1 if this label isn't being used.
|
||||
};
|
||||
|
||||
|
||||
// This is provided by each mod to access data that may not be the same across mods.
|
||||
class IVoiceStatusHelper
|
||||
{
|
||||
public:
|
||||
virtual ~IVoiceStatusHelper() {}
|
||||
|
||||
// Get RGB color for voice status text about this player.
|
||||
virtual void GetPlayerTextColor(int entindex, int color[3]) = 0;
|
||||
|
||||
// Force it to update the cursor state.
|
||||
virtual void UpdateCursorState() = 0;
|
||||
|
||||
// Return the height above the bottom that the voice ack icons should be drawn at.
|
||||
virtual int GetAckIconHeight() = 0;
|
||||
|
||||
// Return true if the voice manager is allowed to show speaker labels
|
||||
// (mods usually return false when the scoreboard is up).
|
||||
virtual bool CanShowSpeakerLabels() = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Holds a color for the shared image
|
||||
//-----------------------------------------------------------------------------
|
||||
class VoiceImagePanel : public vgui::ImagePanel
|
||||
{
|
||||
virtual void paintBackground()
|
||||
{
|
||||
if (_image!=null)
|
||||
{
|
||||
vgui::Color col;
|
||||
getFgColor(col);
|
||||
_image->setColor(col);
|
||||
_image->doPaint(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CVoiceStatus : public CHudBase, public vgui::CDefaultInputSignal
|
||||
{
|
||||
public:
|
||||
CVoiceStatus();
|
||||
virtual ~CVoiceStatus();
|
||||
|
||||
// CHudBase overrides.
|
||||
public:
|
||||
|
||||
// Initialize the cl_dll's voice manager.
|
||||
virtual int Init(
|
||||
IVoiceStatusHelper *m_pHelper,
|
||||
vgui::Panel **pParentPanel);
|
||||
|
||||
// ackPosition is the bottom position of where CVoiceStatus will draw the voice acknowledgement labels.
|
||||
virtual int VidInit();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Call from HUD_Frame each frame.
|
||||
void Frame(double frametime);
|
||||
|
||||
// Called when a player starts or stops talking.
|
||||
// entindex is -1 to represent the local client talking (before the data comes back from the server).
|
||||
// When the server acknowledges that the local client is talking, then entindex will be gEngfuncs.GetLocalPlayer().
|
||||
// entindex is -2 to represent the local client's voice being acked by the server.
|
||||
void UpdateSpeakerStatus(int entindex, qboolean bTalking);
|
||||
|
||||
// sets the correct image in the label for the player
|
||||
void UpdateSpeakerImage(vgui::Label *pLabel, int iPlayer);
|
||||
|
||||
// Call from the HUD_CreateEntities function so it can add sprites above player heads.
|
||||
void CreateEntities();
|
||||
|
||||
// Called when the server registers a change to who this client can hear.
|
||||
void HandleVoiceMaskMsg(int iSize, void *pbuf);
|
||||
|
||||
// The server sends this message initially to tell the client to send their state.
|
||||
void HandleReqStateMsg(int iSize, void *pbuf);
|
||||
|
||||
|
||||
// Squelch mode functions.
|
||||
public:
|
||||
|
||||
// When you enter squelch mode, pass in
|
||||
void StartSquelchMode();
|
||||
void StopSquelchMode();
|
||||
bool IsInSquelchMode();
|
||||
|
||||
// returns true if the target client has been banned
|
||||
// playerIndex is of range 1..maxplayers
|
||||
bool IsPlayerBlocked(int iPlayerIndex);
|
||||
|
||||
// returns false if the player can't hear the other client due to game rules (eg. the other team)
|
||||
bool IsPlayerAudible(int iPlayerIndex);
|
||||
|
||||
// blocks the target client from being heard
|
||||
void SetPlayerBlockedState(int iPlayerIndex, bool blocked);
|
||||
|
||||
public:
|
||||
|
||||
CVoiceLabel* FindVoiceLabel(int clientindex); // Find a CVoiceLabel representing the specified speaker.
|
||||
// Returns NULL if none.
|
||||
// entindex can be -1 if you want a currently-unused voice label.
|
||||
CVoiceLabel* GetFreeVoiceLabel(); // Get an unused voice label. Returns NULL if none.
|
||||
|
||||
void RepositionLabels();
|
||||
|
||||
void FreeBitmaps();
|
||||
|
||||
void UpdateServerState(bool bForce);
|
||||
|
||||
// Update the button artwork to reflect the client's current state.
|
||||
void UpdateBanButton(int iClient);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
enum {MAX_VOICE_SPEAKERS=7};
|
||||
|
||||
float m_LastUpdateServerState; // Last time we called this function.
|
||||
int m_bServerModEnable; // What we've sent to the server about our "voice_modenable" cvar.
|
||||
|
||||
vgui::Panel **m_pParentPanel;
|
||||
CPlayerBitVec m_VoicePlayers; // Who is currently talking. Indexed by client index.
|
||||
|
||||
// This is the gamerules-defined list of players that you can hear. It is based on what teams people are on
|
||||
// and is totally separate from the ban list. Indexed by client index.
|
||||
CPlayerBitVec m_AudiblePlayers;
|
||||
|
||||
// Players who have spoken at least once in the game so far
|
||||
CPlayerBitVec m_VoiceEnabledPlayers;
|
||||
|
||||
// This is who the server THINKS we have banned (it can become incorrect when a new player arrives on the server).
|
||||
// It is checked periodically, and the server is told to squelch or unsquelch the appropriate players.
|
||||
CPlayerBitVec m_ServerBannedPlayers;
|
||||
|
||||
cl_entity_s m_VoiceHeadModels[VOICE_MAX_PLAYERS]; // These aren't necessarily in the order of players. They are just
|
||||
// a place for it to put data in during CreateEntities.
|
||||
|
||||
IVoiceStatusHelper *m_pHelper; // Each mod provides an implementation of this.
|
||||
|
||||
|
||||
// Scoreboard icons.
|
||||
double m_BlinkTimer; // Blink scoreboard icons..
|
||||
vgui::BitmapTGA *m_pScoreboardNeverSpoken;
|
||||
vgui::BitmapTGA *m_pScoreboardNotSpeaking;
|
||||
vgui::BitmapTGA *m_pScoreboardSpeaking;
|
||||
vgui::BitmapTGA *m_pScoreboardSpeaking2;
|
||||
vgui::BitmapTGA *m_pScoreboardSquelch;
|
||||
vgui::BitmapTGA *m_pScoreboardBanned;
|
||||
|
||||
vgui::Label *m_pBanButtons[VOICE_MAX_PLAYERS]; // scoreboard buttons.
|
||||
|
||||
// Squelch mode stuff.
|
||||
bool m_bInSquelchMode;
|
||||
|
||||
HSPRITE m_VoiceHeadModel; // Voice head model (goes above players who are speaking).
|
||||
float m_VoiceHeadModelHeight; // Height above their head to place the model.
|
||||
|
||||
vgui::Image *m_pSpeakerLabelIcon; // Icon next to speaker labels.
|
||||
|
||||
// Lower-right icons telling when the local player is talking..
|
||||
vgui::BitmapTGA *m_pLocalBitmap; // Represents the local client talking.
|
||||
vgui::BitmapTGA *m_pAckBitmap; // Represents the server ack'ing the client talking.
|
||||
vgui::ImagePanel *m_pLocalLabel; // Represents the local client talking.
|
||||
|
||||
bool m_bTalking; // Set to true when the client thinks it's talking.
|
||||
bool m_bServerAcked; // Set to true when the server knows the client is talking.
|
||||
|
||||
public:
|
||||
|
||||
CVoiceBanMgr m_BanMgr; // Tracks which users we have squelched and don't want to hear.
|
||||
|
||||
public:
|
||||
|
||||
bool m_bBanMgrInitialized;
|
||||
|
||||
// Labels telling who is speaking.
|
||||
CVoiceLabel m_Labels[MAX_VOICE_SPEAKERS];
|
||||
|
||||
// Cache the game directory for use when we shut down
|
||||
char * m_pchGameDir;
|
||||
};
|
||||
|
||||
|
||||
// Get the (global) voice manager.
|
||||
CVoiceStatus* GetClientVoiceMgr();
|
||||
|
||||
|
||||
#endif // VOICE_STATUS_H
|
|
@ -0,0 +1,16 @@
|
|||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
#pragma once
|
||||
#if !defined( WRECTH )
|
||||
#define WRECTH
|
||||
|
||||
typedef struct rect_s
|
||||
{
|
||||
int left, right, top, bottom;
|
||||
} wrect_t;
|
||||
|
||||
#endif
|
118
cl_dll/wscript
118
cl_dll/wscript
|
@ -4,63 +4,129 @@
|
|||
|
||||
from waflib import Utils
|
||||
import os
|
||||
|
||||
|
||||
def options(opt):
|
||||
# stub
|
||||
return
|
||||
|
||||
def configure(conf):
|
||||
if conf.env.DEST_OS == 'win32':
|
||||
conf.check_cxx(lib='user32')
|
||||
|
||||
if conf.env.GOLDSRC:
|
||||
if conf.env.DEST_OS != 'win32':
|
||||
if conf.env.DEST_OS == 'win32':
|
||||
conf.check_cxx(lib='winmm')
|
||||
else:
|
||||
conf.check_cc(lib='dl')
|
||||
|
||||
def build(bld):
|
||||
source = bld.path.parent.ant_glob([
|
||||
'pm_shared/*.c',
|
||||
'dlls/crossbow.cpp', 'dlls/crowbar.cpp', 'dlls/egon.cpp', 'dlls/gauss.cpp', 'dlls/handgrenade.cpp',
|
||||
'dlls/hornetgun.cpp', 'dlls/mp5.cpp', 'dlls/python.cpp', 'dlls/rpg.cpp', 'dlls/satchel.cpp',
|
||||
'dlls/shotgun.cpp', 'dlls/squeakgrenade.cpp', 'dlls/tripmine.cpp', 'dlls/glock.cpp'
|
||||
'pm_shared/*.c'
|
||||
])
|
||||
source += bld.path.ant_glob([
|
||||
'hl/*.cpp'
|
||||
])
|
||||
source += bld.path.parent.ant_glob([
|
||||
'dlls/crossbow.cpp',
|
||||
'dlls/crowbar.cpp',
|
||||
'dlls/egon.cpp',
|
||||
'dlls/gauss.cpp',
|
||||
'dlls/glock.cpp',
|
||||
'dlls/handgrenade.cpp',
|
||||
'dlls/hornetgun.cpp',
|
||||
'dlls/mp5.cpp',
|
||||
'dlls/python.cpp',
|
||||
'dlls/rpg.cpp',
|
||||
'dlls/satchel.cpp',
|
||||
'dlls/shotgun.cpp',
|
||||
'dlls/squeakgrenade.cpp',
|
||||
'dlls/tripmine.cpp'
|
||||
])
|
||||
|
||||
source += bld.path.ant_glob(['hl/*.cpp'])
|
||||
source += [
|
||||
'ev_hldm.cpp', 'ammo.cpp', 'ammo_secondary.cpp', 'ammohistory.cpp',
|
||||
'battery.cpp', 'cdll_int.cpp', 'com_weapons.cpp', 'death.cpp',
|
||||
'demo.cpp', 'entity.cpp', 'ev_common.cpp', 'events.cpp',
|
||||
'flashlight.cpp', 'GameStudioModelRenderer.cpp', 'geiger.cpp',
|
||||
'health.cpp', 'hud.cpp', 'hud_msg.cpp', 'hud_redraw.cpp',
|
||||
'hud_spectator.cpp', 'hud_update.cpp', 'in_camera.cpp',
|
||||
'input.cpp', 'input_goldsource.cpp', 'input_mouse.cpp',
|
||||
'input_xash3d.cpp', 'menu.cpp', 'message.cpp',
|
||||
'overview.cpp', 'parsemsg.cpp', 'saytext.cpp',
|
||||
'status_icons.cpp', 'statusbar.cpp', 'studio_util.cpp',
|
||||
'StudioModelRenderer.cpp', 'text_message.cpp', 'train.cpp',
|
||||
'tri.cpp', 'util.cpp', 'view.cpp', 'scoreboard.cpp', 'MOTD.cpp'
|
||||
'GameStudioModelRenderer.cpp',
|
||||
'MOTD.cpp',
|
||||
'StudioModelRenderer.cpp',
|
||||
'ammo.cpp',
|
||||
'ammo_secondary.cpp',
|
||||
'ammohistory.cpp',
|
||||
'battery.cpp',
|
||||
'cdll_int.cpp',
|
||||
'com_weapons.cpp',
|
||||
'death.cpp',
|
||||
'demo.cpp',
|
||||
'entity.cpp',
|
||||
'ev_hldm.cpp',
|
||||
'ev_common.cpp',
|
||||
'events.cpp',
|
||||
'flashlight.cpp',
|
||||
'geiger.cpp',
|
||||
'health.cpp',
|
||||
'hud.cpp',
|
||||
'hud_msg.cpp',
|
||||
'hud_redraw.cpp',
|
||||
'hud_spectator.cpp',
|
||||
'hud_update.cpp',
|
||||
'in_camera.cpp',
|
||||
'input.cpp',
|
||||
'input_goldsource.cpp',
|
||||
'input_mouse.cpp',
|
||||
'input_xash3d.cpp',
|
||||
'menu.cpp',
|
||||
'message.cpp',
|
||||
'parsemsg.cpp',
|
||||
'saytext.cpp',
|
||||
'scoreboard.cpp',
|
||||
'status_icons.cpp',
|
||||
'statusbar.cpp',
|
||||
'studio_util.cpp',
|
||||
'text_message.cpp',
|
||||
'train.cpp',
|
||||
'tri.cpp',
|
||||
'util.cpp',
|
||||
'view.cpp'
|
||||
]
|
||||
|
||||
includes = Utils.to_list('. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/false_vgui/include')
|
||||
includes = [
|
||||
'.',
|
||||
'hl/',
|
||||
'../dlls',
|
||||
'../common',
|
||||
'../engine',
|
||||
'../pm_shared',
|
||||
'../game_shared',
|
||||
'../public',
|
||||
'../utils/fake_vgui/include'
|
||||
]
|
||||
|
||||
defines = ['CLIENT_DLL']
|
||||
if bld.env.GOLDSRC:
|
||||
defines += ['GOLDSOURCE_SUPPORT']
|
||||
|
||||
libs = []
|
||||
if bld.env.GOLDSRC:
|
||||
libs += ['DL']
|
||||
if bld.env.DEST_OS == 'win32':
|
||||
libs += ["USER32"]
|
||||
|
||||
if bld.env.DEST_OS2 not in ['android']:
|
||||
if bld.env.GOLDSRC:
|
||||
if bld.env.DEST_OS == 'win32':
|
||||
libs += ["WINMM"]
|
||||
else:
|
||||
libs += ['DL']
|
||||
|
||||
if bld.env.DEST_OS not in ['android', 'dos']:
|
||||
install_path = os.path.join(bld.env.GAMEDIR, bld.env.CLIENT_DIR)
|
||||
else:
|
||||
install_path = bld.env.PREFIX
|
||||
|
||||
bld.shlib(
|
||||
source = source,
|
||||
target = 'client',
|
||||
target = 'client' + bld.env.POSTFIX,
|
||||
name = 'client',
|
||||
features = 'c cxx',
|
||||
includes = includes,
|
||||
defines = defines,
|
||||
use = libs,
|
||||
install_path = install_path,
|
||||
subsystem = bld.env.MSVC_SUBSYSTEM,
|
||||
idx = 1
|
||||
idx = bld.get_taskgen_count()
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,162 @@
|
|||
include(CheckSymbolExists)
|
||||
|
||||
# generated(see comments in public/build.h)
|
||||
# cat build.h | grep '^#undef XASH' | awk '{ print "check_symbol_exists(" $2 " \"build.h\" " $2 ")" }'
|
||||
set(CMAKE_REQUIRED_INCLUDES "${PROJECT_SOURCE_DIR}/public/")
|
||||
check_symbol_exists(XASH_64BIT "build.h" XASH_64BIT)
|
||||
check_symbol_exists(XASH_AMD64 "build.h" XASH_AMD64)
|
||||
check_symbol_exists(XASH_ANDROID "build.h" XASH_ANDROID)
|
||||
check_symbol_exists(XASH_APPLE "build.h" XASH_APPLE)
|
||||
check_symbol_exists(XASH_ARM "build.h" XASH_ARM)
|
||||
check_symbol_exists(XASH_ARM_HARDFP "build.h" XASH_ARM_HARDFP)
|
||||
check_symbol_exists(XASH_ARM_SOFTFP "build.h" XASH_ARM_SOFTFP)
|
||||
check_symbol_exists(XASH_ARMv4 "build.h" XASH_ARMv4)
|
||||
check_symbol_exists(XASH_ARMv5 "build.h" XASH_ARMv5)
|
||||
check_symbol_exists(XASH_ARMv6 "build.h" XASH_ARMv6)
|
||||
check_symbol_exists(XASH_ARMv7 "build.h" XASH_ARMv7)
|
||||
check_symbol_exists(XASH_ARMv8 "build.h" XASH_ARMv8)
|
||||
check_symbol_exists(XASH_BIG_ENDIAN "build.h" XASH_BIG_ENDIAN)
|
||||
check_symbol_exists(XASH_BSD "build.h" XASH_BSD)
|
||||
check_symbol_exists(XASH_DOS4GW "build.h" XASH_DOS4GW)
|
||||
check_symbol_exists(XASH_E2K "build.h" XASH_E2K)
|
||||
check_symbol_exists(XASH_EMSCRIPTEN "build.h" XASH_EMSCRIPTEN)
|
||||
check_symbol_exists(XASH_FREEBSD "build.h" XASH_FREEBSD)
|
||||
check_symbol_exists(XASH_HAIKU "build.h" XASH_HAIKU)
|
||||
check_symbol_exists(XASH_IOS "build.h" XASH_IOS)
|
||||
check_symbol_exists(XASH_JS "build.h" XASH_JS)
|
||||
check_symbol_exists(XASH_LINUX "build.h" XASH_LINUX)
|
||||
check_symbol_exists(XASH_LITTLE_ENDIAN "build.h" XASH_LITTLE_ENDIAN)
|
||||
check_symbol_exists(XASH_MINGW "build.h" XASH_MINGW)
|
||||
check_symbol_exists(XASH_MIPS "build.h" XASH_MIPS)
|
||||
check_symbol_exists(XASH_PPC "build.h" XASH_PPC)
|
||||
check_symbol_exists(XASH_MOBILE_PLATFORM "build.h" XASH_MOBILE_PLATFORM)
|
||||
check_symbol_exists(XASH_MSVC "build.h" XASH_MSVC)
|
||||
check_symbol_exists(XASH_NETBSD "build.h" XASH_NETBSD)
|
||||
check_symbol_exists(XASH_OPENBSD "build.h" XASH_OPENBSD)
|
||||
check_symbol_exists(XASH_POSIX "build.h" XASH_POSIX)
|
||||
check_symbol_exists(XASH_RISCV "build.h" XASH_RISCV)
|
||||
check_symbol_exists(XASH_RISCV_DOUBLEFP "build.h" XASH_RISCV_DOUBLEFP)
|
||||
check_symbol_exists(XASH_RISCV_SINGLEFP "build.h" XASH_RISCV_SINGLEFP)
|
||||
check_symbol_exists(XASH_RISCV_SOFTFP "build.h" XASH_RISCV_SOFTFP)
|
||||
check_symbol_exists(XASH_SERENITY "build.h" XASH_SERENITY)
|
||||
check_symbol_exists(XASH_WIN32 "build.h" XASH_WIN32)
|
||||
check_symbol_exists(XASH_WIN64 "build.h" XASH_WIN64)
|
||||
check_symbol_exists(XASH_X86 "build.h" XASH_X86)
|
||||
check_symbol_exists(XASH_NSWITCH "build.h" XASH_NSWITCH)
|
||||
check_symbol_exists(XASH_PSVITA "build.h" XASH_PSVITA)
|
||||
unset(CMAKE_REQUIRED_INCLUDES)
|
||||
|
||||
# engine/common/build.c
|
||||
if(XASH_ANDROID)
|
||||
set(BUILDOS "android")
|
||||
elseif(XASH_WIN32 OR XASH_LINUX OR XASH_APPLE)
|
||||
set(BUILDOS "") # no prefix for default OS
|
||||
elseif(XASH_FREEBSD)
|
||||
set(BUILDOS "freebsd")
|
||||
elseif(XASH_NETBSD)
|
||||
set(BUILDOS "netbsd")
|
||||
elseif(XASH_OPENBSD)
|
||||
set(BUILDOS "openbsd")
|
||||
elseif(XASH_EMSCRIPTEN)
|
||||
set(BUILDOS "emscripten")
|
||||
elseif(XASH_DOS4GW)
|
||||
set(BUILDOS "DOS4GW")
|
||||
elseif(XASH_HAIKU)
|
||||
set(BUILDOS "haiku")
|
||||
elseif(XASH_SERENITY)
|
||||
set(BUILDOS "serenityos")
|
||||
elseif(XASH_NSWITCH)
|
||||
set(BUILDOS "nswitch")
|
||||
elseif(XASH_PSVITA)
|
||||
set(BUILDOS "psvita")
|
||||
else()
|
||||
message(SEND_ERROR "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug")
|
||||
endif()
|
||||
|
||||
if(XASH_AMD64)
|
||||
set(BUILDARCH "amd64")
|
||||
elseif(XASH_X86)
|
||||
if(XASH_WIN32 OR XASH_LINUX OR XASH_APPLE)
|
||||
set(BUILDARCH "") # no prefix for default OS
|
||||
else()
|
||||
set(BUILDARCH "i386")
|
||||
endif()
|
||||
elseif(XASH_ARM AND XASH_64BIT)
|
||||
set(BUILDARCH "arm64")
|
||||
elseif(XASH_ARM)
|
||||
set(BUILDARCH "armv")
|
||||
if(XASH_ARMv8)
|
||||
set(BUILDARCH "${BUILDARCH}8_32")
|
||||
elseif(XASH_ARMv7)
|
||||
set(BUILDARCH "${BUILDARCH}7")
|
||||
elseif(XASH_ARMv6)
|
||||
set(BUILDARCH "${BUILDARCH}6")
|
||||
elseif(XASH_ARMv5)
|
||||
set(BUILDARCH "${BUILDARCH}5")
|
||||
elseif(XASH_ARMv4)
|
||||
set(BUILDARCH "${BUILDARCH}4")
|
||||
else()
|
||||
message(SEND_ERROR "Unknown ARM")
|
||||
endif()
|
||||
|
||||
if(XASH_ARM_HARDFP)
|
||||
set(BUILDARCH "${BUILDARCH}hf")
|
||||
else()
|
||||
set(BUILDARCH "${BUILDARCH}l")
|
||||
endif()
|
||||
elseif(XASH_MIPS)
|
||||
set(BUILDARCH "mips")
|
||||
if(XASH_64BIT)
|
||||
set(BUILDARCH "${BUILDARCH}64")
|
||||
endif()
|
||||
|
||||
if(XASH_LITTLE_ENDIAN)
|
||||
set(BUILDARCH "${BUILDARCH}el")
|
||||
endif()
|
||||
elseif(XASH_PPC)
|
||||
set(BUILDARCH "powerpc")
|
||||
if(XASH_64BIT)
|
||||
set(BUILDARCH "${BUILDARCH}64")
|
||||
endif()
|
||||
|
||||
if(XASH_LITTLE_ENDIAN)
|
||||
set(BUILDARCH "${BUILDARCH}le")
|
||||
endif()
|
||||
elseif(XASH_RISCV)
|
||||
set(BUILDARCH "riscv")
|
||||
if(XASH_64BIT)
|
||||
set(BUILDARCH "${BUILDARCH}64")
|
||||
else()
|
||||
set(BUILDARCH "${BUILDARCH}32")
|
||||
endif()
|
||||
|
||||
if(XASH_RISCV_DOUBLEFP)
|
||||
set(BUILDARCH "${BUILDARCH}d")
|
||||
elseif(XASH_RISCV_SINGLEFP)
|
||||
set(BUILDARCH "${BUILDARCH}f")
|
||||
endif()
|
||||
elseif(XASH_JS)
|
||||
set(BUILDARCH "javascript")
|
||||
elseif(XASH_E2K)
|
||||
set(BUILDARCH "e2k")
|
||||
else()
|
||||
message(SEND_ERROR "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug")
|
||||
endif()
|
||||
|
||||
if(BUILDOS STREQUAL "android")
|
||||
set(POSTFIX "") # force disable for Android, as Android ports aren't distributed in normal way and doesn't follow library naming
|
||||
elseif(BUILDOS AND BUILDARCH)
|
||||
set(POSTFIX "_${BUILDOS}_${BUILDARCH}")
|
||||
elseif(BUILDARCH)
|
||||
set(POSTFIX "_${BUILDARCH}")
|
||||
else()
|
||||
set(POSTFIX "")
|
||||
endif()
|
||||
|
||||
message(STATUS "Library postfix: " ${POSTFIX})
|
||||
|
||||
set(CMAKE_RELEASE_POSTFIX ${POSTFIX})
|
||||
set(CMAKE_DEBUG_POSTFIX ${POSTFIX})
|
||||
set(CMAKE_RELWITHDEBINFO_POSTFIX ${POSTFIX})
|
||||
set(CMAKE_MINSIZEREL_POSTFIX ${POSTFIX})
|
||||
set(CMAKE_POSTFIX ${POSTFIX})
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
****/
|
||||
#pragma once
|
||||
#ifndef BEAMDEF_H
|
||||
#if !defined(BEAMDEF_H)
|
||||
#define BEAMDEF_H
|
||||
|
||||
#define FBEAM_STARTENTITY 0x00000001
|
||||
|
|
246
common/bspfile.h
246
common/bspfile.h
|
@ -1,246 +0,0 @@
|
|||
/*
|
||||
bspfile.h - BSP format included q1, hl1 support
|
||||
Copyright (C) 2010 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef BSPFILE_H
|
||||
#define BSPFILE_H
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
BRUSH MODELS
|
||||
|
||||
.bsp contain level static geometry with including PVS and lightning info
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
// header
|
||||
#define Q1BSP_VERSION 29 // quake1 regular version (beta is 28)
|
||||
#define HLBSP_VERSION 30 // half-life regular version
|
||||
#define XTBSP_VERSION 31 // extended lightmaps and expanded clipnodes limit
|
||||
|
||||
#define IDEXTRAHEADER (('H'<<24)+('S'<<16)+('A'<<8)+'X') // little-endian "XASH"
|
||||
#define EXTRA_VERSION 2 // because version 1 was occupied by old versions of XashXT
|
||||
|
||||
#define DELUXEMAP_VERSION 1
|
||||
#define IDDELUXEMAPHEADER (('T'<<24)+('I'<<16)+('L'<<8)+'Q') // little-endian "QLIT"
|
||||
|
||||
// worldcraft predefined angles
|
||||
#define ANGLE_UP -1
|
||||
#define ANGLE_DOWN -2
|
||||
|
||||
// bmodel limits
|
||||
#define MAX_MAP_HULLS 4 // MAX_HULLS
|
||||
|
||||
#define SURF_NOCULL BIT( 0 ) // two-sided polygon (e.g. 'water4b')
|
||||
#define SURF_PLANEBACK BIT( 1 ) // plane should be negated
|
||||
#define SURF_DRAWSKY BIT( 2 ) // sky surface
|
||||
#define SURF_WATERCSG BIT( 3 ) // culled by csg (was SURF_DRAWSPRITE)
|
||||
#define SURF_DRAWTURB BIT( 4 ) // warp surface
|
||||
#define SURF_DRAWTILED BIT( 5 ) // face without lighmap
|
||||
#define SURF_CONVEYOR BIT( 6 ) // scrolled texture (was SURF_DRAWBACKGROUND)
|
||||
#define SURF_UNDERWATER BIT( 7 ) // caustics
|
||||
#define SURF_TRANSPARENT BIT( 8 ) // it's a transparent texture (was SURF_DONTWARP)
|
||||
|
||||
#define SURF_REFLECT BIT( 31 ) // reflect surface (mirror)
|
||||
|
||||
// lightstyle management
|
||||
#define LM_STYLES 4 // MAXLIGHTMAPS
|
||||
#define LS_NORMAL 0x00
|
||||
#define LS_UNUSED 0xFE
|
||||
#define LS_NONE 0xFF
|
||||
|
||||
#define MAX_MAP_MODELS 1024 // can be increased up to 2048 if needed
|
||||
#define MAX_MAP_BRUSHES 32768 // unsigned short limit
|
||||
#define MAX_MAP_ENTITIES 8192 // can be increased up to 32768 if needed
|
||||
#define MAX_MAP_ENTSTRING 0x80000 // 512 kB should be enough
|
||||
#define MAX_MAP_PLANES 65536 // can be increased without problems
|
||||
#define MAX_MAP_NODES 32767 // because negative shorts are leafs
|
||||
#define MAX_MAP_CLIPNODES 32767 // because negative shorts are contents
|
||||
#define MAX_MAP_LEAFS 32767 // signed short limit
|
||||
#define MAX_MAP_VERTS 65535 // unsigned short limit
|
||||
#define MAX_MAP_FACES 65535 // unsigned short limit
|
||||
#define MAX_MAP_MARKSURFACES 65535 // unsigned short limit
|
||||
#define MAX_MAP_TEXINFO MAX_MAP_FACES // in theory each face may have personal texinfo
|
||||
#define MAX_MAP_EDGES 0x100000 // can be increased but not needed
|
||||
#define MAX_MAP_SURFEDGES 0x200000 // can be increased but not needed
|
||||
#define MAX_MAP_TEXTURES 2048 // can be increased but not needed
|
||||
#define MAX_MAP_MIPTEX 0x2000000 // 32 Mb internal textures data
|
||||
#define MAX_MAP_LIGHTING 0x2000000 // 32 Mb lightmap raw data (can contain deluxemaps)
|
||||
#define MAX_MAP_VISIBILITY 0x800000 // 8 Mb visdata
|
||||
|
||||
// quake lump ordering
|
||||
#define LUMP_ENTITIES 0
|
||||
#define LUMP_PLANES 1
|
||||
#define LUMP_TEXTURES 2 // internal textures
|
||||
#define LUMP_VERTEXES 3
|
||||
#define LUMP_VISIBILITY 4
|
||||
#define LUMP_NODES 5
|
||||
#define LUMP_TEXINFO 6
|
||||
#define LUMP_FACES 7
|
||||
#define LUMP_LIGHTING 8
|
||||
#define LUMP_CLIPNODES 9
|
||||
#define LUMP_LEAFS 10
|
||||
#define LUMP_MARKSURFACES 11
|
||||
#define LUMP_EDGES 12
|
||||
#define LUMP_SURFEDGES 13
|
||||
#define LUMP_MODELS 14 // internal submodels
|
||||
#define HEADER_LUMPS 15
|
||||
|
||||
// version 31
|
||||
#define LUMP_CLIPNODES2 15 // hull0 goes into LUMP_NODES, hull1 goes into LUMP_CLIPNODES,
|
||||
#define LUMP_CLIPNODES3 16 // hull2 goes into LUMP_CLIPNODES2, hull3 goes into LUMP_CLIPNODES3
|
||||
#define HEADER_LUMPS_31 17
|
||||
|
||||
#define LUMP_FACES_EXTRADATA 0 // extension of dface_t
|
||||
#define LUMP_VERTS_EXTRADATA 1 // extension of dvertex_t
|
||||
#define LUMP_CUBEMAPS 2 // cubemap description
|
||||
|
||||
#define EXTRA_LUMPS 8 // g-cont. just for future expansions
|
||||
|
||||
// texture flags
|
||||
#define TEX_SPECIAL BIT( 0 ) // sky or slime, no lightmap or 256 subdivision
|
||||
|
||||
// ambient sound types
|
||||
enum
|
||||
{
|
||||
AMBIENT_WATER = 0, // waterfall
|
||||
AMBIENT_SKY, // wind
|
||||
AMBIENT_SLIME, // never used in quake
|
||||
AMBIENT_LAVA, // never used in quake
|
||||
NUM_AMBIENTS // automatic ambient sounds
|
||||
};
|
||||
|
||||
//
|
||||
// BSP File Structures
|
||||
//
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int fileofs;
|
||||
int filelen;
|
||||
} dlump_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int version;
|
||||
dlump_t lumps[HEADER_LUMPS];
|
||||
} dheader_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int version;
|
||||
dlump_t lumps[HEADER_LUMPS_31];
|
||||
} dheader31_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int id; // must be little endian XASH
|
||||
int version;
|
||||
dlump_t lumps[EXTRA_LUMPS];
|
||||
} dextrahdr_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t mins;
|
||||
vec3_t maxs;
|
||||
vec3_t origin; // for sounds or lights
|
||||
int headnode[MAX_MAP_HULLS];
|
||||
int visleafs; // not including the solid leaf 0
|
||||
int firstface;
|
||||
int numfaces;
|
||||
} dmodel_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int nummiptex;
|
||||
int dataofs[4]; // [nummiptex]
|
||||
} dmiptexlump_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t point;
|
||||
} dvertex_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
int type; // PLANE_X - PLANE_ANYZ ?
|
||||
} dplane_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int planenum;
|
||||
short children[2]; // negative numbers are -(leafs + 1), not nodes
|
||||
short mins[3]; // for sphere culling
|
||||
short maxs[3];
|
||||
word firstface;
|
||||
word numfaces; // counting both sides
|
||||
} dnode_t;
|
||||
|
||||
// leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas
|
||||
// all other leafs need visibility info
|
||||
typedef struct
|
||||
{
|
||||
int contents;
|
||||
int visofs; // -1 = no visibility info
|
||||
|
||||
short mins[3]; // for frustum culling
|
||||
short maxs[3];
|
||||
word firstmarksurface;
|
||||
word nummarksurfaces;
|
||||
|
||||
// automatic ambient sounds
|
||||
byte ambient_level[NUM_AMBIENTS]; // ambient sound level (0 - 255)
|
||||
} dleaf_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int planenum;
|
||||
short children[2]; // negative numbers are contents
|
||||
} dclipnode_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float vecs[2][4]; // texmatrix [s/t][xyz offset]
|
||||
int miptex;
|
||||
int flags;
|
||||
} dtexinfo_t;
|
||||
|
||||
typedef word dmarkface_t; // leaf marksurfaces indexes
|
||||
typedef int dsurfedge_t; // map surfedges
|
||||
|
||||
// NOTE: that edge 0 is never used, because negative edge nums
|
||||
// are used for counterclockwise use of the edge in a face
|
||||
typedef struct
|
||||
{
|
||||
word v[2]; // vertex numbers
|
||||
} dedge_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
word planenum;
|
||||
short side;
|
||||
|
||||
int firstedge; // we must support > 64k edges
|
||||
short numedges;
|
||||
short texinfo;
|
||||
|
||||
// lighting info
|
||||
byte styles[LM_STYLES];
|
||||
int lightofs; // start of [numstyles*surfsize] samples
|
||||
} dface_t;
|
||||
|
||||
#endif//BSPFILE_H
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
****/
|
||||
#pragma once
|
||||
#ifndef CL_ENTITY_H
|
||||
#if !defined(CL_ENTITY_H)
|
||||
#define CL_ENTITY_H
|
||||
|
||||
typedef struct efrag_s
|
||||
|
|
|
@ -1,59 +1,77 @@
|
|||
/*
|
||||
com_model.h - cient model structures
|
||||
Copyright (C) 2010 Uncle Mike
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
*/
|
||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================
|
||||
// com_model.h
|
||||
#pragma once
|
||||
#ifndef COM_MODEL_H
|
||||
#if !defined( COM_MODEL_H )
|
||||
#define COM_MODEL_H
|
||||
|
||||
#include "bspfile.h" // we need some declarations from it
|
||||
#define STUDIO_RENDER 1
|
||||
#define STUDIO_EVENTS 2
|
||||
|
||||
typedef vec_t vec2_t[2];
|
||||
typedef vec_t vec4_t[4];
|
||||
#define MAX_CLIENTS 32
|
||||
#define MAX_EDICTS 900
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
#define MAX_MODEL_NAME 64
|
||||
#define MAX_MAP_HULLS 4
|
||||
#define MIPLEVELS 4
|
||||
#define NUM_AMBIENTS 4 // automatic ambient sounds
|
||||
#define MAXLIGHTMAPS 4
|
||||
#define PLANE_ANYZ 5
|
||||
|
||||
ENGINE MODEL FORMAT
|
||||
==============================================================================
|
||||
*/
|
||||
#define STUDIO_RENDER 1
|
||||
#define STUDIO_EVENTS 2
|
||||
#define ALIAS_Z_CLIP_PLANE 5
|
||||
|
||||
#define ZISCALE ((float)0x8000)
|
||||
// flags in finalvert_t.flags
|
||||
#define ALIAS_LEFT_CLIP 0x0001
|
||||
#define ALIAS_TOP_CLIP 0x0002
|
||||
#define ALIAS_RIGHT_CLIP 0x0004
|
||||
#define ALIAS_BOTTOM_CLIP 0x0008
|
||||
#define ALIAS_Z_CLIP 0x0010
|
||||
#define ALIAS_ONSEAM 0x0020
|
||||
#define ALIAS_XY_CLIP_MASK 0x000F
|
||||
|
||||
#define MIPLEVELS 4
|
||||
#define VERTEXSIZE 7
|
||||
#define MAXLIGHTMAPS 4
|
||||
#define NUM_AMBIENTS 4 // automatic ambient sounds
|
||||
#define ZISCALE ((float)0x8000)
|
||||
|
||||
// model types
|
||||
typedef enum
|
||||
{
|
||||
mod_bad = -1,
|
||||
mod_brush,
|
||||
mod_sprite,
|
||||
mod_alias,
|
||||
mod_studio
|
||||
} modtype_t;
|
||||
|
||||
// must match definition in modelgen.h
|
||||
#if !defined(SYNCTYPE_T)
|
||||
#define SYNCTYPE_T
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ST_SYNC=0,
|
||||
ST_RAND
|
||||
} synctype_t;
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float mins[3], maxs[3];
|
||||
float origin[3];
|
||||
int headnode[MAX_MAP_HULLS];
|
||||
int visleafs; // not including the solid leaf 0
|
||||
int firstface, numfaces;
|
||||
} dmodel_t;
|
||||
|
||||
// plane_t structure
|
||||
typedef struct mplane_s
|
||||
{
|
||||
vec3_t normal;
|
||||
float dist;
|
||||
byte type; // for fast side tests
|
||||
byte signbits; // signx + (signy<<1) + (signz<<1)
|
||||
byte pad[2];
|
||||
vec3_t normal; // surface normal
|
||||
float dist; // closest appoach to origin
|
||||
byte type; // for texture axis selection and fast side tests
|
||||
byte signbits; // signx + signy<<1 + signz<<1
|
||||
byte pad[2];
|
||||
} mplane_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -70,292 +88,246 @@ typedef struct
|
|||
typedef struct texture_s
|
||||
{
|
||||
char name[16];
|
||||
unsigned int width, height;
|
||||
int gl_texturenum;
|
||||
struct msurface_s *texturechain; // for gl_texsort drawing
|
||||
int anim_total; // total tenths in sequence ( 0 = no)
|
||||
int anim_min, anim_max; // time for this frame min <=time< max
|
||||
struct texture_s *anim_next; // in the animation sequence
|
||||
struct texture_s *alternate_anims; // bmodels in frame 1 use these
|
||||
unsigned short fb_texturenum; // auto-luma texturenum
|
||||
unsigned short dt_texturenum; // detail-texture binding
|
||||
unsigned int unused[3]; // reserved
|
||||
unsigned width, height;
|
||||
int anim_total; // total tenths in sequence ( 0 = no)
|
||||
int anim_min, anim_max; // time for this frame min <=time< max
|
||||
struct texture_s *anim_next; // in the animation sequence
|
||||
struct texture_s *alternate_anims; // bmodels in frame 1 use these
|
||||
unsigned offsets[MIPLEVELS]; // four mip maps stored
|
||||
unsigned paloffset;
|
||||
} texture_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float vecs[2][4]; // [s/t] unit vectors in world space.
|
||||
// [i][3] is the s/t offset relative to the origin.
|
||||
// s or t = dot( 3Dpoint, vecs[i] ) + vecs[i][3]
|
||||
float mipadjust; // mipmap limits for very small surfaces
|
||||
texture_t *texture;
|
||||
int flags; // sky or slime, no lightmap or 256 subdivision
|
||||
float vecs[2][4]; // [s/t] unit vectors in world space.
|
||||
// [i][3] is the s/t offset relative to the origin.
|
||||
// s or t = dot(3Dpoint,vecs[i])+vecs[i][3]
|
||||
float mipadjust; // ?? mipmap limits for very small surfaces
|
||||
texture_t *texture;
|
||||
int flags; // sky or slime, no lightmap or 256 subdivision
|
||||
} mtexinfo_t;
|
||||
|
||||
// 73 bytes per VBO vertex
|
||||
// FIXME: align to 32 bytes
|
||||
typedef struct glvert_s
|
||||
{
|
||||
vec3_t vertex; // position
|
||||
vec3_t normal; // normal
|
||||
vec2_t stcoord; // ST texture coords
|
||||
vec2_t lmcoord; // ST lightmap coords
|
||||
vec2_t sccoord; // ST scissor coords (decals only) - for normalmap coords migration
|
||||
vec3_t tangent; // tangent
|
||||
vec3_t binormal; // binormal
|
||||
byte color[4]; // colors per vertex
|
||||
} glvert_t;
|
||||
|
||||
typedef struct glpoly_s
|
||||
{
|
||||
struct glpoly_s *next;
|
||||
struct glpoly_s *chain;
|
||||
int numverts;
|
||||
int flags; // for SURF_UNDERWATER
|
||||
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
||||
} glpoly_t;
|
||||
|
||||
typedef struct mnode_s
|
||||
{
|
||||
// common with leaf
|
||||
int contents; // 0, to differentiate from leafs
|
||||
int visframe; // node needs to be traversed if current
|
||||
int contents; // 0, to differentiate from leafs
|
||||
int visframe; // node needs to be traversed if current
|
||||
|
||||
short minmaxs[6]; // for bounding box culling
|
||||
|
||||
float minmaxs[6]; // for bounding box culling
|
||||
struct mnode_s *parent;
|
||||
|
||||
// node specific
|
||||
mplane_t *plane;
|
||||
mplane_t *plane;
|
||||
struct mnode_s *children[2];
|
||||
|
||||
unsigned short firstsurface;
|
||||
unsigned short numsurfaces;
|
||||
unsigned short firstsurface;
|
||||
unsigned short numsurfaces;
|
||||
} mnode_t;
|
||||
|
||||
typedef struct msurface_s msurface_t;
|
||||
typedef struct decal_s decal_t;
|
||||
typedef struct decal_s decal_t;
|
||||
|
||||
// JAY: Compress this as much as possible
|
||||
struct decal_s
|
||||
{
|
||||
decal_t *pnext; // linked list for each surface
|
||||
msurface_t *psurface; // Surface id for persistence / unlinking
|
||||
float dx; // local texture coordinates
|
||||
float dy; //
|
||||
float scale; // Pixel scale
|
||||
decal_t *pnext; // linked list for each surface
|
||||
msurface_t *psurface; // Surface id for persistence / unlinking
|
||||
short dx; // Offsets into surface texture (in texture coordinates, so we don't need floats)
|
||||
short dy;
|
||||
short texture; // Decal texture
|
||||
byte flags; // Decal flags FDECAL_*
|
||||
byte scale; // Pixel scale
|
||||
byte flags; // Decal flags
|
||||
|
||||
short entityIndex; // Entity this is attached to
|
||||
// Xash3D added
|
||||
vec3_t position; // location of the decal center in world space.
|
||||
vec3_t saxis; // direction of the s axis in world space
|
||||
struct msurfmesh_s *mesh; // decal mesh in local space
|
||||
int reserved[4]; // for future expansions
|
||||
};
|
||||
|
||||
typedef struct mleaf_s
|
||||
{
|
||||
// common with node
|
||||
int contents;
|
||||
int visframe; // node needs to be traversed if current
|
||||
int contents; // wil be a negative contents number
|
||||
int visframe; // node needs to be traversed if current
|
||||
|
||||
float minmaxs[6]; // for bounding box culling
|
||||
short minmaxs[6]; // for bounding box culling
|
||||
|
||||
struct mnode_s *parent;
|
||||
|
||||
// leaf specific
|
||||
byte *compressed_vis;
|
||||
struct efrag_s *efrags;
|
||||
|
||||
msurface_t **firstmarksurface;
|
||||
int nummarksurfaces;
|
||||
byte *compressed_pas;
|
||||
int nummarksurfaces;
|
||||
int key; // BSP sequence number for leaf's contents
|
||||
byte ambient_sound_level[NUM_AMBIENTS];
|
||||
|
||||
} mleaf_t;
|
||||
|
||||
typedef struct msurface_s
|
||||
struct msurface_s
|
||||
{
|
||||
int visframe; // should be drawn when node is crossed
|
||||
int visframe; // should be drawn when node is crossed
|
||||
|
||||
mplane_t *plane; // pointer to shared plane
|
||||
int flags; // see SURF_ #defines
|
||||
int dlightframe; // last frame the surface was checked by an animated light
|
||||
int dlightbits; // dynamically generated. Indicates if the surface illumination
|
||||
// is modified by an animated light.
|
||||
|
||||
int firstedge; // look up in model->surfedges[], negative numbers
|
||||
int numedges; // are backwards edges
|
||||
mplane_t *plane; // pointer to shared plane
|
||||
int flags; // see SURF_ #defines
|
||||
|
||||
short texturemins[2];
|
||||
short extents[2];
|
||||
int firstedge; // look up in model->surfedges[], negative numbers
|
||||
int numedges; // are backwards edges
|
||||
|
||||
// surface generation data
|
||||
struct surfcache_s *cachespots[MIPLEVELS];
|
||||
|
||||
int light_s, light_t; // gl lightmap coordinates
|
||||
short texturemins[2]; // smallest s/t position on the surface.
|
||||
short extents[2]; // ?? s/t texture size, 1..256 for all non-sky surfaces
|
||||
|
||||
glpoly_t *polys; // multiple if warped
|
||||
struct msurface_s *texturechain;
|
||||
|
||||
mtexinfo_t *texinfo;
|
||||
|
||||
// lighting info
|
||||
int dlightframe; // last frame the surface was checked by an animated light
|
||||
int dlightbits; // dynamically generated. Indicates if the surface illumination
|
||||
// is modified by an animated light.
|
||||
|
||||
int lightmaptexturenum;
|
||||
byte styles[MAXLIGHTMAPS];
|
||||
int cached_light[MAXLIGHTMAPS]; // values currently used in lightmap
|
||||
struct msurface_s *lightmapchain; // for new dlights rendering (was cached_dlight)
|
||||
|
||||
color24 *samples; // note: this is the actual lightmap data for this surface
|
||||
mtexinfo_t *texinfo;
|
||||
|
||||
// lighting info
|
||||
byte styles[MAXLIGHTMAPS]; // index into d_lightstylevalue[] for animated lights
|
||||
// no one surface can be effected by more than 4
|
||||
// animated lights.
|
||||
color24 *samples;
|
||||
|
||||
decal_t *pdecals;
|
||||
} msurface_t;
|
||||
};
|
||||
|
||||
typedef struct msurfmesh_s
|
||||
typedef struct
|
||||
{
|
||||
unsigned short numVerts;
|
||||
unsigned short numElems; // ~ 20 000 vertex per one surface. Should be enough
|
||||
unsigned int startVert; // user-variable. may be used for construct world single-VBO
|
||||
unsigned int startElem; // user-variable. may be used for construct world single-VBO
|
||||
|
||||
glvert_t *verts; // vertexes array
|
||||
unsigned short *elems; // indices
|
||||
|
||||
struct msurface_s *surf; // pointer to parent surface. Just for consistency
|
||||
struct msurfmesh_s *next; // temporary chain of subdivided surfaces
|
||||
} msurfmesh_t;
|
||||
|
||||
// surface extradata stored in cache.data for all brushmodels
|
||||
typedef struct mextrasurf_s
|
||||
{
|
||||
vec3_t mins, maxs;
|
||||
vec3_t origin; // surface origin
|
||||
msurfmesh_t *mesh; // VBO\VA ready surface mesh. Not used by engine but can be used by mod-makers
|
||||
|
||||
int dlight_s, dlight_t; // gl lightmap coordinates for dynamic lightmaps
|
||||
|
||||
int mirrortexturenum; // gl texnum
|
||||
float mirrormatrix[4][4];
|
||||
struct mextrasurf_s *mirrorchain; // for gl_texsort drawing
|
||||
struct mextrasurf_s *detailchain; // for detail textures drawing
|
||||
color24 *deluxemap; // note: this is the actual deluxemap data for this surface
|
||||
|
||||
int reserved[32]; // just for future expansions or mod-makers
|
||||
} mextrasurf_t;
|
||||
int planenum;
|
||||
short children[2]; // negative numbers are contents
|
||||
} dclipnode_t;
|
||||
|
||||
typedef struct hull_s
|
||||
{
|
||||
dclipnode_t *clipnodes;
|
||||
mplane_t *planes;
|
||||
int firstclipnode;
|
||||
int lastclipnode;
|
||||
mplane_t *planes;
|
||||
int firstclipnode;
|
||||
int lastclipnode;
|
||||
vec3_t clip_mins;
|
||||
vec3_t clip_maxs;
|
||||
} hull_t;
|
||||
|
||||
#ifndef CACHE_USER
|
||||
#if !defined( CACHE_USER ) && !defined( QUAKEDEF_H )
|
||||
#define CACHE_USER
|
||||
typedef struct cache_user_s
|
||||
{
|
||||
void *data; // extradata
|
||||
void *data;
|
||||
} cache_user_t;
|
||||
#endif
|
||||
|
||||
typedef struct model_s
|
||||
{
|
||||
char name[64]; // model name
|
||||
qboolean needload; // bmodels and sprites don't cache normally
|
||||
char name[ MAX_MODEL_NAME ];
|
||||
qboolean needload; // bmodels and sprites don't cache normally
|
||||
|
||||
// shared modelinfo
|
||||
modtype_t type; // model type
|
||||
int numframes; // sprite's framecount
|
||||
byte *mempool; // private mempool (was synctype)
|
||||
int flags; // hl compatibility
|
||||
modtype_t type;
|
||||
int numframes;
|
||||
synctype_t synctype;
|
||||
|
||||
int flags;
|
||||
|
||||
//
|
||||
// volume occupied by the model
|
||||
//
|
||||
vec3_t mins, maxs; // bounding box at angles '0 0 0'
|
||||
//
|
||||
vec3_t mins, maxs;
|
||||
float radius;
|
||||
|
||||
// brush model
|
||||
int firstmodelsurface;
|
||||
int nummodelsurfaces;
|
||||
|
||||
int numsubmodels;
|
||||
dmodel_t *submodels; // or studio animations
|
||||
//
|
||||
// brush model
|
||||
//
|
||||
int firstmodelsurface, nummodelsurfaces;
|
||||
|
||||
int numplanes;
|
||||
mplane_t *planes;
|
||||
int numsubmodels;
|
||||
dmodel_t *submodels;
|
||||
|
||||
int numleafs; // number of visible leafs, not counting 0
|
||||
mleaf_t *leafs;
|
||||
int numplanes;
|
||||
mplane_t *planes;
|
||||
|
||||
int numvertexes;
|
||||
mvertex_t *vertexes;
|
||||
int numleafs; // number of visible leafs, not counting 0
|
||||
struct mleaf_s *leafs;
|
||||
|
||||
int numedges;
|
||||
int numvertexes;
|
||||
mvertex_t *vertexes;
|
||||
|
||||
int numedges;
|
||||
medge_t *edges;
|
||||
|
||||
int numnodes;
|
||||
int numnodes;
|
||||
mnode_t *nodes;
|
||||
|
||||
int numtexinfo;
|
||||
int numtexinfo;
|
||||
mtexinfo_t *texinfo;
|
||||
|
||||
int numsurfaces;
|
||||
int numsurfaces;
|
||||
msurface_t *surfaces;
|
||||
|
||||
int numsurfedges;
|
||||
int *surfedges;
|
||||
int numsurfedges;
|
||||
int *surfedges;
|
||||
|
||||
int numclipnodes;
|
||||
int numclipnodes;
|
||||
dclipnode_t *clipnodes;
|
||||
|
||||
int nummarksurfaces;
|
||||
int nummarksurfaces;
|
||||
msurface_t **marksurfaces;
|
||||
|
||||
hull_t hulls[MAX_MAP_HULLS];
|
||||
|
||||
int numtextures;
|
||||
texture_t **textures;
|
||||
int numtextures;
|
||||
texture_t **textures;
|
||||
|
||||
byte *visdata;
|
||||
|
||||
color24 *lightdata;
|
||||
|
||||
char *entities;
|
||||
|
||||
//
|
||||
// additional model data
|
||||
//
|
||||
cache_user_t cache; // only access through Mod_Extradata
|
||||
|
||||
} model_t;
|
||||
|
||||
typedef vec_t vec4_t[4];
|
||||
|
||||
typedef struct alight_s
|
||||
{
|
||||
int ambientlight; // clip at 128
|
||||
int shadelight; // clip at 192 - ambientlight
|
||||
int ambientlight; // clip at 128
|
||||
int shadelight; // clip at 192 - ambientlight
|
||||
vec3_t color;
|
||||
float *plightvec;
|
||||
} alight_t;
|
||||
|
||||
typedef struct auxvert_s
|
||||
{
|
||||
float fv[3]; // viewspace x, y
|
||||
float fv[3]; // viewspace x, y
|
||||
} auxvert_t;
|
||||
|
||||
#define MAX_SCOREBOARDNAME 32
|
||||
#define MAX_INFO_STRING 256
|
||||
|
||||
#include "custom.h"
|
||||
|
||||
#define MAX_INFO_STRING 256
|
||||
#define MAX_SCOREBOARDNAME 32
|
||||
typedef struct player_info_s
|
||||
{
|
||||
int userid; // User id on server
|
||||
char userinfo[MAX_INFO_STRING]; // User info string
|
||||
char name[MAX_SCOREBOARDNAME]; // Name (extracted from userinfo)
|
||||
int spectator; // Spectator or not, unused
|
||||
// User id on server
|
||||
int userid;
|
||||
|
||||
// User info string
|
||||
char userinfo[ MAX_INFO_STRING ];
|
||||
|
||||
// Name
|
||||
char name[ MAX_SCOREBOARDNAME ];
|
||||
|
||||
// Spectator or not, unused
|
||||
int spectator;
|
||||
|
||||
int ping;
|
||||
int packet_loss;
|
||||
|
||||
// skin information
|
||||
char model[64];
|
||||
char model[MAX_QPATH];
|
||||
int topcolor;
|
||||
int bottomcolor;
|
||||
|
||||
|
@ -364,50 +336,12 @@ typedef struct player_info_s
|
|||
|
||||
// Gait frame estimation
|
||||
int gaitsequence;
|
||||
float gaitframe;
|
||||
float gaityaw;
|
||||
vec3_t prevgaitorigin;
|
||||
float gaitframe;
|
||||
float gaityaw;
|
||||
vec3_t prevgaitorigin;
|
||||
|
||||
customization_t customdata;
|
||||
customization_t customdata;
|
||||
} player_info_t;
|
||||
|
||||
//
|
||||
// sprite representation in memory
|
||||
//
|
||||
typedef enum { SPR_SINGLE = 0, SPR_GROUP, SPR_ANGLED } spriteframetype_t;
|
||||
#endif // COM_MODEL_H
|
||||
|
||||
typedef struct mspriteframe_s
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
float up, down, left, right;
|
||||
int gl_texturenum;
|
||||
} mspriteframe_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int numframes;
|
||||
float *intervals;
|
||||
mspriteframe_t *frames[1];
|
||||
} mspritegroup_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
spriteframetype_t type;
|
||||
mspriteframe_t *frameptr;
|
||||
} mspriteframedesc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short type;
|
||||
short texFormat;
|
||||
int maxwidth;
|
||||
int maxheight;
|
||||
int numframes;
|
||||
int radius;
|
||||
int facecull;
|
||||
int synctype;
|
||||
mspriteframedesc_t frames[1];
|
||||
} msprite_t;
|
||||
|
||||
#endif//COM_MODEL_H
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
****/
|
||||
#pragma once
|
||||
#ifndef CON_NPRINT_H
|
||||
#if !defined(CON_NPRINT_H)
|
||||
#define CON_NPRINT_H
|
||||
|
||||
typedef struct con_nprint_s
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
****/
|
||||
#pragma once
|
||||
#ifndef CONST_H
|
||||
#if !defined(CONST_H)
|
||||
#define CONST_H
|
||||
//
|
||||
// Constants shared by the engine and dlls
|
||||
|
@ -742,7 +742,7 @@ typedef unsigned short word;
|
|||
#undef true
|
||||
#undef false
|
||||
|
||||
#ifndef __cplusplus
|
||||
#if !__cplusplus
|
||||
typedef enum { false, true } qboolean;
|
||||
#else
|
||||
typedef int qboolean;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue