How to regain confidence in yourself as a man after being mistreated

r/

In my previous relationship, I had so much confidence in myself. I was providing for my girlfriend well, sexually I was very motivated and had lots of passion/drive, I wanted to work out, I had this strong will to be strong and good looking.

I found out that while I was bending over backwards for my girlfriend (things like working extra jobs to help her financially when it was hard for her), she was flirting with a rich dude. To add, I was just mistreated and not valued.

Since then, I’ve found it very hard to be as motivated. I’m much less motivated for sex, much less motivated to exercise or be physically fit. This in turn is making me feel shit about myself. I feel like a shell of a man, and I feel like I’m being a very shitty man. I feel out of shape and unmotivated

I’m not sure how to pull myself out of this. I’m unsure how to gain the confidence and motivation to bring myself out of this

Right now the only thing I’ve got going for me is that I still have the motivation to learn and become more educated. I’ve been enjoying learning a new language

Physically I just feel so out of shape. Emotionally I feel worse because I have no sexual drive and no drive to get fit

Does anyone have any perspective

EDIT:
To be clear…I understand my emotions well regarding her. My question is more…last time I had this motivation I was hurt so unbelievably deep. How do you slowly build up the confidence to go again, to rebuild yourself.