Skip to content

Commit

Permalink
v3.2 (#11)
Browse files Browse the repository at this point in the history
* Added dank.game!
* now uses get_path()

* Added Translator:
- dank.win-activate.py
- dank.browser-backup.py

* Code Cleanup:
- dank.minecraft-server-scanner.py
- dank.spotify.py
- executor.py
- dank.tool.py

Former-commit-id: 4b84ef1
  • Loading branch information
SirDank authored Oct 18, 2023
1 parent e4bec98 commit 9c9a1b7
Show file tree
Hide file tree
Showing 24 changed files with 489 additions and 183 deletions.
Binary file added __assets__/dank.game/textures/acacia_log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __assets__/dank.game/textures/azalea_leaves.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __assets__/dank.game/textures/grass1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __assets__/dank.game/textures/grass2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __assets__/dank.game/textures/mossy_cobblestone1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __assets__/dank.game/textures/mossy_cobblestone2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __assets__/dank.game/textures/mossy_stone_bricks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __assets__/dank.game/textures/sky.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions __assets__/dank.game/textures/texture_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
37 changes: 29 additions & 8 deletions __modules__/dank.browser-backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@
import zipfile
import datetime
from psutil import process_iter
from translatepy import Translator
from dankware import white, white_normal, red, red_normal, red_dim
from dankware import title, cls, clr, err, align, rm_line, is_admin, export_registry_keys
from dankware import title, cls, clr, err, align, rm_line, is_admin, export_registry_keys, get_path

from rich.live import Live
from rich.panel import Panel
from rich.table import Table
from rich.progress import Progress, SpinnerColumn, BarColumn, TextColumn, TimeRemainingColumn, TimeElapsedColumn

def translate(text):

if DANK_TOOL_LANG:
try: text = translator.translate(text, source_language='en', destination_language=DANK_TOOL_LANG)
except: pass
return text

def chrome_installed():
try:
reg_path = r"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe"
Expand All @@ -28,12 +36,12 @@ def backup(browser, compression_level):
path_to_backup = os.path.expandvars(r"%LOCALAPPDATA%\Google\Chrome\User Data")

if not chrome_installed():
cls(); print(clr("\n > Chrome possibly not installed!",2))
cls(); print(clr(f"\n > {translate('Chrome possibly not installed')}!",2))

if not os.path.exists(path_to_backup):
print(clr(f"\n > Invalid Path: {path_to_backup}\n",2))
print(clr(f"\n > {translate('Invalid Path')}: {path_to_backup}\n",2))
while True:
path_to_backup = input(clr(" > Input user data folder path: ")); rm_line()
path_to_backup = input(clr(f" > {translate('Input user data folder path')}: ")); rm_line()
if os.path.exists(path_to_backup) and r"Google\Chrome\User Data" in path_to_backup: break

while True:
Expand All @@ -44,10 +52,10 @@ def backup(browser, compression_level):
if chrome_running: input(clr("\n > Chrome is running! Terminate it and press [ENTER]... ",2))
else: break

cls(); print(clr("\n > Exporting registry keys..."))
cls(); print(clr(f"\n > {translate('Exporting registry keys')}..."))
export_registry_keys('HKEY_CURRENT_USER', r'Software\Google\Chrome\PreferenceMACs', export_path='chrome.reg')

print(clr("\n > Compressing... (this might take a few minutes)\n"))
print(clr(f"\n > {translate('Compressing... (this might take a few minutes)')}\n"))

num_source_files = 0
for root, dirs, files in os.walk(path_to_backup):
Expand Down Expand Up @@ -89,13 +97,26 @@ def backup(browser, compression_level):
#elif browser == "Brave":

def main():

global DANK_TOOL_LANG, translator

# check if translator is enabled (dank.tool.exe)

try:
DANK_TOOL_LANG = os.environ['DANK_TOOL_LANG']
if DANK_TOOL_LANG == 'en':
DANK_TOOL_LANG = ''
else:
translator = Translator()
except:
DANK_TOOL_LANG = ''

cls(); title("𝚍𝚊𝚗𝚔.𝚋𝚛𝚘𝚠𝚜𝚎𝚛-𝚋𝚊𝚌𝚔𝚞𝚙"); banner = "\n\n \n _ _ _ _ _ \n _| |___ ___| |_ | |_ ___ ___ _ _ _ ___ ___ ___ ___| |_ ___ ___| |_ _ _ ___ \n| . | .'| | '_|_| . | _| . | | | |_ -| -_| _|___| . | .'| _| '_| | | . |\n|___|__,|_|_|_,_|_|___|_| |___|_____|___|___|_| |___|__,|___|_,_|___| _|\n |_| \n\n"
try:
if not is_admin(): raise RuntimeError(clr("Not executed as administrator! Exporting browser data and registry keys requires admin privileges!"))
except: sys.exit(clr(err(sys.exc_info()),2))

try: os.chdir(os.path.join(os.environ['USERPROFILE'],'Documents'))
try: os.chdir(get_path('Documents'))
except: os.chdir("C:\\")
try: os.mkdir('dank.browser-backup')
except: pass
Expand Down Expand Up @@ -124,7 +145,7 @@ def main():

print("")
while True:
compression_level = input(clr(" > Compression level (Fast/Best) [1/2]: ") + red).lower()
compression_level = input(clr(f" > {translate('Compression level (Fast/Best)')} [1/2]: ") + red).lower()
if compression_level in ('1', 'fast'):
compression_level = 0; break
elif compression_level in ('2', 'best'):
Expand Down
4 changes: 2 additions & 2 deletions __modules__/dank.fusion-fall.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import shutil
import requests
import pretty_errors
from dankware import align, clr, cls, err, rm_line, file_selector, title
from dankware import align, clr, cls, err, rm_line, file_selector, title, get_path
from dankware import white, white_normal, red, red_normal, red_dim, green, reset, Style

title("𝚍𝚊𝚗𝚔.𝚏𝚞𝚜𝚒𝚘𝚗-𝚏𝚊𝚕𝚕")
Expand Down Expand Up @@ -70,7 +70,7 @@ def banner():

def open_workspace():

dankff_path = os.path.join(os.environ['USERPROFILE'], 'Documents')
dankff_path = get_path('Documents')
if not os.path.exists(dankff_path):
dankff_path = "C:\\"
dankff_path = os.path.join(dankff_path, "dank.fusion-fall")
Expand Down
232 changes: 232 additions & 0 deletions __modules__/dank.game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
import os
from ursina import *
from numpy.random import choice
from numpy.random import randint
from dankware import cls, clr, title
from ursina.shaders import texture_blend_shader
from concurrent.futures import ThreadPoolExecutor
from ursina.prefabs.first_person_controller import FirstPersonController

os.chdir(os.path.dirname(__file__))
title("𝚍𝚊𝚗𝚔.𝚐𝚊𝚖𝚎")
cls()

input(clr("""\n [ DISCLAIMER ]
- This game is in early development, expect bugs!
- Game updates might be slow!
[ CONTROLS ]
- WASD to move
- SPACE to jump
- ESC to quit (will not return to menu)
> Press [ENTER] to start...
"""))

# game settings

app = Ursina(
title='𝚍𝚊𝚗𝚔.𝚐𝚊𝚖𝚎',
borderless=True,
fullscreen=True,
vsync=True,
show_ursina_splash=True
)

#player = EditorCamera()
player = FirstPersonController()
sky = Sky(texture='sky.png')
Entity.default_shader = texture_blend_shader

world_size = 250 # n*2 x n*2
render_dist = 10 # nxn
textures = {
"grass1": 0.445,
"grass2": 0.445,
"mossy_cobblestone1": 0.05,
"mossy_cobblestone2": 0.05,
"mossy_stone_bricks": 0.01,
}
weights = tuple(textures.values())
textures = tuple(textures.keys())

# lighting

def enable_lighting():
scene.fog_density = 0.3
scene.fog_color = color.black
player_light = PointLight(color=color.white, parent=player, position=(0, 2, 0))

# terrain vertices generation

enable_lighting()

start_time = time.time()
print(clr("\n > Generating terrain vertices..."))

def gen_vertices(x, z):

new_vertices = [Vec3(x-.5, 0, z-.5), Vec3(x+.5, 0, z-.5), Vec3(x+.5, 0, z+.5), Vec3(x-.5, 0, z+.5)]

terrain_keys = terrain.keys()
if (x-1, z) in terrain_keys: terrain_beside = True
else: terrain_beside = False
if (x, z-1) in terrain_keys: terrain_below = True
else: terrain_below = False

if terrain_below and terrain_beside:
vert_0_y = terrain[(x, z-1)][3][1]
vert_1_y = terrain[(x, z-1)][2][1]
vert_3_y = terrain[(x-1, z)][2][1]
vert_2_y = choice([vert_0_y, vert_0_y+.05, vert_0_y-.05, vert_1_y, vert_1_y+.05, vert_1_y-.05, vert_3_y, vert_3_y+.05, vert_3_y-.05])
new_vertices[0][1] = vert_0_y
new_vertices[1][1] = vert_1_y
new_vertices[2][1] = vert_2_y
new_vertices[3][1] = vert_3_y

elif terrain_beside:
vert_0_y = terrain[(x-1, z)][1][1]
vert_3_y = terrain[(x-1, z)][2][1]
vert_1_y = choice([vert_0_y, vert_0_y+.05, vert_0_y-.05, vert_3_y, vert_3_y+.05, vert_3_y-.05])
vert_2_y = choice([vert_0_y, vert_0_y+.05, vert_0_y-.05, vert_3_y, vert_3_y+.05, vert_3_y-.05])
new_vertices[0][1] = vert_0_y
new_vertices[1][1] = vert_1_y
new_vertices[2][1] = vert_2_y
new_vertices[3][1] = vert_3_y

elif terrain_below:
vert_0_y = terrain[(x, z-1)][3][1]
vert_1_y = terrain[(x, z-1)][2][1]
vert_2_y = choice([vert_0_y, vert_0_y+.05, vert_0_y-.05, vert_1_y, vert_1_y+.05, vert_1_y-.05])
vert_3_y = choice([vert_0_y, vert_0_y+.05, vert_0_y-.05, vert_1_y, vert_1_y+.05, vert_1_y-.05])
new_vertices[0][1] = vert_0_y
new_vertices[1][1] = vert_1_y
new_vertices[2][1] = vert_2_y
new_vertices[3][1] = vert_3_y

return tuple(new_vertices)

terrain = {}
for x in range(-world_size, world_size):
for z in range(-world_size, world_size):
terrain[(x, z)] = gen_vertices(x, z)
terrain_keys = terrain.keys()

print(clr(f"\n > Generated {len(terrain_keys)} sets of terrain vertices in {int(time.time() - start_time)} seconds!\n"))
del start_time

# randomised entity generation

def create_entity(x, z, vertices):

terrain[(x, z)] = []
mesh = Mesh(vertices=vertices, triangles=[[0,1,2,3]], uvs=[(0,0),(1,0),(1,1),(0,1)])
mesh.generate_normals(smooth=True)
executor.submit(terrain[(x, z)].append(Entity(model=mesh, collider="mesh", texture=choice(textures, p=weights), ignore=True)))

if choice([0, 1], p=[0.99, 0.01]):
vertices[0][1] += 0.01
vertices[1][1] += 0.01
vertices[2][1] += 0.01
vertices[3][1] += 0.01
mesh = Mesh(vertices=vertices, triangles=[[0,1,2,3]], uvs=[(0,0),(1,0),(1,1),(0,1)])
mesh.generate_normals(smooth=True)
executor.submit(terrain[(x, z)].append(Entity(model=mesh, collider="mesh", texture=choice(["mangrove_leaves_inventory", "azalea_leaves", "flowering_azalea_leaves"]), ignore=True)))

if choice([0, 1], p=[0.98, 0.02]):
y_rot = randint(0, 90)
x_rot = randint(-5, +5)
z_rot = randint(-5, +5)
leaves_level_current = 1
leaves_level_start = (render_dist)-3
next_pos = Vec3(x, min(vertices[0][1], vertices[1][1], vertices[2][1], vertices[3][1]), z)

for _ in range(render_dist):

entity = Entity(model="cube", collider="box", texture="acacia_log", position=next_pos, rotation=(x_rot,y_rot,z_rot), ignore=True)
terrain[(x, z)].append(entity)

if _ > leaves_level_start:

back_2 = entity.back + entity.back
forward_2 = entity.forward + entity.forward
left_2 = entity.left + entity.left
right_2 = entity.right + entity.right

if leaves_level_current == 1:
for pos in [back_2 + left_2, entity.back + left_2, left_2, entity.forward + left_2, forward_2 + left_2, back_2 + entity.left, forward_2 + entity.left, back_2, forward_2, back_2 + entity.right, forward_2 + entity.right, back_2 + right_2, entity.back + right_2, right_2, entity.forward + right_2, forward_2 + right_2]:
executor.submit(terrain[(x, z)].append(Entity(model="cube", texture="azalea_leaves", position=next_pos + pos, rotation=(x_rot,y_rot,z_rot), ignore=True)))
if leaves_level_current == 2:
for pos in [entity.back + entity.left, entity.left, entity.forward + entity.left, entity.back, entity.forward, entity.back + entity.right, entity.right, entity.forward + entity.right]:
executor.submit(terrain[(x, z)].append(Entity(model="cube", texture="azalea_leaves", position=next_pos + pos, rotation=(x_rot,y_rot,z_rot), ignore=True)))

leaves_level_current += 1

y_rot = randint(y_rot-5, y_rot+5)
x_rot = randint(x_rot-5, x_rot+5)
z_rot = randint(z_rot-5, z_rot+5)
next_pos += entity.up

def check_player_pos():
while running:
if player.y < -40:
player.position = (0, 20, 0)
time.sleep(1)

# load / unload entities

def render():

global render_view_global
render_view_global = {}
lower_lim = render_dist
upper_lim = render_dist + 1

while running:
render_view_local = {}
for x in range(int(player.x) - lower_lim, int(player.x) + upper_lim):
for z in range(int(player.z) - lower_lim, int(player.z) + upper_lim):
pos = (x, z)
render_view_global[pos] = ''
render_view_local[pos] = ''
if pos not in rendered_chunks and pos in terrain_keys:
if type(terrain[pos]) == tuple:
create_entity(x, z, terrain[pos])
else:
for entity in terrain[pos]:
entity.enabled = True
rendered_chunks.append(pos)
render_view_global = render_view_local
time.sleep(0.1)

def disable_entity(entity):
entity.enabled = False

def unload():
time.sleep(3)
while running:
for pos in rendered_chunks:
if pos not in render_view_global.keys():
for entity in terrain[pos]:
executor.submit(disable_entity, entity)
rendered_chunks.remove(pos)
time.sleep(0.1)

def input(key):
if key == 'escape':
#global running
#running = False
#executor.shutdown(wait=True, cancel_futures=True)
#application.quit()
os.system("taskkill /f /im dank.tool.exe")

running = True
rendered_chunks = []
player.position = (0, 20, 0)
executor = ThreadPoolExecutor(max_workers=500)
executor.submit(check_player_pos)
executor.submit(render)
executor.submit(unload)
app.run()
23 changes: 10 additions & 13 deletions __modules__/dank.minecraft-server-builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import subprocess
from translatepy import Translator
from dankware import white, white_normal, red, red_normal, red_dim, red, reset
from dankware import title, rm_line, align, cls, clr, github_file_selector, multithread, sys_open, err
from dankware import title, rm_line, align, cls, clr, github_file_selector, multithread, sys_open, err, get_path

headers = {'User-Agent': 'dank.tool', 'Content-Type': 'application/json'}

Expand All @@ -23,22 +23,14 @@ def print_read_me():
def translate(text):

if DANK_TOOL_LANG:
try:
text = translator.translate(text, source_language='en', destination_language=DANK_TOOL_LANG)
except:
pass

try: text = translator.translate(text, source_language='en', destination_language=DANK_TOOL_LANG)
except: pass
return text

def main_one():

global banner, read_me, name, version, cracked, install_Via, ram, motd_spaces, playit, extra_flag, dir_name, latest_java_version, translator, DANK_TOOL_LANG

title("𝚍𝚊𝚗𝚔.𝚖𝚒𝚗𝚎𝚌𝚛𝚊𝚏𝚝-𝚜𝚎𝚛𝚟𝚎𝚛-𝚋𝚞𝚒𝚕𝚍𝚎𝚛")

banner = "\n\n\n _ _ _ _ _ _ ___ \n _| |___ ___| |_ ___ ___ ___ _ _ ___ ___ ___| |_ _ _|_| |_| |___ ___ |_ |\n| . | .'| | '_|_|_ -| -_| _| | | -_| _|___| . | | | | | . | -_| _| |_ |\n|___|__,|_|_|_,_|_|___|___|_| \\_/|___|_| |___|___|_|_|___|___|_| |___|\n"
read_me = '\n\n::::::::: :::::::::: ::: ::::::::: :::: :::: ::::::::::\n:+: :+: :+: :+: :+: :+: :+: +:+:+: :+:+:+ :+: \n+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+:+ +:+ +:+ \n+#++:++#: +#++:++# +#++:++#++: +#+ +:+ +#+ +:+ +#+ +#++:++# \n+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ \n#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# \n### ### ########## ### ### ######### ### ### ##########\n\n\n'

# check if translator is enabled (dank.tool.exe)

try:
Expand All @@ -49,12 +41,17 @@ def main_one():
translator = Translator()
except:
DANK_TOOL_LANG = ''

title("𝚍𝚊𝚗𝚔.𝚖𝚒𝚗𝚎𝚌𝚛𝚊𝚏𝚝-𝚜𝚎𝚛𝚟𝚎𝚛-𝚋𝚞𝚒𝚕𝚍𝚎𝚛")

banner = "\n\n\n _ _ _ _ _ _ ___ \n _| |___ ___| |_ ___ ___ ___ _ _ ___ ___ ___| |_ _ _|_| |_| |___ ___ |_ |\n| . | .'| | '_|_|_ -| -_| _| | | -_| _|___| . | | | | | . | -_| _| |_ |\n|___|__,|_|_|_,_|_|___|___|_| \\_/|___|_| |___|___|_|_|___|___|_| |___|\n"
read_me = '\n\n::::::::: :::::::::: ::: ::::::::: :::: :::: ::::::::::\n:+: :+: :+: :+: :+: :+: :+: +:+:+: :+:+:+ :+: \n+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+:+ +:+ +:+ \n+#++:++#: +#++:++# +#++:++#++: +#+ +:+ +#+ +:+ +#+ +#++:++# \n+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ \n#+# #+# #+# #+# #+# #+# #+# #+# #+# #+# \n### ### ########## ### ### ######### ### ### ##########\n\n\n'

# change dir and print banner

try: os.chdir(os.path.join(os.environ['USERPROFILE'],'Desktop'))
try: get_path('Desktop')
except:
try: os.chdir(os.path.join(os.environ['USERPROFILE'],'Documents'))
try: get_path('Documents')
except: os.chdir("C:\\")

# install java if not installed
Expand Down
Loading

0 comments on commit 9c9a1b7

Please sign in to comment.